zenstack-kit 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (93) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +313 -0
  3. package/dist/cli/app.d.ts +12 -0
  4. package/dist/cli/app.d.ts.map +1 -0
  5. package/dist/cli/app.js +253 -0
  6. package/dist/cli/commands.d.ts +70 -0
  7. package/dist/cli/commands.d.ts.map +1 -0
  8. package/dist/cli/commands.js +308 -0
  9. package/dist/cli/index.d.ts +12 -0
  10. package/dist/cli/index.d.ts.map +1 -0
  11. package/dist/cli/index.js +12 -0
  12. package/dist/cli/prompt-provider.d.ts +10 -0
  13. package/dist/cli/prompt-provider.d.ts.map +1 -0
  14. package/dist/cli/prompt-provider.js +41 -0
  15. package/dist/cli/prompts.d.ts +27 -0
  16. package/dist/cli/prompts.d.ts.map +1 -0
  17. package/dist/cli/prompts.js +133 -0
  18. package/dist/cli.d.ts +12 -0
  19. package/dist/cli.d.ts.map +1 -0
  20. package/dist/cli.js +240 -0
  21. package/dist/config/index.d.ts +96 -0
  22. package/dist/config/index.d.ts.map +1 -0
  23. package/dist/config/index.js +48 -0
  24. package/dist/config/loader.d.ts +11 -0
  25. package/dist/config/loader.d.ts.map +1 -0
  26. package/dist/config/loader.js +44 -0
  27. package/dist/config-loader.d.ts +6 -0
  28. package/dist/config-loader.d.ts.map +1 -0
  29. package/dist/config-loader.js +36 -0
  30. package/dist/config.d.ts +62 -0
  31. package/dist/config.d.ts.map +1 -0
  32. package/dist/config.js +44 -0
  33. package/dist/index.d.ts +19 -0
  34. package/dist/index.d.ts.map +1 -0
  35. package/dist/index.js +23 -0
  36. package/dist/init-prompts.d.ts +13 -0
  37. package/dist/init-prompts.d.ts.map +1 -0
  38. package/dist/init-prompts.js +64 -0
  39. package/dist/introspect.d.ts +54 -0
  40. package/dist/introspect.d.ts.map +1 -0
  41. package/dist/introspect.js +75 -0
  42. package/dist/kysely-adapter.d.ts +49 -0
  43. package/dist/kysely-adapter.d.ts.map +1 -0
  44. package/dist/kysely-adapter.js +74 -0
  45. package/dist/migrate-apply.d.ts +18 -0
  46. package/dist/migrate-apply.d.ts.map +1 -0
  47. package/dist/migrate-apply.js +61 -0
  48. package/dist/migrate.d.ts +108 -0
  49. package/dist/migrate.d.ts.map +1 -0
  50. package/dist/migrate.js +127 -0
  51. package/dist/migrations/apply.d.ts +18 -0
  52. package/dist/migrations/apply.d.ts.map +1 -0
  53. package/dist/migrations/apply.js +61 -0
  54. package/dist/migrations/diff.d.ts +161 -0
  55. package/dist/migrations/diff.d.ts.map +1 -0
  56. package/dist/migrations/diff.js +620 -0
  57. package/dist/migrations/prisma.d.ts +193 -0
  58. package/dist/migrations/prisma.d.ts.map +1 -0
  59. package/dist/migrations/prisma.js +929 -0
  60. package/dist/migrations.d.ts +161 -0
  61. package/dist/migrations.d.ts.map +1 -0
  62. package/dist/migrations.js +620 -0
  63. package/dist/prisma-migrations.d.ts +160 -0
  64. package/dist/prisma-migrations.d.ts.map +1 -0
  65. package/dist/prisma-migrations.js +789 -0
  66. package/dist/prompts.d.ts +10 -0
  67. package/dist/prompts.d.ts.map +1 -0
  68. package/dist/prompts.js +41 -0
  69. package/dist/pull.d.ts +23 -0
  70. package/dist/pull.d.ts.map +1 -0
  71. package/dist/pull.js +424 -0
  72. package/dist/schema/introspect.d.ts +54 -0
  73. package/dist/schema/introspect.d.ts.map +1 -0
  74. package/dist/schema/introspect.js +75 -0
  75. package/dist/schema/pull.d.ts +23 -0
  76. package/dist/schema/pull.d.ts.map +1 -0
  77. package/dist/schema/pull.js +424 -0
  78. package/dist/schema/snapshot.d.ts +46 -0
  79. package/dist/schema/snapshot.d.ts.map +1 -0
  80. package/dist/schema/snapshot.js +278 -0
  81. package/dist/schema-snapshot.d.ts +45 -0
  82. package/dist/schema-snapshot.d.ts.map +1 -0
  83. package/dist/schema-snapshot.js +265 -0
  84. package/dist/sql/compiler.d.ts +74 -0
  85. package/dist/sql/compiler.d.ts.map +1 -0
  86. package/dist/sql/compiler.js +270 -0
  87. package/dist/sql/kysely-adapter.d.ts +49 -0
  88. package/dist/sql/kysely-adapter.d.ts.map +1 -0
  89. package/dist/sql/kysely-adapter.js +74 -0
  90. package/dist/sql-compiler.d.ts +74 -0
  91. package/dist/sql-compiler.d.ts.map +1 -0
  92. package/dist/sql-compiler.js +243 -0
  93. package/package.json +81 -0
@@ -0,0 +1,270 @@
1
+ /**
2
+ * SQL Compiler - Generates raw SQL from schema operations using Kysely's compile()
3
+ *
4
+ * Uses Kysely with DummyDriver to compile schema operations to dialect-specific SQL
5
+ * without requiring a database connection.
6
+ */
7
+ import { Kysely, DummyDriver, SqliteAdapter, SqliteIntrospector, SqliteQueryCompiler, PostgresAdapter, PostgresIntrospector, PostgresQueryCompiler, MysqlAdapter, MysqlIntrospector, MysqlQueryCompiler, sql, } from "kysely";
8
+ /**
9
+ * Create a Kysely instance configured for SQL compilation only (no actual DB connection)
10
+ */
11
+ function createCompilerDb(dialect) {
12
+ if (dialect === "sqlite") {
13
+ return new Kysely({
14
+ dialect: {
15
+ createAdapter: () => new SqliteAdapter(),
16
+ createDriver: () => new DummyDriver(),
17
+ createIntrospector: (db) => new SqliteIntrospector(db),
18
+ createQueryCompiler: () => new SqliteQueryCompiler(),
19
+ },
20
+ });
21
+ }
22
+ else if (dialect === "postgres") {
23
+ return new Kysely({
24
+ dialect: {
25
+ createAdapter: () => new PostgresAdapter(),
26
+ createDriver: () => new DummyDriver(),
27
+ createIntrospector: (db) => new PostgresIntrospector(db),
28
+ createQueryCompiler: () => new PostgresQueryCompiler(),
29
+ },
30
+ });
31
+ }
32
+ else {
33
+ return new Kysely({
34
+ dialect: {
35
+ createAdapter: () => new MysqlAdapter(),
36
+ createDriver: () => new DummyDriver(),
37
+ createIntrospector: (db) => new MysqlIntrospector(db),
38
+ createQueryCompiler: () => new MysqlQueryCompiler(),
39
+ },
40
+ });
41
+ }
42
+ }
43
+ /**
44
+ * Compile a CREATE TABLE statement to SQL
45
+ */
46
+ export function compileCreateTable(model, options) {
47
+ const db = createCompilerDb(options.dialect);
48
+ let builder = db.schema.createTable(model.name);
49
+ for (const column of model.columns) {
50
+ const columnType = mapColumnType(column.type, options.dialect, {
51
+ isArray: column.isArray,
52
+ isAutoincrement: column.isAutoincrement,
53
+ });
54
+ builder = builder.addColumn(column.name, sql.raw(columnType), (cb) => {
55
+ // For SERIAL types in PostgreSQL, NOT NULL is implicit and we don't need defaults
56
+ const isSerialType = column.isAutoincrement && options.dialect === "postgres";
57
+ if (column.notNull && !isSerialType) {
58
+ cb = cb.notNull();
59
+ }
60
+ if (column.default !== undefined && !isSerialType) {
61
+ cb = cb.defaultTo(sql.raw(formatDefault(column.default, options.dialect)));
62
+ }
63
+ return cb;
64
+ });
65
+ }
66
+ // Add primary key constraint
67
+ if (model.primaryKey) {
68
+ builder = builder.addPrimaryKeyConstraint(model.primaryKey.name, model.primaryKey.columns);
69
+ }
70
+ // Add unique constraints
71
+ for (const unique of model.uniqueConstraints) {
72
+ builder = builder.addUniqueConstraint(unique.name, unique.columns);
73
+ }
74
+ // Add foreign key constraints
75
+ for (const fk of model.foreignKeys) {
76
+ builder = builder.addForeignKeyConstraint(fk.name, fk.columns, fk.referencedTable, fk.referencedColumns);
77
+ }
78
+ return builder.compile().sql + ";";
79
+ }
80
+ /**
81
+ * Compile a DROP TABLE statement to SQL
82
+ */
83
+ export function compileDropTable(tableName, options) {
84
+ const db = createCompilerDb(options.dialect);
85
+ return db.schema.dropTable(tableName).ifExists().compile().sql + ";";
86
+ }
87
+ /**
88
+ * Compile an ADD COLUMN statement to SQL
89
+ */
90
+ export function compileAddColumn(tableName, column, options) {
91
+ const db = createCompilerDb(options.dialect);
92
+ const columnType = mapColumnType(column.type, options.dialect, {
93
+ isArray: column.isArray,
94
+ isAutoincrement: column.isAutoincrement,
95
+ });
96
+ return (db.schema
97
+ .alterTable(tableName)
98
+ .addColumn(column.name, sql.raw(columnType), (cb) => {
99
+ const isSerialType = column.isAutoincrement && options.dialect === "postgres";
100
+ if (column.notNull && !isSerialType) {
101
+ cb = cb.notNull();
102
+ }
103
+ if (column.default !== undefined && !isSerialType) {
104
+ cb = cb.defaultTo(sql.raw(formatDefault(column.default, options.dialect)));
105
+ }
106
+ return cb;
107
+ })
108
+ .compile().sql + ";");
109
+ }
110
+ /**
111
+ * Compile a DROP COLUMN statement to SQL
112
+ */
113
+ export function compileDropColumn(tableName, columnName, options) {
114
+ const db = createCompilerDb(options.dialect);
115
+ return db.schema.alterTable(tableName).dropColumn(columnName).compile().sql + ";";
116
+ }
117
+ /**
118
+ * Compile a RENAME TABLE statement to SQL
119
+ */
120
+ export function compileRenameTable(fromName, toName, options) {
121
+ const db = createCompilerDb(options.dialect);
122
+ return db.schema.alterTable(fromName).renameTo(toName).compile().sql + ";";
123
+ }
124
+ /**
125
+ * Compile a RENAME COLUMN statement to SQL
126
+ */
127
+ export function compileRenameColumn(tableName, fromName, toName, options) {
128
+ const db = createCompilerDb(options.dialect);
129
+ return (db.schema.alterTable(tableName).renameColumn(fromName, toName).compile().sql + ";");
130
+ }
131
+ /**
132
+ * Compile a CREATE INDEX statement to SQL
133
+ */
134
+ export function compileCreateIndex(tableName, indexName, columns, options) {
135
+ const db = createCompilerDb(options.dialect);
136
+ let builder = db.schema.createIndex(indexName).on(tableName);
137
+ for (const col of columns) {
138
+ builder = builder.column(col);
139
+ }
140
+ return builder.compile().sql + ";";
141
+ }
142
+ /**
143
+ * Compile a DROP INDEX statement to SQL
144
+ */
145
+ export function compileDropIndex(indexName, options) {
146
+ const db = createCompilerDb(options.dialect);
147
+ return db.schema.dropIndex(indexName).compile().sql + ";";
148
+ }
149
+ /**
150
+ * Compile an ADD CONSTRAINT (unique) statement to SQL
151
+ */
152
+ export function compileAddUniqueConstraint(tableName, constraintName, columns, options) {
153
+ const db = createCompilerDb(options.dialect);
154
+ return (db.schema
155
+ .alterTable(tableName)
156
+ .addUniqueConstraint(constraintName, columns)
157
+ .compile().sql + ";");
158
+ }
159
+ /**
160
+ * Compile a DROP CONSTRAINT statement to SQL
161
+ */
162
+ export function compileDropConstraint(tableName, constraintName, options) {
163
+ const db = createCompilerDb(options.dialect);
164
+ return (db.schema.alterTable(tableName).dropConstraint(constraintName).compile().sql + ";");
165
+ }
166
+ /**
167
+ * Compile an ADD FOREIGN KEY CONSTRAINT statement to SQL
168
+ */
169
+ export function compileAddForeignKeyConstraint(tableName, constraintName, columns, referencedTable, referencedColumns, options) {
170
+ const db = createCompilerDb(options.dialect);
171
+ return (db.schema
172
+ .alterTable(tableName)
173
+ .addForeignKeyConstraint(constraintName, columns, referencedTable, referencedColumns)
174
+ .compile().sql + ";");
175
+ }
176
+ /**
177
+ * Compile an ADD PRIMARY KEY CONSTRAINT statement to SQL
178
+ */
179
+ export function compileAddPrimaryKeyConstraint(tableName, constraintName, columns, options) {
180
+ const db = createCompilerDb(options.dialect);
181
+ return (db.schema
182
+ .alterTable(tableName)
183
+ .addPrimaryKeyConstraint(constraintName, columns)
184
+ .compile().sql + ";");
185
+ }
186
+ /**
187
+ * Compile ALTER COLUMN statements for type/nullability/default changes
188
+ */
189
+ export function compileAlterColumn(tableName, columnName, changes, options) {
190
+ const db = createCompilerDb(options.dialect);
191
+ const statements = [];
192
+ if (changes.setType) {
193
+ const columnType = mapColumnType(changes.setType, options.dialect);
194
+ statements.push(db.schema
195
+ .alterTable(tableName)
196
+ .alterColumn(columnName, (ac) => ac.setDataType(columnType))
197
+ .compile().sql + ";");
198
+ }
199
+ if (changes.setNotNull) {
200
+ statements.push(db.schema
201
+ .alterTable(tableName)
202
+ .alterColumn(columnName, (ac) => ac.setNotNull())
203
+ .compile().sql + ";");
204
+ }
205
+ if (changes.dropNotNull) {
206
+ statements.push(db.schema
207
+ .alterTable(tableName)
208
+ .alterColumn(columnName, (ac) => ac.dropNotNull())
209
+ .compile().sql + ";");
210
+ }
211
+ if (changes.setDefault !== undefined) {
212
+ statements.push(db.schema
213
+ .alterTable(tableName)
214
+ .alterColumn(columnName, (ac) => ac.setDefault(sql.raw(formatDefault(changes.setDefault, options.dialect))))
215
+ .compile().sql + ";");
216
+ }
217
+ if (changes.dropDefault) {
218
+ statements.push(db.schema
219
+ .alterTable(tableName)
220
+ .alterColumn(columnName, (ac) => ac.dropDefault())
221
+ .compile().sql + ";");
222
+ }
223
+ return statements;
224
+ }
225
+ /**
226
+ * Map our internal type names to dialect-specific SQL types
227
+ */
228
+ function mapColumnType(type, dialect, options) {
229
+ const { isArray, isAutoincrement } = options ?? {};
230
+ // Handle autoincrement for PostgreSQL - use SERIAL/BIGSERIAL types
231
+ if (isAutoincrement && dialect === "postgres") {
232
+ if (type === "bigint") {
233
+ return "bigserial";
234
+ }
235
+ return "serial";
236
+ }
237
+ // Handle autoincrement for MySQL
238
+ if (isAutoincrement && dialect === "mysql") {
239
+ // MySQL uses AUTO_INCREMENT attribute, but we can map to appropriate int type
240
+ // The actual AUTO_INCREMENT will be added via the modifier
241
+ return type;
242
+ }
243
+ // Handle array types for PostgreSQL
244
+ if (isArray && dialect === "postgres") {
245
+ return `${type}[]`;
246
+ }
247
+ // Most types are already SQL types from our snapshot, just return as-is
248
+ // The Kysely compiler will handle dialect-specific adjustments
249
+ return type;
250
+ }
251
+ /**
252
+ * Format a default value for SQL
253
+ */
254
+ function formatDefault(value, dialect) {
255
+ if (typeof value === "string") {
256
+ // Check if it's a function call like now() or autoincrement()
257
+ if (/^\w+\([^)]*\)$/.test(value)) {
258
+ return value;
259
+ }
260
+ // Escape string values
261
+ return `'${value.replace(/'/g, "''")}'`;
262
+ }
263
+ if (typeof value === "boolean") {
264
+ if (dialect === "sqlite") {
265
+ return value ? "1" : "0";
266
+ }
267
+ return value ? "true" : "false";
268
+ }
269
+ return String(value);
270
+ }
@@ -0,0 +1,49 @@
1
+ /**
2
+ * Kysely database adapter
3
+ *
4
+ * Provides utilities to create Kysely instances configured for use
5
+ * with ZenStack-generated types.
6
+ */
7
+ import type { Kysely } from "kysely";
8
+ export type KyselyDialect = "sqlite" | "postgres" | "mysql";
9
+ export interface KyselyAdapterOptions {
10
+ /** Database dialect */
11
+ dialect: KyselyDialect;
12
+ /** Database connection URL */
13
+ connectionUrl?: string;
14
+ /** SQLite database path (for SQLite dialect) */
15
+ databasePath?: string;
16
+ /** Connection pool settings */
17
+ pool?: {
18
+ min?: number;
19
+ max?: number;
20
+ };
21
+ }
22
+ export interface KyselyAdapter<DB> {
23
+ /** The Kysely instance */
24
+ db: Kysely<DB>;
25
+ /** Destroy the connection pool */
26
+ destroy: () => Promise<void>;
27
+ }
28
+ /**
29
+ * Creates a Kysely adapter for use with ZenStack schemas
30
+ *
31
+ * @example
32
+ * ```ts
33
+ * import { createKyselyAdapter } from "zenstack-kit";
34
+ * import type { Database } from "./generated/kysely-types";
35
+ *
36
+ * const { db, destroy } = await createKyselyAdapter<Database>({
37
+ * dialect: "postgres",
38
+ * connectionUrl: process.env.DATABASE_URL,
39
+ * });
40
+ *
41
+ * // Use db for queries
42
+ * const users = await db.selectFrom("user").selectAll().execute();
43
+ *
44
+ * // Clean up
45
+ * await destroy();
46
+ * ```
47
+ */
48
+ export declare function createKyselyAdapter<DB>(options: KyselyAdapterOptions): Promise<KyselyAdapter<DB>>;
49
+ //# sourceMappingURL=kysely-adapter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"kysely-adapter.d.ts","sourceRoot":"","sources":["../../src/sql/kysely-adapter.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAW,MAAM,QAAQ,CAAC;AAE9C,MAAM,MAAM,aAAa,GAAG,QAAQ,GAAG,UAAU,GAAG,OAAO,CAAC;AAE5D,MAAM,WAAW,oBAAoB;IACnC,uBAAuB;IACvB,OAAO,EAAE,aAAa,CAAC;IACvB,8BAA8B;IAC9B,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,gDAAgD;IAChD,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,+BAA+B;IAC/B,IAAI,CAAC,EAAE;QACL,GAAG,CAAC,EAAE,MAAM,CAAC;QACb,GAAG,CAAC,EAAE,MAAM,CAAC;KACd,CAAC;CACH;AAED,MAAM,WAAW,aAAa,CAAC,EAAE;IAC/B,0BAA0B;IAC1B,EAAE,EAAE,MAAM,CAAC,EAAE,CAAC,CAAC;IACf,kCAAkC;IAClC,OAAO,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAC9B;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAsB,mBAAmB,CAAC,EAAE,EAC1C,OAAO,EAAE,oBAAoB,GAC5B,OAAO,CAAC,aAAa,CAAC,EAAE,CAAC,CAAC,CAwD5B"}
@@ -0,0 +1,74 @@
1
+ /**
2
+ * Kysely database adapter
3
+ *
4
+ * Provides utilities to create Kysely instances configured for use
5
+ * with ZenStack-generated types.
6
+ */
7
+ /**
8
+ * Creates a Kysely adapter for use with ZenStack schemas
9
+ *
10
+ * @example
11
+ * ```ts
12
+ * import { createKyselyAdapter } from "zenstack-kit";
13
+ * import type { Database } from "./generated/kysely-types";
14
+ *
15
+ * const { db, destroy } = await createKyselyAdapter<Database>({
16
+ * dialect: "postgres",
17
+ * connectionUrl: process.env.DATABASE_URL,
18
+ * });
19
+ *
20
+ * // Use db for queries
21
+ * const users = await db.selectFrom("user").selectAll().execute();
22
+ *
23
+ * // Clean up
24
+ * await destroy();
25
+ * ```
26
+ */
27
+ export async function createKyselyAdapter(options) {
28
+ // Dynamic imports based on dialect to avoid bundling unused drivers
29
+ let dialect;
30
+ switch (options.dialect) {
31
+ case "sqlite": {
32
+ const { default: Database } = await import("better-sqlite3");
33
+ const { SqliteDialect } = await import("kysely");
34
+ dialect = new SqliteDialect({
35
+ database: new Database(options.databasePath || ":memory:"),
36
+ });
37
+ break;
38
+ }
39
+ case "postgres": {
40
+ // Note: User needs to install pg package
41
+ const { Pool } = await import("pg");
42
+ const { PostgresDialect } = await import("kysely");
43
+ dialect = new PostgresDialect({
44
+ pool: new Pool({
45
+ connectionString: options.connectionUrl,
46
+ min: options.pool?.min ?? 2,
47
+ max: options.pool?.max ?? 10,
48
+ }),
49
+ });
50
+ break;
51
+ }
52
+ case "mysql": {
53
+ // Note: User needs to install mysql2 package
54
+ const mysql = await import("mysql2");
55
+ const { MysqlDialect } = await import("kysely");
56
+ dialect = new MysqlDialect({
57
+ pool: mysql.createPool({
58
+ uri: options.connectionUrl,
59
+ }),
60
+ });
61
+ break;
62
+ }
63
+ default:
64
+ throw new Error(`Unsupported dialect: ${options.dialect}`);
65
+ }
66
+ const { Kysely } = await import("kysely");
67
+ const db = new Kysely({ dialect });
68
+ return {
69
+ db,
70
+ destroy: async () => {
71
+ await db.destroy();
72
+ },
73
+ };
74
+ }
@@ -0,0 +1,74 @@
1
+ /**
2
+ * SQL Compiler - Generates raw SQL from schema operations using Kysely's compile()
3
+ *
4
+ * Uses Kysely with DummyDriver to compile schema operations to dialect-specific SQL
5
+ * without requiring a database connection.
6
+ */
7
+ import type { KyselyDialect } from "./kysely-adapter.js";
8
+ import type { SchemaTable, SchemaColumn } from "./schema-snapshot.js";
9
+ export interface SqlMigration {
10
+ up: string[];
11
+ down: string[];
12
+ }
13
+ export interface CompileSqlOptions {
14
+ dialect: KyselyDialect;
15
+ }
16
+ /**
17
+ * Compile a CREATE TABLE statement to SQL
18
+ */
19
+ export declare function compileCreateTable(model: SchemaTable, options: CompileSqlOptions): string;
20
+ /**
21
+ * Compile a DROP TABLE statement to SQL
22
+ */
23
+ export declare function compileDropTable(tableName: string, options: CompileSqlOptions): string;
24
+ /**
25
+ * Compile an ADD COLUMN statement to SQL
26
+ */
27
+ export declare function compileAddColumn(tableName: string, column: SchemaColumn, options: CompileSqlOptions): string;
28
+ /**
29
+ * Compile a DROP COLUMN statement to SQL
30
+ */
31
+ export declare function compileDropColumn(tableName: string, columnName: string, options: CompileSqlOptions): string;
32
+ /**
33
+ * Compile a RENAME TABLE statement to SQL
34
+ */
35
+ export declare function compileRenameTable(fromName: string, toName: string, options: CompileSqlOptions): string;
36
+ /**
37
+ * Compile a RENAME COLUMN statement to SQL
38
+ */
39
+ export declare function compileRenameColumn(tableName: string, fromName: string, toName: string, options: CompileSqlOptions): string;
40
+ /**
41
+ * Compile a CREATE INDEX statement to SQL
42
+ */
43
+ export declare function compileCreateIndex(tableName: string, indexName: string, columns: string[], options: CompileSqlOptions): string;
44
+ /**
45
+ * Compile a DROP INDEX statement to SQL
46
+ */
47
+ export declare function compileDropIndex(indexName: string, options: CompileSqlOptions): string;
48
+ /**
49
+ * Compile an ADD CONSTRAINT (unique) statement to SQL
50
+ */
51
+ export declare function compileAddUniqueConstraint(tableName: string, constraintName: string, columns: string[], options: CompileSqlOptions): string;
52
+ /**
53
+ * Compile a DROP CONSTRAINT statement to SQL
54
+ */
55
+ export declare function compileDropConstraint(tableName: string, constraintName: string, options: CompileSqlOptions): string;
56
+ /**
57
+ * Compile an ADD FOREIGN KEY CONSTRAINT statement to SQL
58
+ */
59
+ export declare function compileAddForeignKeyConstraint(tableName: string, constraintName: string, columns: string[], referencedTable: string, referencedColumns: string[], options: CompileSqlOptions): string;
60
+ /**
61
+ * Compile an ADD PRIMARY KEY CONSTRAINT statement to SQL
62
+ */
63
+ export declare function compileAddPrimaryKeyConstraint(tableName: string, constraintName: string, columns: string[], options: CompileSqlOptions): string;
64
+ /**
65
+ * Compile ALTER COLUMN statements for type/nullability/default changes
66
+ */
67
+ export declare function compileAlterColumn(tableName: string, columnName: string, changes: {
68
+ setType?: string;
69
+ setNotNull?: boolean;
70
+ dropNotNull?: boolean;
71
+ setDefault?: string | number | boolean;
72
+ dropDefault?: boolean;
73
+ }, options: CompileSqlOptions): string[];
74
+ //# sourceMappingURL=sql-compiler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sql-compiler.d.ts","sourceRoot":"","sources":["../src/sql-compiler.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAgBH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB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