drizzle-kit 0.20.14-1ebe0ff → 0.20.14-1f99bf7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (54) hide show
  1. package/bin.cjs +46606 -46728
  2. package/cli/commands/migrate.d.ts +24 -24
  3. package/cli/commands/mysqlIntrospect.d.ts +119 -0
  4. package/cli/commands/mysqlPushUtils.d.ts +18 -0
  5. package/cli/commands/mysqlUp.d.ts +2 -2
  6. package/cli/commands/pgConnect.d.ts +1 -1
  7. package/cli/commands/pgIntrospect.d.ts +9 -9
  8. package/cli/commands/pgPushUtils.d.ts +2 -2
  9. package/cli/commands/pgUp.d.ts +2 -2
  10. package/cli/commands/sqliteIntrospect.d.ts +9 -9
  11. package/cli/commands/sqlitePushUtils.d.ts +21 -0
  12. package/cli/commands/upFolders.d.ts +1 -1
  13. package/cli/commands/utils.d.ts +14 -259
  14. package/cli/validations/cli.d.ts +104 -0
  15. package/cli/validations/common.d.ts +205 -7
  16. package/cli/validations/mysql.d.ts +6 -1
  17. package/cli/validations/pg.d.ts +6 -1
  18. package/cli/validations/sqlite.d.ts +165 -3
  19. package/cli/views.d.ts +1 -1
  20. package/drivers/index.d.ts +14 -0
  21. package/global.d.ts +2 -1
  22. package/index.d.mts +8 -6
  23. package/index.d.ts +8 -6
  24. package/index.js +1 -0
  25. package/introspect-mysql.d.ts +9 -0
  26. package/introspect-pg.d.ts +1 -1
  27. package/introspect-sqlite.d.ts +1 -1
  28. package/jsonStatements.d.ts +1 -1
  29. package/package.json +17 -4
  30. package/payload.d.mts +33 -0
  31. package/payload.d.ts +33 -0
  32. package/payload.js +37106 -0
  33. package/payload.mjs +37124 -0
  34. package/schemaValidator.d.ts +40 -40
  35. package/serializer/mysqlImports.d.ts +5 -0
  36. package/serializer/mysqlSchema.d.ts +1991 -753
  37. package/serializer/mysqlSerializer.d.ts +4 -4
  38. package/serializer/pgSchema.d.ts +1113 -788
  39. package/serializer/sqliteImports.d.ts +4 -0
  40. package/serializer/sqliteSchema.d.ts +144 -570
  41. package/serializer/sqliteSerializer.d.ts +2 -2
  42. package/snapshotsDiffer.d.ts +24 -20
  43. package/utils-studio.js +21 -8
  44. package/utils-studio.mjs +20 -8
  45. package/utils.d.ts +13 -27
  46. package/utils.js +3080 -54201
  47. package/utils.mjs +8175 -0
  48. package/cli/commands/sqliteUtils.d.ts +0 -162
  49. package/cli/utils.d.ts +0 -12
  50. package/cli/validations/studio.d.ts +0 -593
  51. package/orm-extenstions/d1-driver/driver.d.ts +0 -8
  52. package/orm-extenstions/d1-driver/session.d.ts +0 -51
  53. package/orm-extenstions/d1-driver/wrangler-client.d.ts +0 -3
  54. package/serializer/studioUtils.d.ts +0 -65
@@ -1,9 +1,9 @@
1
1
  import { CommonSchema, CommonSquashedSchema, Dialect } from "../../schemaValidator";
2
2
  import { schema } from "../views";
3
- import { PgSchema } from "src/serializer/pgSchema";
4
- import { SQLiteSchema } from "src/serializer/sqliteSchema";
5
- import { MySqlSchema } from "src/serializer/mysqlSchema";
6
- import { Journal } from "src/utils";
3
+ import { PgSchema } from "../../serializer/pgSchema";
4
+ import { SQLiteSchema } from "../../serializer/sqliteSchema";
5
+ import { MySqlSchema } from "../../serializer/mysqlSchema";
6
+ import { Journal } from "../../utils";
7
7
  import { GenerateConfig } from "./utils";
8
8
  export type Named = {
9
9
  name: string;
@@ -26,10 +26,6 @@ export declare const prepareMySQLPush: (config: {
26
26
  } | undefined>;
27
27
  } | undefined>;
28
28
  } | undefined;
29
- id: string;
30
- prevId: string;
31
- version: "5";
32
- dialect: "mysql";
33
29
  tables: Record<string, {
34
30
  schema?: string | undefined;
35
31
  name: string;
@@ -68,6 +64,10 @@ export declare const prepareMySQLPush: (config: {
68
64
  columns: string[];
69
65
  }>;
70
66
  }>;
67
+ id: string;
68
+ prevId: string;
69
+ version: "6";
70
+ dialect: "mysql";
71
71
  schemas: Record<string, string>;
72
72
  _meta: {
73
73
  columns: Record<string, string>;
@@ -83,10 +83,6 @@ export declare const prepareMySQLPush: (config: {
83
83
  } | undefined>;
84
84
  } | undefined>;
85
85
  } | undefined;
86
- id: string;
87
- prevId: string;
88
- version: "5";
89
- dialect: "mysql";
90
86
  tables: Record<string, {
91
87
  schema?: string | undefined;
92
88
  name: string;
@@ -125,6 +121,10 @@ export declare const prepareMySQLPush: (config: {
125
121
  columns: string[];
126
122
  }>;
127
123
  }>;
124
+ id: string;
125
+ prevId: string;
126
+ version: "6";
127
+ dialect: "mysql";
128
128
  schemas: Record<string, string>;
129
129
  _meta: {
130
130
  columns: Record<string, string>;
@@ -132,7 +132,7 @@ export declare const prepareMySQLPush: (config: {
132
132
  schemas: Record<string, string>;
133
133
  };
134
134
  };
135
- } | undefined>;
135
+ }>;
136
136
  export declare const prepareSQLitePush: (config: {
137
137
  schema: string | string[];
138
138
  }, snapshot: SQLiteSchema) => Promise<{
@@ -140,8 +140,6 @@ export declare const prepareSQLitePush: (config: {
140
140
  statements: import("../../jsonStatements").JsonStatement[];
141
141
  squashedPrev: {
142
142
  enums?: any;
143
- version: "5";
144
- dialect: "sqlite";
145
143
  tables: Record<string, {
146
144
  name: string;
147
145
  columns: Record<string, {
@@ -157,11 +155,11 @@ export declare const prepareSQLitePush: (config: {
157
155
  compositePrimaryKeys: Record<string, string>;
158
156
  uniqueConstraints: Record<string, string>;
159
157
  }>;
158
+ version: "5";
159
+ dialect: "sqlite";
160
160
  };
161
161
  squashedCur: {
162
162
  enums?: any;
163
- version: "5";
164
- dialect: "sqlite";
165
163
  tables: Record<string, {
166
164
  name: string;
167
165
  columns: Record<string, {
@@ -177,21 +175,21 @@ export declare const prepareSQLitePush: (config: {
177
175
  compositePrimaryKeys: Record<string, string>;
178
176
  uniqueConstraints: Record<string, string>;
179
177
  }>;
178
+ version: "5";
179
+ dialect: "sqlite";
180
180
  };
181
181
  meta: {
182
182
  schemas: {};
183
183
  tables: {};
184
184
  columns: {};
185
185
  } | undefined;
186
- } | undefined>;
186
+ }>;
187
187
  export declare const preparePgPush: (config: {
188
188
  schema: string | string[];
189
189
  }, snapshot: PgSchema, schemaFilter: string[]) => Promise<{
190
190
  sqlStatements: string[];
191
191
  statements: import("../../jsonStatements").JsonStatement[];
192
192
  squashedPrev: {
193
- version: "5";
194
- dialect: "pg";
195
193
  tables: Record<string, {
196
194
  name: string;
197
195
  columns: Record<string, {
@@ -210,6 +208,8 @@ export declare const preparePgPush: (config: {
210
208
  compositePrimaryKeys: Record<string, string>;
211
209
  uniqueConstraints: Record<string, string>;
212
210
  }>;
211
+ version: "6";
212
+ dialect: "pg";
213
213
  schemas: Record<string, string>;
214
214
  enums: Record<string, {
215
215
  name: string;
@@ -217,8 +217,6 @@ export declare const preparePgPush: (config: {
217
217
  }>;
218
218
  };
219
219
  squashedCur: {
220
- version: "5";
221
- dialect: "pg";
222
220
  tables: Record<string, {
223
221
  name: string;
224
222
  columns: Record<string, {
@@ -237,16 +235,18 @@ export declare const preparePgPush: (config: {
237
235
  compositePrimaryKeys: Record<string, string>;
238
236
  uniqueConstraints: Record<string, string>;
239
237
  }>;
238
+ version: "6";
239
+ dialect: "pg";
240
240
  schemas: Record<string, string>;
241
241
  enums: Record<string, {
242
242
  name: string;
243
243
  values: Record<string, string>;
244
244
  }>;
245
245
  };
246
- } | undefined>;
246
+ }>;
247
247
  export declare const prepareAndMigrateMySql: (config: GenerateConfig) => Promise<void>;
248
248
  export declare const prepareAndMigrateSqlite: (config: GenerateConfig) => Promise<void>;
249
- export declare const prepareSQL: (prev: CommonSquashedSchema, cur: CommonSquashedSchema, dialect: Dialect, prevFull?: any, curFull?: any) => Promise<{
249
+ export declare const prepareSQL: (prev: CommonSquashedSchema, cur: CommonSquashedSchema, dialect: Dialect, prevFull: PgSchema | MySqlSchema | SQLiteSchema, curFull: PgSchema | MySqlSchema | SQLiteSchema) => Promise<{
250
250
  statements: import("../../jsonStatements").JsonStatement[];
251
251
  sqlStatements: string[];
252
252
  _meta: {
@@ -0,0 +1,119 @@
1
+ import { MySQLConfigIntrospect, MySQLConnectionConfig } from "../validations/mysql";
2
+ import { DrizzleDbClient, MySQL2Client } from "src/drivers";
3
+ export declare const connectToMySQL: (config: MySQLConnectionConfig) => Promise<{
4
+ client: MySQL2Client;
5
+ databaseName: string;
6
+ }>;
7
+ export declare const mysqlIntrospect: (config: MySQLConfigIntrospect, filters: string[]) => Promise<{
8
+ schema: {
9
+ tables: Record<string, {
10
+ schema?: string | undefined;
11
+ name: string;
12
+ columns: Record<string, {
13
+ default?: any;
14
+ onUpdate?: any;
15
+ autoincrement?: boolean | undefined;
16
+ name: string;
17
+ type: string;
18
+ primaryKey: boolean;
19
+ notNull: boolean;
20
+ }>;
21
+ indexes: Record<string, {
22
+ using?: "btree" | "hash" | undefined;
23
+ algorithm?: "default" | "inplace" | "copy" | undefined;
24
+ lock?: "default" | "none" | "shared" | "exclusive" | undefined;
25
+ name: string;
26
+ columns: string[];
27
+ isUnique: boolean;
28
+ }>;
29
+ foreignKeys: Record<string, {
30
+ onUpdate?: string | undefined;
31
+ onDelete?: string | undefined;
32
+ name: string;
33
+ tableFrom: string;
34
+ columnsFrom: string[];
35
+ tableTo: string;
36
+ columnsTo: string[];
37
+ }>;
38
+ compositePrimaryKeys: Record<string, {
39
+ name: string;
40
+ columns: string[];
41
+ }>;
42
+ uniqueConstraints: Record<string, {
43
+ name: string;
44
+ columns: string[];
45
+ }>;
46
+ }>;
47
+ id: string;
48
+ prevId: string;
49
+ version: "6";
50
+ dialect: "mysql";
51
+ schemas: Record<string, string>;
52
+ _meta: {
53
+ columns: Record<string, string>;
54
+ tables: Record<string, string>;
55
+ schemas: Record<string, string>;
56
+ };
57
+ };
58
+ ts: {
59
+ file: string;
60
+ imports: string;
61
+ decalrations: string;
62
+ schemaEntry: string;
63
+ };
64
+ }>;
65
+ export declare const mysqlPushIntrospect: (connection: {
66
+ client: DrizzleDbClient;
67
+ databaseName: string;
68
+ }, filters: string[]) => Promise<{
69
+ schema: {
70
+ tables: Record<string, {
71
+ schema?: string | undefined;
72
+ name: string;
73
+ columns: Record<string, {
74
+ default?: any;
75
+ onUpdate?: any;
76
+ autoincrement?: boolean | undefined;
77
+ name: string;
78
+ type: string;
79
+ primaryKey: boolean;
80
+ notNull: boolean;
81
+ }>;
82
+ indexes: Record<string, {
83
+ using?: "btree" | "hash" | undefined;
84
+ algorithm?: "default" | "inplace" | "copy" | undefined;
85
+ lock?: "default" | "none" | "shared" | "exclusive" | undefined;
86
+ name: string;
87
+ columns: string[];
88
+ isUnique: boolean;
89
+ }>;
90
+ foreignKeys: Record<string, {
91
+ onUpdate?: string | undefined;
92
+ onDelete?: string | undefined;
93
+ name: string;
94
+ tableFrom: string;
95
+ columnsFrom: string[];
96
+ tableTo: string;
97
+ columnsTo: string[];
98
+ }>;
99
+ compositePrimaryKeys: Record<string, {
100
+ name: string;
101
+ columns: string[];
102
+ }>;
103
+ uniqueConstraints: Record<string, {
104
+ name: string;
105
+ columns: string[];
106
+ }>;
107
+ }>;
108
+ id: string;
109
+ prevId: string;
110
+ version: "6";
111
+ dialect: "mysql";
112
+ schemas: Record<string, string>;
113
+ _meta: {
114
+ columns: Record<string, string>;
115
+ tables: Record<string, string>;
116
+ schemas: Record<string, string>;
117
+ };
118
+ };
119
+ }>;
@@ -0,0 +1,18 @@
1
+ import { DrizzleDbClient } from "src/drivers";
2
+ import { JsonStatement } from "../../jsonStatements";
3
+ import { mysqlSchema } from "../../serializer/mysqlSchema";
4
+ import { TypeOf } from "zod";
5
+ export declare const filterStatements: (statements: JsonStatement[], currentSchema: TypeOf<typeof mysqlSchema>, prevSchema: TypeOf<typeof mysqlSchema>) => JsonStatement[];
6
+ export declare const logSuggestionsAndReturn: ({ connection, statements, json2, }: {
7
+ statements: JsonStatement[];
8
+ connection: DrizzleDbClient;
9
+ json2: TypeOf<typeof mysqlSchema>;
10
+ }) => Promise<{
11
+ statementsToExecute: string[];
12
+ shouldAskForApprove: boolean;
13
+ infoToPrint: string[];
14
+ columnsToRemove: string[];
15
+ schemasToRemove: string[];
16
+ tablesToTruncate: string[];
17
+ tablesToRemove: string[];
18
+ }>;
@@ -1,4 +1,4 @@
1
- import { MySqlSchema, MySqlSchemaV4 } from "src/serializer/mysqlSchema";
1
+ import { MySqlSchemaV4, MySqlSchemaV5 } from "../../serializer/mysqlSchema";
2
2
  export declare const upMysqlHandler: (out: string) => void;
3
- export declare const upMySqlHandlerV4toV5: (obj: MySqlSchemaV4) => MySqlSchema;
3
+ export declare const upMySqlHandlerV4toV5: (obj: MySqlSchemaV4) => MySqlSchemaV5;
4
4
  export declare const upMysqlHandlerV4: (out: string) => void;
@@ -1,5 +1,5 @@
1
1
  import type { PgConnectionConfig } from "../validations/pg";
2
- import { PgPostgres } from "src/drivers";
2
+ import { PgPostgres } from "../../drivers";
3
3
  export declare const connectToPg: (config: PgConnectionConfig) => Promise<{
4
4
  client: PgPostgres;
5
5
  }>;
@@ -1,14 +1,10 @@
1
1
  import type { PgConfigIntrospect } from "../validations/pg";
2
- import type { DrizzleDbClient } from "src/drivers";
2
+ import type { DrizzleDbClient } from "../../drivers";
3
3
  export declare const pgSchemas: (client: DrizzleDbClient) => Promise<string[]>;
4
4
  export declare const pgPushIntrospect: (connection: {
5
5
  client: DrizzleDbClient;
6
6
  }, filters: string[], schemaFilters: string[]) => Promise<{
7
7
  schema: {
8
- id: string;
9
- prevId: string;
10
- version: "5";
11
- dialect: "pg";
12
8
  tables: Record<string, {
13
9
  name: string;
14
10
  columns: Record<string, {
@@ -47,6 +43,10 @@ export declare const pgPushIntrospect: (connection: {
47
43
  nullsNotDistinct: boolean;
48
44
  }>;
49
45
  }>;
46
+ id: string;
47
+ prevId: string;
48
+ version: "6";
49
+ dialect: "pg";
50
50
  schemas: Record<string, string>;
51
51
  _meta: {
52
52
  columns: Record<string, string>;
@@ -61,10 +61,6 @@ export declare const pgPushIntrospect: (connection: {
61
61
  }>;
62
62
  export declare const pgIntrospect: (config: PgConfigIntrospect, filters: string[], schemaFilters: string[]) => Promise<{
63
63
  schema: {
64
- id: string;
65
- prevId: string;
66
- version: "5";
67
- dialect: "pg";
68
64
  tables: Record<string, {
69
65
  name: string;
70
66
  columns: Record<string, {
@@ -103,6 +99,10 @@ export declare const pgIntrospect: (config: PgConfigIntrospect, filters: string[
103
99
  nullsNotDistinct: boolean;
104
100
  }>;
105
101
  }>;
102
+ id: string;
103
+ prevId: string;
104
+ version: "6";
105
+ dialect: "pg";
106
106
  schemas: Record<string, string>;
107
107
  _meta: {
108
108
  columns: Record<string, string>;
@@ -1,5 +1,5 @@
1
- import { DrizzleDbClient } from "src/drivers";
2
- import { JsonStatement } from "src/jsonStatements";
1
+ import { DrizzleDbClient } from "../../drivers";
2
+ import { JsonStatement } from "../../jsonStatements";
3
3
  export declare const pgSuggestions: ({ connection, statements, }: {
4
4
  statements: JsonStatement[];
5
5
  connection: DrizzleDbClient;
@@ -1,4 +1,4 @@
1
- import { PgSchema, PgSchemaV4 } from "src/serializer/pgSchema";
2
- export declare const upPgHandlerV4toV5: (obj: PgSchemaV4) => PgSchema;
1
+ import { PgSchemaV4, PgSchemaV5 } from "../../serializer/pgSchema";
3
2
  export declare const upPgHandler: (out: string) => void;
3
+ export declare const upPgHandlerV4toV5: (obj: PgSchemaV4) => PgSchemaV5;
4
4
  export declare const upPgHandlerV4: (out: string) => void;
@@ -1,4 +1,4 @@
1
- import type { SQLiteCliConfig, SQLiteConnectionConfig } from "./sqliteUtils";
1
+ import type { SQLiteCliConfig, SQLiteConnectionConfig } from "../validations/sqlite";
2
2
  import type { DrizzleDbClient } from "../../drivers";
3
3
  export declare const connectToSQLite: (config: SQLiteConnectionConfig) => Promise<{
4
4
  client: import("../../drivers").BetterSqlite;
@@ -7,10 +7,6 @@ export declare const connectToSQLite: (config: SQLiteConnectionConfig) => Promis
7
7
  }>;
8
8
  export declare const sqliteIntrospect: (config: SQLiteCliConfig, filters: string[]) => Promise<{
9
9
  schema: {
10
- id: string;
11
- prevId: string;
12
- version: "5";
13
- dialect: "sqlite";
14
10
  tables: Record<string, {
15
11
  name: string;
16
12
  columns: Record<string, {
@@ -45,6 +41,10 @@ export declare const sqliteIntrospect: (config: SQLiteCliConfig, filters: string
45
41
  columns: string[];
46
42
  }>;
47
43
  }>;
44
+ id: string;
45
+ prevId: string;
46
+ version: "5";
47
+ dialect: "sqlite";
48
48
  _meta: {
49
49
  columns: Record<string, string>;
50
50
  tables: Record<string, string>;
@@ -60,10 +60,6 @@ export declare const sqliteIntrospect: (config: SQLiteCliConfig, filters: string
60
60
  }>;
61
61
  export declare const sqlitePushIntrospect: (client: DrizzleDbClient, filters: string[]) => Promise<{
62
62
  schema: {
63
- id: string;
64
- prevId: string;
65
- version: "5";
66
- dialect: "sqlite";
67
63
  tables: Record<string, {
68
64
  name: string;
69
65
  columns: Record<string, {
@@ -98,6 +94,10 @@ export declare const sqlitePushIntrospect: (client: DrizzleDbClient, filters: st
98
94
  columns: string[];
99
95
  }>;
100
96
  }>;
97
+ id: string;
98
+ prevId: string;
99
+ version: "5";
100
+ dialect: "sqlite";
101
101
  _meta: {
102
102
  columns: Record<string, string>;
103
103
  tables: Record<string, string>;
@@ -0,0 +1,21 @@
1
+ import { DrizzleDbClient } from "../../drivers";
2
+ import { JsonStatement } from "../../jsonStatements";
3
+ import { SQLiteSchemaInternal, SQLiteSchemaSquashed } from "../../serializer/sqliteSchema";
4
+ export declare const _moveDataStatements: (tableName: string, json: SQLiteSchemaSquashed, dataLoss?: boolean) => string[];
5
+ export declare const getOldTableName: (tableName: string, meta: SQLiteSchemaInternal["_meta"]) => string;
6
+ export declare const getNewTableName: (tableName: string, meta: SQLiteSchemaInternal["_meta"]) => string;
7
+ export declare const logSuggestionsAndReturn: ({ connection, statements, json1, json2, meta, }: {
8
+ statements: JsonStatement[];
9
+ connection: DrizzleDbClient;
10
+ json1: SQLiteSchemaSquashed;
11
+ json2: SQLiteSchemaSquashed;
12
+ meta: SQLiteSchemaInternal["_meta"];
13
+ }) => Promise<{
14
+ statementsToExecute: string[];
15
+ shouldAskForApprove: boolean;
16
+ infoToPrint: string[];
17
+ columnsToRemove: string[];
18
+ schemasToRemove: string[];
19
+ tablesToTruncate: string[];
20
+ tablesToRemove: string[];
21
+ }>;
@@ -1,4 +1,4 @@
1
- import { Dialect } from "src/schemaValidator";
1
+ import { Dialect } from "../../schemaValidator";
2
2
  import { Named, NamedWithSchema } from "./migrate";
3
3
  export declare const resolveSchemas: <T extends Named>(missingSchemas: T[], newSchemas: T[], predicate: (leftMissing: T[], created: T) => T | undefined) => {
4
4
  created: T[];