@memberjunction/sql-converter 6.3.0-edge.1 → 6.3.0-edge.2

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 (98) hide show
  1. package/README.md +16 -0
  2. package/dist/IncrementalBaker.d.ts +61 -2
  3. package/dist/IncrementalBaker.d.ts.map +1 -1
  4. package/dist/IncrementalBaker.js +103 -11
  5. package/dist/IncrementalBaker.js.map +1 -1
  6. package/dist/MigrationConverter.d.ts +54 -1
  7. package/dist/MigrationConverter.d.ts.map +1 -1
  8. package/dist/MigrationConverter.js +226 -23
  9. package/dist/MigrationConverter.js.map +1 -1
  10. package/dist/MigrationStatementSplitter.d.ts +11 -1
  11. package/dist/MigrationStatementSplitter.d.ts.map +1 -1
  12. package/dist/MigrationStatementSplitter.js +6 -3
  13. package/dist/MigrationStatementSplitter.js.map +1 -1
  14. package/dist/index.d.ts +6 -6
  15. package/dist/index.d.ts.map +1 -1
  16. package/dist/index.js +3 -3
  17. package/dist/index.js.map +1 -1
  18. package/dist/rules/AlterTableRule.d.ts.map +1 -1
  19. package/dist/rules/AlterTableRule.js +6 -1
  20. package/dist/rules/AlterTableRule.js.map +1 -1
  21. package/dist/rules/BatchConverter.d.ts +16 -0
  22. package/dist/rules/BatchConverter.d.ts.map +1 -1
  23. package/dist/rules/BatchConverter.js +151 -12
  24. package/dist/rules/BatchConverter.js.map +1 -1
  25. package/dist/rules/BitColumnRegistry.d.ts +9 -0
  26. package/dist/rules/BitColumnRegistry.d.ts.map +1 -0
  27. package/dist/rules/BitColumnRegistry.js +111 -0
  28. package/dist/rules/BitColumnRegistry.js.map +1 -0
  29. package/dist/rules/CatalogViewRule.d.ts +6 -0
  30. package/dist/rules/CatalogViewRule.d.ts.map +1 -1
  31. package/dist/rules/CatalogViewRule.js +11 -0
  32. package/dist/rules/CatalogViewRule.js.map +1 -1
  33. package/dist/rules/ConditionalDDLRule.d.ts +6 -0
  34. package/dist/rules/ConditionalDDLRule.d.ts.map +1 -1
  35. package/dist/rules/ConditionalDDLRule.js +30 -0
  36. package/dist/rules/ConditionalDDLRule.js.map +1 -1
  37. package/dist/rules/CreateIndexRule.d.ts +18 -0
  38. package/dist/rules/CreateIndexRule.d.ts.map +1 -1
  39. package/dist/rules/CreateIndexRule.js +47 -14
  40. package/dist/rules/CreateIndexRule.js.map +1 -1
  41. package/dist/rules/CreateTableRule.d.ts.map +1 -1
  42. package/dist/rules/CreateTableRule.js +10 -3
  43. package/dist/rules/CreateTableRule.js.map +1 -1
  44. package/dist/rules/DeclareDmlBlockRule.d.ts +9 -3
  45. package/dist/rules/DeclareDmlBlockRule.d.ts.map +1 -1
  46. package/dist/rules/DeclareDmlBlockRule.js +12 -47
  47. package/dist/rules/DeclareDmlBlockRule.js.map +1 -1
  48. package/dist/rules/DialectHeaderBuilder.d.ts +50 -4
  49. package/dist/rules/DialectHeaderBuilder.d.ts.map +1 -1
  50. package/dist/rules/DialectHeaderBuilder.js +50 -4
  51. package/dist/rules/DialectHeaderBuilder.js.map +1 -1
  52. package/dist/rules/ExpressionHelpers.d.ts +76 -5
  53. package/dist/rules/ExpressionHelpers.d.ts.map +1 -1
  54. package/dist/rules/ExpressionHelpers.js +323 -11
  55. package/dist/rules/ExpressionHelpers.js.map +1 -1
  56. package/dist/rules/FunctionRule.d.ts.map +1 -1
  57. package/dist/rules/FunctionRule.js +7 -5
  58. package/dist/rules/FunctionRule.js.map +1 -1
  59. package/dist/rules/GrantRule.d.ts +12 -1
  60. package/dist/rules/GrantRule.d.ts.map +1 -1
  61. package/dist/rules/GrantRule.js +122 -2
  62. package/dist/rules/GrantRule.js.map +1 -1
  63. package/dist/rules/InsertRule.d.ts +1 -0
  64. package/dist/rules/InsertRule.d.ts.map +1 -1
  65. package/dist/rules/InsertRule.js +156 -9
  66. package/dist/rules/InsertRule.js.map +1 -1
  67. package/dist/rules/PostProcessor.d.ts.map +1 -1
  68. package/dist/rules/PostProcessor.js +43 -26
  69. package/dist/rules/PostProcessor.js.map +1 -1
  70. package/dist/rules/ProcedureToFunctionRule.d.ts +27 -0
  71. package/dist/rules/ProcedureToFunctionRule.d.ts.map +1 -1
  72. package/dist/rules/ProcedureToFunctionRule.js +286 -7
  73. package/dist/rules/ProcedureToFunctionRule.js.map +1 -1
  74. package/dist/rules/SequenceDeduplicator.d.ts +16 -2
  75. package/dist/rules/SequenceDeduplicator.d.ts.map +1 -1
  76. package/dist/rules/SequenceDeduplicator.js +50 -14
  77. package/dist/rules/SequenceDeduplicator.js.map +1 -1
  78. package/dist/rules/StatementClassifier.d.ts +9 -0
  79. package/dist/rules/StatementClassifier.d.ts.map +1 -1
  80. package/dist/rules/StatementClassifier.js +53 -7
  81. package/dist/rules/StatementClassifier.js.map +1 -1
  82. package/dist/rules/SubSplitter.d.ts.map +1 -1
  83. package/dist/rules/SubSplitter.js +95 -2
  84. package/dist/rules/SubSplitter.js.map +1 -1
  85. package/dist/rules/ViewRule.d.ts +0 -2
  86. package/dist/rules/ViewRule.d.ts.map +1 -1
  87. package/dist/rules/ViewRule.js +8 -57
  88. package/dist/rules/ViewRule.js.map +1 -1
  89. package/dist/rules/index.d.ts +6 -4
  90. package/dist/rules/index.d.ts.map +1 -1
  91. package/dist/rules/index.js +4 -3
  92. package/dist/rules/index.js.map +1 -1
  93. package/dist/rules/types.d.ts +12 -2
  94. package/dist/rules/types.d.ts.map +1 -1
  95. package/dist/rules/types.js +7 -0
  96. package/dist/rules/types.js.map +1 -1
  97. package/dist/tsconfig.tsbuildinfo +1 -1
  98. package/package.json +3 -3
package/README.md CHANGED
@@ -108,6 +108,22 @@ sequenceDiagram
108
108
  PP->>O: Final PostgreSQL SQL
109
109
  ```
110
110
 
111
+ ## Bake and rebake
112
+
113
+ `mj migrate convert --split --bake-codegen` applies each new migration to a working PostgreSQL database
114
+ and bakes native CodeGen into its `.pg.sql` (see `IncrementalBaker`). `mj migrate rebake` re-captures
115
+ the CodeGen of migrations that already have a counterpart:
116
+
117
+ | Flag | Effect |
118
+ |---|---|
119
+ | `--file <name>.sql` | Re-bake one migration and write it. A file the baker wrote keeps its hand region (everything above the CodeGen section header) byte for byte; only the CodeGen section is replaced. |
120
+ | `--capture-only` | With `--file`: do not apply the migration (it is already applied); capture its CodeGen only. |
121
+ | `--write` | Without `--file`: write the re-baked files. Without it, a full re-bake is a dry run. |
122
+
123
+ A CodeGen capture that fails after the apply throws `BakeApplyError` naming the file and the
124
+ `mj migrate rebake --file … --capture-only` command that resumes it. `convert` skips `V…` files
125
+ older than the oldest baseline in the source folder (they are inside it).
126
+
111
127
  ## Rule System
112
128
 
113
129
  ### How Rules Work
@@ -48,7 +48,38 @@ export interface BakerWorkingDB {
48
48
  * {@link SelectBakeableEntities} implements the selection over the provider's entity list.
49
49
  */
50
50
  listBakeableEntities(schema: string): Promise<string[]>;
51
+ /**
52
+ * Run PostgreSQL's EntityField sync (`spUpdateExistingEntityFieldsFromSchema`, after ensuring
53
+ * CodeGen's metadata support objects) for the named entities and return the EntityField
54
+ * `DefaultValue` changes it made (issue #5650). Called after a migration's hand body is applied
55
+ * and before the capture, so a default the migration added to an existing column reaches the
56
+ * metadata the baked `spCreate…` is generated from. Optional: a working DB without it bakes as
57
+ * before.
58
+ */
59
+ syncFieldDefaults?(entityDisplayNames: string[]): Promise<FieldDefaultChange[]>;
60
+ }
61
+ /** One EntityField row as {@link BakerWorkingDB.syncFieldDefaults} snapshots it. */
62
+ export interface EntityFieldDefault {
63
+ ID: string;
64
+ EntityName: string;
65
+ FieldName: string;
66
+ DefaultValue: string | null;
67
+ }
68
+ /** A `DefaultValue` the field sync changed: the row after the sync, with the value before it. */
69
+ export interface FieldDefaultChange extends EntityFieldDefault {
70
+ PreviousDefaultValue: string | null;
51
71
  }
72
+ /**
73
+ * The `DefaultValue` changes between two EntityField snapshots, matched on ID (case-insensitive),
74
+ * in `after` order. A row present only after the sync (a new field) is not a change: its
75
+ * registration already carries the default.
76
+ */
77
+ export declare function DiffFieldDefaults(before: ReadonlyArray<EntityFieldDefault>, after: ReadonlyArray<EntityFieldDefault>): FieldDefaultChange[];
78
+ /**
79
+ * The EntityField UPDATEs that carry `DefaultValue` changes into a baked migration, so a fresh
80
+ * install (which never runs the field sync) gets the same metadata the bake used (issue #5650).
81
+ */
82
+ export declare function FieldDefaultUpdatesSQL(changes: ReadonlyArray<FieldDefaultChange>, coreSchema: string): string;
52
83
  /** The entity fields {@link SelectBakeableEntities} reads (a structural subset of `EntityInfo`). */
53
84
  export interface BakeableEntityCandidate {
54
85
  Name: string;
@@ -90,6 +121,8 @@ export interface BakedMigrationResult {
90
121
  unhandled: UnhandledStatement[];
91
122
  /** Hand-written procedural routines the migration carries (require human PG authoring). */
92
123
  handProcedural: string[];
124
+ /** Named, non-blocking warnings from the conversion (never a reason not to bake). */
125
+ warnings: string[];
93
126
  /**
94
127
  * `'baked'` — native CodeGen captured + assembled into `pgSQL`.
95
128
  * `'preserved'` — a transpile gap (unhandled statement / hand-procedural) made an auto-bake
@@ -99,6 +132,30 @@ export interface BakedMigrationResult {
99
132
  */
100
133
  mode: 'baked' | 'preserved' | 'gap-no-bake';
101
134
  }
135
+ /** Options for one {@link IncrementalBaker.BakeMigration} call. */
136
+ export interface BakeMigrationOptions {
137
+ /**
138
+ * Skip applying the migration to the working DB and only capture its CodeGen: the migration is
139
+ * already applied (a capture that failed after the apply, or a hand-finished file applied by
140
+ * hand). Used by `mj migrate rebake --file … --capture-only` (#6538 item 5, #6348).
141
+ */
142
+ CaptureOnly?: boolean;
143
+ }
144
+ /** The two regions of a baked `.pg.sql`: everything above the CodeGen section, and the section. */
145
+ export interface BakedFileRegions {
146
+ /** Header, hand-written DDL and metadata DML — the part a person may have finished by hand. */
147
+ handRegion: string;
148
+ /** The baked CodeGen section, header line included; empty when the file has none. */
149
+ codeGenSection: string;
150
+ }
151
+ /**
152
+ * Split a committed `.pg.sql` that the baker wrote (or a `.needs-hand` artifact a person finished)
153
+ * at the CodeGen section header. Returns null for a file the baker did not write — a legacy
154
+ * conversion has no hand/CodeGen boundary to keep.
155
+ */
156
+ export declare function SplitBakedFile(pgSql: string): BakedFileRegions | null;
157
+ /** The command that resumes a bake whose capture failed after the migration was applied. */
158
+ export declare function CaptureOnlyResumeCommand(fileName: string): string;
102
159
  export declare class IncrementalBaker {
103
160
  private readonly opts;
104
161
  private readonly schema;
@@ -129,9 +186,9 @@ export declare class IncrementalBaker {
129
186
  * gaps (`needs-hand-authoring`); they aren't referenced by base views/sprocs, so the capture is
130
187
  * complete regardless and the caller authors them into the final `.pg.sql`.
131
188
  */
132
- BakeMigration(ssSql: string, fileName: string, committedPgSql?: string): Promise<BakedMigrationResult>;
189
+ BakeMigration(ssSql: string, fileName: string, committedPgSql?: string, options?: BakeMigrationOptions): Promise<BakedMigrationResult>;
133
190
  /** @deprecated Use {@link BakeMigration}. */
134
- bakeMigration(ssSql: string, fileName: string, committedPgSql?: string): Promise<BakedMigrationResult>;
191
+ bakeMigration(ssSql: string, fileName: string, committedPgSql?: string, options?: BakeMigrationOptions): Promise<BakedMigrationResult>;
135
192
  /**
136
193
  * Run one bake path's working-DB apply/capture; on ANY failure, rethrow it as a BakeApplyError
137
194
  * carrying `preservedBody` so the CLI can still write the transpiled artifact to `.needs-hand`
@@ -143,6 +200,8 @@ export declare class IncrementalBaker {
143
200
  private captureEntities;
144
201
  /** Build the standalone baked `.pg.sql`: baked header, hand body, then native CodeGen. */
145
202
  private assemble;
203
+ /** A committed hand region followed by a freshly captured CodeGen section. */
204
+ private withCodeGenSection;
146
205
  private bakedHeader;
147
206
  /** Prepend a search_path set so any unqualified identifiers in the hand body resolve. */
148
207
  private withSearchPath;
@@ -1 +1 @@
1
- {"version":3,"file":"IncrementalBaker.d.ts","sourceRoot":"","sources":["../src/IncrementalBaker.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAExG;;;;;;;GAOG;AACH,qBAAa,cAAe,SAAQ,KAAK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M,CAKxD;AAED,oDAAoD;AACpD,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAExD"}
@@ -16,6 +16,7 @@
16
16
  * dependency — mirroring how `convertMigration` takes an injected transpiler.
17
17
  */
18
18
  import { ConvertMigration } from './MigrationConverter.js';
19
+ import { BuildPgExtensionStatements } from './rules/DialectHeaderBuilder.js';
19
20
  /**
20
21
  * Thrown when the working-DB apply/capture fails DURING a bake — carries the already-transpiled
21
22
  * `transpiledBody` so the caller can still write it to `.needs-hand` instead of discarding it for a
@@ -34,6 +35,35 @@ export class BakeApplyError extends Error {
34
35
  this.name = 'BakeApplyError';
35
36
  }
36
37
  }
38
+ /**
39
+ * The `DefaultValue` changes between two EntityField snapshots, matched on ID (case-insensitive),
40
+ * in `after` order. A row present only after the sync (a new field) is not a change: its
41
+ * registration already carries the default.
42
+ */
43
+ export function DiffFieldDefaults(before, after) {
44
+ const prior = new Map(before.map((f) => [f.ID.toLowerCase(), f]));
45
+ const changes = [];
46
+ for (const f of after) {
47
+ const old = prior.get(f.ID.toLowerCase());
48
+ if (old && old.DefaultValue !== f.DefaultValue)
49
+ changes.push({ ...f, PreviousDefaultValue: old.DefaultValue });
50
+ }
51
+ return changes;
52
+ }
53
+ /**
54
+ * The EntityField UPDATEs that carry `DefaultValue` changes into a baked migration, so a fresh
55
+ * install (which never runs the field sync) gets the same metadata the bake used (issue #5650).
56
+ */
57
+ export function FieldDefaultUpdatesSQL(changes, coreSchema) {
58
+ if (changes.length === 0)
59
+ return '';
60
+ const literal = (v) => (v === null ? 'NULL' : `'${v.replace(/'/g, "''")}'`);
61
+ return [
62
+ '-- EntityField DefaultValue changes from the PostgreSQL field sync (a fresh install does not run it)',
63
+ ...changes.map((c) => `-- ${c.EntityName}.${c.FieldName}\n` +
64
+ `UPDATE ${coreSchema}."EntityField" SET "DefaultValue" = ${literal(c.DefaultValue)} WHERE "ID" = '${c.ID}';`),
65
+ ].join('\n');
66
+ }
37
67
  /**
38
68
  * Select the entities a baseline bake captures: those CodeGen generates objects for
39
69
  * (`IncludeInAPI`, schema not in `excludeSchemas`) that live in `schema`, in input order.
@@ -50,6 +80,25 @@ export function SelectBakeableEntities(entities, schema, excludeSchemas = []) {
50
80
  .filter((e) => e.SchemaName.toLowerCase() === target)
51
81
  .map((e) => e.Name);
52
82
  }
83
+ /** Line that opens the header {@link IncrementalBaker} writes on every baked file. */
84
+ const BAKED_HEADER_MARKER = '-- Split-and-regenerate with INLINE NATIVE CodeGen baking';
85
+ /**
86
+ * Split a committed `.pg.sql` that the baker wrote (or a `.needs-hand` artifact a person finished)
87
+ * at the CodeGen section header. Returns null for a file the baker did not write — a legacy
88
+ * conversion has no hand/CodeGen boundary to keep.
89
+ */
90
+ export function SplitBakedFile(pgSql) {
91
+ if (!pgSql.includes(BAKED_HEADER_MARKER))
92
+ return null;
93
+ const at = pgSql.indexOf(CODEGEN_SECTION_HEADER);
94
+ if (at < 0)
95
+ return { handRegion: pgSql.trimEnd(), codeGenSection: '' };
96
+ return { handRegion: pgSql.slice(0, at).trimEnd(), codeGenSection: pgSql.slice(at).trimEnd() };
97
+ }
98
+ /** The command that resumes a bake whose capture failed after the migration was applied. */
99
+ export function CaptureOnlyResumeCommand(fileName) {
100
+ return `mj migrate rebake --file ${fileName} --capture-only`;
101
+ }
53
102
  const DEFAULT_SCHEMA = '__mj';
54
103
  /** MJ core's schema — the value `${mjSchema}` resolves to unless the caller overrides it. */
55
104
  const DEFAULT_CORE_SCHEMA = '__mj';
@@ -90,7 +139,8 @@ export class IncrementalBaker {
90
139
  * gaps (`needs-hand-authoring`); they aren't referenced by base views/sprocs, so the capture is
91
140
  * complete regardless and the caller authors them into the final `.pg.sql`.
92
141
  */
93
- async BakeMigration(ssSql, fileName, committedPgSql) {
142
+ async BakeMigration(ssSql, fileName, committedPgSql, options = {}) {
143
+ const captureOnly = options.CaptureOnly === true;
94
144
  const conv = await ConvertMigration(ssSql, fileName, {
95
145
  transpiler: this.opts.transpiler,
96
146
  schema: this.schema,
@@ -105,14 +155,28 @@ export class IncrementalBaker {
105
155
  affectedEntities: entities,
106
156
  unhandled: conv.unhandled,
107
157
  handProcedural: conv.handProcedural,
158
+ warnings: conv.warnings,
108
159
  };
109
160
  // The transpile-only artifact (header + gap comments + transpiled DDL, no CodeGen). Preserved
110
161
  // into `.needs-hand` if the working-DB apply/capture below throws (issue #3252 review P2).
111
162
  const transpiledArtifact = this.assemble(fileName, handBody, []);
112
163
  if (committedPgSql !== undefined) {
164
+ const regions = SplitBakedFile(committedPgSql);
113
165
  return this.applyAndCapture(fileName, committedPgSql, async () => {
114
- await this.opts.db.apply(committedPgSql); // advance via the known-good committed file
166
+ if (!captureOnly)
167
+ await this.opts.db.apply(committedPgSql); // advance via the known-good committed file
115
168
  await this.opts.db.refreshMetadata();
169
+ if (regions) {
170
+ // A file the baker wrote: keep its hand region byte for byte (a person may have finished
171
+ // it) and replace only the CodeGen section. Gaps in the fresh transpile no longer matter,
172
+ // because the transpile is not used (#3345 item 4, #6348).
173
+ if (entities.length === 0)
174
+ return { ...base, pgSQL: committedPgSql, mode: 'preserved' };
175
+ const captured = await this.captureEntities(entities);
176
+ return { ...base, pgSQL: this.withCodeGenSection(regions.handRegion, captured), mode: 'baked' };
177
+ }
178
+ // A legacy conversion has no hand/CodeGen boundary; rebuild it from the fresh transpile,
179
+ // which is only safe when the transpile has no gaps.
116
180
  if (conv.status === 'needs-hand-authoring' || conv.unhandled.length > 0) {
117
181
  return { ...base, pgSQL: committedPgSql, mode: 'preserved' };
118
182
  }
@@ -137,17 +201,35 @@ export class IncrementalBaker {
137
201
  return { ...base, pgSQL: transpiledArtifact, mode: 'gap-no-bake' };
138
202
  }
139
203
  return this.applyAndCapture(fileName, transpiledArtifact, async () => {
140
- if (handBody) {
204
+ if (handBody && !captureOnly) {
141
205
  await this.opts.db.apply(this.withSearchPath(handBody));
142
206
  }
143
- await this.opts.db.refreshMetadata();
144
- const captured = await this.captureEntities(entities);
145
- return { ...base, pgSQL: this.assemble(fileName, handBody, captured), mode: 'baked' };
207
+ // From here on the working DB is advanced past this migration. A capture failure must say
208
+ // so and name the way to resume, or a re-run starts from an inconsistent state (#6538 item 5).
209
+ // (One transaction around apply + capture does not work: CodeGen reads metadata through
210
+ // other pool connections, which cannot see uncommitted DDL.)
211
+ try {
212
+ // Field sync between apply and capture (issue #5650): a default added to an existing column
213
+ // reaches the metadata the capture reads, and the change is baked into the file.
214
+ const defaults = this.opts.db.syncFieldDefaults && entities.length > 0
215
+ ? await this.opts.db.syncFieldDefaults(entities)
216
+ : [];
217
+ await this.opts.db.refreshMetadata();
218
+ const captured = await this.captureEntities(entities);
219
+ const body = [handBody, FieldDefaultUpdatesSQL(defaults, this.coreSchema)].filter((p) => p).join('\n\n');
220
+ return { ...base, pgSQL: this.assemble(fileName, body, captured), mode: 'baked' };
221
+ }
222
+ catch (err) {
223
+ const msg = err instanceof Error ? err.message : String(err);
224
+ throw new BakeApplyError(fileName, transpiledArtifact, `CodeGen capture failed after ${fileName} was applied to the working DB (${msg}). ` +
225
+ `The working DB is now past this migration. Finish the .needs-hand file, save it as the ` +
226
+ `.pg.sql counterpart, then resume with: ${CaptureOnlyResumeCommand(fileName)}`);
227
+ }
146
228
  });
147
229
  }
148
230
  /** @deprecated Use {@link BakeMigration}. */
149
- async bakeMigration(ssSql, fileName, committedPgSql) {
150
- return this.BakeMigration(ssSql, fileName, committedPgSql);
231
+ async bakeMigration(ssSql, fileName, committedPgSql, options = {}) {
232
+ return this.BakeMigration(ssSql, fileName, committedPgSql, options);
151
233
  }
152
234
  /**
153
235
  * Run one bake path's working-DB apply/capture; on ANY failure, rethrow it as a BakeApplyError
@@ -176,7 +258,8 @@ export class IncrementalBaker {
176
258
  }
177
259
  /** Build the standalone baked `.pg.sql`: baked header, hand body, then native CodeGen. */
178
260
  assemble(fileName, handBody, captured) {
179
- const parts = [this.bakedHeader(fileName)];
261
+ // The header is built from everything it precedes, so it emits only the extensions used.
262
+ const parts = [this.bakedHeader(fileName, [handBody, ...captured].join('\n'))];
180
263
  if (handBody) {
181
264
  parts.push(handBody);
182
265
  }
@@ -192,7 +275,16 @@ export class IncrementalBaker {
192
275
  .replaceAll('${flyway:defaultSchema}', () => this.schema)
193
276
  .replaceAll('${mjSchema}', () => this.coreSchema) + '\n';
194
277
  }
195
- bakedHeader(fileName) {
278
+ /** A committed hand region followed by a freshly captured CodeGen section. */
279
+ withCodeGenSection(handRegion, captured) {
280
+ const parts = [handRegion.trimEnd()];
281
+ if (captured.length > 0) {
282
+ parts.push(CODEGEN_SECTION_HEADER);
283
+ parts.push(captured.join('\n\n'));
284
+ }
285
+ return parts.join('\n\n') + '\n';
286
+ }
287
+ bakedHeader(fileName, body) {
196
288
  return [
197
289
  '-- ============================================================================',
198
290
  `-- MemberJunction PostgreSQL Migration — ${fileName}`,
@@ -201,7 +293,7 @@ export class IncrementalBaker {
201
293
  '-- baked natively from `mj codegen`. Applies standalone via `mj migrate` — no deploy codegen.',
202
294
  '-- ============================================================================',
203
295
  '',
204
- 'CREATE EXTENSION IF NOT EXISTS "pgcrypto";',
296
+ BuildPgExtensionStatements(body),
205
297
  `CREATE SCHEMA IF NOT EXISTS ${this.schema};`,
206
298
  `SET search_path TO ${this.schema}, public;`,
207
299
  'SET standard_conforming_strings = on;',
@@ -1 +1 @@
1
- {"version":3,"file":"IncrementalBaker.js","sourceRoot":"","sources":["../src/IncrementalBaker.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAG3D;;;;;;;GAOG;AACH,MAAM,OAAO,cAAe,SAAQ,KAAK;IACvC,YACkB,QAAgB,EAAG,sIAAsI;IACzJ,cAAsB,EAAG,sIAAsI;IAC/K,OAAe;QAEf,KAAK,CAAC,OAAO,CAAC,CAAC;QAJC,aAAQ,GAAR,QAAQ,CAAQ;QAChB,mBAAc,GAAd,cAAc,CAAQ;QAItC,IAAI,CAAC,IAA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AAI,CAAC;YAChC,+BAA+B,IAAI,CAAC,MAAM,GAAG;YAC7C,sBAAsB,IAAI,CAAC,MAAM,WAAW;YAC5C,uCAAuC;SACxC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACf,CAAC;IAED,yFAAyF;IACjF,cAAc,CAAC,GAAW;QAChC,OAAO,sBAAsB,IAAI,CAAC,MAAM,cAAc,GAAG,EAAE,CAAC;IAC9D,CAAC;CACF;AAED;;;;;GAKG;AACH,MAAM,UAAU,oBAAoB,CAAC,GAAW;IAC9C,OAAO,GAAG;SACP,KAAK,CAAC,IAAI,CAAC;SACX,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,yBAAyB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;SACvD,IAAI,CAAC,IAAI,CAAC,CAAC;AAChB,CAAC;AAED,oDAAoD;AACpD,MAAM,UAAU,oBAAoB,CAAC,GAAW;IAC9C,OAAO,oBAAoB,CAAC,GAAG,CAAC,CAAC;AACnC,CAAC"}
@@ -7,7 +7,10 @@
7
7
  * It does NOT try to translate everything. Content is routed by which generator
8
8
  * produced it:
9
9
  * - Category A (CodeGen objects) → DROPPED; regenerated natively by `mj codegen` on PG.
10
- * - Category M (mj-sync metadata) → DROPPED; re-seeded by `mj sync push` on PG.
10
+ * - Category M (mj-sync metadata) → an mj-sync log file is converted inline through the
11
+ * legacy rule pipeline's EXEC-block conversion (one `DO` block per save), so a migrate-only
12
+ * install (an Open App) gets its seed rows (#5543). Metadata DML inside a schema migration
13
+ * is still dropped as before.
11
14
  * - Category B (regular hand DDL/DML) → transpiled via the AST dialect (sqlglot `mj_postgres.py`).
12
15
  * - Category C (hand-written procedural SQL) → schema DDL still transpiled; the
13
16
  * procedural routines are surfaced as NEEDS-HAND-AUTHORING gaps.
@@ -80,6 +83,12 @@ export interface KeptTSQL {
80
83
  split: MigrationSplitResult;
81
84
  /** Lines of Category-A CodeGen output dropped (regenerated natively instead). */
82
85
  droppedCodeGenLines: number;
86
+ /**
87
+ * Content classification itself dropped that nothing reproduces on PostgreSQL, reported as gaps
88
+ * (`METADATA-DML-DROPPED`). ConvertMigration adds these to `unhandled`, so a bake halts with a
89
+ * named reason instead of writing a file that silently lacks them.
90
+ */
91
+ classificationGaps: UnhandledStatement[];
83
92
  }
84
93
  /**
85
94
  * A coarse source→output statement-count reconciliation for one migration (issue #3252
@@ -125,6 +134,12 @@ export interface MigrationConversionResult {
125
134
  notes: string[];
126
135
  /** Coarse source→output statement-count reconciliation (issue #3252 Phase 3). */
127
136
  reconciliation: ConversionReconciliation;
137
+ /**
138
+ * Named, non-blocking warnings: work the converter cannot do that a person must finish by hand,
139
+ * which does not stop the file converting or baking. Today: one per `sp_refreshview` (see
140
+ * {@link RefreshViewWarnings}).
141
+ */
142
+ warnings: string[];
128
143
  }
129
144
  export interface ConvertMigrationOptions {
130
145
  /** Target schema substituted for `${flyway:defaultSchema}` in the output (default '__mj'). */
@@ -149,8 +164,24 @@ export interface ConvertMigrationOptions {
149
164
  */
150
165
  transpiler?: TSQLToPGTranspiler;
151
166
  }
167
+ /**
168
+ * One warning per `EXEC sp_refreshview` in a migration, hand region or CodeGen block alike
169
+ * (issue #5649, decision pg.5; see {@link DescribeRefreshView}). The split path drops the CodeGen
170
+ * block before transpiling and the dialect only accounts the call, so the source is scanned here.
171
+ */
172
+ export declare function RefreshViewWarnings(sql: string, fileName: string): string[];
152
173
  /** Classify a migration and return the kept T-SQL to transpile — the single classification entry point. */
153
174
  export declare function ExtractKeptTSQL(sql: string, fileName: string): KeptTSQL;
175
+ /**
176
+ * Whether the views in a migration are the author's own rather than CodeGen output: true for a
177
+ * non-baseline file with no CodeGen banner and no CodeGen-named routine. CodeGen writes its
178
+ * banner, so an unbannered `vw…` view there is hand-written (issue #5551, a layered wrapper
179
+ * view; also MJ's own hand-maintained views such as `vwEntityFieldsWithCheckConstraints`).
180
+ * Baselines (`B…`) are squashed snapshots whose generated views carry no banner, and an older
181
+ * file that pasted CodeGen's CRUD routines without the banner (spCreate…/trgUpdate…) holds its
182
+ * generated view too, so both keep the name-based rule.
183
+ */
184
+ export declare function ViewsAreHandWritten(split: MigrationSplitResult, sql: string): boolean;
154
185
  /** @deprecated Use {@link ExtractKeptTSQL}. */
155
186
  export declare function extractKeptTSQL(sql: string, fileName: string): KeptTSQL;
156
187
  /**
@@ -163,6 +194,28 @@ export declare function extractKeptTSQL(sql: string, fileName: string): KeptTSQL
163
194
  * because a backend was missing.
164
195
  */
165
196
  export declare function ConvertMigration(sql: string, fileName: string, options?: ConvertMigrationOptions): Promise<MigrationConversionResult>;
197
+ /**
198
+ * Whether a migration is an mj-sync log: named `…Metadata_Sync…`, or with nothing but mj-sync
199
+ * metadata regions and nothing for the AST transpiler. Such a file is converted inline
200
+ * ({@link convertSyncLogInline}) instead of becoming a "re-seeded by `mj sync push`" marker.
201
+ */
202
+ export declare function IsMetadataSyncLog(kept: KeptTSQL): boolean;
203
+ /** The catalog views found in kept T-SQL, and what is left for the AST transpiler. */
204
+ export interface CatalogViewExtraction {
205
+ /** The kept T-SQL without the catalog-view batches. */
206
+ tsql: string;
207
+ /** PostgreSQL definitions for the catalog views that were removed. */
208
+ pgViews: string[];
209
+ /** A `CREATE VIEW` over `sys.*` that is not one of MJ's catalog views. */
210
+ unhandled: UnhandledStatement[];
211
+ }
212
+ /**
213
+ * Splits MJ's catalog wrapper views (`vwSQLColumnsAndEntityFields`, `vwTableUniqueKeys`, …) out of
214
+ * kept T-SQL batches: each becomes the legacy {@link GetPGCatalogViewDefinition} text. Any other
215
+ * `CREATE VIEW` that reads `sys.*` is removed and reported, since its transpile would reach
216
+ * PostgreSQL naming SQL Server's catalog.
217
+ */
218
+ export declare function ExtractCatalogViews(tsql: string, coreSchema?: string): CatalogViewExtraction;
166
219
  /** @deprecated Use {@link ConvertMigration}. */
167
220
  export declare function convertMigration(sql: string, fileName: string, options?: ConvertMigrationOptions): Promise<MigrationConversionResult>;
168
221
  //# sourceMappingURL=MigrationConverter.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"MigrationConverter.d.ts","sourceRoot":"","sources":["../src/MigrationConverter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,OAAO,EAAkB,KAAK,oBAAoB,EAA4B,MAAM,wBAAwB,CAAC;AAK7G,MAAM,MAAM,gBAAgB;AAC1B,sDAAsD;AACpD,WAAW;AACb,4FAA4F;GAC1F,sBAAsB;AACxB,mHAAmH;GACjH,sBAAsB,CAAC;AAE3B,yEAAyE;AACzE,MAAM,WAAW,kBAAkB;IACjC,qEAAqE;IACrE,IAAI,EAAE,MAAM,CAAC;IACb,+DAA+D;IAC/D,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,sDAAsD;AACtD,MAAM,WAAW,iBAAiB;IAChC,mDAAmD;IACnD,GAAG,EAAE,MAAM,EAAE,CAAC;IACd,2EAA2E;IAC3E,SAAS,EAAE,kBAAkB,EAAE,CAAC;IAChC;;;;OAIG;IACH,OAAO,CAAC,EAAE,kBAAkB,EAAE,CAAC;CAChC;AAED;;;;GAIG;AACH,MAAM,WAAW,kBAAkB;IACjC,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;CACrD;AAED;;;;GAIG;AACH,MAAM,WAAW,QAAQ;IACvB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,gBAAgB,CAAC;IACzB,qEAAqE;IACrE,IAAI,EAAE,MAAM,CAAC;IACb,2EAA2E;IAC3E,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,sFAAsF;IACtF,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,qEAAqE;IACrE,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,iFAAiF;IACjF,KAAK,EAAE,oBAAoB,CAAC;IAC5B,iFAAiF;IACjF,mBAAmB,EAAE,MAAM,CAAC;CAC7B;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,wBAAwB;IACvC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