@intentius/sql-yodeler 0.0.0-stage → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +202 -0
- package/README.md +112 -2
- package/dist/bin.d.ts +2 -0
- package/dist/bin.js +29 -0
- package/dist/bin.js.map +1 -0
- package/dist/chant/apply.d.ts +59 -0
- package/dist/chant/apply.js +116 -0
- package/dist/chant/apply.js.map +1 -0
- package/dist/chant/build.d.ts +34 -0
- package/dist/chant/build.js +48 -0
- package/dist/chant/build.js.map +1 -0
- package/dist/chant/drift.d.ts +112 -0
- package/dist/chant/drift.js +238 -0
- package/dist/chant/drift.js.map +1 -0
- package/dist/chant/plan.d.ts +45 -0
- package/dist/chant/plan.js +61 -0
- package/dist/chant/plan.js.map +1 -0
- package/dist/chant/process.d.ts +41 -0
- package/dist/chant/process.js +87 -0
- package/dist/chant/process.js.map +1 -0
- package/dist/chant/runnable.d.ts +19 -0
- package/dist/chant/runnable.js +47 -0
- package/dist/chant/runnable.js.map +1 -0
- package/dist/cli.d.ts +8 -0
- package/dist/cli.js +99 -0
- package/dist/cli.js.map +1 -0
- package/dist/command.d.ts +23 -0
- package/dist/command.js +13 -0
- package/dist/command.js.map +1 -0
- package/dist/commands/apply.d.ts +3 -0
- package/dist/commands/apply.js +426 -0
- package/dist/commands/apply.js.map +1 -0
- package/dist/commands/approve.d.ts +5 -0
- package/dist/commands/approve.js +111 -0
- package/dist/commands/approve.js.map +1 -0
- package/dist/commands/drift.d.ts +14 -0
- package/dist/commands/drift.js +267 -0
- package/dist/commands/drift.js.map +1 -0
- package/dist/commands/index.d.ts +3 -0
- package/dist/commands/index.js +28 -0
- package/dist/commands/index.js.map +1 -0
- package/dist/commands/init.d.ts +6 -0
- package/dist/commands/init.js +139 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/lint.d.ts +3 -0
- package/dist/commands/lint.js +202 -0
- package/dist/commands/lint.js.map +1 -0
- package/dist/commands/mcp.d.ts +3 -0
- package/dist/commands/mcp.js +50 -0
- package/dist/commands/mcp.js.map +1 -0
- package/dist/commands/new.d.ts +5 -0
- package/dist/commands/new.js +292 -0
- package/dist/commands/new.js.map +1 -0
- package/dist/commands/override.d.ts +3 -0
- package/dist/commands/override.js +118 -0
- package/dist/commands/override.js.map +1 -0
- package/dist/commands/plan.d.ts +3 -0
- package/dist/commands/plan.js +183 -0
- package/dist/commands/plan.js.map +1 -0
- package/dist/commands/rebase.d.ts +3 -0
- package/dist/commands/rebase.js +167 -0
- package/dist/commands/rebase.js.map +1 -0
- package/dist/commands/repair.d.ts +14 -0
- package/dist/commands/repair.js +125 -0
- package/dist/commands/repair.js.map +1 -0
- package/dist/commands/status.d.ts +7 -0
- package/dist/commands/status.js +54 -0
- package/dist/commands/status.js.map +1 -0
- package/dist/config/define.d.ts +148 -0
- package/dist/config/define.js +20 -0
- package/dist/config/define.js.map +1 -0
- package/dist/config/index.d.ts +11 -0
- package/dist/config/index.js +12 -0
- package/dist/config/index.js.map +1 -0
- package/dist/config/load.d.ts +17 -0
- package/dist/config/load.js +162 -0
- package/dist/config/load.js.map +1 -0
- package/dist/config/settings.d.ts +53 -0
- package/dist/config/settings.js +116 -0
- package/dist/config/settings.js.map +1 -0
- package/dist/env-args.d.ts +24 -0
- package/dist/env-args.js +92 -0
- package/dist/env-args.js.map +1 -0
- package/dist/exit.d.ts +20 -0
- package/dist/exit.js +28 -0
- package/dist/exit.js.map +1 -0
- package/dist/history/client.d.ts +25 -0
- package/dist/history/client.js +42 -0
- package/dist/history/client.js.map +1 -0
- package/dist/history/ddl.d.ts +58 -0
- package/dist/history/ddl.js +100 -0
- package/dist/history/ddl.js.map +1 -0
- package/dist/history/index.d.ts +25 -0
- package/dist/history/index.js +26 -0
- package/dist/history/index.js.map +1 -0
- package/dist/history/lock.d.ts +104 -0
- package/dist/history/lock.js +230 -0
- package/dist/history/lock.js.map +1 -0
- package/dist/history/postgres/ddl.d.ts +22 -0
- package/dist/history/postgres/ddl.js +47 -0
- package/dist/history/postgres/ddl.js.map +1 -0
- package/dist/history/postgres/index.d.ts +12 -0
- package/dist/history/postgres/index.js +13 -0
- package/dist/history/postgres/index.js.map +1 -0
- package/dist/history/postgres/lock.d.ts +48 -0
- package/dist/history/postgres/lock.js +95 -0
- package/dist/history/postgres/lock.js.map +1 -0
- package/dist/history/postgres/store.d.ts +39 -0
- package/dist/history/postgres/store.js +68 -0
- package/dist/history/postgres/store.js.map +1 -0
- package/dist/history/rows.d.ts +96 -0
- package/dist/history/rows.js +73 -0
- package/dist/history/rows.js.map +1 -0
- package/dist/history/store.d.ts +72 -0
- package/dist/history/store.js +134 -0
- package/dist/history/store.js.map +1 -0
- package/dist/history/topology.d.ts +41 -0
- package/dist/history/topology.js +54 -0
- package/dist/history/topology.js.map +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +10 -0
- package/dist/index.js.map +1 -0
- package/dist/init/adopt.d.ts +70 -0
- package/dist/init/adopt.js +143 -0
- package/dist/init/adopt.js.map +1 -0
- package/dist/init/baseline.d.ts +61 -0
- package/dist/init/baseline.js +88 -0
- package/dist/init/baseline.js.map +1 -0
- package/dist/init/files.d.ts +23 -0
- package/dist/init/files.js +77 -0
- package/dist/init/files.js.map +1 -0
- package/dist/init/index.d.ts +16 -0
- package/dist/init/index.js +17 -0
- package/dist/init/index.js.map +1 -0
- package/dist/init/live.d.ts +39 -0
- package/dist/init/live.js +68 -0
- package/dist/init/live.js.map +1 -0
- package/dist/lint/check.d.ts +88 -0
- package/dist/lint/check.js +227 -0
- package/dist/lint/check.js.map +1 -0
- package/dist/lint/config.d.ts +21 -0
- package/dist/lint/config.js +43 -0
- package/dist/lint/config.js.map +1 -0
- package/dist/lint/index.d.ts +31 -0
- package/dist/lint/index.js +43 -0
- package/dist/lint/index.js.map +1 -0
- package/dist/lint/project-rules.d.ts +19 -0
- package/dist/lint/project-rules.js +32 -0
- package/dist/lint/project-rules.js.map +1 -0
- package/dist/lint/report.d.ts +7 -0
- package/dist/lint/report.js +48 -0
- package/dist/lint/report.js.map +1 -0
- package/dist/lint/rules.d.ts +53 -0
- package/dist/lint/rules.js +42 -0
- package/dist/lint/rules.js.map +1 -0
- package/dist/lint/silences.d.ts +49 -0
- package/dist/lint/silences.js +91 -0
- package/dist/lint/silences.js.map +1 -0
- package/dist/lint/statements.d.ts +38 -0
- package/dist/lint/statements.js +120 -0
- package/dist/lint/statements.js.map +1 -0
- package/dist/mcp/server.d.ts +40 -0
- package/dist/mcp/server.js +106 -0
- package/dist/mcp/server.js.map +1 -0
- package/dist/mcp/tools.d.ts +72 -0
- package/dist/mcp/tools.js +178 -0
- package/dist/mcp/tools.js.map +1 -0
- package/dist/migrations/checks.d.ts +28 -0
- package/dist/migrations/checks.js +97 -0
- package/dist/migrations/checks.js.map +1 -0
- package/dist/migrations/checksum.d.ts +56 -0
- package/dist/migrations/checksum.js +72 -0
- package/dist/migrations/checksum.js.map +1 -0
- package/dist/migrations/create.d.ts +75 -0
- package/dist/migrations/create.js +120 -0
- package/dist/migrations/create.js.map +1 -0
- package/dist/migrations/directory.d.ts +119 -0
- package/dist/migrations/directory.js +229 -0
- package/dist/migrations/directory.js.map +1 -0
- package/dist/migrations/document.d.ts +106 -0
- package/dist/migrations/document.js +83 -0
- package/dist/migrations/document.js.map +1 -0
- package/dist/migrations/index.d.ts +21 -0
- package/dist/migrations/index.js +22 -0
- package/dist/migrations/index.js.map +1 -0
- package/dist/pr/comment.d.ts +32 -0
- package/dist/pr/comment.js +99 -0
- package/dist/pr/comment.js.map +1 -0
- package/dist/pr/forge.d.ts +54 -0
- package/dist/pr/forge.js +119 -0
- package/dist/pr/forge.js.map +1 -0
- package/dist/pr/issue.d.ts +68 -0
- package/dist/pr/issue.js +107 -0
- package/dist/pr/issue.js.map +1 -0
- package/dist/pr/model.d.ts +99 -0
- package/dist/pr/model.js +137 -0
- package/dist/pr/model.js.map +1 -0
- package/dist/pr/render.d.ts +29 -0
- package/dist/pr/render.js +279 -0
- package/dist/pr/render.js.map +1 -0
- package/dist/project.d.ts +62 -0
- package/dist/project.js +92 -0
- package/dist/project.js.map +1 -0
- package/dist/rebase/index.d.ts +121 -0
- package/dist/rebase/index.js +390 -0
- package/dist/rebase/index.js.map +1 -0
- package/dist/rebase/repair.d.ts +41 -0
- package/dist/rebase/repair.js +68 -0
- package/dist/rebase/repair.js.map +1 -0
- package/dist/replay/clickhouse.d.ts +33 -0
- package/dist/replay/clickhouse.js +106 -0
- package/dist/replay/clickhouse.js.map +1 -0
- package/dist/replay/index.d.ts +39 -0
- package/dist/replay/index.js +57 -0
- package/dist/replay/index.js.map +1 -0
- package/dist/replay/postgres.d.ts +31 -0
- package/dist/replay/postgres.js +140 -0
- package/dist/replay/postgres.js.map +1 -0
- package/dist/replay/replay.d.ts +114 -0
- package/dist/replay/replay.js +98 -0
- package/dist/replay/replay.js.map +1 -0
- package/dist/replay/report.d.ts +18 -0
- package/dist/replay/report.js +72 -0
- package/dist/replay/report.js.map +1 -0
- package/dist/replay/shared.d.ts +28 -0
- package/dist/replay/shared.js +77 -0
- package/dist/replay/shared.js.map +1 -0
- package/dist/schemas.d.ts +34 -0
- package/dist/schemas.js +38 -0
- package/dist/schemas.js.map +1 -0
- package/dist/server.d.ts +40 -0
- package/dist/server.js +87 -0
- package/dist/server.js.map +1 -0
- package/dist/steps/backfill.d.ts +132 -0
- package/dist/steps/backfill.js +307 -0
- package/dist/steps/backfill.js.map +1 -0
- package/dist/steps/index.d.ts +52 -0
- package/dist/steps/index.js +52 -0
- package/dist/steps/index.js.map +1 -0
- package/dist/steps/kinds.d.ts +101 -0
- package/dist/steps/kinds.js +143 -0
- package/dist/steps/kinds.js.map +1 -0
- package/dist/steps/postgres-migration.d.ts +95 -0
- package/dist/steps/postgres-migration.js +149 -0
- package/dist/steps/postgres-migration.js.map +1 -0
- package/dist/steps/rebuild.d.ts +97 -0
- package/dist/steps/rebuild.js +155 -0
- package/dist/steps/rebuild.js.map +1 -0
- package/dist/steps/run.d.ts +45 -0
- package/dist/steps/run.js +72 -0
- package/dist/steps/run.js.map +1 -0
- package/dist/topology/render.d.ts +17 -0
- package/dist/topology/render.js +17 -0
- package/dist/topology/render.js.map +1 -0
- package/dist/version.d.ts +2 -0
- package/dist/version.js +11 -0
- package/dist/version.js.map +1 -0
- package/dist/versioned/approval.d.ts +35 -0
- package/dist/versioned/approval.js +53 -0
- package/dist/versioned/approval.js.map +1 -0
- package/dist/versioned/checks.d.ts +29 -0
- package/dist/versioned/checks.js +54 -0
- package/dist/versioned/checks.js.map +1 -0
- package/dist/versioned/clickhouse.d.ts +24 -0
- package/dist/versioned/clickhouse.js +42 -0
- package/dist/versioned/clickhouse.js.map +1 -0
- package/dist/versioned/digest.d.ts +77 -0
- package/dist/versioned/digest.js +69 -0
- package/dist/versioned/digest.js.map +1 -0
- package/dist/versioned/driver.d.ts +51 -0
- package/dist/versioned/driver.js +13 -0
- package/dist/versioned/driver.js.map +1 -0
- package/dist/versioned/engine.d.ts +206 -0
- package/dist/versioned/engine.js +370 -0
- package/dist/versioned/engine.js.map +1 -0
- package/dist/versioned/explain.d.ts +123 -0
- package/dist/versioned/explain.js +294 -0
- package/dist/versioned/explain.js.map +1 -0
- package/dist/versioned/index.d.ts +46 -0
- package/dist/versioned/index.js +77 -0
- package/dist/versioned/index.js.map +1 -0
- package/dist/versioned/op.d.ts +72 -0
- package/dist/versioned/op.js +185 -0
- package/dist/versioned/op.js.map +1 -0
- package/dist/versioned/policy.d.ts +67 -0
- package/dist/versioned/policy.js +161 -0
- package/dist/versioned/policy.js.map +1 -0
- package/dist/versioned/postgres/catalog.d.ts +33 -0
- package/dist/versioned/postgres/catalog.js +34 -0
- package/dist/versioned/postgres/catalog.js.map +1 -0
- package/dist/versioned/postgres/driver.d.ts +71 -0
- package/dist/versioned/postgres/driver.js +140 -0
- package/dist/versioned/postgres/driver.js.map +1 -0
- package/dist/versioned/postgres/executor.d.ts +104 -0
- package/dist/versioned/postgres/executor.js +172 -0
- package/dist/versioned/postgres/executor.js.map +1 -0
- package/dist/versioned/postgres/index.d.ts +11 -0
- package/dist/versioned/postgres/index.js +12 -0
- package/dist/versioned/postgres/index.js.map +1 -0
- package/dist/versioned/postgres/waits.d.ts +46 -0
- package/dist/versioned/postgres/waits.js +78 -0
- package/dist/versioned/postgres/waits.js.map +1 -0
- package/dist/versioned/report.d.ts +25 -0
- package/dist/versioned/report.js +84 -0
- package/dist/versioned/report.js.map +1 -0
- package/dist/versioned/stand-down.d.ts +30 -0
- package/dist/versioned/stand-down.js +56 -0
- package/dist/versioned/stand-down.js.map +1 -0
- package/dist/versioned/state.d.ts +108 -0
- package/dist/versioned/state.js +153 -0
- package/dist/versioned/state.js.map +1 -0
- package/package.json +61 -4
- package/schemas/apply.schema.json +269 -0
- package/schemas/common.schema.json +213 -0
- package/schemas/drift.schema.json +36 -0
- package/schemas/init.schema.json +31 -0
- package/schemas/lint-rules.schema.json +54 -0
- package/schemas/lint.schema.json +290 -0
- package/schemas/mcp.schema.json +70 -0
- package/schemas/new.schema.json +71 -0
- package/schemas/plan.schema.json +371 -0
- package/schemas/rebase.schema.json +54 -0
- package/schemas/repair.schema.json +20 -0
- package/schemas/status.schema.json +310 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plan.js","sourceRoot":"","sources":["../../src/commands/plan.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEtC,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AACzC,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,UAAU,EAAkC,MAAM,eAAe,CAAC;AAC5G,OAAO,EAAE,0BAA0B,EAAE,wBAAwB,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAClH,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,kBAAkB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EAAE,QAAQ,IAAI,CAAC,CAAC;IAE3C,IAAI,MAAM,IAAI,MAAM,EAAE,CAAC;QACrB,MAAM,MAAM,GAAG,MAAM,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,kBAAkB,CAAC,MAAM,CAAC,EAAE,QAAQ,CAAC,CAAC;QACzF,EAAE,CAAC,GAAG,CAAC,eAAe,MAAM,CAAC,MAAM,wBAAwB,MAAM,CAAC,KAAK,IAAI,MAAM,CAAC,IAAI,IAAI,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,MAAM,CAAC,OAAO,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,aAAa,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC;IACjN,CAAC;IACD,IAAI,CAAC,CAAC,MAAM,KAAK,MAAM;QAAE,EAAE,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,iBAAiB,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC;SACtF,IAAI,CAAC,CAAC,MAAM,KAAK,UAAU;QAAE,EAAE,CAAC,GAAG,CAAC,kBAAkB,CAAC,MAAM,CAAC,CAAC,CAAC;;QAChE,EAAE,CAAC,GAAG,CAAC,cAAc,CAAC,MAAM,EAAE,EAAE,QAAQ,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,QAAQ,CAAC,CAAC,EAAE,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC;IACnF,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import { parseArgs } from "node:util";
|
|
2
|
+
import { guarded } from "../env-args.js";
|
|
3
|
+
import { loadProject, resolveEnvironment, YodelError } from "../project.js";
|
|
4
|
+
import { MigrationDirectoryError, refusedSteps, scanMigrations } from "../migrations/index.js";
|
|
5
|
+
import { closeVersioned, migrationsDir, openVersioned } from "../versioned/index.js";
|
|
6
|
+
import { planRebase, REBASE_REFUSED, writeRebase } from "../rebase/index.js";
|
|
7
|
+
const usage = "usage: yodel rebase [<id>] [--onto <parent-id>] [--env <env>]... [--force] [--json] [--dir <project>]";
|
|
8
|
+
const help = `${usage}
|
|
9
|
+
|
|
10
|
+
Moves a migration onto another parent and rewrites it, so two branches that
|
|
11
|
+
each added a migration can both merge. With no <id>, the directory's one
|
|
12
|
+
fork (two migrations that follow the same parent) is resolved: the newer of
|
|
13
|
+
the two (by the timestamp in its id) moves onto the end of the other's
|
|
14
|
+
branch. Name <id> to move another one, and --onto to choose its new parent.
|
|
15
|
+
Migrations that follow the moved one move with it.
|
|
16
|
+
|
|
17
|
+
Each moved migration's change (its recorded schema against its old
|
|
18
|
+
parent's) is applied to its new parent's recorded schema, giving its new
|
|
19
|
+
recorded schema; its statements are diffed again from the new parent's, and
|
|
20
|
+
its migration.sql, migration.json and checksum are written again. When both
|
|
21
|
+
branches change the same object, differently, nothing is written and the
|
|
22
|
+
object is named: resolve it by hand (delete the migration, then yodel new).
|
|
23
|
+
Each -- yodel:allow line is carried over to the same statement in the new
|
|
24
|
+
migration.sql; when that statement is gone or changed, nothing is written
|
|
25
|
+
and the line is named.
|
|
26
|
+
Offline: no database is read, except the histories --env names.
|
|
27
|
+
|
|
28
|
+
Ids do not change. The order is the chain of parent ids, not the ids'
|
|
29
|
+
timestamps, so a rebased migration runs after its new parent whatever its
|
|
30
|
+
timestamp says, and anything that names it still does.
|
|
31
|
+
|
|
32
|
+
Options:
|
|
33
|
+
--onto <id> the new parent (default: the end of the other branch)
|
|
34
|
+
--env <env> refuse if this environment's history records a migration
|
|
35
|
+
the rebase would rewrite; repeat for more environments.
|
|
36
|
+
Without it, no history is checked: never rebase a
|
|
37
|
+
migration that ran somewhere
|
|
38
|
+
--force rewrite migrations whose files were edited by hand (the
|
|
39
|
+
edits are dropped; well-formed -- yodel:allow lines are
|
|
40
|
+
still carried over)
|
|
41
|
+
--json print what was rewritten as JSON
|
|
42
|
+
-C, --dir <dir> the project directory (default: the working directory)
|
|
43
|
+
|
|
44
|
+
Exit codes:
|
|
45
|
+
0 rebased, or no fork to rebase
|
|
46
|
+
4 refused, nothing written: both branches change the same object, a
|
|
47
|
+
migration to rewrite was edited by hand (without --force), a
|
|
48
|
+
yodel:allow line's statement is gone or changed, a history records one
|
|
49
|
+
of them, or the moved migration adds nothing on its new parent
|
|
50
|
+
1 the rebase could not be worked out: no such migration, a fork the
|
|
51
|
+
defaults cannot settle, a bad config, a server that does not answer
|
|
52
|
+
`;
|
|
53
|
+
function parseRebaseArgs(args) {
|
|
54
|
+
let parsed;
|
|
55
|
+
try {
|
|
56
|
+
parsed = parseArgs({
|
|
57
|
+
args,
|
|
58
|
+
allowPositionals: true,
|
|
59
|
+
strict: true,
|
|
60
|
+
options: {
|
|
61
|
+
onto: { type: "string" },
|
|
62
|
+
env: { type: "string", multiple: true },
|
|
63
|
+
force: { type: "boolean" },
|
|
64
|
+
json: { type: "boolean" },
|
|
65
|
+
dir: { type: "string", short: "C" },
|
|
66
|
+
},
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
catch (e) {
|
|
70
|
+
throw new YodelError(`${e instanceof Error ? e.message : String(e)}\n${usage}`);
|
|
71
|
+
}
|
|
72
|
+
const { values, positionals } = parsed;
|
|
73
|
+
if (positionals.length > 1)
|
|
74
|
+
throw new YodelError(usage);
|
|
75
|
+
const envs = Array.isArray(values.env) ? values.env.filter((e) => typeof e === "string") : [];
|
|
76
|
+
return {
|
|
77
|
+
id: positionals[0],
|
|
78
|
+
onto: typeof values.onto === "string" ? values.onto : undefined,
|
|
79
|
+
envs,
|
|
80
|
+
force: values.force === true,
|
|
81
|
+
json: values.json === true,
|
|
82
|
+
dir: typeof values.dir === "string" ? values.dir : process.cwd(),
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
/** Refuses when an environment's history names a migration the rebase would rewrite. */
|
|
86
|
+
async function checkHistories(project, envs, plan) {
|
|
87
|
+
for (const name of envs) {
|
|
88
|
+
const env = resolveEnvironment(project, name);
|
|
89
|
+
const venv = await openVersioned(project, env);
|
|
90
|
+
const state = await venv.store.state().finally(() => closeVersioned(venv));
|
|
91
|
+
const ran = plan.rewritten.flatMap((m) => {
|
|
92
|
+
const rec = state.byId.get(m.id);
|
|
93
|
+
return rec ? [`${m.id} (${rec.status === "succeeded" ? "applied" : `ran part way, ${rec.status}`})`] : [];
|
|
94
|
+
});
|
|
95
|
+
if (ran.length > 0) {
|
|
96
|
+
throw new YodelError(`refused: ${name}'s history records ${ran.join(", ")}. Nothing was written. A migration that ran is never rebased: ` +
|
|
97
|
+
`its statements already ran in that order. Rebase the other branch onto it instead (yodel rebase <the other> --onto <the end of this one>).`, REBASE_REFUSED);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
function report(io, json, plan, envs) {
|
|
102
|
+
if (json) {
|
|
103
|
+
io.out(`${JSON.stringify({
|
|
104
|
+
rebased: true,
|
|
105
|
+
moved: plan.moved,
|
|
106
|
+
from: plan.from,
|
|
107
|
+
onto: plan.onto,
|
|
108
|
+
historiesChecked: envs,
|
|
109
|
+
rewritten: plan.rewritten.map((m) => ({
|
|
110
|
+
id: m.id,
|
|
111
|
+
path: m.dir,
|
|
112
|
+
oldParent: m.oldParent,
|
|
113
|
+
parent: m.parent,
|
|
114
|
+
oldChecksum: m.oldChecksum,
|
|
115
|
+
checksum: m.checksum,
|
|
116
|
+
statements: m.statements.steps.length - refusedSteps(m.statements.steps).length,
|
|
117
|
+
refused: m.statements.refused,
|
|
118
|
+
silences: m.silences.map((x) => ({ step: x.step, rule: x.rule, reason: x.reason, line: x.line })),
|
|
119
|
+
handEdited: m.handEdited,
|
|
120
|
+
})),
|
|
121
|
+
}, null, 2)}\n`);
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
const lines = [`Rebased ${plan.moved} onto ${plan.onto} (it followed ${plan.from ?? "nothing"}).`];
|
|
125
|
+
for (const m of plan.rewritten) {
|
|
126
|
+
const n = m.statements.steps.length - refusedSteps(m.statements.steps).length;
|
|
127
|
+
lines.push(` ${m.id}: follows ${m.parent}; ${String(n)} statement${n === 1 ? "" : "s"}${m.statements.refused ? " and an Op or manual step" : ""}${m.silences.length > 0 ? `; ${String(m.silences.length)} yodel:allow line${m.silences.length === 1 ? "" : "s"} carried over` : ""}; checksum ${m.oldChecksum} -> ${m.checksum}`);
|
|
128
|
+
for (const h of m.statements.hints)
|
|
129
|
+
lines.push(` hint: ${h}`);
|
|
130
|
+
}
|
|
131
|
+
lines.push(envs.length > 0
|
|
132
|
+
? `Checked against the history of ${envs.join(", ")}: none of them had run.`
|
|
133
|
+
: "No history was checked (--env): make sure none of these ran anywhere before merging.");
|
|
134
|
+
io.out(`${lines.join("\n")}\n`);
|
|
135
|
+
}
|
|
136
|
+
/** `yodel rebase`; the exit codes are in `help`. */
|
|
137
|
+
export const rebase = {
|
|
138
|
+
name: "rebase",
|
|
139
|
+
summary: "move a migration onto a new parent and recompute its schema",
|
|
140
|
+
implemented: true,
|
|
141
|
+
run: (args, io) => guarded("rebase", io, args, help, async () => {
|
|
142
|
+
const options = parseRebaseArgs(args);
|
|
143
|
+
const project = await loadProject(options.dir);
|
|
144
|
+
const scan = scanMigrations(migrationsDir(project));
|
|
145
|
+
const structural = scan.problems.filter((p) => p.kind === "unreadable" || p.kind === "id-mismatch" || p.kind === "missing-parent");
|
|
146
|
+
if (structural.length > 0)
|
|
147
|
+
throw new MigrationDirectoryError(scan.dir, structural);
|
|
148
|
+
const plan = planRebase(scan.migrations, { id: options.id, onto: options.onto });
|
|
149
|
+
if (plan.moved === undefined) {
|
|
150
|
+
if (options.json)
|
|
151
|
+
io.out(`${JSON.stringify({ rebased: false }, null, 2)}\n`);
|
|
152
|
+
else
|
|
153
|
+
io.out("No fork: every migration follows a different parent. Nothing to rebase.\n");
|
|
154
|
+
return 0;
|
|
155
|
+
}
|
|
156
|
+
const edited = plan.rewritten.filter((m) => m.handEdited);
|
|
157
|
+
if (edited.length > 0 && !options.force) {
|
|
158
|
+
throw new YodelError(`refused: ${edited.map((m) => m.id).join(", ")} ${edited.length === 1 ? "has" : "have"} files that differ from what yodel wrote (an edit by hand, or a checksum that no longer matches). ` +
|
|
159
|
+
`Rebasing writes them again from their recorded schema and drops that edit. Nothing was written; pass --force to rebase anyway, then make the edit again.`, REBASE_REFUSED);
|
|
160
|
+
}
|
|
161
|
+
await checkHistories(project, options.envs, plan);
|
|
162
|
+
writeRebase(plan);
|
|
163
|
+
report(io, options.json, plan, options.envs);
|
|
164
|
+
return 0;
|
|
165
|
+
}),
|
|
166
|
+
};
|
|
167
|
+
//# sourceMappingURL=rebase.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rebase.js","sourceRoot":"","sources":["../../src/commands/rebase.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEtC,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AACzC,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,UAAU,EAAgB,MAAM,eAAe,CAAC;AAC1F,OAAO,EAAE,uBAAuB,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAC/F,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACrF,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,WAAW,EAAmB,MAAM,oBAAoB,CAAC;AAE9F,MAAM,KAAK,GAAG,uGAAuG,CAAC;AAEtH,MAAM,IAAI,GAAG,GAAG,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4CpB,CAAC;AAWF,SAAS,eAAe,CAAC,IAAc;IACrC,IAAI,MAAoC,CAAC;IACzC,IAAI,CAAC;QACH,MAAM,GAAG,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C;;gBACxE,EAAE,CAAC,GAAG,CAAC,2EAA2E,CAAC,CAAC;YACzF,OAAO,CAAC,CAAC;QACX,CAAC;QACD,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC;QAC1D,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;YACxC,MAAM,IAAI,UAAU,CAClB,YAAY,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,oGAAoG;gBACxL,0JAA0J,EAC5J,cAAc,CACf,CAAC;QACJ,CAAC;QACD,MAAM,cAAc,CAAC,OAAO,EAAE,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;QAClD,WAAW,CAAC,IAAI,CAAC,CAAC;QAClB,MAAM,CAAC,EAAE,EAAE,OAAO,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;QAC7C,OAAO,CAAC,CAAC;IACX,CAAC,CAAC;CACL,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Command } from "../command.js";
|
|
2
|
+
/** `yodel repair <id> --reason ... <env>`; the exit codes are in `help`. */
|
|
3
|
+
export declare const repair: Command;
|
|
4
|
+
/** `yodel repair --json` (schemas/repair.schema.json). */
|
|
5
|
+
export declare function repairJson(r: {
|
|
6
|
+
id: string;
|
|
7
|
+
environment: string;
|
|
8
|
+
oldChecksum: string;
|
|
9
|
+
newChecksum: string;
|
|
10
|
+
reason: string;
|
|
11
|
+
seq: number;
|
|
12
|
+
runId: string;
|
|
13
|
+
migrationJsonUpdated: boolean;
|
|
14
|
+
}): Record<string, unknown>;
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { renameSync, writeFileSync } from "node:fs";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import { parseArgs } from "node:util";
|
|
4
|
+
import { guarded } from "../env-args.js";
|
|
5
|
+
import { loadProject, resolveEnvironment, YodelError } from "../project.js";
|
|
6
|
+
import { MIGRATION_JSON, scanMigrations, serializeDocument, verifyChecksum } from "../migrations/index.js";
|
|
7
|
+
import { appliedBy, newRunContext, withLock } from "../history/index.js";
|
|
8
|
+
import { closeVersioned, migrationsDir, openVersioned } from "../versioned/index.js";
|
|
9
|
+
import { checkRepair, repairRow } from "../rebase/repair.js";
|
|
10
|
+
/** A migration directory's name: `<YYYYMMDDTHHMM>-<name>`. */
|
|
11
|
+
const MIGRATION_ID = /^\d{8}T\d{4}-/;
|
|
12
|
+
const usage = 'usage: yodel repair <env> <id> --reason "<text>" [--json] [--dir <project>]\n (or yodel repair <id> --reason "<text>" <env>)';
|
|
13
|
+
const help = `${usage}
|
|
14
|
+
|
|
15
|
+
Records an intended edit to a migration that is already applied in <env>:
|
|
16
|
+
appends a row to the environment's history table (yodel.config.ts
|
|
17
|
+
history.database, else YODEL_HISTORY_DATABASE, default yodeler; on
|
|
18
|
+
Postgres the schema of that name) with the checksum the migration's files
|
|
19
|
+
have now and the reason, under the apply lock. After it, yodel status and
|
|
20
|
+
yodel apply compare the files with the new checksum. Nothing is run on the server: the edit is
|
|
21
|
+
recorded, not applied. Repair each environment the migration ran in.
|
|
22
|
+
|
|
23
|
+
When migration.json's own checksum field is stale too (it is not part of
|
|
24
|
+
what the checksum covers), it is written again to match.
|
|
25
|
+
|
|
26
|
+
Options:
|
|
27
|
+
--reason <text> why the files changed; required, and kept in the history
|
|
28
|
+
--json print the repair as JSON
|
|
29
|
+
-C, --dir <dir> the project directory (default: the working directory)
|
|
30
|
+
|
|
31
|
+
Exit codes:
|
|
32
|
+
0 the new checksum is recorded
|
|
33
|
+
4 refused, nothing written: the migration is not applied in <env> (not
|
|
34
|
+
run, or part way), its files already match the history, or it is gone
|
|
35
|
+
from the directory
|
|
36
|
+
5 another apply holds the lock
|
|
37
|
+
1 anything else: no --reason, a bad config, a server that does not answer
|
|
38
|
+
`;
|
|
39
|
+
function parseRepairArgs(args) {
|
|
40
|
+
let parsed;
|
|
41
|
+
try {
|
|
42
|
+
parsed = parseArgs({
|
|
43
|
+
args,
|
|
44
|
+
allowPositionals: true,
|
|
45
|
+
strict: true,
|
|
46
|
+
options: { reason: { type: "string" }, json: { type: "boolean" }, dir: { type: "string", short: "C" } },
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
catch (e) {
|
|
50
|
+
throw new YodelError(`${e instanceof Error ? e.message : String(e)}\n${usage}`);
|
|
51
|
+
}
|
|
52
|
+
const { values, positionals } = parsed;
|
|
53
|
+
if (positionals.length !== 2)
|
|
54
|
+
throw new YodelError(usage);
|
|
55
|
+
// <env> <id>, as every other command takes the environment first, or <id> ... <env> (#19): the id is the one shaped like one.
|
|
56
|
+
const [first = "", second = ""] = positionals;
|
|
57
|
+
const [id, env] = MIGRATION_ID.test(first) && !MIGRATION_ID.test(second) ? [first, second] : [second, first];
|
|
58
|
+
const reason = typeof values.reason === "string" ? values.reason.trim() : "";
|
|
59
|
+
if (reason === "")
|
|
60
|
+
throw new YodelError(`a repair needs a reason: --reason "<why the files changed>"\n${usage}`);
|
|
61
|
+
return { id, env, reason, json: values.json === true, dir: typeof values.dir === "string" ? values.dir : process.cwd() };
|
|
62
|
+
}
|
|
63
|
+
/** Writes migration.json again with its checksum field matching its files, when it does not. Returns whether it wrote. */
|
|
64
|
+
function syncRecordedChecksum(m) {
|
|
65
|
+
const check = verifyChecksum(m);
|
|
66
|
+
if (check.ok)
|
|
67
|
+
return false;
|
|
68
|
+
const path = join(m.dir, MIGRATION_JSON);
|
|
69
|
+
const tmp = join(m.dir, `.${MIGRATION_JSON}.repairing`);
|
|
70
|
+
writeFileSync(tmp, serializeDocument({ ...JSON.parse(m.files.json), checksum: check.actual }));
|
|
71
|
+
renameSync(tmp, path);
|
|
72
|
+
return true;
|
|
73
|
+
}
|
|
74
|
+
/** `yodel repair <id> --reason ... <env>`; the exit codes are in `help`. */
|
|
75
|
+
export const repair = {
|
|
76
|
+
name: "repair",
|
|
77
|
+
summary: "record a new checksum for an applied migration, with a reason",
|
|
78
|
+
implemented: true,
|
|
79
|
+
run: (args, io) => guarded("repair", io, args, help, async () => {
|
|
80
|
+
const { id, env: name, reason, json, dir } = parseRepairArgs(args);
|
|
81
|
+
const project = await loadProject(dir);
|
|
82
|
+
const env = resolveEnvironment(project, name);
|
|
83
|
+
const m = scanMigrations(migrationsDir(project)).migrations.find((x) => x.id === id);
|
|
84
|
+
const venv = await openVersioned(project, env);
|
|
85
|
+
try {
|
|
86
|
+
return await repairWith(venv, m, { id, envName: env.name, reason, json, io });
|
|
87
|
+
}
|
|
88
|
+
finally {
|
|
89
|
+
await closeVersioned(venv);
|
|
90
|
+
}
|
|
91
|
+
}),
|
|
92
|
+
};
|
|
93
|
+
/** `yodel repair --json` (schemas/repair.schema.json). */
|
|
94
|
+
export function repairJson(r) {
|
|
95
|
+
return { repaired: true, ...r };
|
|
96
|
+
}
|
|
97
|
+
async function repairWith(venv, m, { id, envName, reason, json, io }) {
|
|
98
|
+
checkRepair(m, id, await venv.store.state(), envName); // refuse before taking the lock
|
|
99
|
+
const lock = await venv.driver.acquireLock(appliedBy());
|
|
100
|
+
if (lock.notice && !json)
|
|
101
|
+
io.err(`lock: ${lock.notice}\n`);
|
|
102
|
+
const row = await withLock(lock, venv.lockTtlMs, async () => {
|
|
103
|
+
const state = await venv.store.state();
|
|
104
|
+
const check = checkRepair(m, id, state, envName);
|
|
105
|
+
const r = repairRow({ migration: m, check, reason, run: newRunContext(check.record.planDigest), seq: state.maxSeq + 1 });
|
|
106
|
+
await venv.store.append([r]);
|
|
107
|
+
return { r, check };
|
|
108
|
+
});
|
|
109
|
+
const synced = syncRecordedChecksum(m);
|
|
110
|
+
if (json) {
|
|
111
|
+
io.out(`${JSON.stringify(repairJson({ id, environment: envName, oldChecksum: row.check.oldChecksum, newChecksum: row.check.newChecksum, reason, seq: row.r.seq, runId: row.r.run_id, migrationJsonUpdated: synced }), null, 2)}\n`);
|
|
112
|
+
}
|
|
113
|
+
else {
|
|
114
|
+
io.out([
|
|
115
|
+
`Repaired ${id} in ${envName}'s history (${venv.location.database}).`,
|
|
116
|
+
` old checksum: ${row.check.oldChecksum}`,
|
|
117
|
+
` new checksum: ${row.check.newChecksum}`,
|
|
118
|
+
` reason: ${reason}`,
|
|
119
|
+
...(synced ? [` ${MIGRATION_JSON}'s checksum field updated to match`] : []),
|
|
120
|
+
"",
|
|
121
|
+
].join("\n"));
|
|
122
|
+
}
|
|
123
|
+
return 0;
|
|
124
|
+
}
|
|
125
|
+
//# sourceMappingURL=repair.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"repair.js","sourceRoot":"","sources":["../../src/commands/repair.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACpD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEtC,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AACzC,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC5E,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,iBAAiB,EAAE,cAAc,EAAkB,MAAM,wBAAwB,CAAC;AAC3H,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AACzE,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,aAAa,EAAqB,MAAM,uBAAuB,CAAC;AACxG,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,qBAAqB,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GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,EAAE,GAAG,CAAC,CAAC,CAAC,MAAM,EAAE,oBAAoB,EAAE,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,CAC5N,CAAC;IACJ,CAAC;SAAM,CAAC;QACN,EAAE,CAAC,GAAG,CACJ;YACE,YAAY,EAAE,OAAO,OAAO,eAAe,IAAI,CAAC,QAAQ,CAAC,QAAQ,IAAI;YACrE,mBAAmB,GAAG,CAAC,KAAK,CAAC,WAAW,EAAE;YAC1C,mBAAmB,GAAG,CAAC,KAAK,CAAC,WAAW,EAAE;YAC1C,aAAa,MAAM,EAAE;YACrB,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,KAAK,cAAc,oCAAoC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;YAC5E,EAAE;SACH,CAAC,IAAI,CAAC,IAAI,CAAC,CACb,CAAC;IACJ,CAAC;IACD,OAAO,CAAC,CAAC;AAEX,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Command } from "../command.js";
|
|
2
|
+
/** Exit code: migrations are pending, and nothing is wrong. */
|
|
3
|
+
export declare const STATUS_PENDING = 3;
|
|
4
|
+
/** Exit code: a checksum mismatch, an applied migration gone from the directory, or an out-of-order migration. */
|
|
5
|
+
export declare const STATUS_REFUSED = 4;
|
|
6
|
+
/** `yodel status <env>`; the exit codes are in `help`. */
|
|
7
|
+
export declare const status: Command;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { guarded, parseEnvArgs, usage } from "../env-args.js";
|
|
2
|
+
import { loadProject, resolveEnvironment } from "../project.js";
|
|
3
|
+
import { closeVersioned, openVersioned, readChain, renderStatus, statusJson, statusReport } from "../versioned/index.js";
|
|
4
|
+
/** Exit code: migrations are pending, and nothing is wrong. */
|
|
5
|
+
export const STATUS_PENDING = 3;
|
|
6
|
+
/** Exit code: a checksum mismatch, an applied migration gone from the directory, or an out-of-order migration. */
|
|
7
|
+
export const STATUS_REFUSED = 4;
|
|
8
|
+
const help = `${usage("status")}
|
|
9
|
+
|
|
10
|
+
Lists the environment's migrations against its history table
|
|
11
|
+
(yodel.config.ts history.database, else YODEL_HISTORY_DATABASE, default
|
|
12
|
+
yodeler) and its topology: applied, pending, out of order (pending, but
|
|
13
|
+
before an applied migration in the chain), failed part way (with the
|
|
14
|
+
statement it resumes at), and checksum mismatches (an applied migration
|
|
15
|
+
whose files changed, or that is gone from the directory). When yodel apply
|
|
16
|
+
would run, prints the plan digest it would ask approval for. Reads only;
|
|
17
|
+
takes no lock.
|
|
18
|
+
|
|
19
|
+
Options:
|
|
20
|
+
--json print the status as JSON
|
|
21
|
+
-C, --dir <dir> the project directory (default: the working directory)
|
|
22
|
+
|
|
23
|
+
Exit codes:
|
|
24
|
+
0 every migration is applied
|
|
25
|
+
3 migrations are pending (failed part way included), and nothing is wrong
|
|
26
|
+
4 a checksum mismatch, an applied migration gone from the directory, an
|
|
27
|
+
out-of-order migration (apply refuses it without --allow-out-of-order),
|
|
28
|
+
or a fork or another problem in the migrations directory
|
|
29
|
+
2 a pending migration has a manual step or an Op step yodel apply does not run
|
|
30
|
+
1 the status could not be read: a bad config, a server that does not answer
|
|
31
|
+
`;
|
|
32
|
+
/** `yodel status <env>`; the exit codes are in `help`. */
|
|
33
|
+
export const status = {
|
|
34
|
+
name: "status",
|
|
35
|
+
summary: "list applied, pending and out-of-order migrations",
|
|
36
|
+
implemented: true,
|
|
37
|
+
run: (args, io) => guarded("status", io, args, help, async () => {
|
|
38
|
+
const { env: name, json, dir } = parseEnvArgs("status", args);
|
|
39
|
+
const project = await loadProject(dir);
|
|
40
|
+
const env = resolveEnvironment(project, name);
|
|
41
|
+
const ordered = readChain(project);
|
|
42
|
+
const venv = await openVersioned(project, env);
|
|
43
|
+
const report = await statusReport(venv, ordered, { sync: false }).finally(() => closeVersioned(venv));
|
|
44
|
+
if (json)
|
|
45
|
+
io.out(`${JSON.stringify(statusJson(report), null, 2)}\n`);
|
|
46
|
+
// The sections already say what is wrong; the refusal's wording is apply's.
|
|
47
|
+
else
|
|
48
|
+
io.out(renderStatus({ ...report, refusal: undefined }));
|
|
49
|
+
if (report.refusal)
|
|
50
|
+
return report.refusal.exitCode;
|
|
51
|
+
return report.status.pending.length > 0 ? STATUS_PENDING : 0;
|
|
52
|
+
}),
|
|
53
|
+
};
|
|
54
|
+
//# sourceMappingURL=status.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"status.js","sourceRoot":"","sources":["../../src/commands/status.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAC9D,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAChE,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,SAAS,EAAE,YAAY,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAEzH,+DAA+D;AAC/D,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,CAAC;AAChC,kHAAkH;AAClH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,CAAC;AAEhC,MAAM,IAAI,GAAG,GAAG,KAAK,CAAC,QAAQ,CAAC;;;;;;;;;;;;;;;;;;;;;;;CAuB9B,CAAC;AAEF,0DAA0D;AAC1D,MAAM,CAAC,MAAM,MAAM,GAAY;IAC7B,IAAI,EAAE,QAAQ;IACd,OAAO,EAAE,mDAAmD;IAC5D,WAAW,EAAE,IAAI;IACjB,GAAG,EAAE,CAAC,IAAI,EAAE,EAAE,EAAE,EAAE,CAChB,OAAO,CAAC,QAAQ,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,IAAI,EAAE;QAC3C,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,YAAY,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;QAC9D,MAAM,OAAO,GAAG,MAAM,WAAW,CAAC,GAAG,CAAC,CAAC;QACvC,MAAM,GAAG,GAAG,kBAAkB,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;QAC9C,MAAM,OAAO,GAAG,SAAS,CAAC,OAAO,CAAC,CAAC;QACnC,MAAM,IAAI,GAAG,MAAM,aAAa,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;QAC/C,MAAM,MAAM,GAAG,MAAM,YAAY,CAAC,IAAI,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC;QACtG,IAAI,IAAI;YAAE,EAAE,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC;QACrE,4EAA4E;;YACvE,EAAE,CAAC,GAAG,CAAC,YAAY,CAAC,EAAE,GAAG,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC;QAC7D,IAAI,MAAM,CAAC,OAAO;YAAE,OAAO,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC;QACnD,OAAO,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC;IAC/D,CAAC,CAAC;CACL,CAAC"}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `yodel.config.ts`: what yodel needs per environment that chant's
|
|
3
|
+
* `chant.config.ts` does not say. Optional; a project without one runs on
|
|
4
|
+
* the defaults below.
|
|
5
|
+
*
|
|
6
|
+
* ```ts
|
|
7
|
+
* // yodel.config.ts
|
|
8
|
+
* import { defineConfig } from "@intentius/sql-yodeler";
|
|
9
|
+
*
|
|
10
|
+
* export default defineConfig({
|
|
11
|
+
* environments: {
|
|
12
|
+
* dev: { topology: "single" },
|
|
13
|
+
* prod: { topology: "cluster:main", history: { database: "yodeler" }, lockTtl: 1800, lockWait: 600 },
|
|
14
|
+
* },
|
|
15
|
+
* });
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
import type { Topology } from "@intentius/chant-lexicon-sql/clickhouse/topology";
|
|
19
|
+
import type { LevelSetting, LintRuleId } from "../lint/rules.js";
|
|
20
|
+
export type { Topology };
|
|
21
|
+
/**
|
|
22
|
+
* A ClickHouse topology in its string form (`single`, `cluster:<name>`,
|
|
23
|
+
* `replicated`, `replicated:<cluster>`, `cloud`) or chant's object form,
|
|
24
|
+
* which also sets a cluster's Keeper path and replica name for the tables
|
|
25
|
+
* the migrations create.
|
|
26
|
+
*/
|
|
27
|
+
export type TopologySetting = string | Topology;
|
|
28
|
+
export interface EnvironmentConfig {
|
|
29
|
+
/**
|
|
30
|
+
* The ClickHouse topology this environment runs. Every statement of every
|
|
31
|
+
* migration is rendered for it when it is sent (`ON CLUSTER`, the
|
|
32
|
+
* replicated engine), and the history table's engine follows it.
|
|
33
|
+
* Default: `sql.profiles.<env>.topology` in chant.config.ts, then
|
|
34
|
+
* `YODEL_TOPOLOGY`, then `single`.
|
|
35
|
+
*/
|
|
36
|
+
topology?: TopologySetting;
|
|
37
|
+
history?: {
|
|
38
|
+
/** The database the history and lock tables live in. Default: `YODEL_HISTORY_DATABASE`, then `yodeler`. */
|
|
39
|
+
database?: string;
|
|
40
|
+
};
|
|
41
|
+
/** The apply lock's TTL, in seconds. Default: `YODEL_LOCK_TTL`, then 900. */
|
|
42
|
+
lockTtl?: number;
|
|
43
|
+
/**
|
|
44
|
+
* How long, in seconds, an apply waits for the lock another apply holds
|
|
45
|
+
* before it gives up (exit 5). `yodel apply --lock-wait` overrides it.
|
|
46
|
+
* Default: `YODEL_LOCK_WAIT`, then 0 (give up at once).
|
|
47
|
+
*/
|
|
48
|
+
lockWait?: number;
|
|
49
|
+
}
|
|
50
|
+
export interface YodelConfig {
|
|
51
|
+
/** Keyed by the environment's name in `sql.profiles`. */
|
|
52
|
+
environments?: Record<string, EnvironmentConfig>;
|
|
53
|
+
/** `yodel lint`'s rule levels: `{ rules: { destructive: "warning" } }`. A misspelled rule name is a type error. */
|
|
54
|
+
lint?: LintConfig;
|
|
55
|
+
/** Rules over the plan (#53) that `yodel plan` reports and `yodel apply` enforces; see {@link PolicyConfig}. */
|
|
56
|
+
policy?: PolicyConfig;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Rules over the versioned plan (#53). `yodel plan` shows each rule's
|
|
60
|
+
* outcome, and `yodel apply` refuses (exit 4) a plan a rule denies, unless
|
|
61
|
+
* someone {@link PolicyConfig.overriders} lists recorded an override of that
|
|
62
|
+
* rule for exactly that plan digest (`yodel override <env> --rule <id>
|
|
63
|
+
* --reason <text>`).
|
|
64
|
+
*
|
|
65
|
+
* ```ts
|
|
66
|
+
* policy: {
|
|
67
|
+
* overriders: ["alice", "bob"],
|
|
68
|
+
* rules: [
|
|
69
|
+
* { id: "no-drops-in-prod", environments: ["prod"], refuse: { classes: ["drop"], destructive: true } },
|
|
70
|
+
* { id: "silences-cite-a-ticket", silences: { reason: /\b[A-Z]+-\d+\b/ } },
|
|
71
|
+
* { id: "no-rebuilds-in-hours", environments: ["prod"], check: (plan) => {
|
|
72
|
+
* const hour = new Date(plan.now).getUTCHours();
|
|
73
|
+
* const rebuilds = plan.pending.flatMap((m) => m.steps.filter((s) => s.classes.includes("rebuild")));
|
|
74
|
+
* return hour >= 8 && hour < 18 && rebuilds.length > 0 ? "a rebuild between 08:00 and 18:00 UTC" : undefined;
|
|
75
|
+
* } },
|
|
76
|
+
* ],
|
|
77
|
+
* }
|
|
78
|
+
* ```
|
|
79
|
+
*/
|
|
80
|
+
export interface PolicyConfig {
|
|
81
|
+
rules: PolicyRule[];
|
|
82
|
+
/** Who may override a rule: an override recorded by anyone else does not count. None listed, no override counts. */
|
|
83
|
+
overriders?: string[];
|
|
84
|
+
}
|
|
85
|
+
/** One rule. It denies the plan when any of `refuse`, `silences` or `check` does. */
|
|
86
|
+
export interface PolicyRule {
|
|
87
|
+
/** Names it in output, in the refusal and in `yodel override --rule`: lowercase letters, digits, `-` and `_`. */
|
|
88
|
+
id: string;
|
|
89
|
+
description?: string;
|
|
90
|
+
/** The environments it applies to. Default: every one. */
|
|
91
|
+
environments?: string[];
|
|
92
|
+
/** Denies a pending step of one of these classes (`drop`, `rebuild`, `rewrite`, ...), or a destructive one when `destructive` is true. */
|
|
93
|
+
refuse?: {
|
|
94
|
+
classes?: string[];
|
|
95
|
+
destructive?: boolean;
|
|
96
|
+
};
|
|
97
|
+
/** Denies a `-- yodel:allow` silence (of one of `rules`, default any) whose reason does not match `reason`. */
|
|
98
|
+
silences?: {
|
|
99
|
+
rules?: string[];
|
|
100
|
+
reason: RegExp;
|
|
101
|
+
};
|
|
102
|
+
/** A predicate over the plan: a message (or several) or `false` denies it; `undefined`, `true` or `[]` allows it. */
|
|
103
|
+
check?: (plan: PolicyPlan) => string | string[] | boolean | undefined;
|
|
104
|
+
}
|
|
105
|
+
/** What a policy rule sees: the plan `yodel apply` would run. Plain JSON. */
|
|
106
|
+
export interface PolicyPlan {
|
|
107
|
+
environment: string;
|
|
108
|
+
dialect: "clickhouse" | "postgres";
|
|
109
|
+
/** When the plan is evaluated, ISO 8601 in UTC. */
|
|
110
|
+
now: string;
|
|
111
|
+
/** The migrations the run would apply, in order. */
|
|
112
|
+
pending: PolicyMigration[];
|
|
113
|
+
}
|
|
114
|
+
export interface PolicyMigration {
|
|
115
|
+
id: string;
|
|
116
|
+
checksum: string;
|
|
117
|
+
outOfOrder: boolean;
|
|
118
|
+
steps: PolicyStep[];
|
|
119
|
+
/** Its `-- yodel:allow` silences. */
|
|
120
|
+
silences: Array<{
|
|
121
|
+
step: number;
|
|
122
|
+
rule: string;
|
|
123
|
+
reason: string;
|
|
124
|
+
}>;
|
|
125
|
+
}
|
|
126
|
+
export interface PolicyStep {
|
|
127
|
+
index: number;
|
|
128
|
+
kind: "statement" | "op" | "manual";
|
|
129
|
+
object: string;
|
|
130
|
+
name: string;
|
|
131
|
+
/** A statement's class, or every class an Op or manual step's changes have. */
|
|
132
|
+
classes: string[];
|
|
133
|
+
destructive: boolean;
|
|
134
|
+
/** The rules that classified it. */
|
|
135
|
+
rules: string[];
|
|
136
|
+
/** A statement's SQL. */
|
|
137
|
+
sql?: string;
|
|
138
|
+
/** An Op step's Op. */
|
|
139
|
+
op?: string;
|
|
140
|
+
}
|
|
141
|
+
/** The rules `lint.rules` can set: every lint rule, and the replay check's. */
|
|
142
|
+
export type LintRuleName = LintRuleId | "replay";
|
|
143
|
+
export interface LintConfig {
|
|
144
|
+
/** Each rule's level. The integrity rules (fork, directory, checksum, unreadable-object) are always errors. */
|
|
145
|
+
rules?: Partial<Record<LintRuleName, LevelSetting>>;
|
|
146
|
+
}
|
|
147
|
+
/** Returns `config` as is; it types the default export of `yodel.config.ts`. */
|
|
148
|
+
export declare const defineConfig: (config: YodelConfig) => YodelConfig;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `yodel.config.ts`: what yodel needs per environment that chant's
|
|
3
|
+
* `chant.config.ts` does not say. Optional; a project without one runs on
|
|
4
|
+
* the defaults below.
|
|
5
|
+
*
|
|
6
|
+
* ```ts
|
|
7
|
+
* // yodel.config.ts
|
|
8
|
+
* import { defineConfig } from "@intentius/sql-yodeler";
|
|
9
|
+
*
|
|
10
|
+
* export default defineConfig({
|
|
11
|
+
* environments: {
|
|
12
|
+
* dev: { topology: "single" },
|
|
13
|
+
* prod: { topology: "cluster:main", history: { database: "yodeler" }, lockTtl: 1800, lockWait: 600 },
|
|
14
|
+
* },
|
|
15
|
+
* });
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
/** Returns `config` as is; it types the default export of `yodel.config.ts`. */
|
|
19
|
+
export const defineConfig = (config) => config;
|
|
20
|
+
//# sourceMappingURL=define.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"define.js","sourceRoot":"","sources":["../../src/config/define.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAsIH,gFAAgF;AAChF,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,MAAmB,EAAe,EAAE,CAAC,MAAM,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `yodel.config.ts` (#9): per-environment settings chant.config.ts does not
|
|
3
|
+
* hold, the ClickHouse topology first.
|
|
4
|
+
*
|
|
5
|
+
* defineConfig({ environments: { <env>: { topology, history, lockTtl } } })
|
|
6
|
+
* loadYodelConfig(dir, profiles) the file, checked; undefined when there is none
|
|
7
|
+
* environmentSettings(project, env) topology, history database, lock TTL, with their fallbacks
|
|
8
|
+
*/
|
|
9
|
+
export * from "./define.js";
|
|
10
|
+
export * from "./load.js";
|
|
11
|
+
export * from "./settings.js";
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `yodel.config.ts` (#9): per-environment settings chant.config.ts does not
|
|
3
|
+
* hold, the ClickHouse topology first.
|
|
4
|
+
*
|
|
5
|
+
* defineConfig({ environments: { <env>: { topology, history, lockTtl } } })
|
|
6
|
+
* loadYodelConfig(dir, profiles) the file, checked; undefined when there is none
|
|
7
|
+
* environmentSettings(project, env) topology, history database, lock TTL, with their fallbacks
|
|
8
|
+
*/
|
|
9
|
+
export * from "./define.js";
|
|
10
|
+
export * from "./load.js";
|
|
11
|
+
export * from "./settings.js";
|
|
12
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Finding, loading and checking `yodel.config.ts`. The file is optional; a
|
|
3
|
+
* project without one gets `undefined` and every setting's default.
|
|
4
|
+
*/
|
|
5
|
+
import type { YodelConfig } from "./define.js";
|
|
6
|
+
export declare const CONFIG_FILE = "yodel.config.ts";
|
|
7
|
+
/**
|
|
8
|
+
* Checks a loaded config's shape. `environments` names each environment by
|
|
9
|
+
* its `sql.profiles` name; one that chant.config.ts does not declare is an
|
|
10
|
+
* error, so a typo does not silently leave an environment on the defaults.
|
|
11
|
+
*/
|
|
12
|
+
export declare function checkYodelConfig(value: unknown, path: string, profiles?: readonly string[]): YodelConfig;
|
|
13
|
+
/** Loads `<dir>/yodel.config.ts`, or `undefined` when there is none. */
|
|
14
|
+
export declare function loadYodelConfig(dir: string, profiles?: readonly string[]): Promise<{
|
|
15
|
+
path: string;
|
|
16
|
+
config: YodelConfig;
|
|
17
|
+
} | undefined>;
|