Implements the remaining items from issue #20: - version is now forward-permissive: any value >= 1 is accepted; a newer-than-known version loads best-effort (unknown fields ignored, warning printed) instead of hard-failing on "must be 1" - from_job input reference: `inputs: [{ from_job: <job> }]` resolves to that job's single-file output + format and implies a dependency edge; combined depends_on + from_job graph gets topological ordering and cycle detection - logfile size-rotation, on by default (5MB, keep 3), overridable per job (log_max_size / log_keep) or file-wide via a top-level defaults block - new commands: split (schema/table subsetting via select:), inspect (rule validation -> markdown/json report, fails job on enforced-rule errors), diff (compare exactly two schemas, never fails), scripts-exec (run SQL script dirs against a live PostgreSQL database) - atomic single-file output/report writes (temp file + rename) - symlink-escape hardening in SafeJoin via EvalSymlinks preflight Updates docs/JOB_FILES.md and examples/jobs/relspec.yml accordingly.
80 lines
2.0 KiB
YAML
80 lines
2.0 KiB
YAML
# Example RelSpec job file. See docs/JOB_FILES.md for the full reference.
|
|
#
|
|
# cd examples/jobs
|
|
# relspec job list
|
|
# relspec job run build-schema --plan
|
|
# relspec job run build-schema
|
|
# relspec job run lint-schema # inspect, consuming build-json's output
|
|
version: 1
|
|
|
|
# File-wide defaults. Individual jobs may override log_max_size / log_keep.
|
|
defaults:
|
|
log_max_size: 2MB
|
|
log_keep: 5
|
|
|
|
jobs:
|
|
build-schema:
|
|
command: convert
|
|
description: Merge the DBML sources and emit PostgreSQL DDL
|
|
inputs:
|
|
- path: schema/core.dbml
|
|
format: dbml
|
|
- path: schema/tenant.dbml
|
|
format: dbml
|
|
output:
|
|
format: pgsql
|
|
path: build/schema.sql
|
|
overwrite: true
|
|
options:
|
|
flatten_schema: false
|
|
logfile: .relspec/log/build-schema.log
|
|
|
|
build-json:
|
|
command: convert
|
|
description: Also emit a JSON schema once build-schema succeeds
|
|
depends_on: [build-schema]
|
|
inputs:
|
|
- path: schema/core.dbml
|
|
format: dbml
|
|
- path: schema/tenant.dbml
|
|
format: dbml
|
|
output:
|
|
format: json
|
|
path: build/schema.json
|
|
overwrite: true
|
|
|
|
migration-order:
|
|
command: scripts-list
|
|
description: Show the combined execution order across script directories
|
|
script_dirs:
|
|
- migrations/core
|
|
- migrations/tenant
|
|
logfile: .relspec/log/migration-order.log
|
|
|
|
lint-schema:
|
|
command: inspect
|
|
description: Validate build-json's output against the built-in rules
|
|
# No depends_on needed: the from_job input implies a dependency on build-json.
|
|
inputs:
|
|
- from_job: build-json
|
|
report:
|
|
format: markdown
|
|
path: build/lint-report.md
|
|
overwrite: true
|
|
logfile: .relspec/log/lint-schema.log
|
|
|
|
posts-only:
|
|
command: split
|
|
description: Extract just the posts table into its own DBML file
|
|
inputs:
|
|
- path: schema/core.dbml
|
|
format: dbml
|
|
- path: schema/tenant.dbml
|
|
format: dbml
|
|
select:
|
|
tables: [posts]
|
|
output:
|
|
format: dbml
|
|
path: build/posts.dbml
|
|
overwrite: true
|