@fragno-dev/db 0.1.3 → 0.1.5

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 (46) hide show
  1. package/.turbo/turbo-build.log +32 -19
  2. package/CHANGELOG.md +13 -0
  3. package/dist/adapters/adapters.js +1 -0
  4. package/dist/adapters/drizzle/generate.js +1 -1
  5. package/dist/adapters/drizzle/generate.js.map +1 -1
  6. package/dist/adapters/kysely/kysely-adapter.d.ts.map +1 -1
  7. package/dist/adapters/kysely/kysely-adapter.js +33 -22
  8. package/dist/adapters/kysely/kysely-adapter.js.map +1 -1
  9. package/dist/adapters/kysely/migration/execute-base.js +128 -0
  10. package/dist/adapters/kysely/migration/execute-base.js.map +1 -0
  11. package/dist/adapters/kysely/migration/execute-factory.js +27 -0
  12. package/dist/adapters/kysely/migration/execute-factory.js.map +1 -0
  13. package/dist/adapters/kysely/migration/execute-mssql.js +112 -0
  14. package/dist/adapters/kysely/migration/execute-mssql.js.map +1 -0
  15. package/dist/adapters/kysely/migration/execute-mysql.js +93 -0
  16. package/dist/adapters/kysely/migration/execute-mysql.js.map +1 -0
  17. package/dist/adapters/kysely/migration/execute-postgres.js +104 -0
  18. package/dist/adapters/kysely/migration/execute-postgres.js.map +1 -0
  19. package/dist/adapters/kysely/migration/execute-sqlite.js +123 -0
  20. package/dist/adapters/kysely/migration/execute-sqlite.js.map +1 -0
  21. package/dist/adapters/kysely/migration/execute.js +23 -168
  22. package/dist/adapters/kysely/migration/execute.js.map +1 -1
  23. package/dist/migration-engine/shared.d.ts +24 -5
  24. package/dist/migration-engine/shared.d.ts.map +1 -1
  25. package/dist/migration-engine/shared.js.map +1 -1
  26. package/dist/query/query.d.ts +4 -4
  27. package/dist/query/query.d.ts.map +1 -1
  28. package/dist/query/unit-of-work.d.ts +22 -22
  29. package/dist/query/unit-of-work.d.ts.map +1 -1
  30. package/dist/schema/create.d.ts +41 -41
  31. package/dist/schema/create.d.ts.map +1 -1
  32. package/package.json +7 -2
  33. package/src/adapters/drizzle/generate.test.ts +97 -0
  34. package/src/adapters/drizzle/generate.ts +3 -2
  35. package/src/adapters/kysely/kysely-adapter.ts +46 -27
  36. package/src/adapters/kysely/migration/execute-base.ts +256 -0
  37. package/src/adapters/kysely/migration/execute-factory.ts +30 -0
  38. package/src/adapters/kysely/migration/execute-mssql.ts +250 -0
  39. package/src/adapters/kysely/migration/execute-mysql.ts +211 -0
  40. package/src/adapters/kysely/migration/execute-postgres.ts +234 -0
  41. package/src/adapters/kysely/migration/execute-sqlite.test.ts +1363 -0
  42. package/src/adapters/kysely/migration/execute-sqlite.ts +247 -0
  43. package/src/adapters/kysely/migration/execute.ts +33 -396
  44. package/src/adapters/kysely/migration/kysely-migrator.test.ts +84 -2
  45. package/src/migration-engine/shared.ts +29 -11
  46. package/tsdown.config.ts +1 -0
@@ -0,0 +1,123 @@
1
+ import { BaseMigrationExecutor, createUniqueIndex, dropUniqueIndex } from "./execute-base.js";
2
+ import { sql } from "kysely";
3
+
4
+ //#region src/adapters/kysely/migration/execute-sqlite.ts
5
+ const errors = {
6
+ IdColumnUpdate: "ID columns cannot be updated. Not every database supports updating primary keys and often requires workarounds.",
7
+ SQLiteUpdateColumn: "SQLite doesn't support updating columns. Recreate the table instead.",
8
+ SQLiteUpdateForeignKeys: "SQLite doesn't support modifying foreign keys directly. Use `recreate-table` instead."
9
+ };
10
+ /**
11
+ * SQLite-specific migration executor.
12
+ * Handles SQLite's limitations around foreign keys and column updates.
13
+ */
14
+ var SqliteMigrationExecutor = class extends BaseMigrationExecutor {
15
+ /**
16
+ * SQLite preprocessing: merge add-foreign-key operations into create-table operations
17
+ * when both exist in the same batch.
18
+ *
19
+ * SQLite requires foreign keys to be defined at table creation time. This preprocessing
20
+ * step identifies create-table + add-foreign-key pairs and merges them.
21
+ */
22
+ preprocessOperations(operations) {
23
+ const result = [];
24
+ const createTableIndices = /* @__PURE__ */ new Map();
25
+ const foreignKeysByTable = /* @__PURE__ */ new Map();
26
+ for (const op of operations) if (op.type === "create-table") {
27
+ createTableIndices.set(op.name, result.length);
28
+ result.push(op);
29
+ } else if (op.type === "add-foreign-key") {
30
+ if (!foreignKeysByTable.has(op.table)) foreignKeysByTable.set(op.table, []);
31
+ foreignKeysByTable.get(op.table).push(op);
32
+ } else result.push(op);
33
+ for (const [tableName, fkOps] of foreignKeysByTable.entries()) {
34
+ const createTableIdx = createTableIndices.get(tableName);
35
+ if (createTableIdx !== void 0) {
36
+ const createOp = result[createTableIdx];
37
+ if (createOp.type === "create-table") result[createTableIdx] = {
38
+ ...createOp,
39
+ metadata: {
40
+ ...createOp.metadata,
41
+ inlineForeignKeys: fkOps.map((fkOp) => {
42
+ if (fkOp.type === "add-foreign-key") return fkOp.value;
43
+ throw new Error("Unexpected operation type");
44
+ })
45
+ }
46
+ };
47
+ } else result.push(...fkOps);
48
+ }
49
+ return result;
50
+ }
51
+ executeOperation(operation, mapper) {
52
+ switch (operation.type) {
53
+ case "create-table": return this.createTable(operation, mapper);
54
+ case "rename-table": return this.renameTable(operation, mapper);
55
+ case "alter-table": return this.alterTable(operation, mapper);
56
+ case "drop-table": return this.dropTable(operation, mapper);
57
+ case "add-foreign-key": throw new Error(errors.SQLiteUpdateForeignKeys);
58
+ case "drop-foreign-key": throw new Error(errors.SQLiteUpdateForeignKeys);
59
+ case "add-index": return this.addIndex(operation, mapper);
60
+ case "drop-index": return this.dropIndex(operation, mapper);
61
+ case "custom": return this.handleCustomOperation(operation);
62
+ }
63
+ }
64
+ createTable(operation, mapper) {
65
+ const tableName = this.getTableName(operation.name, mapper);
66
+ let builder = this.db.schema.createTable(tableName);
67
+ for (const columnInfo of operation.columns) builder = builder.addColumn(columnInfo.name, sql.raw(this.getDBType(columnInfo)), this.getColumnBuilderCallback(columnInfo));
68
+ const inlineForeignKeys = operation.metadata?.inlineForeignKeys;
69
+ if (inlineForeignKeys) for (const fk of inlineForeignKeys) builder = builder.addForeignKeyConstraint(fk.name, fk.columns, this.getTableName(fk.referencedTable, mapper), fk.referencedColumns, (cb) => cb.onUpdate("restrict").onDelete("restrict"));
70
+ return builder;
71
+ }
72
+ renameTable(operation, mapper) {
73
+ return this.db.schema.alterTable(this.getTableName(operation.from, mapper)).renameTo(this.getTableName(operation.to, mapper));
74
+ }
75
+ alterTable(operation, mapper) {
76
+ const results = [];
77
+ const tableName = this.getTableName(operation.name, mapper);
78
+ for (const columnOp of operation.value) results.push(...this.executeColumnOperation(tableName, columnOp));
79
+ return results;
80
+ }
81
+ executeColumnOperation(tableName, operation) {
82
+ const next = () => this.db.schema.alterTable(tableName);
83
+ const results = [];
84
+ switch (operation.type) {
85
+ case "rename-column":
86
+ results.push(next().renameColumn(operation.from, operation.to));
87
+ return results;
88
+ case "drop-column":
89
+ results.push(next().dropColumn(operation.name));
90
+ return results;
91
+ case "create-column": {
92
+ const col = operation.value;
93
+ results.push(next().addColumn(col.name, sql.raw(this.getDBType(col)), this.getColumnBuilderCallback(col)));
94
+ return results;
95
+ }
96
+ case "update-column": {
97
+ const col = operation.value;
98
+ if (col.role === "external-id" || col.role === "internal-id") throw new Error(errors.IdColumnUpdate);
99
+ throw new Error(errors.SQLiteUpdateColumn);
100
+ }
101
+ }
102
+ }
103
+ dropTable(operation, mapper) {
104
+ return this.db.schema.dropTable(this.getTableName(operation.name, mapper));
105
+ }
106
+ addIndex(operation, mapper) {
107
+ const tableName = this.getTableName(operation.table, mapper);
108
+ if (operation.unique) return createUniqueIndex(this.db, operation.name, tableName, operation.columns, this.provider);
109
+ return this.db.schema.createIndex(operation.name).on(tableName).columns(operation.columns);
110
+ }
111
+ dropIndex(operation, mapper) {
112
+ const tableName = this.getTableName(operation.table, mapper);
113
+ return dropUniqueIndex(this.db, operation.name, tableName, this.provider);
114
+ }
115
+ handleCustomOperation(operation) {
116
+ const statement = sql.raw(operation["sql"]);
117
+ return this.rawToNode(statement);
118
+ }
119
+ };
120
+
121
+ //#endregion
122
+ export { SqliteMigrationExecutor };
123
+ //# sourceMappingURL=execute-sqlite.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"execute-sqlite.js","names":["result: MigrationOperation<SqliteCreateTableMetadata>[]","builder: any","results: ExecuteNode[]"],"sources":["../../../../src/adapters/kysely/migration/execute-sqlite.ts"],"sourcesContent":["import { sql } from \"kysely\";\nimport type {\n ColumnOperation,\n MigrationOperation,\n SqliteCreateTableMetadata,\n} from \"../../../migration-engine/shared\";\nimport type { TableNameMapper } from \"../kysely-shared\";\nimport {\n BaseMigrationExecutor,\n createUniqueIndex,\n dropUniqueIndex,\n type ExecuteNode,\n} from \"./execute-base\";\n\nconst errors = {\n IdColumnUpdate:\n \"ID columns cannot be updated. Not every database supports updating primary keys and often requires workarounds.\",\n SQLiteUpdateColumn: \"SQLite doesn't support updating columns. Recreate the table instead.\",\n SQLiteUpdateForeignKeys:\n \"SQLite doesn't support modifying foreign keys directly. Use `recreate-table` instead.\",\n} as const;\n\n/**\n * SQLite-specific migration executor.\n * Handles SQLite's limitations around foreign keys and column updates.\n */\nexport class SqliteMigrationExecutor extends BaseMigrationExecutor<SqliteCreateTableMetadata> {\n /**\n * SQLite preprocessing: merge add-foreign-key operations into create-table operations\n * when both exist in the same batch.\n *\n * SQLite requires foreign keys to be defined at table creation time. This preprocessing\n * step identifies create-table + add-foreign-key pairs and merges them.\n */\n preprocessOperations(\n operations: MigrationOperation[],\n ): MigrationOperation<SqliteCreateTableMetadata>[] {\n const result: MigrationOperation<SqliteCreateTableMetadata>[] = [];\n const createTableIndices = new Map<string, number>(); // table name -> index in result\n const foreignKeysByTable = new Map<string, (typeof operations)[number][]>();\n\n // First pass: identify create-table operations and collect foreign keys\n for (const op of operations) {\n if (op.type === \"create-table\") {\n createTableIndices.set(op.name, result.length);\n result.push(op);\n } else if (op.type === \"add-foreign-key\") {\n if (!foreignKeysByTable.has(op.table)) {\n foreignKeysByTable.set(op.table, []);\n }\n foreignKeysByTable.get(op.table)!.push(op);\n } else {\n result.push(op);\n }\n }\n\n // Second pass: attach foreign keys as metadata to create-table ops\n for (const [tableName, fkOps] of foreignKeysByTable.entries()) {\n const createTableIdx = createTableIndices.get(tableName);\n\n if (createTableIdx !== undefined) {\n // Table is being created in this batch - attach FKs as metadata\n const createOp = result[createTableIdx];\n if (createOp.type === \"create-table\") {\n result[createTableIdx] = {\n ...createOp,\n metadata: {\n ...createOp.metadata,\n inlineForeignKeys: fkOps.map((fkOp) => {\n if (fkOp.type === \"add-foreign-key\") {\n return fkOp.value;\n }\n throw new Error(\"Unexpected operation type\");\n }),\n },\n };\n }\n } else {\n // Table already exists - keep add-foreign-key operations (will throw error during execution)\n result.push(...fkOps);\n }\n }\n\n return result;\n }\n\n executeOperation(\n operation: MigrationOperation<SqliteCreateTableMetadata>,\n mapper?: TableNameMapper,\n ): ExecuteNode | ExecuteNode[] {\n switch (operation.type) {\n case \"create-table\":\n return this.createTable(operation, mapper);\n case \"rename-table\":\n return this.renameTable(operation, mapper);\n case \"alter-table\":\n return this.alterTable(operation, mapper);\n case \"drop-table\":\n return this.dropTable(operation, mapper);\n case \"add-foreign-key\":\n throw new Error(errors.SQLiteUpdateForeignKeys);\n case \"drop-foreign-key\":\n throw new Error(errors.SQLiteUpdateForeignKeys);\n case \"add-index\":\n return this.addIndex(operation, mapper);\n case \"drop-index\":\n return this.dropIndex(operation, mapper);\n case \"custom\":\n return this.handleCustomOperation(operation);\n }\n }\n\n private createTable(\n operation: Extract<MigrationOperation<SqliteCreateTableMetadata>, { type: \"create-table\" }>,\n mapper?: TableNameMapper,\n ): ExecuteNode {\n const tableName = this.getTableName(operation.name, mapper);\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n let builder: any = this.db.schema.createTable(tableName);\n\n // Add columns\n for (const columnInfo of operation.columns) {\n builder = builder.addColumn(\n columnInfo.name,\n sql.raw(this.getDBType(columnInfo)),\n this.getColumnBuilderCallback(columnInfo),\n );\n }\n\n // Add inline foreign keys from metadata (SQLite-specific)\n const inlineForeignKeys = operation.metadata?.inlineForeignKeys;\n if (inlineForeignKeys) {\n for (const fk of inlineForeignKeys) {\n builder = builder.addForeignKeyConstraint(\n fk.name,\n fk.columns,\n this.getTableName(fk.referencedTable, mapper),\n fk.referencedColumns,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (cb: any) => cb.onUpdate(\"restrict\").onDelete(\"restrict\"),\n );\n }\n }\n\n return builder;\n }\n\n private renameTable(\n operation: Extract<MigrationOperation, { type: \"rename-table\" }>,\n mapper?: TableNameMapper,\n ): ExecuteNode {\n return this.db.schema\n .alterTable(this.getTableName(operation.from, mapper))\n .renameTo(this.getTableName(operation.to, mapper));\n }\n\n private alterTable(\n operation: Extract<MigrationOperation, { type: \"alter-table\" }>,\n mapper?: TableNameMapper,\n ): ExecuteNode[] {\n const results: ExecuteNode[] = [];\n const tableName = this.getTableName(operation.name, mapper);\n\n for (const columnOp of operation.value) {\n results.push(...this.executeColumnOperation(tableName, columnOp));\n }\n\n return results;\n }\n\n private executeColumnOperation(tableName: string, operation: ColumnOperation): ExecuteNode[] {\n const next = () => this.db.schema.alterTable(tableName);\n const results: ExecuteNode[] = [];\n\n switch (operation.type) {\n case \"rename-column\":\n results.push(next().renameColumn(operation.from, operation.to));\n return results;\n\n case \"drop-column\":\n results.push(next().dropColumn(operation.name));\n return results;\n\n case \"create-column\": {\n const col = operation.value;\n results.push(\n next().addColumn(\n col.name,\n sql.raw(this.getDBType(col)),\n this.getColumnBuilderCallback(col),\n ),\n );\n return results;\n }\n\n case \"update-column\": {\n const col = operation.value;\n // Check for ID columns first to provide a more specific error message\n if (col.role === \"external-id\" || col.role === \"internal-id\") {\n throw new Error(errors.IdColumnUpdate);\n }\n throw new Error(errors.SQLiteUpdateColumn);\n }\n }\n }\n\n private dropTable(\n operation: Extract<MigrationOperation, { type: \"drop-table\" }>,\n mapper?: TableNameMapper,\n ): ExecuteNode {\n return this.db.schema.dropTable(this.getTableName(operation.name, mapper));\n }\n\n private addIndex(\n operation: Extract<MigrationOperation, { type: \"add-index\" }>,\n mapper?: TableNameMapper,\n ): ExecuteNode {\n const tableName = this.getTableName(operation.table, mapper);\n\n if (operation.unique) {\n return createUniqueIndex(\n this.db,\n operation.name,\n tableName,\n operation.columns,\n this.provider,\n );\n }\n\n return this.db.schema.createIndex(operation.name).on(tableName).columns(operation.columns);\n }\n\n private dropIndex(\n operation: Extract<MigrationOperation, { type: \"drop-index\" }>,\n mapper?: TableNameMapper,\n ): ExecuteNode {\n const tableName = this.getTableName(operation.table, mapper);\n return dropUniqueIndex(this.db, operation.name, tableName, this.provider);\n }\n\n private handleCustomOperation(\n operation: Extract<MigrationOperation, { type: \"custom\" }>,\n ): ExecuteNode {\n const statement = sql.raw(operation[\"sql\"] as string);\n return this.rawToNode(statement);\n }\n}\n"],"mappings":";;;;AAcA,MAAM,SAAS;CACb,gBACE;CACF,oBAAoB;CACpB,yBACE;CACH;;;;;AAMD,IAAa,0BAAb,cAA6C,sBAAiD;;;;;;;;CAQ5F,qBACE,YACiD;EACjD,MAAMA,SAA0D,EAAE;EAClE,MAAM,qCAAqB,IAAI,KAAqB;EACpD,MAAM,qCAAqB,IAAI,KAA4C;AAG3E,OAAK,MAAM,MAAM,WACf,KAAI,GAAG,SAAS,gBAAgB;AAC9B,sBAAmB,IAAI,GAAG,MAAM,OAAO,OAAO;AAC9C,UAAO,KAAK,GAAG;aACN,GAAG,SAAS,mBAAmB;AACxC,OAAI,CAAC,mBAAmB,IAAI,GAAG,MAAM,CACnC,oBAAmB,IAAI,GAAG,OAAO,EAAE,CAAC;AAEtC,sBAAmB,IAAI,GAAG,MAAM,CAAE,KAAK,GAAG;QAE1C,QAAO,KAAK,GAAG;AAKnB,OAAK,MAAM,CAAC,WAAW,UAAU,mBAAmB,SAAS,EAAE;GAC7D,MAAM,iBAAiB,mBAAmB,IAAI,UAAU;AAExD,OAAI,mBAAmB,QAAW;IAEhC,MAAM,WAAW,OAAO;AACxB,QAAI,SAAS,SAAS,eACpB,QAAO,kBAAkB;KACvB,GAAG;KACH,UAAU;MACR,GA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YAAY,UAAU,KAAK,CAAC,GAAG,UAAU,CAAC,QAAQ,UAAU,QAAQ;;CAG5F,AAAQ,UACN,WACA,QACa;EACb,MAAM,YAAY,KAAK,aAAa,UAAU,OAAO,OAAO;AAC5D,SAAO,gBAAgB,KAAK,IAAI,UAAU,MAAM,WAAW,KAAK,SAAS;;CAG3E,AAAQ,sBACN,WACa;EACb,MAAM,YAAY,IAAI,IAAI,UAAU,OAAiB;AACrD,SAAO,KAAK,UAAU,UAAU"}
@@ -1,179 +1,34 @@
1
- import { SETTINGS_TABLE_NAME } from "../../../shared/settings-schema.js";
2
- import { schemaToDBType } from "../../../schema/serialize.js";
3
- import { isUpdated } from "../../../migration-engine/shared.js";
4
- import { sql } from "kysely";
1
+ import { createMigrationExecutor } from "./execute-factory.js";
5
2
 
6
3
  //#region src/adapters/kysely/migration/execute.ts
7
- const errors = {
8
- IdColumnUpdate: "ID columns cannot be updated. Not every database supports updating primary keys and often requires workarounds.",
9
- SQLiteUpdateColumn: "SQLite doesn't support updating columns. Recreate the table instead.",
10
- SQLiteUpdateForeignKeys: "SQLite doesn't support modifying foreign keys directly. Use `recreate-table` instead."
11
- };
12
4
  /**
13
- * Returns the appropriate foreign key action based on the provider.
14
- * MSSQL doesn't support RESTRICT, so we use NO ACTION (functionally equivalent).
5
+ * Execute a single migration operation using the appropriate provider-specific executor.
6
+ *
7
+ * @param operation - The migration operation to execute
8
+ * @param config - Kysely configuration with database instance and provider
9
+ * @param onCustomNode - Handler for custom operations
10
+ * @param mapper - Optional table name mapper for namespacing
11
+ * @returns ExecuteNode(s) that can be compiled to SQL or executed
15
12
  */
16
- function getForeignKeyAction(provider) {
17
- return provider === "mssql" ? "no action" : "restrict";
13
+ function execute(operation, config, onCustomNode, mapper) {
14
+ if (operation.type === "custom") return onCustomNode(operation);
15
+ return createMigrationExecutor(config).executeOperation(operation, mapper);
18
16
  }
19
17
  /**
20
- * Generates MSSQL default constraint name following the DF_tableName_columnName pattern.
18
+ * Preprocess a batch of migration operations.
19
+ * This allows provider-specific transformations before execution.
20
+ *
21
+ * For example, SQLite merges add-foreign-key operations into create-table operations
22
+ * since foreign keys must be defined at table creation time.
23
+ *
24
+ * @param operations - The migration operations to preprocess
25
+ * @param config - Kysely configuration with database instance and provider
26
+ * @returns Preprocessed migration operations
21
27
  */
22
- function getMssqlDefaultConstraintName(tableName, columnName) {
23
- return `DF_${tableName}_${columnName}`;
24
- }
25
- function createUniqueIndex(db, name, tableName, cols, provider) {
26
- const query = db.schema.createIndex(name).on(tableName).columns(cols).unique();
27
- if (provider === "mssql") return query.where((b) => {
28
- return b.and(cols.map((col) => b(col, "is not", null)));
29
- });
30
- return query;
31
- }
32
- function dropUniqueIndex(db, name, tableName, provider) {
33
- let query = db.schema.dropIndex(name).ifExists();
34
- if (provider === "cockroachdb") query = query.cascade();
35
- if (provider === "mssql") query = query.on(tableName);
36
- return query;
37
- }
38
- function executeColumn(tableName, operation, config) {
39
- const { db, provider } = config;
40
- const next = () => db.schema.alterTable(tableName);
41
- const results = [];
42
- switch (operation.type) {
43
- case "rename-column":
44
- results.push(next().renameColumn(operation.from, operation.to));
45
- return results;
46
- case "drop-column":
47
- results.push(next().dropColumn(operation.name));
48
- return results;
49
- case "create-column": {
50
- const col = operation.value;
51
- results.push(next().addColumn(col.name, sql.raw(schemaToDBType(col, provider)), getColumnBuilderCallback(col, provider)));
52
- return results;
53
- }
54
- case "update-column": {
55
- const col = operation.value;
56
- if (col.role === "external-id" || col.role === "internal-id") throw new Error(errors.IdColumnUpdate);
57
- if (provider === "sqlite") throw new Error(errors.SQLiteUpdateColumn);
58
- if (!isUpdated(operation)) return results;
59
- if (provider === "mysql") {
60
- results.push(next().modifyColumn(operation.name, sql.raw(schemaToDBType(col, provider)), getColumnBuilderCallback(col, provider)));
61
- return results;
62
- }
63
- const mssqlRecreateDefaultConstraint = operation.updateDataType || operation.updateDefault;
64
- if (provider === "mssql" && mssqlRecreateDefaultConstraint) results.push(rawToNode(db, mssqlDropDefaultConstraint(tableName, col.name)));
65
- if (operation.updateDataType) {
66
- const dbType = sql.raw(schemaToDBType(col, provider));
67
- if (provider === "postgresql" || provider === "cockroachdb") results.push(rawToNode(db, sql`ALTER TABLE ${sql.ref(tableName)} ALTER COLUMN ${sql.ref(operation.name)} TYPE ${dbType} USING (${sql.ref(operation.name)}::${dbType})`));
68
- else results.push(next().alterColumn(operation.name, (b) => b.setDataType(dbType)));
69
- }
70
- if (operation.updateNullable) results.push(next().alterColumn(operation.name, (build) => col.isNullable ? build.dropNotNull() : build.setNotNull()));
71
- if (provider === "mssql" && mssqlRecreateDefaultConstraint) {
72
- const defaultValue = defaultValueToDB(col, provider);
73
- if (defaultValue) {
74
- const constraintName = getMssqlDefaultConstraintName(tableName, col.name);
75
- results.push(rawToNode(db, sql`ALTER TABLE ${sql.ref(tableName)} ADD CONSTRAINT ${sql.ref(constraintName)} DEFAULT ${defaultValue} FOR ${sql.ref(col.name)}`));
76
- }
77
- } else if (operation.updateDefault) {
78
- const defaultValue = defaultValueToDB(col, provider);
79
- results.push(next().alterColumn(operation.name, (build) => {
80
- if (!defaultValue) return build.dropDefault();
81
- return build.setDefault(defaultValue);
82
- }));
83
- }
84
- return results;
85
- }
86
- }
87
- }
88
- function execute(operation, config, onCustomNode, mapper) {
89
- const { db, provider } = config;
90
- const getTableName = (tableName) => tableName === SETTINGS_TABLE_NAME ? tableName : mapper ? mapper.toPhysical(tableName) : tableName;
91
- function createTable(tableName, columns) {
92
- let builder = db.schema.createTable(getTableName(tableName));
93
- for (const columnInfo of columns) builder = builder.addColumn(columnInfo.name, sql.raw(schemaToDBType(columnInfo, provider)), getColumnBuilderCallback(columnInfo, provider));
94
- return builder;
95
- }
96
- switch (operation.type) {
97
- case "create-table": return createTable(operation.name, operation.columns);
98
- case "rename-table":
99
- if (provider === "mssql") return rawToNode(db, sql`EXEC sp_rename ${sql.lit(getTableName(operation.from))}, ${sql.lit(getTableName(operation.to))}`);
100
- return db.schema.alterTable(getTableName(operation.from)).renameTo(getTableName(operation.to));
101
- case "alter-table": {
102
- const results = [];
103
- for (const op of operation.value) results.push(...executeColumn(getTableName(operation.name), op, config));
104
- return results;
105
- }
106
- case "drop-table": return db.schema.dropTable(getTableName(operation.name));
107
- case "custom": return onCustomNode(operation);
108
- case "add-foreign-key": {
109
- if (provider === "sqlite") throw new Error(errors.SQLiteUpdateForeignKeys);
110
- const { table, value } = operation;
111
- const action = getForeignKeyAction(provider);
112
- return db.schema.alterTable(getTableName(table)).addForeignKeyConstraint(value.name, value.columns, getTableName(value.referencedTable), value.referencedColumns, (b) => b.onUpdate(action).onDelete(action));
113
- }
114
- case "drop-foreign-key": {
115
- if (provider === "sqlite") throw new Error(errors.SQLiteUpdateForeignKeys);
116
- const { table, name } = operation;
117
- let query = db.schema.alterTable(getTableName(table)).dropConstraint(name);
118
- if (provider !== "mysql") query = query.ifExists();
119
- return query;
120
- }
121
- case "add-index":
122
- if (operation.unique) return createUniqueIndex(db, operation.name, getTableName(operation.table), operation.columns, provider);
123
- return db.schema.createIndex(operation.name).on(getTableName(operation.table)).columns(operation.columns);
124
- case "drop-index": return dropUniqueIndex(db, operation.name, getTableName(operation.table), provider);
125
- }
126
- }
127
- function getColumnBuilderCallback(col, provider) {
128
- return (build) => {
129
- if (!col.isNullable) build = build.notNull();
130
- if (col.role === "internal-id") {
131
- build = build.primaryKey();
132
- if (provider === "postgresql" || provider === "cockroachdb") {} else if (provider === "mysql") build = build.autoIncrement();
133
- else if (provider === "sqlite") build = build.autoIncrement();
134
- else if (provider === "mssql") build = build.identity();
135
- }
136
- if (col.role === "external-id") build = build.unique();
137
- const defaultValue = defaultValueToDB(col, provider);
138
- if (defaultValue) build = build.defaultTo(defaultValue);
139
- return build;
140
- };
141
- }
142
- function rawToNode(db, raw) {
143
- return {
144
- compile() {
145
- return raw.compile(db);
146
- },
147
- execute() {
148
- return raw.execute(db);
149
- }
150
- };
151
- }
152
- function mssqlDropDefaultConstraint(tableName, columnName) {
153
- return sql`
154
- DECLARE @ConstraintName NVARCHAR(200);
155
-
156
- SELECT @ConstraintName = dc.name
157
- FROM sys.default_constraints dc
158
- JOIN sys.columns c ON dc.parent_object_id = c.object_id AND dc.parent_column_id = c.column_id
159
- JOIN sys.tables t ON t.object_id = c.object_id
160
- JOIN sys.schemas s ON t.schema_id = s.schema_id
161
- WHERE s.name = 'dbo' AND t.name = ${sql.lit(tableName)} AND c.name = ${sql.lit(columnName)};
162
-
163
- IF @ConstraintName IS NOT NULL
164
- BEGIN
165
- EXEC('ALTER TABLE [dbo].[' + ${sql.lit(tableName)} + '] DROP CONSTRAINT [' + @ConstraintName + ']');
166
- END`;
167
- }
168
- function defaultValueToDB(column, provider) {
169
- const value = column.default;
170
- if (!value) return;
171
- if (provider === "mysql" && column.type === "string") return;
172
- if ("value" in value && value.value !== void 0) return sql.lit(value.value);
173
- if ("dbSpecial" in value && value.dbSpecial === "now") return sql`CURRENT_TIMESTAMP`;
174
- if ("runtime" in value) return;
28
+ function preprocessOperations(operations, config) {
29
+ return createMigrationExecutor(config).preprocessOperations(operations);
175
30
  }
176
31
 
177
32
  //#endregion
178
- export { execute };
33
+ export { execute, preprocessOperations };
179
34
  //# sourceMappingURL=execute.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"execute.js","names":["results: ExecuteNode[]"],"sources":["../../../../src/adapters/kysely/migration/execute.ts"],"sourcesContent":["import {\n type ColumnBuilderCallback,\n type Compilable,\n type CreateTableBuilder,\n type Kysely,\n type RawBuilder,\n sql,\n} from \"kysely\";\nimport {\n type CustomOperation,\n isUpdated,\n type ColumnOperation,\n type MigrationOperation,\n type ColumnInfo,\n} from \"../../../migration-engine/shared\";\nimport type { SQLProvider } from \"../../../shared/providers\";\nimport { schemaToDBType } from \"../../../schema/serialize\";\nimport type { KyselyConfig } from \"../kysely-adapter\";\nimport type { TableNameMapper } from \"../kysely-shared\";\nimport { SETTINGS_TABLE_NAME } from \"../../../shared/settings-schema\";\n\nexport type ExecuteNode = Compilable & {\n execute(): Promise<unknown>;\n};\n\ntype KyselyAny = Kysely<any>; // eslint-disable-line @typescript-eslint/no-explicit-any\n\nconst errors = {\n IdColumnUpdate:\n \"ID columns cannot be updated. Not every database supports updating primary keys and often requires workarounds.\",\n SQLiteUpdateColumn: \"SQLite doesn't support updating columns. Recreate the table instead.\",\n SQLiteUpdateForeignKeys:\n \"SQLite doesn't support modifying foreign keys directly. Use `recreate-table` instead.\",\n} as const;\n\n/**\n * Returns the appropriate foreign key action based on the provider.\n * MSSQL doesn't support RESTRICT, so we use NO ACTION (functionally equivalent).\n */\nfunction getForeignKeyAction(provider: SQLProvider): \"restrict\" | \"no action\" {\n return provider === \"mssql\" ? \"no action\" : \"restrict\";\n}\n\n/**\n * Generates MSSQL default constraint name following the DF_tableName_columnName pattern.\n */\nfunction getMssqlDefaultConstraintName(tableName: string, columnName: string): string {\n const MSSQL_DEFAULT_CONSTRAINT_PREFIX = \"DF\" as const;\n return `${MSSQL_DEFAULT_CONSTRAINT_PREFIX}_${tableName}_${columnName}`;\n}\n\nfunction createUniqueIndex(\n db: KyselyAny,\n name: string,\n tableName: string,\n cols: string[],\n provider: SQLProvider,\n) {\n const query = db.schema.createIndex(name).on(tableName).columns(cols).unique();\n\n if (provider === \"mssql\") {\n // MSSQL: ignore null values in unique indexes by default\n return query.where((b) => {\n return b.and(cols.map((col) => b(col, \"is not\", null)));\n });\n }\n\n return query;\n}\n\nfunction dropUniqueIndex(db: KyselyAny, name: string, tableName: string, provider: SQLProvider) {\n let query = db.schema.dropIndex(name).ifExists();\n\n if (provider === \"cockroachdb\") {\n query = query.cascade();\n }\n\n if (provider === \"mssql\") {\n query = query.on(tableName);\n }\n\n return query;\n}\n\nfunction executeColumn(\n tableName: string,\n operation: ColumnOperation,\n config: KyselyConfig,\n): ExecuteNode[] {\n const { db, provider } = config;\n const next = () => db.schema.alterTable(tableName);\n const results: ExecuteNode[] = [];\n\n switch (operation.type) {\n case \"rename-column\":\n results.push(next().renameColumn(operation.from, operation.to));\n return results;\n\n case \"drop-column\":\n results.push(next().dropColumn(operation.name));\n\n return results;\n case \"create-column\": {\n const col = operation.value;\n\n results.push(\n next().addColumn(\n col.name,\n sql.raw(schemaToDBType(col, provider)),\n getColumnBuilderCallback(col, provider),\n ),\n );\n\n return results;\n }\n case \"update-column\": {\n const col = operation.value;\n\n if (col.role === \"external-id\" || col.role === \"internal-id\") {\n throw new Error(errors.IdColumnUpdate);\n }\n if (provider === \"sqlite\") {\n throw new Error(errors.SQLiteUpdateColumn);\n }\n\n if (!isUpdated(operation)) {\n return results;\n }\n if (provider === \"mysql\") {\n results.push(\n next().modifyColumn(\n operation.name,\n sql.raw(schemaToDBType(col, provider)),\n getColumnBuilderCallback(col, provider),\n ),\n );\n return results;\n }\n\n // MSSQL requires dropping and recreating default constraints when changing data type or default value\n const mssqlRecreateDefaultConstraint = operation.updateDataType || operation.updateDefault;\n\n if (provider === \"mssql\" && mssqlRecreateDefaultConstraint) {\n results.push(rawToNode(db, mssqlDropDefaultConstraint(tableName, col.name)));\n }\n\n // TODO: We should maybe do some of these operations in a single query\n\n if (operation.updateDataType) {\n const dbType = sql.raw(schemaToDBType(col, provider));\n\n if (provider === \"postgresql\" || provider === \"cockroachdb\") {\n // PostgreSQL/CockroachDB: Use explicit USING clause for type conversion\n results.push(\n rawToNode(\n db,\n sql`ALTER TABLE ${sql.ref(tableName)} ALTER COLUMN ${sql.ref(operation.name)} TYPE ${dbType} USING (${sql.ref(operation.name)}::${dbType})`,\n ),\n );\n } else {\n results.push(next().alterColumn(operation.name, (b) => b.setDataType(dbType)));\n }\n }\n\n if (operation.updateNullable) {\n results.push(\n next().alterColumn(operation.name, (build) =>\n col.isNullable ? build.dropNotNull() : build.setNotNull(),\n ),\n );\n }\n\n if (provider === \"mssql\" && mssqlRecreateDefaultConstraint) {\n const defaultValue = defaultValueToDB(col, provider);\n\n if (defaultValue) {\n const constraintName = getMssqlDefaultConstraintName(tableName, col.name);\n\n results.push(\n rawToNode(\n db,\n sql`ALTER TABLE ${sql.ref(tableName)} ADD CONSTRAINT ${sql.ref(constraintName)} DEFAULT ${defaultValue} FOR ${sql.ref(col.name)}`,\n ),\n );\n }\n } else if (operation.updateDefault) {\n const defaultValue = defaultValueToDB(col, provider);\n\n results.push(\n next().alterColumn(operation.name, (build) => {\n if (!defaultValue) {\n return build.dropDefault();\n }\n return build.setDefault(defaultValue);\n }),\n );\n }\n\n return results;\n }\n }\n}\n\nexport function execute(\n operation: MigrationOperation,\n config: KyselyConfig,\n onCustomNode: (op: CustomOperation) => ExecuteNode | ExecuteNode[],\n mapper?: TableNameMapper,\n): ExecuteNode | ExecuteNode[] {\n const { db, provider } = config;\n\n // Settings table is never namespaced\n const getTableName = (tableName: string) =>\n tableName === SETTINGS_TABLE_NAME\n ? tableName\n : mapper\n ? mapper.toPhysical(tableName)\n : tableName;\n\n function createTable(tableName: string, columns: ColumnInfo[]) {\n let builder = db.schema.createTable(getTableName(tableName)) as CreateTableBuilder<\n string,\n string\n >;\n\n // Add columns from the column info array\n for (const columnInfo of columns) {\n builder = builder.addColumn(\n columnInfo.name,\n sql.raw(schemaToDBType(columnInfo, provider)),\n getColumnBuilderCallback(columnInfo, provider),\n );\n }\n\n return builder;\n }\n\n switch (operation.type) {\n case \"create-table\":\n return createTable(operation.name, operation.columns);\n case \"rename-table\":\n if (provider === \"mssql\") {\n return rawToNode(\n db,\n sql`EXEC sp_rename ${sql.lit(getTableName(operation.from))}, ${sql.lit(getTableName(operation.to))}`,\n );\n }\n\n return db.schema\n .alterTable(getTableName(operation.from))\n .renameTo(getTableName(operation.to));\n case \"alter-table\": {\n const results: ExecuteNode[] = [];\n\n for (const op of operation.value) {\n results.push(...executeColumn(getTableName(operation.name), op, config));\n }\n\n return results;\n }\n case \"drop-table\":\n return db.schema.dropTable(getTableName(operation.name));\n case \"custom\":\n return onCustomNode(operation);\n case \"add-foreign-key\": {\n if (provider === \"sqlite\") {\n throw new Error(errors.SQLiteUpdateForeignKeys);\n }\n\n const { table, value } = operation;\n const action = getForeignKeyAction(provider);\n\n return db.schema\n .alterTable(getTableName(table))\n .addForeignKeyConstraint(\n value.name,\n value.columns,\n getTableName(value.referencedTable),\n value.referencedColumns,\n (b) => b.onUpdate(action).onDelete(action),\n );\n }\n case \"drop-foreign-key\": {\n if (provider === \"sqlite\") {\n throw new Error(errors.SQLiteUpdateForeignKeys);\n }\n\n const { table, name } = operation;\n let query = db.schema.alterTable(getTableName(table)).dropConstraint(name);\n\n // MySQL doesn't support IF EXISTS for dropping constraints\n if (provider !== \"mysql\") {\n query = query.ifExists();\n }\n\n return query;\n }\n case \"add-index\": {\n if (operation.unique) {\n return createUniqueIndex(\n db,\n operation.name,\n getTableName(operation.table),\n operation.columns,\n provider,\n );\n }\n return db.schema\n .createIndex(operation.name)\n .on(getTableName(operation.table))\n .columns(operation.columns);\n }\n case \"drop-index\": {\n return dropUniqueIndex(db, operation.name, getTableName(operation.table), provider);\n }\n }\n}\n\n// ============================================================================\n// Helper Functions\n// ============================================================================\n\nfunction getColumnBuilderCallback(col: ColumnInfo, provider: SQLProvider): ColumnBuilderCallback {\n return (build) => {\n if (!col.isNullable) {\n build = build.notNull();\n }\n\n // Internal ID is the primary key with auto-increment\n if (col.role === \"internal-id\") {\n build = build.primaryKey();\n // Auto-increment for internal ID\n if (provider === \"postgresql\" || provider === \"cockroachdb\") {\n // SERIAL/BIGSERIAL handles auto-increment\n // Already handled in schemaToDBType\n } else if (provider === \"mysql\") {\n build = build.autoIncrement();\n } else if (provider === \"sqlite\") {\n build = build.autoIncrement();\n } else if (provider === \"mssql\") {\n build = build.identity();\n }\n }\n\n // External ID must be unique\n if (col.role === \"external-id\") {\n build = build.unique();\n }\n\n const defaultValue = defaultValueToDB(col, provider);\n if (defaultValue) {\n build = build.defaultTo(defaultValue);\n }\n return build;\n };\n}\n\nfunction rawToNode(db: KyselyAny, raw: RawBuilder<unknown>): ExecuteNode {\n return {\n compile() {\n return raw.compile(db);\n },\n execute() {\n return raw.execute(db);\n },\n };\n}\n\nfunction mssqlDropDefaultConstraint(tableName: string, columnName: string) {\n return sql`\nDECLARE @ConstraintName NVARCHAR(200);\n\nSELECT @ConstraintName = dc.name\nFROM sys.default_constraints dc\nJOIN sys.columns c ON dc.parent_object_id = c.object_id AND dc.parent_column_id = c.column_id\nJOIN sys.tables t ON t.object_id = c.object_id\nJOIN sys.schemas s ON t.schema_id = s.schema_id\nWHERE s.name = 'dbo' AND t.name = ${sql.lit(tableName)} AND c.name = ${sql.lit(columnName)};\n\nIF @ConstraintName IS NOT NULL\nBEGIN\n EXEC('ALTER TABLE [dbo].[' + ${sql.lit(tableName)} + '] DROP CONSTRAINT [' + @ConstraintName + ']');\nEND`;\n}\n\nfunction defaultValueToDB(column: ColumnInfo, provider: SQLProvider) {\n const value = column.default;\n if (!value) {\n return undefined;\n }\n\n // MySQL doesn't support default values for TEXT columns\n if (provider === \"mysql\" && column.type === \"string\") {\n return undefined;\n }\n\n // Static default values: defaultTo(value)\n if (\"value\" in value && value.value !== undefined) {\n return sql.lit(value.value);\n }\n\n // Database-level special functions: defaultTo(b => b.now())\n if (\"dbSpecial\" in value && value.dbSpecial === \"now\") {\n return sql`CURRENT_TIMESTAMP`;\n }\n\n // Runtime defaults (defaultTo$) are NOT generated in SQL - they're handled in application code\n if (\"runtime\" in value) {\n return undefined;\n }\n\n return undefined;\n}\n"],"mappings":";;;;;;AA2BA,MAAM,SAAS;CACb,gBACE;CACF,oBAAoB;CACpB,yBACE;CACH;;;;;AAMD,SAAS,oBAAoB,UAAiD;AAC5E,QAAO,aAAa,UAAU,cAAc;;;;;AAM9C,SAAS,8BAA8B,WAAmB,YAA4B;AAEpF,QAAO,MAAsC,UAAU,GAAG;;AAG5D,SAAS,kBACP,IACA,MACA,WACA,MACA,UACA;CACA,MAAM,QAAQ,GAAG,OAAO,YAAY,KAAK,CAAC,GAAG,UAAU,CAAC,QAAQ,KAAK,CAAC,QAAQ;AAE9E,KAAI,aAAa,QAEf,QAAO,MAAM,OAAO,MAAM;AACxB,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UAAuB;CACnE,MAAM,QAAQ,OAAO;AACrB,KAAI,CAAC,MACH;AAIF,KAAI,aAAa,WAAW,OAAO,SAAS,SAC1C;AAIF,KAAI,WAAW,SAAS,MAAM,UAAU,OACtC,QAAO,IAAI,IAAI,MAAM,MAAM;AAI7B,KAAI,eAAe,SAAS,MAAM,cAAc,MAC9C,QAAO,GAAG;AAIZ,KAAI,aAAa,MACf"}
1
+ {"version":3,"file":"execute.js","names":[],"sources":["../../../../src/adapters/kysely/migration/execute.ts"],"sourcesContent":["import type { CustomOperation, MigrationOperation } from \"../../../migration-engine/shared\";\nimport type { KyselyConfig } from \"../kysely-adapter\";\nimport type { TableNameMapper } from \"../kysely-shared\";\nimport type { ExecuteNode } from \"./execute-base\";\nimport { createMigrationExecutor } from \"./execute-factory\";\n\nexport type { ExecuteNode };\n\n/**\n * Execute a single migration operation using the appropriate provider-specific executor.\n *\n * @param operation - The migration operation to execute\n * @param config - Kysely configuration with database instance and provider\n * @param onCustomNode - Handler for custom operations\n * @param mapper - Optional table name mapper for namespacing\n * @returns ExecuteNode(s) that can be compiled to SQL or executed\n */\nexport function execute(\n operation: MigrationOperation,\n config: KyselyConfig,\n onCustomNode: (op: CustomOperation) => ExecuteNode | ExecuteNode[],\n mapper?: TableNameMapper,\n): ExecuteNode | ExecuteNode[] {\n // For custom operations, use the provided handler\n if (operation.type === \"custom\") {\n return onCustomNode(operation);\n }\n\n const executor = createMigrationExecutor(config);\n return executor.executeOperation(operation, mapper);\n}\n\n/**\n * Preprocess a batch of migration operations.\n * This allows provider-specific transformations before execution.\n *\n * For example, SQLite merges add-foreign-key operations into create-table operations\n * since foreign keys must be defined at table creation time.\n *\n * @param operations - The migration operations to preprocess\n * @param config - Kysely configuration with database instance and provider\n * @returns Preprocessed migration operations\n */\nexport function preprocessOperations(\n operations: MigrationOperation[],\n config: KyselyConfig,\n): MigrationOperation[] {\n const executor = createMigrationExecutor(config);\n return executor.preprocessOperations(operations);\n}\n"],"mappings":";;;;;;;;;;;;AAiBA,SAAgB,QACd,WACA,QACA,cACA,QAC6B;AAE7B,KAAI,UAAU,SAAS,SACrB,QAAO,aAAa,UAAU;AAIhC,QADiB,wBAAwB,OAAO,CAChC,iBAAiB,WAAW,OAAO;;;;;;;;;;;;;AAcrD,SAAgB,qBACd,YACA,QACsB;AAEtB,QADiB,wBAAwB,OAAO,CAChC,qBAAqB,WAAW"}
@@ -5,6 +5,13 @@ interface ForeignKeyInfo {
5
5
  referencedTable: string;
6
6
  referencedColumns: string[];
7
7
  }
8
+ /**
9
+ * Provider-specific metadata that can be attached to operations during preprocessing.
10
+ * This allows providers to add additional context without polluting the core operation types.
11
+ */
12
+ interface MigrationOperationMetadata {
13
+ [key: string]: unknown;
14
+ }
8
15
  interface ColumnInfo {
9
16
  name: string;
10
17
  type: "string" | "integer" | "bigint" | "decimal" | "bool" | "date" | "timestamp" | "json" | "binary" | `varchar(${number})`;
@@ -18,25 +25,37 @@ interface ColumnInfo {
18
25
  runtime: "cuid" | "now";
19
26
  };
20
27
  }
21
- type MigrationOperation = TableOperation | {
28
+ type MigrationOperation<TMeta extends MigrationOperationMetadata = MigrationOperationMetadata> = (TableOperation & {
29
+ metadata?: TMeta;
30
+ }) | ({
22
31
  type: "add-foreign-key";
23
32
  table: string;
24
33
  value: ForeignKeyInfo;
25
- } | {
34
+ } & {
35
+ metadata?: TMeta;
36
+ }) | ({
26
37
  type: "drop-foreign-key";
27
38
  table: string;
28
39
  name: string;
29
- } | {
40
+ } & {
41
+ metadata?: TMeta;
42
+ }) | ({
30
43
  type: "drop-index";
31
44
  table: string;
32
45
  name: string;
33
- } | {
46
+ } & {
47
+ metadata?: TMeta;
48
+ }) | ({
34
49
  type: "add-index";
35
50
  table: string;
36
51
  columns: string[];
37
52
  name: string;
38
53
  unique: boolean;
39
- } | CustomOperation;
54
+ } & {
55
+ metadata?: TMeta;
56
+ }) | (CustomOperation & {
57
+ metadata?: TMeta;
58
+ });
40
59
  type CustomOperation = {
41
60
  type: "custom";
42
61
  } & Record<string, unknown>;
@@ -1 +1 @@
1
- {"version":3,"file":"shared.d.ts","names":[],"sources":["../../src/migration-engine/shared.ts"],"sourcesContent":[],"mappings":";UAAiB,cAAA;EAAA,IAAA,EAAA,MAAA;EAOA,OAAA,EAAA,MAAU,EAAA;EAkBf,eAAA,EAAA,MAAkB;EAC1B,iBAAA,EAAA,MAAA,EAAA;;AAyBA,UA5Ca,UAAA,CA4Cb;EAAe,IAAA,EAAA,MAAA;EAEP,IAAA,EAAA,QAAA,GAAA,SAAe,GAAA,QAEvB,GAAM,SAAA,GAAA,MAAA,GAAA,MAAA,GAAA,WAAA,GAAA,MAAA,GAAA,QAAA,GAAA,WAAA,MAAA,GAAA;EAEE,UAAA,EAAA,OAAc;EAqBd,IAAA,EAAA,aAAe,GAAA,aAed,GAAA,SAgBA,GAAA,WAAU,GAAA,SAAA;;;;;;;;;KApFX,kBAAA,GACR;;;SAKS;;;;;;;;;;;;;;;IAoBT;KAEQ,eAAA;;IAER;KAEQ,cAAA;;;WAIG;;;;;;;SASF;;;;;;KAQD,eAAA;;;;;;;;;;;;SAeC;;;;;;;;;;;;;;;SAgBA"}
1
+ {"version":3,"file":"shared.d.ts","names":[],"sources":["../../src/migration-engine/shared.ts"],"sourcesContent":[],"mappings":";UAAiB,cAAA;EAAA,IAAA,EAAA,MAAA;EAWA,OAAA,EAAA,MAAA,EAAA;EAYA,eAAU,EAAA,MAAA;EAkBf,iBAAA,EAAA,MAAkB,EAAA;;;;;;AAST,UAvCJ,0BAAA,CAuCI;EAMA,CAAA,GAAA,EAAA,MAAA,CAAA,EAAA,OAAA;;UAjCJ,UAAA;;;;;;;;;;;;;KAkBL,iCACI,6BAA6B,+BAExC;aAA8B;;;;SAKtB;;aACQ;;;;;;aAMA;;;;;;aAKA;;;;;;;;aAOA;MAChB;aAA+B;;KAExB,eAAA;;IAER;KAEQ,cAAA;;;WAIG;;;;;;;SASF;;;;;;KAQD,eAAA;;;;;;;;;;;;SAeC;;;;;;;;;;;;;;;SAgBA"}
@@ -1 +1 @@
1
- {"version":3,"file":"shared.js","names":[],"sources":["../../src/migration-engine/shared.ts"],"sourcesContent":["export interface ForeignKeyInfo {\n name: string;\n columns: string[];\n referencedTable: string;\n referencedColumns: string[];\n}\n\nexport interface ColumnInfo {\n name: string;\n type:\n | \"string\"\n | \"integer\"\n | \"bigint\"\n | \"decimal\"\n | \"bool\"\n | \"date\"\n | \"timestamp\"\n | \"json\"\n | \"binary\"\n | `varchar(${number})`;\n isNullable: boolean;\n role: \"external-id\" | \"internal-id\" | \"version\" | \"reference\" | \"regular\";\n default?: { value: unknown } | { dbSpecial: \"now\" } | { runtime: \"cuid\" | \"now\" };\n}\n\nexport type MigrationOperation =\n | TableOperation\n | {\n // warning: not supported by SQLite\n type: \"add-foreign-key\";\n table: string;\n value: ForeignKeyInfo;\n }\n | {\n // warning: not supported by SQLite\n type: \"drop-foreign-key\";\n table: string;\n name: string;\n }\n | {\n type: \"drop-index\";\n table: string;\n name: string;\n }\n | {\n type: \"add-index\";\n table: string;\n columns: string[];\n name: string;\n unique: boolean;\n }\n | CustomOperation;\n\nexport type CustomOperation = {\n type: \"custom\";\n} & Record<string, unknown>;\n\nexport type TableOperation =\n | {\n type: \"create-table\";\n name: string;\n columns: ColumnInfo[];\n }\n | {\n type: \"drop-table\";\n name: string;\n }\n | {\n type: \"alter-table\";\n name: string;\n value: ColumnOperation[];\n }\n | {\n type: \"rename-table\";\n from: string;\n to: string;\n };\n\nexport type ColumnOperation =\n | {\n type: \"rename-column\";\n from: string;\n to: string;\n }\n | {\n type: \"drop-column\";\n name: string;\n }\n | {\n /**\n * Note: unique constraints are not created, please use dedicated operations like `add-index` instead\n */\n type: \"create-column\";\n value: ColumnInfo;\n }\n | {\n /**\n * warning: Not supported by SQLite\n */\n type: \"update-column\";\n name: string;\n /**\n * For databases like MySQL, it requires the full definition for any modify column statement.\n * Hence, you need to specify the full information of your column here.\n *\n * Then, opt-in for in-detail modification for other databases that supports changing data type/nullable/default separately, such as PostgreSQL.\n *\n * Note: unique constraints are not updated, please use dedicated operations like `add-index` instead\n */\n value: ColumnInfo;\n\n updateNullable: boolean;\n updateDefault: boolean;\n updateDataType: boolean;\n };\n\nexport function isUpdated(op: Extract<ColumnOperation, { type: \"update-column\" }>): boolean {\n return op.updateDataType || op.updateDefault || op.updateNullable;\n}\n"],"mappings":";AAoHA,SAAgB,UAAU,IAAkE;AAC1F,QAAO,GAAG,kBAAkB,GAAG,iBAAiB,GAAG"}
1
+ {"version":3,"file":"shared.js","names":[],"sources":["../../src/migration-engine/shared.ts"],"sourcesContent":["export interface ForeignKeyInfo {\n name: string;\n columns: string[];\n referencedTable: string;\n referencedColumns: string[];\n}\n\n/**\n * Provider-specific metadata that can be attached to operations during preprocessing.\n * This allows providers to add additional context without polluting the core operation types.\n */\nexport interface MigrationOperationMetadata {\n [key: string]: unknown;\n}\n\n/**\n * SQLite-specific metadata for create-table operations.\n * Includes foreign keys that should be created inline with the table.\n */\nexport interface SqliteCreateTableMetadata extends MigrationOperationMetadata {\n inlineForeignKeys?: ForeignKeyInfo[];\n}\n\nexport interface ColumnInfo {\n name: string;\n type:\n | \"string\"\n | \"integer\"\n | \"bigint\"\n | \"decimal\"\n | \"bool\"\n | \"date\"\n | \"timestamp\"\n | \"json\"\n | \"binary\"\n | `varchar(${number})`;\n isNullable: boolean;\n role: \"external-id\" | \"internal-id\" | \"version\" | \"reference\" | \"regular\";\n default?: { value: unknown } | { dbSpecial: \"now\" } | { runtime: \"cuid\" | \"now\" };\n}\n\nexport type MigrationOperation<\n TMeta extends MigrationOperationMetadata = MigrationOperationMetadata,\n> =\n | (TableOperation & { metadata?: TMeta })\n | ({\n // warning: not supported by SQLite\n type: \"add-foreign-key\";\n table: string;\n value: ForeignKeyInfo;\n } & { metadata?: TMeta })\n | ({\n // warning: not supported by SQLite\n type: \"drop-foreign-key\";\n table: string;\n name: string;\n } & { metadata?: TMeta })\n | ({\n type: \"drop-index\";\n table: string;\n name: string;\n } & { metadata?: TMeta })\n | ({\n type: \"add-index\";\n table: string;\n columns: string[];\n name: string;\n unique: boolean;\n } & { metadata?: TMeta })\n | (CustomOperation & { metadata?: TMeta });\n\nexport type CustomOperation = {\n type: \"custom\";\n} & Record<string, unknown>;\n\nexport type TableOperation =\n | {\n type: \"create-table\";\n name: string;\n columns: ColumnInfo[];\n }\n | {\n type: \"drop-table\";\n name: string;\n }\n | {\n type: \"alter-table\";\n name: string;\n value: ColumnOperation[];\n }\n | {\n type: \"rename-table\";\n from: string;\n to: string;\n };\n\nexport type ColumnOperation =\n | {\n type: \"rename-column\";\n from: string;\n to: string;\n }\n | {\n type: \"drop-column\";\n name: string;\n }\n | {\n /**\n * Note: unique constraints are not created, please use dedicated operations like `add-index` instead\n */\n type: \"create-column\";\n value: ColumnInfo;\n }\n | {\n /**\n * warning: Not supported by SQLite\n */\n type: \"update-column\";\n name: string;\n /**\n * For databases like MySQL, it requires the full definition for any modify column statement.\n * Hence, you need to specify the full information of your column here.\n *\n * Then, opt-in for in-detail modification for other databases that supports changing data type/nullable/default separately, such as PostgreSQL.\n *\n * Note: unique constraints are not updated, please use dedicated operations like `add-index` instead\n */\n value: ColumnInfo;\n\n updateNullable: boolean;\n updateDefault: boolean;\n updateDataType: boolean;\n };\n\nexport function isUpdated(op: Extract<ColumnOperation, { type: \"update-column\" }>): boolean {\n return op.updateDataType || op.updateDefault || op.updateNullable;\n}\n"],"mappings":";AAsIA,SAAgB,UAAU,IAAkE;AAC1F,QAAO,GAAG,kBAAkB,GAAG,iBAAiB,GAAG"}
@@ -14,16 +14,16 @@ type RawInsertValues<T extends AnyTable> = { [K in keyof T["columns"] as string
14
14
  type TableToInsertValues<T extends AnyTable> = Prettify<Partial<PickNullable<RawInsertValues<T>>> & PickNotNullable<RawInsertValues<T>>>;
15
15
  type TableToUpdateValues<T extends AnyTable> = { [K in keyof T["columns"] as string extends K ? never : K]?: T["columns"][K] extends IdColumn ? never : T["columns"][K]["$in"] };
16
16
  type MainSelectResult<S extends SelectClause<T>, T extends AnyTable> = S extends true ? TableToColumnValues<T> : S extends (keyof T["columns"])[] ? { [K in S[number] as string extends K ? never : K]: K extends keyof T["columns"] ? T["columns"][K]["$out"] : never } : never;
17
- type SelectResult<T extends AnyTable, JoinOut$1, Select$1 extends SelectClause<T>> = MainSelectResult<Select$1, T> & JoinOut$1;
17
+ type SelectResult<T extends AnyTable, JoinOut, Select extends SelectClause<T>> = MainSelectResult<Select, T> & JoinOut;
18
18
  interface MapRelationType<Type$1> {
19
19
  one: Type$1 | null;
20
20
  many: Type$1[];
21
21
  }
22
22
  type JoinBuilder<T extends AnyTable, Out = {}> = { [K in keyof T["relations"]]: T["relations"][K] extends Relation<infer Type, infer Target> ? <Select extends SelectClause<Target> = true, JoinOut = {}>(options?: FindManyOptions<Target, Select, JoinOut, false>) => JoinBuilder<T, Out & { [$K in K]: MapRelationType<SelectResult<Target, JoinOut, Select>>[Type] }> : never };
23
23
  type OrderBy<Column = string> = [columnName: Column, "asc" | "desc"];
24
- type FindFirstOptions<T extends AnyTable = AnyTable, Select$1 extends SelectClause<T> = SelectClause<T>, JoinOut$1 = {}, IsRoot extends boolean = true> = Omit<FindManyOptions<T, Select$1, JoinOut$1, IsRoot>, IsRoot extends true ? "limit" : "limit" | "offset" | "orderBy">;
25
- type FindManyOptions<T extends AnyTable = AnyTable, Select$1 extends SelectClause<T> = SelectClause<T>, _JoinOut = {}, IsRoot extends boolean = true> = {
26
- select?: Select$1;
24
+ type FindFirstOptions<T extends AnyTable = AnyTable, Select extends SelectClause<T> = SelectClause<T>, JoinOut = {}, IsRoot extends boolean = true> = Omit<FindManyOptions<T, Select, JoinOut, IsRoot>, IsRoot extends true ? "limit" : "limit" | "offset" | "orderBy">;
25
+ type FindManyOptions<T extends AnyTable = AnyTable, Select extends SelectClause<T> = SelectClause<T>, _JoinOut = {}, IsRoot extends boolean = true> = {
26
+ select?: Select;
27
27
  where?: (eb: ConditionBuilder<T["columns"]>) => Condition | boolean;
28
28
  limit?: number;
29
29
  orderBy?: OrderBy<keyof T["columns"]> | OrderBy<keyof T["columns"]>[];
@@ -1 +1 @@
1
- {"version":3,"file":"query.d.ts","names":[],"sources":["../../src/query/query.ts"],"sourcesContent":[],"mappings":";;;;;;KAWY,eAAA,GAAkB,aAAa;KAE/B,uBAAuB,0BAA0B;AAFjD,KAIA,eAJe,CAAA,UAIW,QAJR,CAAA,GAAA,QAElB,MAGE,CAHF,CAAA,SAAY,CAAA,IAAW,MAAA,SAGU,CAHiB,GAAA,KAAA,GAGL,CAHK,GAGD,CAHC,CAAA,SAAA,CAAA,CAGY,CAHZ,CAAA,CAAA,MAAA,CAAA,EAE9D;AAAsC,KAI1B,mBAJ0B,CAAA,UAII,QAJJ,CAAA,GAIgB,eAJhB,CAIgC,CAJhC,CAAA;KAMjC,YALS,CAAA,CAAA,CAAA,GAAA,QAA+B,MAM/B,CAN+B,IAAA,IAAA,SAMb,CANa,CAMX,CANW,CAAA,GAMN,CANM,GAAA,KAAA,GAMM,CANN,CAMQ,CANR,CAAA,EAAY;KASpD,eATwD,CAAA,CAAA,CAAA,GAAA,QAAa,MAU5D,CAV4D,IAAA,IAAA,SAU1C,CAV0C,CAUxC,CAVwC,CAAA,GAAA,KAAA,GAU3B,CAV2B,GAUvB,CAVuB,CAUrB,CAVqB,CAAA,EAAC;AAG3E,KAUK,eAVO,CAAA,UAUmB,QAVA,CAAA,GAAA,QAAW,MAW5B,CAX4B,CAAA,SAAA,CAAA,IAAA,MAAA,SAWG,CAXH,GAAA,KAAA,GAWe,CAXf,GAWmB,CAXnB,CAAA,SAAA,CAAA,CAWgC,CAXhC,CAAA,CAAA,KAAA,CAAA,EAA4B;AAAhB,KAc1C,mBAd0C,CAAA,UAcZ,QAdY,CAAA,GAcA,QAdA,CAepD,OAfoD,CAe5C,YAf4C,CAe/B,eAf+B,CAef,CAfe,CAAA,CAAA,CAAA,GAeR,eAfQ,CAeQ,eAfR,CAewB,CAfxB,CAAA,CAAA,CAAA;AAAe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