@metaobjectsdev/migrate-ts 0.23.2 → 0.24.1

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 (59) hide show
  1. package/dist/diff/index.d.ts.map +1 -1
  2. package/dist/diff/index.js +8 -7
  3. package/dist/diff/index.js.map +1 -1
  4. package/dist/drift/drift.d.ts +32 -2
  5. package/dist/drift/drift.d.ts.map +1 -1
  6. package/dist/drift/drift.js +15 -8
  7. package/dist/drift/drift.js.map +1 -1
  8. package/dist/emit/postgres.js +69 -12
  9. package/dist/emit/postgres.js.map +1 -1
  10. package/dist/emit/sqlite.d.ts.map +1 -1
  11. package/dist/emit/sqlite.js +9 -2
  12. package/dist/emit/sqlite.js.map +1 -1
  13. package/dist/expected-schema.d.ts +35 -0
  14. package/dist/expected-schema.d.ts.map +1 -1
  15. package/dist/expected-schema.js +29 -2
  16. package/dist/expected-schema.js.map +1 -1
  17. package/dist/index.d.ts +8 -2
  18. package/dist/index.d.ts.map +1 -1
  19. package/dist/index.js +7 -1
  20. package/dist/index.js.map +1 -1
  21. package/dist/qualified-name.d.ts +9 -0
  22. package/dist/qualified-name.d.ts.map +1 -0
  23. package/dist/qualified-name.js +21 -0
  24. package/dist/qualified-name.js.map +1 -0
  25. package/dist/scope.d.ts +121 -0
  26. package/dist/scope.d.ts.map +1 -0
  27. package/dist/scope.js +193 -0
  28. package/dist/scope.js.map +1 -0
  29. package/dist/snapshot/plan.d.ts +23 -1
  30. package/dist/snapshot/plan.d.ts.map +1 -1
  31. package/dist/snapshot/plan.js +17 -9
  32. package/dist/snapshot/plan.js.map +1 -1
  33. package/dist/types.d.ts +17 -0
  34. package/dist/types.d.ts.map +1 -1
  35. package/dist/unmanaged.d.ts.map +1 -1
  36. package/dist/unmanaged.js +3 -3
  37. package/dist/unmanaged.js.map +1 -1
  38. package/dist/verify/replay-engine.d.ts +10 -0
  39. package/dist/verify/replay-engine.d.ts.map +1 -0
  40. package/dist/verify/replay-engine.js +161 -0
  41. package/dist/verify/replay-engine.js.map +1 -0
  42. package/dist/verify/replay.d.ts +15 -0
  43. package/dist/verify/replay.d.ts.map +1 -1
  44. package/dist/verify/replay.js +7 -1
  45. package/dist/verify/replay.js.map +1 -1
  46. package/package.json +14 -3
  47. package/src/diff/index.ts +8 -7
  48. package/src/drift/drift.ts +55 -15
  49. package/src/emit/postgres.ts +70 -12
  50. package/src/emit/sqlite.ts +9 -2
  51. package/src/expected-schema.ts +57 -2
  52. package/src/index.ts +18 -2
  53. package/src/qualified-name.ts +22 -0
  54. package/src/scope.ts +261 -0
  55. package/src/snapshot/plan.ts +45 -13
  56. package/src/types.ts +17 -0
  57. package/src/unmanaged.ts +2 -3
  58. package/src/verify/replay-engine.ts +184 -0
  59. package/src/verify/replay.ts +21 -1
package/dist/scope.js ADDED
@@ -0,0 +1,193 @@
1
+ // Per-command scope — narrowing a migrate/verify run to the objects it governs.
2
+ //
3
+ // A consumer sharing a database with another owner declares
4
+ // `"migrate": { "scope": ["acme::platform::**"] }`. Tables and views outside that
5
+ // scope are neither created nor dropped, which takes TWO suppressions:
6
+ //
7
+ // 1. drop them from the EXPECTED side, so nothing is created or altered;
8
+ // 2. suppress the same names on the ACTUAL side (via `diff`'s `unmanagedNames`,
9
+ // the seam `@unmanaged` already uses), so nothing is dropped.
10
+ //
11
+ // Doing only (1) is strictly worse than doing nothing: every out-of-scope table that
12
+ // EXISTS in the database becomes a proposed `DROP TABLE` — the precise hazard this
13
+ // feature exists to remove. `scopeExpectedSchema` therefore returns both halves and
14
+ // callers must thread `outOfScope` into the diff.
15
+ //
16
+ // There is a THIRD half, and it is the one that bites hardest when the scope is
17
+ // wrong. `diff` derives its SCHEMA scope from the schemas the expected side
18
+ // mentions, falling back to "no schema scoping at all" when expected is empty (the
19
+ // legacy whole-DB path for a project with no model). A scope matching NOTHING
20
+ // empties `expected`, reaches that fallback, and every actual table in every schema
21
+ // becomes a drop candidate — another owner's included, which was never in `expected`
22
+ // so it has no provenance and never lands in `outOfScope`. Narrowing must never
23
+ // WIDEN. `declaredSchemas` below reports the UNSCOPED model's schemas so callers can
24
+ // pin `diff`'s `scopeSchemas` to a property of the whole model, which `migrate.scope`
25
+ // then cannot move in either direction.
26
+ //
27
+ // THE RULE THAT FOLLOWS FROM THAT, stated once because it is easy to read the other
28
+ // way: **a scope narrows which OBJECTS the tool governs, never which SCHEMAS it is
29
+ // allowed to see.** Pinning `scopeSchemas` to the unscoped model means a scope that
30
+ // excludes every declared object in schema `X` leaves `X` in scope, so another
31
+ // owner's UNDECLARED table in `X` stays a drop candidate — exactly as it would be on
32
+ // an unscoped run of the same model. That is deliberate: a schema this model
33
+ // declares into is a schema this model manages, and deriving the schema set from the
34
+ // survivors instead is precisely the inversion above. Declaring a scope is not a way
35
+ // to hand a schema over; removing the objects from the model is.
36
+ //
37
+ // `scopedDiffInputs` exists so no caller has to remember any of this: it returns all
38
+ // three obligations as one object, and every scoped `diff` call goes through it.
39
+ import { DEFAULT_DB_SCHEMA_POSTGRES } from "@metaobjectsdev/metadata";
40
+ import { qualifiedDbName } from "./qualified-name.js";
41
+ /**
42
+ * Carry an out-of-scope object forward into the snapshot a run is about to commit.
43
+ *
44
+ * The committed snapshot is built from the metadata-expected schema, which a scoped
45
+ * run has already narrowed — so accepting a scoped run DELETES every out-of-scope
46
+ * entry the previous snapshot held. Widening or removing `migrate.scope` later then
47
+ * proposes `CREATE TABLE` for a table that exists, and the migration fails at apply.
48
+ *
49
+ * `prior` is the snapshot (or introspected schema) the run diffed against, and the
50
+ * entries taken from it are exactly the ones this run excluded — nothing else is
51
+ * carried, so a table the model never declared is unaffected either way. An empty
52
+ * `outOfScope` returns the SAME object, so an unscoped run commits a byte-identical
53
+ * snapshot.
54
+ */
55
+ export function carryForwardOutOfScope(next, prior, outOfScope) {
56
+ if (outOfScope.length === 0)
57
+ return next;
58
+ const excluded = new Set(outOfScope);
59
+ return {
60
+ ...next,
61
+ tables: [...next.tables, ...splitOnName(prior.tables, excluded).named],
62
+ views: [...next.views, ...splitOnName(prior.views, excluded).named],
63
+ };
64
+ }
65
+ /**
66
+ * Drop the out-of-scope entries from a COMMITTED SNAPSHOT, producing the same
67
+ * three-part shape `scopeExpectedSchema` produces so the result can go straight
68
+ * through {@link scopedDiffInputs}.
69
+ *
70
+ * `verify`'s committed-snapshot gate (#292) needs this: `unmanagedNames` suppresses
71
+ * only the ACTUAL side, which is right when the expected side is the metadata (it is
72
+ * already scoped) and wrong here, where the expected side IS the snapshot — a
73
+ * snapshot written before the scope was declared still carries the other owner's
74
+ * tables, and leaving them in reports a phantom disagreement about an object this
75
+ * consumer does not manage.
76
+ *
77
+ * `governed` is the scope decision the caller's drift comparison already made — pass
78
+ * the `DriftResult` itself, which satisfies this shape. Taking `declaredSchemas`
79
+ * from there rather than re-deriving it from the snapshot is what closes the last
80
+ * whole-database door: a snapshot that is present but EMPTY (a never-migrated
81
+ * project) declares no schemas at all, so deriving from it hands `diff` nothing and
82
+ * reaches its "no model, govern the whole database" fallback — the very inversion
83
+ * this module exists to prevent, at the one call site that was still re-deriving.
84
+ *
85
+ * An empty `outOfScope` returns the SAME snapshot object with no schema pin, so an
86
+ * unscoped project's `diff` arguments are byte-for-byte what they always were.
87
+ */
88
+ export function excludeFromSnapshot(snapshot, governed) {
89
+ if (governed.outOfScope.length === 0)
90
+ return { snapshot, outOfScope: [] };
91
+ const excluded = new Set(governed.outOfScope);
92
+ const declared = governed.declaredSchemas ?? declaredSchemasOf(snapshot);
93
+ return {
94
+ snapshot: {
95
+ ...snapshot,
96
+ tables: splitOnName(snapshot.tables, excluded).rest,
97
+ views: splitOnName(snapshot.views, excluded).rest,
98
+ },
99
+ outOfScope: [...governed.outOfScope],
100
+ declaredSchemas: [...declared],
101
+ };
102
+ }
103
+ /**
104
+ * Partition `objs` on whether `qualifiedDbName(o)` is in `names`.
105
+ *
106
+ * `carryForwardOutOfScope` wants the `named` half (carry the excluded entries
107
+ * forward) and `excludeFromSnapshot` wants the `rest` half (drop them). They are
108
+ * exact complements over the same key function, so they share one traversal rather
109
+ * than two filters that could come to key differently.
110
+ */
111
+ function splitOnName(objs, names) {
112
+ const named = [];
113
+ const rest = [];
114
+ for (const o of objs)
115
+ (names.has(qualifiedDbName(o)) ? named : rest).push(o);
116
+ return { named, rest };
117
+ }
118
+ /**
119
+ * The three `diff` arguments a scoped run owes, as ONE value.
120
+ *
121
+ * The module header lists them as three separate obligations, and five call sites
122
+ * re-derived them by hand — one of which had already drifted into its own guard.
123
+ * Every scoped `diff` call is now
124
+ * `diff({ ...scopedDiffInputs(scoped, collectUnmanagedNames(metadata)), actual, ... })`,
125
+ * so the rule is enforced by the type rather than by the comment.
126
+ *
127
+ * `unmanaged` is the `@unmanaged`-declared set (`collectUnmanagedNames`); it is
128
+ * MERGED with `outOfScope`, never replaced by it — both must reach `diff`.
129
+ * `scopeSchemas` is omitted entirely when the run narrowed nothing, so an unscoped
130
+ * project's arguments are unchanged.
131
+ */
132
+ export function scopedDiffInputs(scoped, unmanaged) {
133
+ return {
134
+ expected: scoped.snapshot,
135
+ unmanagedNames: [...unmanaged, ...scoped.outOfScope],
136
+ ...(scoped.declaredSchemas !== undefined ? { scopeSchemas: scoped.declaredSchemas } : {}),
137
+ };
138
+ }
139
+ /**
140
+ * The distinct database schemas a snapshot's tables and views sit in, absent
141
+ * normalized to the Postgres default — the value `diff` derives for itself when no
142
+ * `scopeSchemas` is supplied. The ONE definition: any caller narrowing an expected
143
+ * side must pin `diff`'s schema scope to the UNNARROWED snapshot's schemas, and a
144
+ * second encoding of "absent means public" here would silently disagree with the
145
+ * one inside `diff`.
146
+ *
147
+ * Empty in ⇒ empty out, which callers translate to "pass nothing", preserving
148
+ * `diff`'s legacy whole-database fallback for a genuinely empty model.
149
+ */
150
+ export function declaredSchemasOf(snapshot) {
151
+ return [
152
+ ...new Set([...snapshot.tables, ...snapshot.views].map((o) => o.schema ?? DEFAULT_DB_SCHEMA_POSTGRES)),
153
+ ].sort();
154
+ }
155
+ /**
156
+ * Narrow an expected schema to the objects inside `inScope`.
157
+ *
158
+ * An undefined predicate returns the input untouched — the SAME snapshot object,
159
+ * not an equal copy — so a project that declares no `migrate.scope` reaches the
160
+ * diff, the emitter and the committed snapshot through an unchanged value.
161
+ *
162
+ * A table or view with NO recorded provenance is KEPT. Scope decides on the
163
+ * declaring object's FQN, and an object whose FQN is unknown was never proven to be
164
+ * anyone else's; dropping it would silently un-manage it (and, worse, suppressing
165
+ * its name on the actual side would hide real drift).
166
+ */
167
+ export function scopeExpectedSchema(built, inScope) {
168
+ if (inScope === undefined)
169
+ return { snapshot: built.snapshot, outOfScope: [] };
170
+ // Computed from `built.snapshot` — the UNSCOPED side — deliberately, and before
171
+ // the filter below runs. Deriving it from the survivors would reproduce exactly
172
+ // the defect this exists to close.
173
+ const declared = declaredSchemasOf(built.snapshot);
174
+ const outOfScope = [];
175
+ const governed = (obj) => {
176
+ const qualified = qualifiedDbName(obj);
177
+ const fqn = built.provenance.get(qualified);
178
+ if (fqn === undefined || inScope(fqn))
179
+ return true;
180
+ outOfScope.push(qualified);
181
+ return false;
182
+ };
183
+ return {
184
+ snapshot: {
185
+ ...built.snapshot,
186
+ tables: built.snapshot.tables.filter(governed),
187
+ views: built.snapshot.views.filter(governed),
188
+ },
189
+ outOfScope,
190
+ ...(declared.length > 0 ? { declaredSchemas: declared } : {}),
191
+ };
192
+ }
193
+ //# sourceMappingURL=scope.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scope.js","sourceRoot":"","sources":["../src/scope.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,EAAE;AACF,4DAA4D;AAC5D,kFAAkF;AAClF,uEAAuE;AACvE,EAAE;AACF,2EAA2E;AAC3E,kFAAkF;AAClF,mEAAmE;AACnE,EAAE;AACF,qFAAqF;AACrF,mFAAmF;AACnF,oFAAoF;AACpF,kDAAkD;AAClD,EAAE;AACF,gFAAgF;AAChF,4EAA4E;AAC5E,mFAAmF;AACnF,8EAA8E;AAC9E,oFA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AAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAC9D,CAAC;AACJ,CAAC"}
@@ -1,5 +1,6 @@
1
1
  import type { ColumnNamingStrategy, MetaData } from "@metaobjectsdev/metadata";
2
2
  import { type DiffArgs } from "../diff/index.js";
3
+ import { type ObjectScopePredicate } from "../scope.js";
3
4
  import type { Dialect, DiffResult, SchemaSnapshot } from "../types.js";
4
5
  import type { ExpectedViewInput } from "../expected-schema.js";
5
6
  export interface PlanOfflineArgs extends Pick<DiffArgs, "allow" | "onAmbiguous" | "ignoreTables"> {
@@ -10,12 +11,33 @@ export interface PlanOfflineArgs extends Pick<DiffArgs, "allow" | "onAmbiguous"
10
11
  columnNamingStrategy?: ColumnNamingStrategy;
11
12
  /** Expected views (via codegen-ts `buildProjectionViews`) — threaded into buildExpectedSchema. */
12
13
  views?: readonly ExpectedViewInput[];
14
+ /**
15
+ * Per-command scope (`migrate.scope`): objects whose declaring FQN this predicate
16
+ * rejects are governed by somebody else. They leave the expected side (so no
17
+ * create/alter) AND the snapshot side (so no drop). Omit to govern everything
18
+ * loaded (unchanged behavior).
19
+ */
20
+ inScope?: ObjectScopePredicate;
13
21
  }
14
22
  export interface PlanOfflineResult {
15
23
  /** The change set to emit, from diffing metadata-expected against the snapshot. */
16
24
  diff: DiffResult;
17
- /** The schema the migration brings us to — write this back as the new snapshot on accept. */
25
+ /**
26
+ * The schema the migration brings us to — write this back as the new snapshot on
27
+ * accept. Under a scope this is the governed schema PLUS the out-of-scope entries
28
+ * the prior snapshot held: committing the narrowed schema would delete them, and a
29
+ * later widening would then propose CREATE TABLE for a table that exists.
30
+ */
18
31
  nextSnapshot: SchemaSnapshot;
32
+ /**
33
+ * The governed (narrowed) expected side — what the diff compared and what the
34
+ * emitter renders against. Identical to `nextSnapshot` for an unscoped run; under
35
+ * a scope it is deliberately the SMALLER of the two, since a run must emit DDL
36
+ * only for what it governs.
37
+ */
38
+ expected: SchemaSnapshot;
39
+ /** Qualified physical names excluded by `inScope`; empty when no scope was given. */
40
+ outOfScope: readonly string[];
19
41
  }
20
42
  /**
21
43
  * Plan a migration offline: build the expected schema from metadata and diff it
@@ -1 +1 @@
1
- {"version":3,"file":"plan.d.ts","sourceRoot":"","sources":["../../src/snapshot/plan.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,oBAAoB,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAE/E,OAAO,EAAQ,KAAK,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAEvD,OAAO,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AACvE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAE/D,MAAM,WAAW,eAAgB,SAAQ,IAAI,CAAC,QAAQ,EAAE,OAAO,GAAG,aAAa,GAAG,cAAc,CAAC;IAC/F,QAAQ,EAAE,QAAQ,CAAC;IACnB,OAAO,EAAE,OAAO,CAAC;IACjB,4GAA4G;IAC5G,QAAQ,EAAE,cAAc,CAAC;IACzB,oBAAoB,CAAC,EAAE,oBAAoB,CAAC;IAC5C,kGAAkG;IAClG,KAAK,CAAC,EAAE,SAAS,iBAAiB,EAAE,CAAC;CACtC;AAED,MAAM,WAAW,iBAAiB;IAChC,mFAAmF;IACnF,IAAI,EAAE,UAAU,CAAC;IACjB,6FAA6F;IAC7F,YAAY,EAAE,cAAc,CAAC;CAC9B;AAED;;;;GAIG;AACH,wBAAsB,WAAW,CAAC,IAAI,EAAE,eAAe,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAuBnF;AAED,8EAA8E;AAC9E,wBAAgB,oBAAoB,CAClC,QAAQ,EAAE,QAAQ,EAClB,OAAO,EAAE,OAAO,EAChB,oBAAoB,CAAC,EAAE,oBAAoB,EAC3C,KAAK,CAAC,EAAE,SAAS,iBAAiB,EAAE,GACnC,cAAc,CAMhB"}
1
+ {"version":3,"file":"plan.d.ts","sourceRoot":"","sources":["../../src/snapshot/plan.ts"],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 -1,34 +1,42 @@
1
- import { buildExpectedSchema } from "../expected-schema.js";
1
+ import { buildExpectedSchema, buildExpectedSchemaWithProvenance } from "../expected-schema.js";
2
2
  import { diff } from "../diff/index.js";
3
3
  import { collectUnmanagedNames } from "../unmanaged.js";
4
+ import { carryForwardOutOfScope, scopeExpectedSchema, scopedDiffInputs } from "../scope.js";
4
5
  /**
5
6
  * Plan a migration offline: build the expected schema from metadata and diff it
6
7
  * against the stored snapshot. No database. The caller emits `diff` and, on
7
8
  * accept, persists `nextSnapshot` via writeSnapshot.
8
9
  */
9
10
  export async function planOffline(args) {
10
- const nextSnapshot = buildExpectedSchema(args.metadata, {
11
+ const scoped = scopeExpectedSchema(buildExpectedSchemaWithProvenance(args.metadata, {
11
12
  dialect: args.dialect,
12
13
  ...(args.columnNamingStrategy ? { columnNamingStrategy: args.columnNamingStrategy } : {}),
13
14
  ...(args.views !== undefined ? { views: args.views } : {}),
14
- });
15
+ }), args.inScope);
16
+ // The DIFF runs against the narrowed side; the SNAPSHOT keeps what this run
17
+ // excluded. Committing the narrowed schema would delete every out-of-scope entry
18
+ // the previous snapshot held, so removing or widening `migrate.scope` later would
19
+ // propose CREATE TABLE for a table that exists and fail at apply. Byte-identical
20
+ // for an unscoped run (`outOfScope` empty ⇒ the same object).
21
+ const nextSnapshot = carryForwardOutOfScope(scoped.snapshot, args.snapshot, scoped.outOfScope);
15
22
  const result = await diff({
16
- expected: nextSnapshot,
23
+ // The three scoped-diff obligations as one value (see scope.ts's header). The
24
+ // `unmanagedNames` merge matters as much on the OFFLINE path as anywhere: an
25
+ // out-of-scope table already recorded in the snapshot must not be dropped just
26
+ // because the scope excludes it, and neither must a declared-@unmanaged one a
27
+ // `baseline --from-db` captured (#208 §7).
28
+ ...scopedDiffInputs(scoped, collectUnmanagedNames(args.metadata)),
17
29
  actual: args.snapshot,
18
30
  dialect: args.dialect,
19
31
  // #258 — migration generation refuses a primary-key MOVE (there is no primary-key
20
32
  // change kind to express it; it would otherwise silently drop the constraint). The
21
33
  // read-only verify/drift path does NOT set this, so `meta verify` still reports drift.
22
34
  refusePrimaryKeyChange: true,
23
- // #208 §7 — exclude declared-@unmanaged objects from the actual (snapshot) side too,
24
- // so the OFFLINE generate path never proposes DROP for an external table that a
25
- // `baseline --from-db` captured into the snapshot (parity with the online/verify paths).
26
- unmanagedNames: collectUnmanagedNames(args.metadata),
27
35
  ...(args.allow ? { allow: args.allow } : {}),
28
36
  ...(args.onAmbiguous ? { onAmbiguous: args.onAmbiguous } : {}),
29
37
  ...(args.ignoreTables ? { ignoreTables: args.ignoreTables } : {}),
30
38
  });
31
- return { diff: result, nextSnapshot };
39
+ return { diff: result, nextSnapshot, expected: scoped.snapshot, outOfScope: scoped.outOfScope };
32
40
  }
33
41
  /** Seed an initial reference snapshot from metadata (greenfield baseline). */
34
42
  export function baselineFromMetadata(metadata, dialect, columnNamingStrategy, views) {
@@ -1 +1 @@
1
- {"version":3,"file":"plan.js","sourceRoot":"","sources":["../../src/snapshot/plan.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,IAAI,EAAiB,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAqBxD;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,IAAqB;IACrD,MAAM,YAAY,GAAG,mBAAmB,CAAC,IAAI,CAAC,QAAQ,EAAE;QACtD,OAAO,EAAE,IAAI,CAAC,OAAO;QACrB,GAAG,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC,CAAC,EAAE,oBAAoB,EAAE,IAAI,CAAC,oBAAoB,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACzF,GAAG,CAAC,IAAI,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAA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I,CAAC,OAAO;QACrB,kFAAkF;QAClF,mFAAmF;QACnF,uFAAuF;QACvF,sBAAsB,EAAE,IAAI;QAC5B,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC5C,GAAG,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC9D,GAAG,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,YAAY,EAAE,IAAI,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAClE,CAAC,CAAC;IACH,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,CAAC,QAAQ,EAAE,UAAU,EAAE,MAAM,CAAC,UAAU,EAAE,CAAC;AAClG,CAAC;AAED,8EAA8E;AAC9E,MAAM,UAAU,oBAAoB,CAClC,QAAkB,EAClB,OAAgB,EAChB,oBAA2C,EAC3C,KAAoC;IAEpC,OAAO,mBAAmB,CAAC,QAAQ,EAAE;QACnC,OAAO;QACP,GAAG,CAAC,oBAAoB,CAAC,CAAC,CAAC,EAAE,oBAAoB,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACzD,GAAG,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAC1C,CAAC,CAAC;AACL,CAAC"}
package/dist/types.d.ts CHANGED
@@ -401,6 +401,23 @@ export interface AllowOptions {
401
401
  * skips the default-diff for a live auto-sequence default entirely.)
402
402
  */
403
403
  dropIdentityDefault?: boolean;
404
+ /**
405
+ * Permits dropping an object the COMMITTED SNAPSHOT never contained — i.e. one
406
+ * this toolchain never managed. Without it, such a drop is refused at generation
407
+ * time, because the migration it would write cannot replay against a database
408
+ * where that object never existed (#313). `classify.ts` already states the
409
+ * doctrine: objects present in the DB but not the snapshot "must never be treated
410
+ * as actionable drift or auto-dropped".
411
+ *
412
+ * The ONE field here read by the CLI's generation-time provenance guard rather
413
+ * than by `diff()`'s status pass — `diff` compares metadata against introspection
414
+ * and never sees the snapshot, which is precisely why the doctrine was not
415
+ * enforced where it mattered. It lives in `AllowOptions` anyway so `--allow` keeps
416
+ * ONE token list and ONE grant map (`ALLOW_TOKENS` / `ALLOW_TOKEN_MAP`, pinned
417
+ * together by `cli/test/unit/allow-tokens-pinned.test.ts`): a second parallel
418
+ * validation path for a single token is the exact drift that pin exists to catch.
419
+ */
420
+ dropUnmanaged?: boolean;
404
421
  }
405
422
  export type AmbiguousChange = {
406
423
  kind: "possible-column-rename";
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAO7C,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,eAAe,EAAE,CAAC;IAC1B,8EAA8E;IAC9E,KAAK,EAAE,cAAc,EAAE,CAAC;IACxB;;;OAGG;IACH,IAAI,CAAC,EAAE,YAAY,CAAC;CACrB;AAED,MAAM,WAAW,YAAY;IAC3B,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb;;;;OAIG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,gBAAgB,EAAE,CAAC;IAC5B,OAAO,EAAE,eAAe,EAAE,CAAC;IAC3B,WAAW,EAAE,YAAY,EAAE,CAAC;IAC5B,MAAM,EAAE,eAAe,EAAE,CAAC;IAC1B,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB;;;;;OAKG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW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C9B,IAAI,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAA;KAAE,CAAC;IAC5C,EAAE,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAA;KAAE,CAAC;IAC1C,aAAa,EAAE,MAAM,CAAC;CACvB,CAAC;AAEN,MAAM,MAAM,mBAAmB,GAAG,QAAQ,GAAG,UAAU,GAAG,OAAO,CAAC;AAElE,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,EAAE,eAAe,KAAK,OAAO,CAAC,mBAAmB,CAAC,CAAC;AAErF,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,iGAAiG;IACjG,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB;AAMD,MAAM,WAAW,UAAU;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb;;;;;;OAMG;IACH,eAAe,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;CACtC;AAED,MAAM,MAAM,OAAO,GAAG,UAAU,GAAG,QAAQ,GAAG,IAAI,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"unmanaged.d.ts","sourceRoot":"","sources":["../src/unmanaged.ts"],"names":[],"mappings":"AASA,OAAO,EAKL,KAAK,QAAQ,EACd,MAAM,0BAA0B,CAAC;AAElC;;;;;;;;;;;;;GAaG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,QAAQ,GAAG,MAAM,EAAE,CAc9D"}
1
+ {"version":3,"file":"unmanaged.d.ts","sourceRoot":"","sources":["../src/unmanaged.ts"],"names":[],"mappings":"AASA,OAAO,EAIL,KAAK,QAAQ,EACd,MAAM,0BAA0B,CAAC;AAGlC;;;;;;;;;;;;;GAaG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,QAAQ,GAAG,MAAM,EAAE,CAa9D"}
package/dist/unmanaged.js CHANGED
@@ -6,7 +6,8 @@
6
6
  // buildProjectionViews skips an @unmanaged view), so no create is proposed. This set is
7
7
  // the ACT-side half: threaded into `diff`, it excludes these names from the introspected
8
8
  // ACTUAL side so a declared-external object produces SILENCE, not a policy-gated drop.
9
- import { isMetaSource, resolveTableSchema, DEFAULT_DB_SCHEMA_POSTGRES, TYPE_OBJECT, } from "@metaobjectsdev/metadata";
9
+ import { isMetaSource, resolveTableSchema, TYPE_OBJECT, } from "@metaobjectsdev/metadata";
10
+ import { qualifiedDbName } from "./qualified-name.js";
10
11
  /**
11
12
  * The qualified physical names (`schema.name`, schema defaulting to Postgres `public`)
12
13
  * of every DB object declared `@unmanaged`. The format matches `tableIdentity` /
@@ -32,8 +33,7 @@ export function collectUnmanagedNames(root) {
32
33
  // object, turning it back into a proposed drop.
33
34
  if (!isMetaSource(src) || !src.isUnmanaged)
34
35
  continue;
35
- const schema = resolveTableSchema(obj) ?? DEFAULT_DB_SCHEMA_POSTGRES;
36
- out.push(`${schema}.${src.physicalName}`);
36
+ out.push(qualifiedDbName({ name: src.physicalName, schema: resolveTableSchema(obj) }));
37
37
  }
38
38
  }
39
39
  return out;
@@ -1 +1 @@
1
- {"version":3,"file":"unmanaged.js","sourceRoot":"","sources":["../src/unmanaged.ts"],"names":[],"mappings":"AAAA,8CAA8C;AAC9C,EAAE;AACF,mFAAmF;AACnF,oFAAoF;AACpF,uFAAuF;AACvF,wFAAwF;AACxF,yFAAyF;AACzF,uFAAuF;AAEvF,OAAO,EACL,YAAY,EACZ,kBAAkB,EAClB,0BAA0B,EAC1B,WAAW,GAEZ,MAAM,0BAA0B,CAAC;AAElC;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,qBAAqB,CAAC,IAAc;IAClD,MAAM,GAAG,GAAa,EAAE,CAAC;IACzB,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,QAAQ,EAAE,EAAE,CAAC;QAClC,IAAI,GAAG,CAAC,IAAI,KAAK,WAAW;YAAE,SAAS;QACvC,KAAK,MA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kB,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC;QACzF,CAAC;IACH,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
@@ -0,0 +1,10 @@
1
+ import { Kysely } from "kysely";
2
+ export interface ReplayEngine {
3
+ /** An empty database. The caller owns applying migrations into it. */
4
+ db: Kysely<Record<string, unknown>>;
5
+ /** Release the engine. Safe to call more than once. */
6
+ dispose: () => Promise<void>;
7
+ }
8
+ /** Open an empty in-process database of the given dialect. */
9
+ export declare function openReplayEngine(dialect: "postgres" | "sqlite"): Promise<ReplayEngine>;
10
+ //# sourceMappingURL=replay-engine.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"replay-engine.d.ts","sourceRoot":"","sources":["../../src/verify/replay-engine.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAKhC,MAAM,WAAW,YAAY;IAC3B,sEAAsE;IACtE,EAAE,EAAE,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IACpC,uDAAuD;IACvD,OAAO,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAC9B;AAED,8DAA8D;AAC9D,wBAAsB,gBAAgB,CACpC,OAAO,EAAE,UAAU,GAAG,QAAQ,GAC7B,OAAO,CAAC,YAAY,CAAC,CAEvB"}
@@ -0,0 +1,161 @@
1
+ // An empty, throwaway database that lives INSIDE this process.
2
+ //
3
+ // The replay gate has to apply a whole committed chain from nothing. Doing that
4
+ // against the user's server would mean CREATE DATABASE — which needs CREATEDB,
5
+ // breaks behind a connection pooler, is restricted on managed Postgres, collides
6
+ // between parallel CI jobs sharing one server, and puts a DROP DATABASE next to a
7
+ // name derived from a real one (Postgres truncates identifiers at 63 bytes, so a
8
+ // long enough target derives a scratch name that truncates back ONTO the target).
9
+ // None of that is worth it when the engine runs locally and disposably: PGlite is
10
+ // real Postgres compiled to WASM and lives in this process; sqlite is a throwaway
11
+ // file in a private temp directory (see `openMemorySqlite` for why not `:memory:`).
12
+ // Nothing to provision, nothing to name, nothing to drop by mistake.
13
+ //
14
+ // Both drivers are OPTIONAL peers imported lazily. PGlite is ~22 MB of WASM and must
15
+ // not land in the node_modules of every adopter who only ever runs `meta gen`; the
16
+ // install hints mirror `buildKyselyFromUrl`'s. `cli` already depends on
17
+ // `@libsql/kysely-libsql` outright, so only a direct embedder can miss that one.
18
+ import { Kysely } from "kysely";
19
+ import { mkdtempSync, rmSync } from "node:fs";
20
+ import { tmpdir } from "node:os";
21
+ import { join } from "node:path";
22
+ /** Open an empty in-process database of the given dialect. */
23
+ export async function openReplayEngine(dialect) {
24
+ return dialect === "postgres" ? openPglite() : openMemorySqlite();
25
+ }
26
+ /**
27
+ * A throwaway sqlite database in a private temp directory, removed on dispose.
28
+ *
29
+ * NOT `:memory:`, and that is the whole point of this comment. Under
30
+ * `@libsql/kysely-libsql`, `:memory:` gives every CONNECTION its own database — so a
31
+ * table created inside a transaction is invisible the moment the transaction's
32
+ * connection is released. `applyPending` runs each migration file in a transaction,
33
+ * which means an in-memory engine would replay a whole chain into a series of
34
+ * throwaway databases, introspect an empty one, and never let migration 2 see
35
+ * migration 1's tables. The gate would pass having proved nothing.
36
+ *
37
+ * `file::memory:?cache=shared` fixes the visibility and breaks isolation instead —
38
+ * two engines in one process land in the SAME database — and libsql rejects the
39
+ * named `?mode=memory&cache=shared` form outright (`URL_PARAM_NOT_SUPPORTED`). A
40
+ * unique temp file is correct on both counts, and it is what the existing
41
+ * `test/integrity/replay.test.ts` has always used.
42
+ */
43
+ async function openMemorySqlite() {
44
+ let LibsqlDialect;
45
+ try {
46
+ const mod = await import("@libsql/kysely-libsql");
47
+ LibsqlDialect = mod.LibsqlDialect;
48
+ }
49
+ catch {
50
+ throw new Error(`the sqlite replay engine requires '@libsql/kysely-libsql'; install it to run 'meta verify --replay'`);
51
+ }
52
+ const dir = mkdtempSync(join(tmpdir(), "meta-replay-"));
53
+ const db = new Kysely({
54
+ dialect: new LibsqlDialect({ url: `file:${join(dir, "replay.db")}` }),
55
+ });
56
+ return disposable(db, async () => {
57
+ rmSync(dir, { recursive: true, force: true });
58
+ });
59
+ }
60
+ async function openPglite() {
61
+ let PGliteCtor;
62
+ try {
63
+ const mod = await import("@electric-sql/pglite");
64
+ PGliteCtor = mod.PGlite;
65
+ }
66
+ catch {
67
+ throw new Error(`the postgres replay engine requires '@electric-sql/pglite' (in-process WASM Postgres); ` +
68
+ `install it to run 'meta verify --replay' against a postgres chain`);
69
+ }
70
+ const { PostgresDialect } = await import("kysely");
71
+ // PGlite is Postgres compiled to WASM, and Emscripten propagates the WASM
72
+ // program's internal exit status into `process.exitCode` — it becomes 99 on the
73
+ // FIRST QUERY (not on teardown) and stays there for the life of the process.
74
+ // Opening an engine must not decide what the HOST process exits with, so the
75
+ // caller's value is captured here and restored on dispose.
76
+ //
77
+ // `bin/meta.ts` ends with `process.exit(code)`, which overrides this, so the
78
+ // shipped CLI never showed it. Anything that does NOT force its own exit did:
79
+ // this package's `bun test` exited 99 on 0 failures, turning two
80
+ // `ci-local.sh --only ts` gates red with no failing test to point at, and an
81
+ // embedder calling `openReplayEngine` directly would exit non-zero on success.
82
+ const hostExitCode = process.exitCode;
83
+ const pg = new PGliteCtor();
84
+ const db = new Kysely({
85
+ dialect: new PostgresDialect({ pool: pgliteAsPool(pg) }),
86
+ });
87
+ // `?? 0` is load-bearing, not defensive: assigning `undefined` to
88
+ // `process.exitCode` is a NO-OP under Bun (measured — set 99, assign
89
+ // `undefined`, it stays 99; assign 0 and it clears). The pristine value IS
90
+ // `undefined`, so restoring it literally runs and changes nothing — which is
91
+ // the shape this bug already took once during the fix.
92
+ //
93
+ // The restore sits in a `finally` because this close is frequently the SECOND:
94
+ // `disposable` runs `db.destroy()` first, which drives the pool's `end()`,
95
+ // which already called `pg.close()`, so this call throws `PGlite is closed`.
96
+ return disposable(db, async () => {
97
+ try {
98
+ await pg.close();
99
+ }
100
+ finally {
101
+ process.exitCode = hostExitCode ?? 0;
102
+ }
103
+ });
104
+ }
105
+ /**
106
+ * Adapt PGlite to the `pg.Pool` shape kysely's `PostgresDialect` expects: `connect()`
107
+ * returning a client with `query()`/`release()`, plus `end()`. PGlite offers only
108
+ * `query`/`close`, so without this the dialect cannot drive it at all.
109
+ *
110
+ * PGlite is a SINGLE session, so every `connect()` hands back the same underlying
111
+ * instance. That is correct here — a replay is strictly sequential — and it is what
112
+ * makes a session advisory lock taken on one kysely connection visible to the next.
113
+ *
114
+ * `command` is read by kysely only to decide whether to report numAffectedRows; the
115
+ * replay path never reads it, so PGlite's `statement` (or a SELECT default) suffices.
116
+ */
117
+ function pgliteAsPool(pg) {
118
+ return {
119
+ async connect() {
120
+ return {
121
+ async query(sqlText, params) {
122
+ if (typeof sqlText !== "string") {
123
+ throw new Error(`the PGlite replay engine does not support cursors`);
124
+ }
125
+ const r = await pg.query(sqlText, params ? [...params] : []);
126
+ return {
127
+ command: r.statement ?? "SELECT",
128
+ rowCount: r.affectedRows ?? r.rows.length,
129
+ rows: r.rows,
130
+ };
131
+ },
132
+ release() { },
133
+ };
134
+ },
135
+ async end() {
136
+ await pg.close();
137
+ },
138
+ };
139
+ }
140
+ function disposable(db, closeEngine) {
141
+ let disposed = false;
142
+ return {
143
+ db,
144
+ dispose: async () => {
145
+ if (disposed)
146
+ return;
147
+ disposed = true;
148
+ // Both swallow: the engine is throwaway, and a teardown error must not mask
149
+ // the replay verdict the caller is about to report.
150
+ try {
151
+ await db.destroy();
152
+ }
153
+ catch { /* ignore */ }
154
+ try {
155
+ await closeEngine();
156
+ }
157
+ catch { /* ignore */ }
158
+ },
159
+ };
160
+ }
161
+ //# sourceMappingURL=replay-engine.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"replay-engine.js","sourceRoot":"","sources":["../../src/verify/replay-engine.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,EAAE;AACF,gFAAgF;AAChF,+EAA+E;AAC/E,iFAAiF;AACjF,kFA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1,6 @@
1
1
  import type { Kysely } from "kysely";
2
2
  import { type DriftClassification } from "../drift/classify.js";
3
+ import { type GovernedScope } from "../scope.js";
3
4
  import type { Dialect, SchemaSnapshot } from "../types.js";
4
5
  export interface VerifyReplayArgs {
5
6
  /** A FRESH, throwaway database. Replay applies every migration into it from empty. */
@@ -9,6 +10,20 @@ export interface VerifyReplayArgs {
9
10
  migrationsDir: string;
10
11
  /** The committed snapshot the migrations are expected to reproduce. */
11
12
  snapshot: SchemaSnapshot;
13
+ /**
14
+ * The scope decision the run made, as `scopeExpectedSchema` reports it.
15
+ *
16
+ * A project declaring `migrate.scope` carries the OTHER owner's tables into its
17
+ * committed snapshot on purpose (`carryForwardOutOfScope`), and its chain — also on
18
+ * purpose — never creates them. Without this they read as missing on every replay,
19
+ * so a scoped project could never use this check at all.
20
+ *
21
+ * Excluded from the SNAPSHOT side only: the replayed database never had them
22
+ * either, so there is nothing to suppress on the actual side. Omitted ⇒ the
23
+ * comparison is byte-for-byte what it was, which is what every unscoped project
24
+ * gets.
25
+ */
26
+ governed?: GovernedScope;
12
27
  }
13
28
  export interface VerifyReplayResult extends DriftClassification {
14
29
  /** True when the replayed schema matches the snapshot (no drift, no unmanaged). */
@@ -1 +1 @@
1
- {"version":3,"file":"replay.d.ts","sourceRoot":"","sources":["../../src/verify/replay.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAIrC,OAAO,EAAwB,KAAK,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AACtF,OAAO,KAAK,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAE3D,MAAM,WAAW,gBAAgB;IAC/B,sFAAsF;IACtF,EAAE,EAAE,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IACpC,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,UAAU,GAAG,QAAQ,CAAC,CAAC;IACjD,8EAA8E;IAC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