@intentius/sql-yodeler 0.1.0 → 0.3.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.
Files changed (297) hide show
  1. package/README.md +28 -26
  2. package/dist/bin.js +15 -0
  3. package/dist/bin.js.map +1 -1
  4. package/dist/chant/apply.d.ts +9 -1
  5. package/dist/chant/apply.js +13 -1
  6. package/dist/chant/apply.js.map +1 -1
  7. package/dist/chant/build.js +7 -0
  8. package/dist/chant/build.js.map +1 -1
  9. package/dist/chant/drift.d.ts +69 -1
  10. package/dist/chant/drift.js +152 -5
  11. package/dist/chant/drift.js.map +1 -1
  12. package/dist/chant/runnable.d.ts +19 -0
  13. package/dist/chant/runnable.js +47 -0
  14. package/dist/chant/runnable.js.map +1 -0
  15. package/dist/ci/render.d.ts +289 -0
  16. package/dist/ci/render.js +688 -0
  17. package/dist/ci/render.js.map +1 -0
  18. package/dist/ci/replay.d.ts +17 -0
  19. package/dist/ci/replay.js +69 -0
  20. package/dist/ci/replay.js.map +1 -0
  21. package/dist/cli.d.ts +4 -0
  22. package/dist/cli.js +40 -0
  23. package/dist/cli.js.map +1 -1
  24. package/dist/command.d.ts +6 -0
  25. package/dist/command.js.map +1 -1
  26. package/dist/commands/apply.d.ts +113 -0
  27. package/dist/commands/apply.js +376 -49
  28. package/dist/commands/apply.js.map +1 -1
  29. package/dist/commands/approve.d.ts +5 -0
  30. package/dist/commands/approve.js +155 -0
  31. package/dist/commands/approve.js.map +1 -0
  32. package/dist/commands/checkpoint.d.ts +3 -0
  33. package/dist/commands/checkpoint.js +78 -0
  34. package/dist/commands/checkpoint.js.map +1 -0
  35. package/dist/commands/ci.d.ts +3 -0
  36. package/dist/commands/ci.js +118 -0
  37. package/dist/commands/ci.js.map +1 -0
  38. package/dist/commands/docs.d.ts +11 -0
  39. package/dist/commands/docs.js +108 -0
  40. package/dist/commands/docs.js.map +1 -0
  41. package/dist/commands/drift.d.ts +23 -0
  42. package/dist/commands/drift.js +263 -18
  43. package/dist/commands/drift.js.map +1 -1
  44. package/dist/commands/index.js +16 -0
  45. package/dist/commands/index.js.map +1 -1
  46. package/dist/commands/init.d.ts +3 -0
  47. package/dist/commands/init.js +15 -11
  48. package/dist/commands/init.js.map +1 -1
  49. package/dist/commands/lint.js +25 -8
  50. package/dist/commands/lint.js.map +1 -1
  51. package/dist/commands/mcp.d.ts +3 -0
  52. package/dist/commands/mcp.js +50 -0
  53. package/dist/commands/mcp.js.map +1 -0
  54. package/dist/commands/new.d.ts +2 -0
  55. package/dist/commands/new.js +134 -10
  56. package/dist/commands/new.js.map +1 -1
  57. package/dist/commands/override.d.ts +3 -0
  58. package/dist/commands/override.js +150 -0
  59. package/dist/commands/override.js.map +1 -0
  60. package/dist/commands/plan.js +43 -27
  61. package/dist/commands/plan.js.map +1 -1
  62. package/dist/commands/repair.d.ts +11 -0
  63. package/dist/commands/repair.js +15 -7
  64. package/dist/commands/repair.js.map +1 -1
  65. package/dist/commands/report.d.ts +13 -0
  66. package/dist/commands/report.js +121 -0
  67. package/dist/commands/report.js.map +1 -0
  68. package/dist/commands/revert.d.ts +20 -0
  69. package/dist/commands/revert.js +246 -0
  70. package/dist/commands/revert.js.map +1 -0
  71. package/dist/commands/status.js +44 -17
  72. package/dist/commands/status.js.map +1 -1
  73. package/dist/config/base.d.ts +69 -0
  74. package/dist/config/base.js +121 -0
  75. package/dist/config/base.js.map +1 -0
  76. package/dist/config/define.d.ts +223 -3
  77. package/dist/config/define.js +3 -1
  78. package/dist/config/define.js.map +1 -1
  79. package/dist/config/index.d.ts +2 -0
  80. package/dist/config/index.js +2 -0
  81. package/dist/config/index.js.map +1 -1
  82. package/dist/config/load.d.ts +1 -1
  83. package/dist/config/load.js +150 -5
  84. package/dist/config/load.js.map +1 -1
  85. package/dist/config/settings.d.ts +18 -2
  86. package/dist/config/settings.js +40 -6
  87. package/dist/config/settings.js.map +1 -1
  88. package/dist/env-args.d.ts +6 -0
  89. package/dist/env-args.js +31 -1
  90. package/dist/env-args.js.map +1 -1
  91. package/dist/exit.d.ts +20 -0
  92. package/dist/exit.js +28 -0
  93. package/dist/exit.js.map +1 -0
  94. package/dist/history/client.d.ts +8 -0
  95. package/dist/history/client.js +24 -1
  96. package/dist/history/client.js.map +1 -1
  97. package/dist/history/lock.d.ts +5 -1
  98. package/dist/history/lock.js +8 -2
  99. package/dist/history/lock.js.map +1 -1
  100. package/dist/history/postgres/ddl.d.ts +18 -0
  101. package/dist/history/postgres/ddl.js +27 -2
  102. package/dist/history/postgres/ddl.js.map +1 -1
  103. package/dist/history/postgres/store.d.ts +2 -0
  104. package/dist/history/postgres/store.js +7 -1
  105. package/dist/history/postgres/store.js.map +1 -1
  106. package/dist/history/rows.d.ts +16 -3
  107. package/dist/history/rows.js +30 -1
  108. package/dist/history/rows.js.map +1 -1
  109. package/dist/history/store.d.ts +2 -0
  110. package/dist/history/store.js +2 -2
  111. package/dist/history/store.js.map +1 -1
  112. package/dist/index.d.ts +4 -1
  113. package/dist/index.js +1 -0
  114. package/dist/index.js.map +1 -1
  115. package/dist/init/adopt.js +8 -3
  116. package/dist/init/adopt.js.map +1 -1
  117. package/dist/init/live.d.ts +11 -0
  118. package/dist/init/live.js +25 -2
  119. package/dist/init/live.js.map +1 -1
  120. package/dist/lint/check.d.ts +8 -1
  121. package/dist/lint/check.js +38 -4
  122. package/dist/lint/check.js.map +1 -1
  123. package/dist/lint/report.js +1 -1
  124. package/dist/lint/report.js.map +1 -1
  125. package/dist/lint/routines.d.ts +26 -0
  126. package/dist/lint/routines.js +65 -0
  127. package/dist/lint/routines.js.map +1 -0
  128. package/dist/lint/rules.d.ts +16 -4
  129. package/dist/lint/rules.js +9 -4
  130. package/dist/lint/rules.js.map +1 -1
  131. package/dist/mcp/server.d.ts +40 -0
  132. package/dist/mcp/server.js +106 -0
  133. package/dist/mcp/server.js.map +1 -0
  134. package/dist/mcp/tools.d.ts +72 -0
  135. package/dist/mcp/tools.js +178 -0
  136. package/dist/mcp/tools.js.map +1 -0
  137. package/dist/migrations/checkpoint.d.ts +45 -0
  138. package/dist/migrations/checkpoint.js +110 -0
  139. package/dist/migrations/checkpoint.js.map +1 -0
  140. package/dist/migrations/checks.d.ts +28 -0
  141. package/dist/migrations/checks.js +97 -0
  142. package/dist/migrations/checks.js.map +1 -0
  143. package/dist/migrations/create.d.ts +3 -1
  144. package/dist/migrations/create.js +3 -0
  145. package/dist/migrations/create.js.map +1 -1
  146. package/dist/migrations/directory.js +4 -0
  147. package/dist/migrations/directory.js.map +1 -1
  148. package/dist/migrations/document.d.ts +33 -0
  149. package/dist/migrations/document.js +2 -0
  150. package/dist/migrations/document.js.map +1 -1
  151. package/dist/migrations/index.d.ts +3 -0
  152. package/dist/migrations/index.js +3 -0
  153. package/dist/migrations/index.js.map +1 -1
  154. package/dist/migrations/routines.d.ts +31 -0
  155. package/dist/migrations/routines.js +55 -0
  156. package/dist/migrations/routines.js.map +1 -0
  157. package/dist/notify/index.d.ts +124 -0
  158. package/dist/notify/index.js +210 -0
  159. package/dist/notify/index.js.map +1 -0
  160. package/dist/notify/verify.d.ts +53 -0
  161. package/dist/notify/verify.js +71 -0
  162. package/dist/notify/verify.js.map +1 -0
  163. package/dist/pr/forge.d.ts +4 -0
  164. package/dist/pr/forge.js +21 -7
  165. package/dist/pr/forge.js.map +1 -1
  166. package/dist/pr/issue.d.ts +68 -0
  167. package/dist/pr/issue.js +107 -0
  168. package/dist/pr/issue.js.map +1 -0
  169. package/dist/pr/model.d.ts +12 -1
  170. package/dist/pr/model.js +44 -6
  171. package/dist/pr/model.js.map +1 -1
  172. package/dist/pr/render.d.ts +3 -1
  173. package/dist/pr/render.js +63 -4
  174. package/dist/pr/render.js.map +1 -1
  175. package/dist/project.d.ts +19 -2
  176. package/dist/project.js +33 -1
  177. package/dist/project.js.map +1 -1
  178. package/dist/replay/index.d.ts +3 -0
  179. package/dist/replay/index.js +3 -0
  180. package/dist/replay/index.js.map +1 -1
  181. package/dist/replay/replay.d.ts +9 -1
  182. package/dist/replay/replay.js +63 -32
  183. package/dist/replay/replay.js.map +1 -1
  184. package/dist/replay/report.js +1 -1
  185. package/dist/replay/report.js.map +1 -1
  186. package/dist/replay/shared.d.ts +28 -0
  187. package/dist/replay/shared.js +77 -0
  188. package/dist/replay/shared.js.map +1 -0
  189. package/dist/report/audit.d.ts +138 -0
  190. package/dist/report/audit.js +202 -0
  191. package/dist/report/audit.js.map +1 -0
  192. package/dist/report/jsonl.d.ts +21 -0
  193. package/dist/report/jsonl.js +52 -0
  194. package/dist/report/jsonl.js.map +1 -0
  195. package/dist/report/model.d.ts +68 -0
  196. package/dist/report/model.js +127 -0
  197. package/dist/report/model.js.map +1 -0
  198. package/dist/report/render.d.ts +18 -0
  199. package/dist/report/render.js +127 -0
  200. package/dist/report/render.js.map +1 -0
  201. package/dist/schema-docs/render.d.ts +49 -0
  202. package/dist/schema-docs/render.js +359 -0
  203. package/dist/schema-docs/render.js.map +1 -0
  204. package/dist/schemas.d.ts +37 -0
  205. package/dist/schemas.js +41 -0
  206. package/dist/schemas.js.map +1 -0
  207. package/dist/server.d.ts +40 -0
  208. package/dist/server.js +87 -0
  209. package/dist/server.js.map +1 -0
  210. package/dist/sources/ddl.d.ts +53 -0
  211. package/dist/sources/ddl.js +347 -0
  212. package/dist/sources/ddl.js.map +1 -0
  213. package/dist/sources/index.d.ts +69 -0
  214. package/dist/sources/index.js +170 -0
  215. package/dist/sources/index.js.map +1 -0
  216. package/dist/steps/backfill.d.ts +21 -17
  217. package/dist/steps/backfill.js +20 -20
  218. package/dist/steps/backfill.js.map +1 -1
  219. package/dist/steps/index.d.ts +2 -2
  220. package/dist/steps/index.js +3 -3
  221. package/dist/steps/index.js.map +1 -1
  222. package/dist/steps/postgres-migration.d.ts +35 -25
  223. package/dist/steps/postgres-migration.js +42 -29
  224. package/dist/steps/postgres-migration.js.map +1 -1
  225. package/dist/steps/rebuild.d.ts +15 -15
  226. package/dist/steps/rebuild.js +17 -24
  227. package/dist/steps/rebuild.js.map +1 -1
  228. package/dist/tenants/index.d.ts +40 -0
  229. package/dist/tenants/index.js +122 -0
  230. package/dist/tenants/index.js.map +1 -0
  231. package/dist/tenants/target.d.ts +23 -0
  232. package/dist/tenants/target.js +29 -0
  233. package/dist/tenants/target.js.map +1 -0
  234. package/dist/versioned/checks.d.ts +29 -0
  235. package/dist/versioned/checks.js +54 -0
  236. package/dist/versioned/checks.js.map +1 -0
  237. package/dist/versioned/clickhouse.js +8 -0
  238. package/dist/versioned/clickhouse.js.map +1 -1
  239. package/dist/versioned/driver.d.ts +10 -0
  240. package/dist/versioned/engine.d.ts +61 -1
  241. package/dist/versioned/engine.js +109 -6
  242. package/dist/versioned/engine.js.map +1 -1
  243. package/dist/versioned/explain.js +7 -2
  244. package/dist/versioned/explain.js.map +1 -1
  245. package/dist/versioned/index.d.ts +10 -0
  246. package/dist/versioned/index.js +25 -1
  247. package/dist/versioned/index.js.map +1 -1
  248. package/dist/versioned/op.d.ts +16 -1
  249. package/dist/versioned/op.js +43 -6
  250. package/dist/versioned/op.js.map +1 -1
  251. package/dist/versioned/policy.d.ts +98 -0
  252. package/dist/versioned/policy.js +212 -0
  253. package/dist/versioned/policy.js.map +1 -0
  254. package/dist/versioned/postgres/driver.d.ts +3 -1
  255. package/dist/versioned/postgres/driver.js +30 -3
  256. package/dist/versioned/postgres/driver.js.map +1 -1
  257. package/dist/versioned/postgres/waits.d.ts +46 -0
  258. package/dist/versioned/postgres/waits.js +78 -0
  259. package/dist/versioned/postgres/waits.js.map +1 -0
  260. package/dist/versioned/report.d.ts +3 -0
  261. package/dist/versioned/report.js +13 -1
  262. package/dist/versioned/report.js.map +1 -1
  263. package/dist/versioned/revert.d.ts +128 -0
  264. package/dist/versioned/revert.js +251 -0
  265. package/dist/versioned/revert.js.map +1 -0
  266. package/dist/versioned/stand-down.d.ts +30 -0
  267. package/dist/versioned/stand-down.js +56 -0
  268. package/dist/versioned/stand-down.js.map +1 -0
  269. package/dist/versioned/state.d.ts +25 -0
  270. package/dist/versioned/state.js +36 -3
  271. package/dist/versioned/state.js.map +1 -1
  272. package/dist/waves/index.d.ts +179 -0
  273. package/dist/waves/index.js +268 -0
  274. package/dist/waves/index.js.map +1 -0
  275. package/dist/waves/promotion.d.ts +56 -0
  276. package/dist/waves/promotion.js +108 -0
  277. package/dist/waves/promotion.js.map +1 -0
  278. package/dist/waves/record.d.ts +24 -0
  279. package/dist/waves/record.js +20 -0
  280. package/dist/waves/record.js.map +1 -0
  281. package/package.json +22 -8
  282. package/schemas/apply.schema.json +428 -0
  283. package/schemas/checkpoint.schema.json +19 -0
  284. package/schemas/common.schema.json +213 -0
  285. package/schemas/drift.schema.json +61 -0
  286. package/schemas/event.schema.json +36 -0
  287. package/schemas/init.schema.json +31 -0
  288. package/schemas/lint-rules.schema.json +54 -0
  289. package/schemas/lint.schema.json +294 -0
  290. package/schemas/mcp.schema.json +70 -0
  291. package/schemas/new.schema.json +71 -0
  292. package/schemas/plan.schema.json +489 -0
  293. package/schemas/rebase.schema.json +54 -0
  294. package/schemas/repair.schema.json +20 -0
  295. package/schemas/report.schema.json +114 -0
  296. package/schemas/revert.schema.json +69 -0
  297. package/schemas/status.schema.json +371 -0
@@ -0,0 +1,170 @@
1
+ /**
2
+ * DDL sources (#67): schema that an ORM defines, read from the DDL it
3
+ * prints, beside the declarations in `src/`.
4
+ *
5
+ * ```ts
6
+ * // yodel.config.ts
7
+ * export default defineConfig({
8
+ * sources: {
9
+ * prisma: { command: "npx prisma migrate diff --from-empty --to-schema-datamodel prisma/schema.prisma --script", schema: "app" },
10
+ * legacy: { file: "db/legacy.sql" },
11
+ * },
12
+ * });
13
+ * ```
14
+ *
15
+ * Before each build, yodel runs each source's command (or reads its file)
16
+ * in the project directory and writes the DDL out as declarations in
17
+ * `<sourceDir>/<name>.generated.ts`, the file `chant import` would write.
18
+ * The build, and so plan, new, apply and drift, read it like any other
19
+ * declaration; the ApplyOp's own build finds it there too. Commit it: a
20
+ * build that does not run yodel (chant build, an Op run elsewhere) reads
21
+ * the committed file.
22
+ *
23
+ * Each object has one owner: an object a source creates that `src/` (or
24
+ * another source) also declares is an error, naming both.
25
+ */
26
+ import { exec } from "node:child_process";
27
+ import { existsSync, readFileSync, writeFileSync } from "node:fs";
28
+ import { isAbsolute, join, relative } from "node:path";
29
+ import { YodelError } from "../project.js";
30
+ import { ddlToDeclarations } from "./ddl.js";
31
+ const SOURCE_NAME = /^[a-z][a-z0-9-]*$/;
32
+ /** The generated file a source writes, relative to the project directory. */
33
+ export const generatedPath = (project, name) => join(project.sourceDir, `${name}.generated.ts`);
34
+ /** Checks `sources` in yodel.config.ts. */
35
+ export function checkSources(value, where) {
36
+ if (typeof value !== "object" || value === null || Array.isArray(value))
37
+ throw new YodelError(`${where}: expected an object keyed by source name`);
38
+ for (const [name, source] of Object.entries(value)) {
39
+ const at = `${where}.${name}`;
40
+ if (!SOURCE_NAME.test(name))
41
+ throw new YodelError(`${at}: a source's name is lowercase letters, digits and -, starting with a letter`);
42
+ if (typeof source !== "object" || source === null || Array.isArray(source))
43
+ throw new YodelError(`${at}: expected { command } or { file }`);
44
+ for (const k of Object.keys(source))
45
+ if (!["command", "file", "schema"].includes(k))
46
+ throw new YodelError(`${at}.${k}: unknown setting (expected command, file, schema)`);
47
+ const s = source;
48
+ if ((s.command === undefined) === (s.file === undefined))
49
+ throw new YodelError(`${at}: give one of command and file`);
50
+ for (const k of ["command", "file", "schema"]) {
51
+ if (s[k] !== undefined && (typeof s[k] !== "string" || s[k] === ""))
52
+ throw new YodelError(`${at}.${k}: expected a non-empty string`);
53
+ }
54
+ }
55
+ return value;
56
+ }
57
+ function runCommand(command, cwd, env) {
58
+ return new Promise((resolve, reject) => {
59
+ exec(command, { cwd, env: env ?? process.env, maxBuffer: 64 * 1024 * 1024 }, (error, stdout, stderr) => {
60
+ if (error)
61
+ reject(new YodelError(`${command} failed (exit ${String(error.code ?? "?")})${stderr.trim() ? `:\n${stderr.trim()}` : ""}`));
62
+ else
63
+ resolve(stdout);
64
+ });
65
+ });
66
+ }
67
+ /** Reads one source's DDL. */
68
+ async function readDdl(project, name, source, env) {
69
+ if (source.command !== undefined) {
70
+ const origin = `sources.${name} (${source.command})`;
71
+ try {
72
+ return { ddl: await runCommand(source.command, project.dir, env), origin };
73
+ }
74
+ catch (e) {
75
+ throw new YodelError(`yodel.config.ts sources.${name}: ${e instanceof Error ? e.message : String(e)}`);
76
+ }
77
+ }
78
+ const given = source.file ?? "";
79
+ const file = isAbsolute(given) ? given : join(project.dir, given);
80
+ if (!existsSync(file))
81
+ throw new YodelError(`yodel.config.ts sources.${name}: no file ${relative(project.dir, file)}`);
82
+ return { ddl: readFileSync(file, "utf8"), origin: `sources.${name} (${relative(project.dir, file)})` };
83
+ }
84
+ /**
85
+ * Writes each source's declarations to its generated file, and returns what
86
+ * each declared. A file whose content is unchanged is not rewritten.
87
+ */
88
+ export async function syncSources(project, options = {}) {
89
+ const sources = project.yodel?.config.sources ?? {};
90
+ const synced = [];
91
+ for (const [name, source] of Object.entries(sources)) {
92
+ const { ddl, origin } = await readDdl(project, name, source, options.env);
93
+ const how = source.command !== undefined ? `the output of: ${source.command}` : `the DDL in ${source.file ?? ""}`;
94
+ const declarations = await ddlToDeclarations(project.dialect, ddl, {
95
+ origin: `yodel.config.ts ${origin}`,
96
+ schema: source.schema,
97
+ header: `Generated by yodel from the DDL source "${name}" in yodel.config.ts,\n${how}\nDo not edit: yodel writes it again before each build.`,
98
+ });
99
+ const path = generatedPath(project, name);
100
+ const full = join(project.dir, path);
101
+ const before = existsSync(full) ? readFileSync(full, "utf8") : undefined;
102
+ if (before !== declarations.content)
103
+ writeFileSync(full, declarations.content);
104
+ synced.push({ name, path, objects: declarations.objects });
105
+ }
106
+ return synced;
107
+ }
108
+ /**
109
+ * chant's build refuses two declarations exported under one name. When one
110
+ * of them is a source's, that is an object declared twice: say so, naming
111
+ * the source.
112
+ */
113
+ export function duplicateExport(buildOutput, synced) {
114
+ const name = /Duplicate export name "([^"]+)"/.exec(buildOutput)?.[1];
115
+ if (!name)
116
+ return undefined;
117
+ const owners = synced.flatMap((s) => s.objects.filter((o) => o.export === name).map((o) => ({ source: s, object: o })));
118
+ const [first] = owners;
119
+ if (!first)
120
+ return undefined;
121
+ const elsewhere = owners.length > 1 ? `the source "${owners[1]?.source.name ?? ""}"` : "src/";
122
+ return new YodelError(`each object has one owner, and ${first.object.name} is declared twice: by ${elsewhere} (export ${name}) and by the source "${first.source.name}" (${first.source.path}). Leave it to one of them.`);
123
+ }
124
+ /** `schema.name` of a built object, read from its CREATE, or undefined when it cannot be read. */
125
+ async function builtName(dialect, type, ddl) {
126
+ try {
127
+ const first = ddl.split(/;\s*\n\s*COMMENT ON\b/i)[0] ?? ddl;
128
+ const [object] = (await ddlToDeclarations(dialect, first, { origin: "build" })).objects;
129
+ return object && (type === undefined || object.type === type) ? object.name : undefined;
130
+ }
131
+ catch {
132
+ return undefined;
133
+ }
134
+ }
135
+ /**
136
+ * Each object declared once: an object a source creates that another export
137
+ * in the build (in `src/`, or another source) also creates is an error.
138
+ */
139
+ export async function checkOwnership(output, synced) {
140
+ if (synced.length === 0)
141
+ return;
142
+ const owner = new Map();
143
+ for (const source of synced)
144
+ for (const object of source.objects)
145
+ owner.set(`${object.type} ${object.name}`, { source, object });
146
+ const problems = [];
147
+ for (const built of output.objects) {
148
+ if (synced.some((s) => s.objects.some((o) => o.export === built.export)))
149
+ continue;
150
+ const name = await builtName(output.dialect, built.type, built.ddl);
151
+ if (!name)
152
+ continue;
153
+ const hit = owner.get(`${built.type ?? ""} ${name}`);
154
+ if (hit)
155
+ problems.push(`${name} is declared by ${built.export} and by the source "${hit.source.name}" (${hit.object.export} in ${hit.source.path})`);
156
+ }
157
+ const seen = new Map();
158
+ for (const source of synced) {
159
+ for (const object of source.objects) {
160
+ const key = `${object.type} ${object.name}`;
161
+ const other = seen.get(key);
162
+ if (other && other !== source.name)
163
+ problems.push(`${object.name} is declared by the sources "${other}" and "${source.name}"`);
164
+ seen.set(key, source.name);
165
+ }
166
+ }
167
+ if (problems.length > 0)
168
+ throw new YodelError(`each object has one owner, and ${problems.length === 1 ? "one is declared twice" : `${String(problems.length)} are declared twice`}:\n${problems.map((p) => ` - ${p}`).join("\n")}`);
169
+ }
170
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/sources/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAClE,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAEvD,OAAO,EAAE,UAAU,EAAgB,MAAM,eAAe,CAAC;AACzD,OAAO,EAAE,iBAAiB,EAAkB,MAAM,UAAU,CAAC;AAuB7D,MAAM,WAAW,GAAG,mBAAmB,CAAC;AAExC,6EAA6E;AAC7E,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,OAAgB,EAAE,IAAY,EAAU,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,GAAG,IAAI,eAAe,CAAC,CAAC;AAEzH,2CAA2C;AAC3C,MAAM,UAAU,YAAY,CAAC,KAAc,EAAE,KAAa;IACxD,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QAAE,MAAM,IAAI,UAAU,CAAC,GAAG,KAAK,2CAA2C,CAAC,CAAC;IACnJ,KAAK,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAgC,CAAC,EAAE,CAAC;QAC9E,MAAM,EAAE,GAAG,GAAG,KAAK,IAAI,IAAI,EAAE,CAAC;QAC9B,IAAI,CAAC,WAAW,CAAC,IAA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,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC,IAAI,gCAAgC,KAAK,UAAU,MAAM,CAAC,IAAI,GAAG,CAAC,CAAC;YAC/H,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC;QAC7B,CAAC;IACH,CAAC;IACD,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC;QAAE,MAAM,IAAI,UAAU,CAAC,kCAAkC,QAAQ,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,uBAAuB,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,qBAAqB,MAAM,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AACvO,CAAC"}
@@ -29,16 +29,16 @@
29
29
  * to repeat (an idempotent `UPDATE`, or a delete of its rows before the
30
30
  * insert), as the rebuild's backfill does per partition.
31
31
  *
32
- * The receipts are rows on the environment's server, addressed
32
+ * The receipts are rows on the environment's server, kept by the sql
33
+ * lexicon's receipt store (`sqlReceiptStore`), addressed
33
34
  * `yodel/<env>/<migration id>/<effect>`, so the same effect name in two
34
35
  * migrations is two receipts:
35
36
  *
36
- * - ClickHouse: chant's receipts table (`chant_receipts.receipts`, the one
37
- * `ClickHouseRebuildOp` uses).
38
- * - Postgres: `<history schema>.__chant_receipts`, chant's Postgres receipt
39
- * table (the one `PostgresMigrationOp` keeps in the migrated table's
40
- * schema), in the schema yodel's history is in. Each batch runs in one
41
- * transaction on the apply's connection, and its receipt is written last
37
+ * - ClickHouse: `chant_receipts.receipts` (the table `ClickHouseRebuildOp`
38
+ * keeps its partition receipts in).
39
+ * - Postgres: `<history schema>.__chant_receipts`, in the schema yodel's
40
+ * history is in, over the apply's connection. Each batch runs in one
41
+ * transaction on that connection, and its receipt is written last
42
42
  * inside it: the batch's statements and its receipt commit together or
43
43
  * not at all, so a run killed anywhere leaves no batch half done, and a
44
44
  * resumed backfill runs no batch twice. A batch's statements must be ones
@@ -55,6 +55,7 @@
55
55
  */
56
56
  import type { OpConfig } from "@intentius/chant/op/types";
57
57
  import type { SqlDialect } from "@intentius/chant-lexicon-sql/dialects";
58
+ import type { ClickHouseEndpoint } from "@intentius/chant-lexicon-sql/clickhouse/http";
58
59
  import type { ReceiptStore } from "@intentius/chant/op/receipt-store";
59
60
  import type { StepRecord } from "@intentius/chant/op/local-executor";
60
61
  import type { ClickHousePort } from "../history/index.js";
@@ -90,18 +91,21 @@ export interface BackfillSummary {
90
91
  }
91
92
  /** A receipt store whose every effect is under `prefix`, so receipts of different migrations never meet. */
92
93
  export declare function prefixedStore(store: ReceiptStore, prefix: string): ReceiptStore;
93
- /** The receipt store on a ClickHouse server: chant's, in `chant_receipts.receipts`. */
94
- export declare function serverReceipts(endpoint: {
95
- url: string;
96
- user?: string;
97
- password?: string;
98
- }, environment: string): Promise<ReceiptStore>;
94
+ /** Where a backfill's receipts are kept: the environment's ClickHouse server, or the apply's Postgres connection and the schema to keep them in. */
95
+ export type ReceiptServer = {
96
+ clickhouse: ClickHouseEndpoint;
97
+ } | {
98
+ postgres: PgClient;
99
+ schema: string;
100
+ };
99
101
  /**
100
- * The receipt store on a Postgres server: chant's, in `<schema>.__chant_receipts`,
101
- * over `client` (so a receipt written inside a batch's transaction commits
102
- * with it). Creates the table when it is not there.
102
+ * The sql lexicon's receipt store on the environment's server, under the
103
+ * stack `yodel`. On Postgres it writes over the apply's connection (so a
104
+ * receipt written inside a batch's transaction commits with it, and the
105
+ * store never closes it), and the table is made here, before any batch's
106
+ * transaction opens.
103
107
  */
104
- export declare function postgresServerReceipts(client: PgClient, schema: string, environment: string): Promise<ReceiptStore>;
108
+ export declare function serverReceipts(server: ReceiptServer, environment: string): Promise<ReceiptStore>;
105
109
  /** A backfill on Postgres: the connection its batches run on, and the environment's timeouts. */
106
110
  export interface PgBackfillServer {
107
111
  client: PgClient;
@@ -29,16 +29,16 @@
29
29
  * to repeat (an idempotent `UPDATE`, or a delete of its rows before the
30
30
  * insert), as the rebuild's backfill does per partition.
31
31
  *
32
- * The receipts are rows on the environment's server, addressed
32
+ * The receipts are rows on the environment's server, kept by the sql
33
+ * lexicon's receipt store (`sqlReceiptStore`), addressed
33
34
  * `yodel/<env>/<migration id>/<effect>`, so the same effect name in two
34
35
  * migrations is two receipts:
35
36
  *
36
- * - ClickHouse: chant's receipts table (`chant_receipts.receipts`, the one
37
- * `ClickHouseRebuildOp` uses).
38
- * - Postgres: `<history schema>.__chant_receipts`, chant's Postgres receipt
39
- * table (the one `PostgresMigrationOp` keeps in the migrated table's
40
- * schema), in the schema yodel's history is in. Each batch runs in one
41
- * transaction on the apply's connection, and its receipt is written last
37
+ * - ClickHouse: `chant_receipts.receipts` (the table `ClickHouseRebuildOp`
38
+ * keeps its partition receipts in).
39
+ * - Postgres: `<history schema>.__chant_receipts`, in the schema yodel's
40
+ * history is in, over the apply's connection. Each batch runs in one
41
+ * transaction on that connection, and its receipt is written last
42
42
  * inside it: the batch's statements and its receipt commit together or
43
43
  * not at all, so a run killed anywhere leaves no batch half done, and a
44
44
  * resumed backfill runs no batch twice. A batch's statements must be ones
@@ -171,21 +171,21 @@ export function prefixedStore(store, prefix) {
171
171
  write: (r, expectation) => store.write({ ...r, effect: `${prefix}${r.effect}` }, expectation),
172
172
  };
173
173
  }
174
- /** The receipt store on a ClickHouse server: chant's, in `chant_receipts.receipts`. */
175
- export async function serverReceipts(endpoint, environment) {
176
- const { clickhouseReceiptStore } = await import("@intentius/chant-lexicon-sql/clickhouse/rebuild/receipts");
177
- return clickhouseReceiptStore(endpoint, { stack: "yodel", env: environment });
178
- }
179
174
  /**
180
- * The receipt store on a Postgres server: chant's, in `<schema>.__chant_receipts`,
181
- * over `client` (so a receipt written inside a batch's transaction commits
182
- * with it). Creates the table when it is not there.
175
+ * The sql lexicon's receipt store on the environment's server, under the
176
+ * stack `yodel`. On Postgres it writes over the apply's connection (so a
177
+ * receipt written inside a batch's transaction commits with it, and the
178
+ * store never closes it), and the table is made here, before any batch's
179
+ * transaction opens.
183
180
  */
184
- export async function postgresServerReceipts(client, schema, environment) {
185
- const { postgresReceiptStore } = await import("@intentius/chant-lexicon-sql/postgres/migrate/receipts");
186
- // The store never closes the apply's connection.
187
- const store = postgresReceiptStore({ query: (sql, params) => client.query(sql, params), end: () => Promise.resolve() }, schema, { stack: "yodel", env: environment });
188
- await store.ensure();
181
+ export async function serverReceipts(server, environment) {
182
+ const { sqlReceiptStore } = await import("@intentius/chant-lexicon-sql/receipts");
183
+ const where = "clickhouse" in server
184
+ ? { clickhouse: { endpoint: server.clickhouse } }
185
+ : { postgres: { query: (sql, params) => server.postgres.query(sql, params), end: () => Promise.resolve() }, schema: server.schema };
186
+ const store = sqlReceiptStore({ environment, stack: "yodel", config: {}, ...where });
187
+ if ("postgres" in server)
188
+ await store.ensure();
189
189
  return store;
190
190
  }
191
191
  function clickhouseBatches(port) {
@@ -1 +1 @@
1
- {"version":3,"file":"backfill.js","sourceRoot":"","sources":["../../src/steps/backfill.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsDG;AAEH,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAMzC,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAI3C,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,YAAY,EAAqB,MAAM,UAAU,CAAC;AAC3E,OAAO,EAAE,aAAa,EAAE,WAAW,EAAqB,MAAM,YAAY,CAAC;AAE3E,gGAAgG;AAChG,MAAM,CAAC,MAAM,YAAY,GAA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 @@ export interface StepContext {
32
32
  }) | undefined;
33
33
  /** Postgres: the environment's lock timeout, for a PostgresMigrationOp step whose options set none. */
34
34
  lockTimeoutMs?: number | undefined;
35
- /** The server, for chant's receipt store; the port is enough for everything else. */
35
+ /** The server, for the backfill's receipt store; the port is enough for everything else. */
36
36
  endpoint?: ClickHouseEndpoint | undefined;
37
37
  migration: Migration;
38
38
  index: number;
@@ -42,7 +42,7 @@ export interface StepContext {
42
42
  run: "refused";
43
43
  }>;
44
44
  log: (line: string) => void;
45
- /** A backfill's receipt store; default chant's on the server. */
45
+ /** A backfill's receipt store; default the sql lexicon's on the server. */
46
46
  receipts?: ReceiptStore | undefined;
47
47
  }
48
48
  /** Runs one Op step to the end and returns the summary its history row records. Throws `StepOpFailed` when it stops part way. */
@@ -9,7 +9,7 @@
9
9
  * defaultStepRunner what the versioned apply calls for an Op step
10
10
  */
11
11
  import { YodelError } from "../project.js";
12
- import { postgresServerReceipts, runBackfill, serverReceipts } from "./backfill.js";
12
+ import { runBackfill, serverReceipts } from "./backfill.js";
13
13
  import { rebuildChantConfig, runRebuild } from "./rebuild.js";
14
14
  import { runPgMigration } from "./postgres-migration.js";
15
15
  export * from "./kinds.js";
@@ -31,9 +31,9 @@ export const defaultStepRunner = async (ctx) => {
31
31
  throw new YodelError("a backfill step runs its SQL on the environment's server, and this environment has none");
32
32
  const receipts = ctx.receipts ??
33
33
  (ctx.postgres
34
- ? await postgresServerReceipts(ctx.postgres.client, ctx.postgres.receiptsSchema, ctx.environment)
34
+ ? await serverReceipts({ postgres: ctx.postgres.client, schema: ctx.postgres.receiptsSchema }, ctx.environment)
35
35
  : ctx.endpoint
36
- ? await serverReceipts(ctx.endpoint, ctx.environment)
36
+ ? await serverReceipts({ clickhouse: ctx.endpoint }, ctx.environment)
37
37
  : undefined);
38
38
  if (!receipts)
39
39
  throw new YodelError("a backfill step needs a receipt store, and this environment has no server endpoint for one");
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":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QAC5B,UAAU,EAAE,GAAG,CAAC,UAAU;QAC1B,WAAW,EAAE,GAAG,CAAC,SAAS,CAAC,EAAE;QAC7B,GAAG,EAAE,GAAG,CAAC,SAAS,CAAC,GAAG;QACtB,IAAI,EAAE,GAAG,CAAC,SAAS,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC;QAChD,GAAG,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,EAAE,MAAM,EAAE,GAAG,CAAC,QAAQ,CAAC,MAAM,EAAE,QAAQ,EAAE,GAAG,CAAC,QAAQ,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,GAAG,CAAC,IAAI,EAAE,CAAC;QACvH,QAAQ;QACR,GAAG,EAAE,GAAG,CAAC,GAAG;KACb,CAAC,CAAC;IACH,OAAO,EAAE,OAAO,EAAE,CAAC;AACrB,CAAC,CAAC"}
@@ -15,40 +15,50 @@
15
15
  *
16
16
  * - The declaration is the migration's recorded schema (`migration.json`'s
17
17
  * `schema`), written to a temporary build file, not a fresh `chant build`.
18
- * - Its two gates (before the switch, before the contract) are left out. The
19
- * approval is the migration's: the step and its options are in the
20
- * migration's checksum, so in the plan digest the migrations Op's gate
21
- * approved. The verification still runs before the switch, and a
18
+ * - It is built with `gates: "outer"`: the approval is the migration's (the
19
+ * step and its options are in the migration's checksum, so in the plan
20
+ * digest the migrations Op's gate approved), so the Op has neither of its
21
+ * gates (before the switch, before the contract) and no Contract phase of
22
+ * its own. The verification still runs before the switch, and a
22
23
  * difference (a row whose new column is not the expression over the old,
23
24
  * a NULL where NOT NULL is declared) fails the step with nothing switched.
24
- * - The old column's retention is the step's `options.retain` when it sets
25
- * one, else none (`0s`): the contract drops the old column (and a rename's
26
- * trigger) in the same run, right after the switch, as the migration's
27
- * recorded schema says it is gone. A step that sets `retain` keeps the old
28
- * column that long; the step succeeds with it kept, its note says until
29
- * when, and dropping it after the date is `chant run` of the Op's
30
- * declaration (in `migration.json`), whose contract is convergent.
31
- * - Its onFailure (which drops what the expand added) is left out, so a step
32
- * that failed or was stopped resumes on the next `yodel apply`. Every
33
- * phase of the Op re-reads the server and does what is left of it: the
34
- * expand finds the new column there and adds nothing, the dual write finds
35
- * its trigger, the backfill skips every batch whose receipt is in
36
- * `<schema>.__chant_receipts` (each receipt commits with its batch, so a
37
- * batch is never filled twice), the carry over builds only the indexes and
38
- * constraints not yet built (an INVALID one it left is built again), the
39
- * verification runs again over every row, and a switch that already ran is
40
- * not run again. To start over instead, drop the new column, its trigger
41
- * and function (chant's working objects, named in their comments).
25
+ * - After the Retain phase the step runs the lexicon's contract activity
26
+ * (`postgresMigrationContract`, the Op's own Contract step, with the same
27
+ * arguments), under the same approval. It drops the old column (and a
28
+ * rename's trigger) only once its retention date has passed. The
29
+ * retention is the step's `options.retain` when it sets one, else none
30
+ * (`0s`): the contract drops the old column in the same run, right after
31
+ * the switch, as the migration's recorded schema says it is gone. A step
32
+ * that sets `retain` keeps the old column that long; the step succeeds
33
+ * with it kept, its note says until when, and dropping it after the date
34
+ * is `chant run` of the Op's declaration (in `migration.json`), whose
35
+ * contract is convergent.
36
+ * - It is built with `onFailure: "keep"`, so a step that failed or was
37
+ * stopped keeps what the expand added and resumes on the next `yodel
38
+ * apply`. Every phase of the Op re-reads the server and does what is left
39
+ * of it: the expand finds the new column there and adds nothing, the dual
40
+ * write finds its trigger, the backfill skips every batch whose receipt
41
+ * is in `<schema>.__chant_receipts` (each receipt commits with its batch,
42
+ * so a batch is never filled twice), the carry over builds only the
43
+ * indexes and constraints not yet built (an INVALID one it left is built
44
+ * again), the verification runs again over every row, and a switch that
45
+ * already ran is not run again. To start over instead, drop the new
46
+ * column, its trigger and function (chant's working objects, named in
47
+ * their comments; a refusal says so).
42
48
  */
43
- import type { OpConfig, PhaseDefinition } from "@intentius/chant/op/types";
49
+ import type { OpConfig } from "@intentius/chant/op/types";
44
50
  import type { ActivityFn } from "@intentius/chant/op/activity-registry";
45
51
  import type { StepRecord } from "@intentius/chant/op/local-executor";
46
52
  import type { PgMigrationOptions } from "./kinds.js";
47
53
  import { type RunOpOptions } from "./run.js";
48
54
  /** The retention a step runs with when its options set none: the contract runs in the same apply. */
49
55
  export declare const STEP_RETAIN = "0s";
50
- /** `PostgresMigrationOp`'s phases as a step runs them: no gates, no onFailure. */
51
- export declare function pgStepPhases(config: OpConfig): PhaseDefinition[];
56
+ /**
57
+ * The Op's Contract step for a config built with `gates: "outer"`: the
58
+ * lexicon's contract activity with the Retain step's arguments. It drops the
59
+ * old column only once its retention date has passed.
60
+ */
61
+ export declare function contractPhase(config: OpConfig): OpConfig["phases"][number];
52
62
  /** The Op a step runs. `buildPath` is the recorded schema's file; `projectDir` holds chant.config.ts. */
53
63
  export declare function pgMigrationOpConfig(options: PgMigrationOptions, ctx: {
54
64
  environment: string;
@@ -15,30 +15,36 @@
15
15
  *
16
16
  * - The declaration is the migration's recorded schema (`migration.json`'s
17
17
  * `schema`), written to a temporary build file, not a fresh `chant build`.
18
- * - Its two gates (before the switch, before the contract) are left out. The
19
- * approval is the migration's: the step and its options are in the
20
- * migration's checksum, so in the plan digest the migrations Op's gate
21
- * approved. The verification still runs before the switch, and a
18
+ * - It is built with `gates: "outer"`: the approval is the migration's (the
19
+ * step and its options are in the migration's checksum, so in the plan
20
+ * digest the migrations Op's gate approved), so the Op has neither of its
21
+ * gates (before the switch, before the contract) and no Contract phase of
22
+ * its own. The verification still runs before the switch, and a
22
23
  * difference (a row whose new column is not the expression over the old,
23
24
  * a NULL where NOT NULL is declared) fails the step with nothing switched.
24
- * - The old column's retention is the step's `options.retain` when it sets
25
- * one, else none (`0s`): the contract drops the old column (and a rename's
26
- * trigger) in the same run, right after the switch, as the migration's
27
- * recorded schema says it is gone. A step that sets `retain` keeps the old
28
- * column that long; the step succeeds with it kept, its note says until
29
- * when, and dropping it after the date is `chant run` of the Op's
30
- * declaration (in `migration.json`), whose contract is convergent.
31
- * - Its onFailure (which drops what the expand added) is left out, so a step
32
- * that failed or was stopped resumes on the next `yodel apply`. Every
33
- * phase of the Op re-reads the server and does what is left of it: the
34
- * expand finds the new column there and adds nothing, the dual write finds
35
- * its trigger, the backfill skips every batch whose receipt is in
36
- * `<schema>.__chant_receipts` (each receipt commits with its batch, so a
37
- * batch is never filled twice), the carry over builds only the indexes and
38
- * constraints not yet built (an INVALID one it left is built again), the
39
- * verification runs again over every row, and a switch that already ran is
40
- * not run again. To start over instead, drop the new column, its trigger
41
- * and function (chant's working objects, named in their comments).
25
+ * - After the Retain phase the step runs the lexicon's contract activity
26
+ * (`postgresMigrationContract`, the Op's own Contract step, with the same
27
+ * arguments), under the same approval. It drops the old column (and a
28
+ * rename's trigger) only once its retention date has passed. The
29
+ * retention is the step's `options.retain` when it sets one, else none
30
+ * (`0s`): the contract drops the old column in the same run, right after
31
+ * the switch, as the migration's recorded schema says it is gone. A step
32
+ * that sets `retain` keeps the old column that long; the step succeeds
33
+ * with it kept, its note says until when, and dropping it after the date
34
+ * is `chant run` of the Op's declaration (in `migration.json`), whose
35
+ * contract is convergent.
36
+ * - It is built with `onFailure: "keep"`, so a step that failed or was
37
+ * stopped keeps what the expand added and resumes on the next `yodel
38
+ * apply`. Every phase of the Op re-reads the server and does what is left
39
+ * of it: the expand finds the new column there and adds nothing, the dual
40
+ * write finds its trigger, the backfill skips every batch whose receipt
41
+ * is in `<schema>.__chant_receipts` (each receipt commits with its batch,
42
+ * so a batch is never filled twice), the carry over builds only the
43
+ * indexes and constraints not yet built (an INVALID one it left is built
44
+ * again), the verification runs again over every row, and a switch that
45
+ * already ran is not run again. To start over instead, drop the new
46
+ * column, its trigger and function (chant's working objects, named in
47
+ * their comments; a refusal says so).
42
48
  */
43
49
  import { mkdtempSync, rmSync, writeFileSync } from "node:fs";
44
50
  import { tmpdir } from "node:os";
@@ -46,9 +52,16 @@ import { join } from "node:path";
46
52
  import { runOp, StepOpFailed } from "./run.js";
47
53
  /** The retention a step runs with when its options set none: the contract runs in the same apply. */
48
54
  export const STEP_RETAIN = "0s";
49
- /** `PostgresMigrationOp`'s phases as a step runs them: no gates, no onFailure. */
50
- export function pgStepPhases(config) {
51
- return config.phases.map((p) => ({ ...p, steps: p.steps.filter((s) => s.kind !== "gate") })).filter((p) => p.steps.length > 0);
55
+ /**
56
+ * The Op's Contract step for a config built with `gates: "outer"`: the
57
+ * lexicon's contract activity with the Retain step's arguments. It drops the
58
+ * old column only once its retention date has passed.
59
+ */
60
+ export function contractPhase(config) {
61
+ const retain = config.phases.flatMap((p) => p.steps).find((s) => s.kind === "activity" && s.fn === "postgresMigrationRetain");
62
+ if (!retain)
63
+ throw new Error(`PostgresMigrationOp "${config.name}" has no Retain step`);
64
+ return { name: "Contract", steps: [{ kind: "activity", fn: "postgresMigrationContract", ...(retain.args ? { args: retain.args } : {}) }] };
52
65
  }
53
66
  /** The Op a step runs. `buildPath` is the recorded schema's file; `projectDir` holds chant.config.ts. */
54
67
  export async function pgMigrationOpConfig(options, ctx) {
@@ -68,11 +81,11 @@ export async function pgMigrationOpConfig(options, ctx) {
68
81
  build: false,
69
82
  output: ctx.buildPath,
70
83
  path: ctx.projectDir,
84
+ gates: "outer",
85
+ onFailure: "keep",
71
86
  });
72
- const full = op.props;
73
- const rest = { ...full, phases: pgStepPhases(full) };
74
- delete rest.onFailure;
75
- return rest;
87
+ const config = op.props;
88
+ return { ...config, phases: [...config.phases, contractPhase(config)] };
76
89
  }
77
90
  /** The migration activities whose results the history's summary keeps. */
78
91
  const SUMMARIZED = ["postgresMigrationPlan", "postgresMigrationBackfill", "postgresMigrationCarry", "postgresMigrationVerify", "postgresMigrationSwitch", "postgresMigrationContract"];