@vibeorm/migrate 1.3.1 → 2.0.0-alpha.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +33 -66
- package/dist/ddl/drop-order.d.ts +25 -0
- package/dist/ddl/drop-order.d.ts.map +1 -0
- package/dist/ddl/mysql.d.ts +46 -0
- package/dist/ddl/mysql.d.ts.map +1 -0
- package/dist/ddl/postgres.d.ts +24 -0
- package/dist/ddl/postgres.d.ts.map +1 -0
- package/dist/ddl/render.d.ts +25 -0
- package/dist/ddl/render.d.ts.map +1 -0
- package/dist/ddl/rls.d.ts +40 -0
- package/dist/ddl/rls.d.ts.map +1 -0
- package/dist/ddl/sqlite.d.ts +79 -0
- package/dist/ddl/sqlite.d.ts.map +1 -0
- package/dist/differ.d.ts +41 -0
- package/dist/differ.d.ts.map +1 -0
- package/dist/down.d.ts +57 -0
- package/dist/down.d.ts.map +1 -0
- package/dist/enum-values.d.ts +32 -0
- package/dist/enum-values.d.ts.map +1 -0
- package/dist/execute.d.ts +124 -0
- package/dist/execute.d.ts.map +1 -0
- package/dist/execution.d.ts +168 -0
- package/dist/execution.d.ts.map +1 -0
- package/dist/extensions.d.ts +74 -0
- package/dist/extensions.d.ts.map +1 -0
- package/dist/index.d.ts +32 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +5688 -0
- package/dist/index.js.map +37 -0
- package/dist/introspect/mysql.d.ts +31 -0
- package/dist/introspect/mysql.d.ts.map +1 -0
- package/dist/introspect/postgres-rls.d.ts +41 -0
- package/dist/introspect/postgres-rls.d.ts.map +1 -0
- package/dist/introspect/postgres.d.ts +12 -0
- package/dist/introspect/postgres.d.ts.map +1 -0
- package/dist/introspect/shared.d.ts +78 -0
- package/dist/introspect/shared.d.ts.map +1 -0
- package/dist/introspect/sqlite.d.ts +53 -0
- package/dist/introspect/sqlite.d.ts.map +1 -0
- package/dist/journal-table.d.ts +15 -0
- package/dist/journal-table.d.ts.map +1 -0
- package/dist/mysql-types.d.ts +66 -0
- package/dist/mysql-types.d.ts.map +1 -0
- package/dist/normalize.d.ts +143 -0
- package/dist/normalize.d.ts.map +1 -0
- package/dist/postgres-types.d.ts +95 -0
- package/dist/postgres-types.d.ts.map +1 -0
- package/dist/push.d.ts +51 -0
- package/dist/push.d.ts.map +1 -0
- package/dist/recovery.d.ts +41 -0
- package/dist/recovery.d.ts.map +1 -0
- package/dist/relations.d.ts +40 -0
- package/dist/relations.d.ts.map +1 -0
- package/dist/renames.d.ts +58 -0
- package/dist/renames.d.ts.map +1 -0
- package/dist/runner.d.ts +181 -0
- package/dist/runner.d.ts.map +1 -0
- package/dist/sqlite-types.d.ts +101 -0
- package/dist/sqlite-types.d.ts.map +1 -0
- package/dist/types.d.ts +329 -0
- package/dist/types.d.ts.map +1 -0
- package/package.json +34 -23
- package/src/cascade-actions.ts +0 -88
- package/src/ddl-builder.ts +0 -415
- package/src/index.ts +0 -41
- package/src/introspector.ts +0 -684
- package/src/migration-runner.ts +0 -127
- package/src/relation-utils.ts +0 -79
- package/src/schema-differ.ts +0 -865
- package/src/schema-printer.ts +0 -259
- package/src/snapshot.ts +0 -141
- package/src/sql-utils.ts +0 -45
- package/src/types.ts +0 -13
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,329 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Public types of @vibeorm/migrate: the executor contract, the dialect-neutral
|
|
3
|
+
* migration step model, and the runner's file/result shapes.
|
|
4
|
+
*
|
|
5
|
+
* Steps carry Schema-IR fragments (FieldIR, EnumIR) — never SQL text. SQL is
|
|
6
|
+
* produced exclusively by the per-dialect renderers (ddl-postgres.ts), so every
|
|
7
|
+
* SQL-text decision stays reviewable in one place (constitution rule 3/4).
|
|
8
|
+
*/
|
|
9
|
+
import type { CascadeAction, CheckIR, EnumIR, FieldIR, SchemaIR } from "@vibeorm/schema";
|
|
10
|
+
import type { MigrationExecution } from "./execution.ts";
|
|
11
|
+
/**
|
|
12
|
+
* Minimal SQL execution contract the migrate engine runs on. Structurally
|
|
13
|
+
* identical to @vibeorm/runtime's `SqlExecutor` (its `toSqlExecutor` bridges a
|
|
14
|
+
* DatabaseAdapter to this shape) — declared here so the dependency direction
|
|
15
|
+
* stays schema ← sql ← migrate.
|
|
16
|
+
*
|
|
17
|
+
* SESSION AFFINITY: the migrate engine issues session-scoped statements
|
|
18
|
+
* through this contract (BEGIN/COMMIT, `PRAGMA foreign_keys`, advisory locks
|
|
19
|
+
* `pg_advisory_lock` / `GET_LOCK`), so every call MUST hit the same database
|
|
20
|
+
* session. Single-connection adapters (pglite, sqlite) satisfy this by
|
|
21
|
+
* construction; pool-backed executors must pin one connection for the whole
|
|
22
|
+
* migrate operation.
|
|
23
|
+
*/
|
|
24
|
+
export type SqlExecutor = (params: {
|
|
25
|
+
text: string;
|
|
26
|
+
values?: unknown[];
|
|
27
|
+
}) => Promise<Record<string, unknown>[]>;
|
|
28
|
+
/** Which aspects of a column an `alterColumn` step changes. */
|
|
29
|
+
export type AlterColumnAspect = "type" | "nullability" | "default";
|
|
30
|
+
/** One column of an index, with its sort direction. */
|
|
31
|
+
export type IndexColumn = {
|
|
32
|
+
readonly name: string;
|
|
33
|
+
readonly desc: boolean;
|
|
34
|
+
/**
|
|
35
|
+
* The field is a Decimal (SQLITE-2, SQL review round 2). Inert everywhere
|
|
36
|
+
* except the sqlite DDL renderer: Decimal stores as TEXT there and every
|
|
37
|
+
* compare/order site reads `CAST(col AS REAL)` (B4), which a plain-column
|
|
38
|
+
* index can never serve (EQP-proven SCAN) — sqlite renders an EXPRESSION
|
|
39
|
+
* index over the same cast instead. Not part of the index comparison key:
|
|
40
|
+
* both sides compare by column name + direction.
|
|
41
|
+
*/
|
|
42
|
+
readonly decimal?: boolean;
|
|
43
|
+
};
|
|
44
|
+
/** One side of an implicit many-to-many join table. */
|
|
45
|
+
export type JoinTableEnd = {
|
|
46
|
+
/** Referenced table (db name). */
|
|
47
|
+
readonly table: string;
|
|
48
|
+
/** Referenced primary-key column (db name). */
|
|
49
|
+
readonly column: string;
|
|
50
|
+
/** The referenced primary-key field — its type renders the join column's type. */
|
|
51
|
+
readonly field: FieldIR;
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* A dialect-neutral migration step produced by `diffSchemas`. `destructive`
|
|
55
|
+
* marks steps that can lose data (dropTable / dropJoinTable / dropColumn /
|
|
56
|
+
* dropEnum / narrowing type changes) — `push` refuses them without
|
|
57
|
+
* `acceptDataLoss`, and `generateMigration` surfaces the flag.
|
|
58
|
+
*/
|
|
59
|
+
export type MigrationStep = ({
|
|
60
|
+
readonly kind: "enableRls" | "forceRls" | "disableRls" | "noForceRls" | "dropPolicy";
|
|
61
|
+
readonly table: string;
|
|
62
|
+
readonly destructive: false;
|
|
63
|
+
} | {
|
|
64
|
+
readonly kind: "createPolicy";
|
|
65
|
+
readonly table: string;
|
|
66
|
+
readonly schema: SchemaIR;
|
|
67
|
+
readonly model: string;
|
|
68
|
+
readonly destructive: false;
|
|
69
|
+
} | {
|
|
70
|
+
readonly kind: "createEnum";
|
|
71
|
+
readonly enumDef: EnumIR;
|
|
72
|
+
readonly destructive: false;
|
|
73
|
+
} | {
|
|
74
|
+
readonly kind: "dropEnum";
|
|
75
|
+
readonly enumName: string;
|
|
76
|
+
readonly destructive: true;
|
|
77
|
+
} | {
|
|
78
|
+
readonly kind: "addEnumValue";
|
|
79
|
+
readonly enumName: string;
|
|
80
|
+
readonly value: string;
|
|
81
|
+
readonly destructive: false;
|
|
82
|
+
} | {
|
|
83
|
+
readonly kind: "createTable";
|
|
84
|
+
readonly table: string;
|
|
85
|
+
readonly columns: readonly FieldIR[];
|
|
86
|
+
/** Primary-key column db names (empty = no PK). */
|
|
87
|
+
readonly primaryKey: readonly string[];
|
|
88
|
+
/** Named CHECK constraints, rendered into the CREATE TABLE. */
|
|
89
|
+
readonly checks?: readonly CheckIR[];
|
|
90
|
+
readonly destructive: false;
|
|
91
|
+
} | {
|
|
92
|
+
readonly kind: "addCheck";
|
|
93
|
+
readonly table: string;
|
|
94
|
+
readonly name: string;
|
|
95
|
+
/** Raw SQL expression, rendered verbatim. */
|
|
96
|
+
readonly expression: string;
|
|
97
|
+
readonly destructive: false;
|
|
98
|
+
} | {
|
|
99
|
+
readonly kind: "dropCheck";
|
|
100
|
+
readonly table: string;
|
|
101
|
+
readonly name: string;
|
|
102
|
+
readonly destructive: false;
|
|
103
|
+
} | {
|
|
104
|
+
readonly kind: "dropTable";
|
|
105
|
+
readonly table: string;
|
|
106
|
+
readonly destructive: true;
|
|
107
|
+
} | {
|
|
108
|
+
readonly kind: "addColumn";
|
|
109
|
+
readonly table: string;
|
|
110
|
+
readonly column: FieldIR;
|
|
111
|
+
readonly destructive: false;
|
|
112
|
+
} | {
|
|
113
|
+
readonly kind: "dropColumn";
|
|
114
|
+
readonly table: string;
|
|
115
|
+
readonly column: string;
|
|
116
|
+
readonly destructive: true;
|
|
117
|
+
} | {
|
|
118
|
+
readonly kind: "alterColumn";
|
|
119
|
+
readonly table: string;
|
|
120
|
+
/** Column db name. */
|
|
121
|
+
readonly column: string;
|
|
122
|
+
readonly from: FieldIR;
|
|
123
|
+
readonly to: FieldIR;
|
|
124
|
+
readonly changes: readonly AlterColumnAspect[];
|
|
125
|
+
readonly destructive: boolean;
|
|
126
|
+
} | {
|
|
127
|
+
readonly kind: "createIndex";
|
|
128
|
+
readonly table: string;
|
|
129
|
+
readonly name: string;
|
|
130
|
+
/** IR index kind ("btree", "gin", …) — `unique` indexes are always btree. */
|
|
131
|
+
readonly indexKind: string;
|
|
132
|
+
readonly unique: boolean;
|
|
133
|
+
readonly columns: readonly IndexColumn[];
|
|
134
|
+
/** Partial-index predicate, raw SQL. */
|
|
135
|
+
readonly where?: string;
|
|
136
|
+
/** `UNIQUE NULLS NOT DISTINCT` (postgres 15+; sqlite/mysql renderers refuse). */
|
|
137
|
+
readonly nullsNotDistinct?: boolean;
|
|
138
|
+
readonly destructive: false;
|
|
139
|
+
} | {
|
|
140
|
+
readonly kind: "dropIndex";
|
|
141
|
+
readonly name: string;
|
|
142
|
+
/**
|
|
143
|
+
* Table the index belongs to. Optional for postgres/sqlite (their DROP
|
|
144
|
+
* INDEX is schema-global) but REQUIRED by the mysql renderer
|
|
145
|
+
* (`DROP INDEX … ON table`); the differ always fills it.
|
|
146
|
+
*/
|
|
147
|
+
readonly table?: string;
|
|
148
|
+
readonly destructive: false;
|
|
149
|
+
} | {
|
|
150
|
+
readonly kind: "addForeignKey";
|
|
151
|
+
readonly table: string;
|
|
152
|
+
readonly constraintName: string;
|
|
153
|
+
readonly columns: readonly string[];
|
|
154
|
+
readonly refTable: string;
|
|
155
|
+
readonly refColumns: readonly string[];
|
|
156
|
+
readonly onDelete: CascadeAction;
|
|
157
|
+
readonly onUpdate: CascadeAction;
|
|
158
|
+
readonly destructive: false;
|
|
159
|
+
} | {
|
|
160
|
+
/**
|
|
161
|
+
* Stage a foreign key without validating existing rows (postgres
|
|
162
|
+
* `NOT VALID`). Skips the scan, NOT the brief ACCESS EXCLUSIVE lock;
|
|
163
|
+
* `validateConstraint` finishes the job under a weaker lock. sqlite and
|
|
164
|
+
* mysql have no such split and refuse this step.
|
|
165
|
+
*/
|
|
166
|
+
readonly kind: "addForeignKeyNotValid";
|
|
167
|
+
readonly table: string;
|
|
168
|
+
readonly constraintName: string;
|
|
169
|
+
readonly columns: readonly string[];
|
|
170
|
+
readonly refTable: string;
|
|
171
|
+
readonly refColumns: readonly string[];
|
|
172
|
+
readonly onDelete: CascadeAction;
|
|
173
|
+
readonly onUpdate: CascadeAction;
|
|
174
|
+
readonly destructive: false;
|
|
175
|
+
} | {
|
|
176
|
+
/** Stage a CHECK without validating existing rows (postgres `NOT VALID`). */
|
|
177
|
+
readonly kind: "addCheckNotValid";
|
|
178
|
+
readonly table: string;
|
|
179
|
+
readonly name: string;
|
|
180
|
+
/** Raw SQL expression, rendered verbatim. */
|
|
181
|
+
readonly expression: string;
|
|
182
|
+
readonly destructive: false;
|
|
183
|
+
} | {
|
|
184
|
+
/** Validate a previously staged NOT VALID constraint (postgres only). */
|
|
185
|
+
readonly kind: "validateConstraint";
|
|
186
|
+
readonly table: string;
|
|
187
|
+
readonly name: string;
|
|
188
|
+
readonly destructive: false;
|
|
189
|
+
} | {
|
|
190
|
+
/**
|
|
191
|
+
* Rename a physical table, preserving its rows, defaults, indexes and
|
|
192
|
+
* inbound foreign keys. Only ever produced from an EXPLICIT rename
|
|
193
|
+
* intent (renames.ts) — never inferred from a drop/create pair.
|
|
194
|
+
*/
|
|
195
|
+
readonly kind: "renameTable";
|
|
196
|
+
readonly from: string;
|
|
197
|
+
readonly to: string;
|
|
198
|
+
readonly destructive: false;
|
|
199
|
+
} | {
|
|
200
|
+
/** Rename a physical column, preserving its data, default and indexes. */
|
|
201
|
+
readonly kind: "renameColumn";
|
|
202
|
+
readonly table: string;
|
|
203
|
+
readonly from: string;
|
|
204
|
+
readonly to: string;
|
|
205
|
+
readonly destructive: false;
|
|
206
|
+
} | {
|
|
207
|
+
readonly kind: "dropForeignKey";
|
|
208
|
+
readonly table: string;
|
|
209
|
+
readonly constraintName: string;
|
|
210
|
+
readonly destructive: false;
|
|
211
|
+
} | {
|
|
212
|
+
readonly kind: "createJoinTable";
|
|
213
|
+
readonly table: string;
|
|
214
|
+
readonly a: JoinTableEnd;
|
|
215
|
+
readonly b: JoinTableEnd;
|
|
216
|
+
readonly destructive: false;
|
|
217
|
+
} | {
|
|
218
|
+
readonly kind: "dropJoinTable";
|
|
219
|
+
readonly table: string;
|
|
220
|
+
readonly destructive: true;
|
|
221
|
+
} | {
|
|
222
|
+
readonly kind: "addPrimaryKey";
|
|
223
|
+
readonly table: string;
|
|
224
|
+
readonly columns: readonly string[];
|
|
225
|
+
readonly destructive: false;
|
|
226
|
+
} | {
|
|
227
|
+
readonly kind: "dropPrimaryKey";
|
|
228
|
+
readonly table: string;
|
|
229
|
+
readonly destructive: false;
|
|
230
|
+
} | {
|
|
231
|
+
/**
|
|
232
|
+
* Drop a view present in the live database but absent from the target
|
|
233
|
+
* schema (board #26). Ordered FIRST — postgres refuses dropping a column
|
|
234
|
+
* a leftover view depends on (2BP01), so removed views must go before
|
|
235
|
+
* the table/column changes they block. Destructive: the view definition
|
|
236
|
+
* is not stored in the IR, so the drop cannot be reversed.
|
|
237
|
+
*/
|
|
238
|
+
readonly kind: "dropView";
|
|
239
|
+
/** View db name. */
|
|
240
|
+
readonly table: string;
|
|
241
|
+
readonly destructive: true;
|
|
242
|
+
}) & {
|
|
243
|
+
/** Separate from data loss: a removal or potentially widening policy replacement. */
|
|
244
|
+
readonly securityChange?: string;
|
|
245
|
+
};
|
|
246
|
+
/** One-line human description of a step (refusal messages, CLI output). */
|
|
247
|
+
export declare function describeStep(params: {
|
|
248
|
+
step: MigrationStep;
|
|
249
|
+
}): string;
|
|
250
|
+
/** A named migration: ordered SQL statements plus its aggregate destructiveness. */
|
|
251
|
+
export type MigrationFile = {
|
|
252
|
+
readonly name: string;
|
|
253
|
+
/** One SQL string per statement, in execution order. */
|
|
254
|
+
readonly sql: readonly string[];
|
|
255
|
+
/** True when any underlying step can lose data. */
|
|
256
|
+
readonly destructive: boolean;
|
|
257
|
+
/**
|
|
258
|
+
* Reverse statements (`down.sql`), when the migration carries them.
|
|
259
|
+
* Migrations generated before down-migration support have none —
|
|
260
|
+
* `rollbackMigration` refuses those with a clear error.
|
|
261
|
+
*/
|
|
262
|
+
readonly downSql?: readonly string[];
|
|
263
|
+
/** Security changes are not authorized by an ordinary data-loss acknowledgement. */
|
|
264
|
+
readonly securityChanges?: readonly string[];
|
|
265
|
+
readonly downSecurityChanges?: readonly string[];
|
|
266
|
+
/** Trusted source declarations used for drift preflight on generated migrations. */
|
|
267
|
+
readonly rls?: {
|
|
268
|
+
readonly from: SchemaIR;
|
|
269
|
+
readonly to: SchemaIR;
|
|
270
|
+
};
|
|
271
|
+
/**
|
|
272
|
+
* Explicit execution semantics (transaction mode, migration-owned session
|
|
273
|
+
* limits, declared per-statement operations). ABSENT means the dialect's
|
|
274
|
+
* existing behaviour, and hashes exactly as it always did — see
|
|
275
|
+
* execution.ts's checksum-compatibility rule.
|
|
276
|
+
*/
|
|
277
|
+
readonly execution?: MigrationExecution;
|
|
278
|
+
/** Execution semantics of `downSql`; absent means the dialect's existing behaviour. */
|
|
279
|
+
readonly downExecution?: MigrationExecution;
|
|
280
|
+
};
|
|
281
|
+
/** Result of `applyMigrations`. */
|
|
282
|
+
export type AppliedResult = {
|
|
283
|
+
/** Migrations executed by this call, in order. */
|
|
284
|
+
readonly applied: readonly string[];
|
|
285
|
+
/** Migrations already recorded and verified, skipped. */
|
|
286
|
+
readonly skipped: readonly string[];
|
|
287
|
+
};
|
|
288
|
+
/** Result of `migrationStatus`. */
|
|
289
|
+
export type MigrationStatus = {
|
|
290
|
+
/** Recorded migrations whose checksum matches. */
|
|
291
|
+
readonly applied: readonly string[];
|
|
292
|
+
/** Migrations with no record yet. */
|
|
293
|
+
readonly pending: readonly string[];
|
|
294
|
+
/** Recorded migrations whose checksum no longer matches their SQL. */
|
|
295
|
+
readonly mismatched: readonly string[];
|
|
296
|
+
/**
|
|
297
|
+
* Migrations whose rollback started but did not finish (mysql only — its
|
|
298
|
+
* DDL is non-transactional, so `rollbackMigration` records per-statement
|
|
299
|
+
* progress). Re-run the rollback to resume, or repair with
|
|
300
|
+
* `resolveMigration`.
|
|
301
|
+
*/
|
|
302
|
+
readonly rollingBack: readonly string[];
|
|
303
|
+
};
|
|
304
|
+
/**
|
|
305
|
+
* How one bookkeeping row stands against the migration file of the same name.
|
|
306
|
+
* `unknown-file` is a recorded migration whose file is missing from the
|
|
307
|
+
* migrations directory — history the tool cannot reverse.
|
|
308
|
+
*/
|
|
309
|
+
export type RecordedMigrationState = "applied" | "partial" | "mismatched" | "rolling-back" | "unknown-file";
|
|
310
|
+
/** One row of the `_vibe_migrations` journal, in the order it was written. */
|
|
311
|
+
export type RecordedMigration = {
|
|
312
|
+
readonly name: string;
|
|
313
|
+
/** Recorded checksum; empty for a `resolveMigration` repair record. */
|
|
314
|
+
readonly checksum: string;
|
|
315
|
+
/** Statements completed; NEGATIVE (-(k+1)) marks an unfinished rollback. */
|
|
316
|
+
readonly statementIndex: number;
|
|
317
|
+
readonly state: RecordedMigrationState;
|
|
318
|
+
};
|
|
319
|
+
/** Result of `push`. */
|
|
320
|
+
export type PushResult = {
|
|
321
|
+
/** The diff that was applied (empty = database already matched). */
|
|
322
|
+
readonly steps: readonly MigrationStep[];
|
|
323
|
+
/** The SQL statements that were executed, in order. */
|
|
324
|
+
readonly applied: readonly string[];
|
|
325
|
+
/** Dry-run statements, never executed. */
|
|
326
|
+
readonly planned?: readonly string[];
|
|
327
|
+
readonly securityChanges?: readonly string[];
|
|
328
|
+
};
|
|
329
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AACzF,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAIzD;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,WAAW,GAAG,CAAC,MAAM,EAAE;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,OAAO,EAAE,CAAC;CACpB,KAAK,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC,CAAC;AAIzC,+DAA+D;AAC/D,MAAM,MAAM,iBAAiB,GAAG,MAAM,GAAG,aAAa,GAAG,SAAS,CAAC;AAEnE,uDAAuD;AACvD,MAAM,MAAM,WAAW,GAAG;IACxB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB;;;;;;;OAOG;IACH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1
1
|
{
|
|
2
2
|
"name": "@vibeorm/migrate",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "Migration
|
|
5
|
-
"license": "MIT",
|
|
3
|
+
"version": "2.0.0-alpha.10",
|
|
4
|
+
"description": "Migration engine for VibeORM v2 — IR differ, per-dialect DDL, migration runner, introspection",
|
|
6
5
|
"keywords": [
|
|
7
6
|
"orm",
|
|
8
|
-
"migrations",
|
|
9
|
-
"postgresql",
|
|
10
|
-
"bun",
|
|
11
7
|
"typescript",
|
|
12
|
-
"
|
|
8
|
+
"sql",
|
|
9
|
+
"database",
|
|
10
|
+
"bun",
|
|
11
|
+
"type-safe",
|
|
12
|
+
"migrations",
|
|
13
|
+
"ddl",
|
|
14
|
+
"introspection",
|
|
15
|
+
"schema-diff",
|
|
16
|
+
"postgres",
|
|
17
|
+
"mysql",
|
|
18
|
+
"sqlite"
|
|
13
19
|
],
|
|
20
|
+
"homepage": "https://github.com/vibeorm/vibeorm/tree/master/packages/migrate#readme",
|
|
21
|
+
"bugs": {
|
|
22
|
+
"url": "https://github.com/vibeorm/vibeorm/issues"
|
|
23
|
+
},
|
|
24
|
+
"repository": {
|
|
25
|
+
"type": "git",
|
|
26
|
+
"url": "https://github.com/vibeorm/vibeorm.git",
|
|
27
|
+
"directory": "packages/migrate"
|
|
28
|
+
},
|
|
29
|
+
"license": "MIT",
|
|
30
|
+
"author": "VibeORM contributors",
|
|
14
31
|
"type": "module",
|
|
15
32
|
"exports": {
|
|
16
33
|
".": {
|
|
17
|
-
"
|
|
18
|
-
"
|
|
34
|
+
"types": "./dist/index.d.ts",
|
|
35
|
+
"default": "./dist/index.js"
|
|
19
36
|
}
|
|
20
37
|
},
|
|
21
38
|
"files": [
|
|
22
|
-
"
|
|
39
|
+
"dist",
|
|
40
|
+
"README.md"
|
|
23
41
|
],
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
"directory": "packages/migrate"
|
|
42
|
+
"engines": {
|
|
43
|
+
"node": ">=18",
|
|
44
|
+
"bun": ">=1.2.0"
|
|
28
45
|
},
|
|
29
|
-
"
|
|
30
|
-
|
|
31
|
-
"
|
|
46
|
+
"dependencies": {
|
|
47
|
+
"@vibeorm/schema": "2.0.0-alpha.8",
|
|
48
|
+
"@vibeorm/sql": "2.0.0-alpha.8"
|
|
32
49
|
},
|
|
33
50
|
"publishConfig": {
|
|
34
51
|
"access": "public"
|
|
35
|
-
},
|
|
36
|
-
"engines": {
|
|
37
|
-
"bun": ">=1.1.0"
|
|
38
|
-
},
|
|
39
|
-
"dependencies": {
|
|
40
|
-
"@vibeorm/parser": "1.3.1"
|
|
41
52
|
}
|
|
42
53
|
}
|
package/src/cascade-actions.ts
DELETED
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Cascade-action resolution and SQL serialisation.
|
|
3
|
-
*
|
|
4
|
-
* Translates a `CascadeAction` from the parser IR into a Postgres
|
|
5
|
-
* `ON DELETE`/`ON UPDATE` clause, applying Prisma-compatible defaults when
|
|
6
|
-
* the schema doesn't specify an action explicitly.
|
|
7
|
-
*
|
|
8
|
-
* Defaults (matching Prisma's Postgres behaviour):
|
|
9
|
-
* - `onDelete`: required FK → `Restrict`, optional FK → `SetNull`
|
|
10
|
-
* - `onUpdate`: always → `Cascade`
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
import type { CascadeAction, RelationField } from "@vibeorm/parser";
|
|
14
|
-
|
|
15
|
-
const ACTION_TO_SQL: Record<CascadeAction, string> = {
|
|
16
|
-
Cascade: "CASCADE",
|
|
17
|
-
Restrict: "RESTRICT",
|
|
18
|
-
NoAction: "NO ACTION",
|
|
19
|
-
SetNull: "SET NULL",
|
|
20
|
-
SetDefault: "SET DEFAULT",
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Inverse of {@link ACTION_TO_SQL} — used by the introspector when reading
|
|
25
|
-
* `pg_constraint.confdeltype`/`confupdtype`. The single-char codes are
|
|
26
|
-
* Postgres's catalog representation.
|
|
27
|
-
*/
|
|
28
|
-
export const PG_CHAR_TO_CASCADE_ACTION: Record<string, CascadeAction> = {
|
|
29
|
-
a: "NoAction",
|
|
30
|
-
r: "Restrict",
|
|
31
|
-
c: "Cascade",
|
|
32
|
-
n: "SetNull",
|
|
33
|
-
d: "SetDefault",
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Resolve the effective onDelete action for a relation, applying the Prisma
|
|
38
|
-
* default when the schema didn't say anything explicit.
|
|
39
|
-
*
|
|
40
|
-
* `isRequired` is the FK column's nullability (Prisma's "required relation").
|
|
41
|
-
*/
|
|
42
|
-
export function resolveOnDelete(params: {
|
|
43
|
-
explicit: CascadeAction | undefined;
|
|
44
|
-
isRequired: boolean;
|
|
45
|
-
}): CascadeAction {
|
|
46
|
-
if (params.explicit) return params.explicit;
|
|
47
|
-
return params.isRequired ? "Restrict" : "SetNull";
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
/** Resolve the effective onUpdate action. Prisma's Postgres default is Cascade. */
|
|
51
|
-
export function resolveOnUpdate(params: {
|
|
52
|
-
explicit: CascadeAction | undefined;
|
|
53
|
-
}): CascadeAction {
|
|
54
|
-
return params.explicit ?? "Cascade";
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
/** Convenience: serialise a CascadeAction to its Postgres clause body. */
|
|
58
|
-
export function cascadeActionSql(params: { action: CascadeAction }): string {
|
|
59
|
-
return ACTION_TO_SQL[params.action];
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* Build the full `ON DELETE X ON UPDATE Y` clause for a relation field,
|
|
64
|
-
* applying defaults as needed.
|
|
65
|
-
*/
|
|
66
|
-
export function buildFkActionClause(params: { rel: RelationField }): string {
|
|
67
|
-
const { rel } = params;
|
|
68
|
-
const onDelete = resolveOnDelete({
|
|
69
|
-
explicit: rel.relation.onDelete,
|
|
70
|
-
isRequired: rel.isRequired,
|
|
71
|
-
});
|
|
72
|
-
const onUpdate = resolveOnUpdate({ explicit: rel.relation.onUpdate });
|
|
73
|
-
return `ON DELETE ${ACTION_TO_SQL[onDelete]} ON UPDATE ${ACTION_TO_SQL[onUpdate]}`;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* Stable comparison key for whether two relations have the same effective
|
|
78
|
-
* cascade behaviour. Used by the differ to detect drift even when the schema
|
|
79
|
-
* was written without explicit actions (defaults must still be considered).
|
|
80
|
-
*/
|
|
81
|
-
export function fkActionFingerprint(params: { rel: RelationField }): string {
|
|
82
|
-
const onDelete = resolveOnDelete({
|
|
83
|
-
explicit: params.rel.relation.onDelete,
|
|
84
|
-
isRequired: params.rel.isRequired,
|
|
85
|
-
});
|
|
86
|
-
const onUpdate = resolveOnUpdate({ explicit: params.rel.relation.onUpdate });
|
|
87
|
-
return `${onDelete}|${onUpdate}`;
|
|
88
|
-
}
|