drizzle-kit 0.20.17-4e262b7 → 0.20.17-7776aba

Sign up to get free protection for your applications and to get access to all the features.
Files changed (56) hide show
  1. package/bin.cjs +22248 -23435
  2. package/cli/commands/migrate.d.ts +135 -152
  3. package/cli/commands/mysqlIntrospect.d.ts +79 -15
  4. package/cli/commands/mysqlPushUtils.d.ts +8 -4
  5. package/cli/commands/mysqlUp.d.ts +4 -0
  6. package/cli/commands/pgConnect.d.ts +5 -0
  7. package/cli/commands/pgIntrospect.d.ts +76 -12
  8. package/cli/commands/pgPushUtils.d.ts +6 -3
  9. package/cli/commands/pgUp.d.ts +4 -0
  10. package/cli/commands/sqliteIntrospect.d.ts +29 -26
  11. package/cli/commands/sqlitePushUtils.d.ts +10 -4
  12. package/cli/commands/sqliteUtils.d.ts +162 -0
  13. package/cli/commands/upFolders.d.ts +27 -0
  14. package/cli/commands/utils.d.ts +255 -39
  15. package/cli/validations/common.d.ts +7 -208
  16. package/cli/validations/mysql.d.ts +337 -7
  17. package/cli/validations/outputs.d.ts +0 -1
  18. package/cli/validations/pg.d.ts +405 -4
  19. package/cli/views.d.ts +5 -7
  20. package/drivers/index.d.ts +39 -0
  21. package/global.d.ts +1 -3
  22. package/index.d.mts +6 -8
  23. package/index.d.ts +6 -8
  24. package/index.js +0 -1
  25. package/introspect-mysql.d.ts +9 -0
  26. package/introspect-pg.d.ts +12 -0
  27. package/introspect-sqlite.d.ts +2 -2
  28. package/jsonDiffer.d.ts +29 -14
  29. package/jsonStatements.d.ts +11 -38
  30. package/package.json +52 -24
  31. package/payload.d.mts +5 -5
  32. package/payload.d.ts +5 -5
  33. package/payload.js +24222 -26044
  34. package/payload.mjs +19956 -21767
  35. package/schemaValidator.d.ts +286 -289
  36. package/serializer/mysqlImports.d.ts +7 -3
  37. package/serializer/mysqlSchema.d.ts +1323 -2454
  38. package/serializer/mysqlSerializer.d.ts +6 -6
  39. package/serializer/pgImports.d.ts +2 -2
  40. package/serializer/pgSchema.d.ts +1283 -1742
  41. package/serializer/pgSerializer.d.ts +2 -2
  42. package/serializer/sqliteImports.d.ts +4 -2
  43. package/serializer/sqliteSchema.d.ts +979 -553
  44. package/serializer/sqliteSerializer.d.ts +4 -4
  45. package/snapshotsDiffer.d.ts +1209 -2486
  46. package/utils/words.d.ts +1 -1
  47. package/utils-studio.d.mts +1 -0
  48. package/utils-studio.d.ts +1 -0
  49. package/utils-studio.js +849 -7058
  50. package/utils-studio.mjs +829 -7035
  51. package/utils.d.ts +141 -14
  52. package/utils.js +7161 -4625
  53. package/utils.mjs +7121 -4585
  54. package/cli/utils.d.ts +0 -12
  55. package/cli/validations/cli.d.ts +0 -169
  56. package/cli/validations/sqlite.d.ts +0 -34
@@ -1,18 +1,81 @@
1
- import type { DB } from "../../utils";
2
- export declare const pgPushIntrospect: (db: DB, filters: string[], schemaFilters: string[]) => Promise<{
1
+ import type { PgConfigIntrospect } from "../validations/pg";
2
+ import type { DrizzleDbClient } from "src/drivers";
3
+ export declare const pgSchemas: (client: DrizzleDbClient) => Promise<string[]>;
4
+ export declare const pgPushIntrospect: (connection: {
5
+ client: DrizzleDbClient;
6
+ }, filters: string[], schemaFilters: string[]) => Promise<{
3
7
  schema: {
8
+ id: string;
9
+ prevId: string;
10
+ version: "5";
11
+ dialect: "pg";
4
12
  tables: Record<string, {
5
13
  name: string;
6
14
  columns: Record<string, {
15
+ isUnique?: any;
16
+ default?: any;
17
+ uniqueName?: string | undefined;
18
+ nullsNotDistinct?: boolean | undefined;
7
19
  name: string;
8
20
  type: string;
9
21
  primaryKey: boolean;
10
22
  notNull: boolean;
23
+ }>;
24
+ indexes: Record<string, {
25
+ name: string;
26
+ columns: string[];
27
+ isUnique: boolean;
28
+ }>;
29
+ foreignKeys: Record<string, {
30
+ onUpdate?: string | undefined;
31
+ onDelete?: string | undefined;
32
+ schemaTo?: string | undefined;
33
+ name: string;
34
+ tableFrom: string;
35
+ columnsFrom: string[];
36
+ tableTo: string;
37
+ columnsTo: string[];
38
+ }>;
39
+ schema: string;
40
+ compositePrimaryKeys: Record<string, {
41
+ name: string;
42
+ columns: string[];
43
+ }>;
44
+ uniqueConstraints: Record<string, {
45
+ name: string;
46
+ columns: string[];
47
+ nullsNotDistinct: boolean;
48
+ }>;
49
+ }>;
50
+ schemas: Record<string, string>;
51
+ _meta: {
52
+ columns: Record<string, string>;
53
+ tables: Record<string, string>;
54
+ schemas: Record<string, string>;
55
+ };
56
+ enums: Record<string, {
57
+ name: string;
58
+ values: Record<string, string>;
59
+ }>;
60
+ };
61
+ }>;
62
+ export declare const pgIntrospect: (config: PgConfigIntrospect, filters: string[], schemaFilters: string[]) => Promise<{
63
+ schema: {
64
+ id: string;
65
+ prevId: string;
66
+ version: "5";
67
+ dialect: "pg";
68
+ tables: Record<string, {
69
+ name: string;
70
+ columns: Record<string, {
11
71
  isUnique?: any;
12
72
  default?: any;
13
- typeSchema?: string | undefined;
14
73
  uniqueName?: string | undefined;
15
74
  nullsNotDistinct?: boolean | undefined;
75
+ name: string;
76
+ type: string;
77
+ primaryKey: boolean;
78
+ notNull: boolean;
16
79
  }>;
17
80
  indexes: Record<string, {
18
81
  name: string;
@@ -20,14 +83,14 @@ export declare const pgPushIntrospect: (db: DB, filters: string[], schemaFilters
20
83
  isUnique: boolean;
21
84
  }>;
22
85
  foreignKeys: Record<string, {
86
+ onUpdate?: string | undefined;
87
+ onDelete?: string | undefined;
88
+ schemaTo?: string | undefined;
23
89
  name: string;
24
90
  tableFrom: string;
25
91
  columnsFrom: string[];
26
92
  tableTo: string;
27
93
  columnsTo: string[];
28
- onUpdate?: string | undefined;
29
- onDelete?: string | undefined;
30
- schemaTo?: string | undefined;
31
94
  }>;
32
95
  schema: string;
33
96
  compositePrimaryKeys: Record<string, {
@@ -40,10 +103,6 @@ export declare const pgPushIntrospect: (db: DB, filters: string[], schemaFilters
40
103
  nullsNotDistinct: boolean;
41
104
  }>;
42
105
  }>;
43
- id: string;
44
- prevId: string;
45
- version: "6";
46
- dialect: "pg";
47
106
  schemas: Record<string, string>;
48
107
  _meta: {
49
108
  columns: Record<string, string>;
@@ -52,8 +111,13 @@ export declare const pgPushIntrospect: (db: DB, filters: string[], schemaFilters
52
111
  };
53
112
  enums: Record<string, {
54
113
  name: string;
55
- values: string[];
56
- schema: string;
114
+ values: Record<string, string>;
57
115
  }>;
58
116
  };
117
+ ts: {
118
+ file: string;
119
+ imports: string;
120
+ decalrations: string;
121
+ schemaEntry: string;
122
+ };
59
123
  }>;
@@ -1,6 +1,9 @@
1
- import type { DB } from "../../utils";
2
- import type { JsonStatement } from "../../jsonStatements";
3
- export declare const pgSuggestions: (db: DB, statements: JsonStatement[]) => Promise<{
1
+ import { DrizzleDbClient } from "src/drivers";
2
+ import { JsonStatement } from "src/jsonStatements";
3
+ export declare const pgSuggestions: ({ connection, statements, }: {
4
+ statements: JsonStatement[];
5
+ connection: DrizzleDbClient;
6
+ }) => Promise<{
4
7
  statementsToExecute: string[];
5
8
  shouldAskForApprove: boolean;
6
9
  infoToPrint: string[];
@@ -0,0 +1,4 @@
1
+ import { PgSchema, PgSchemaV4 } from "src/serializer/pgSchema";
2
+ export declare const upPgHandlerV4toV5: (obj: PgSchemaV4) => PgSchema;
3
+ export declare const upPgHandler: (out: string) => void;
4
+ export declare const upPgHandlerV4: (out: string) => void;
@@ -1,47 +1,50 @@
1
- import type { SqliteCredentials } from "../validations/sqlite";
2
- import type { SQLiteDB } from "../../utils";
3
- import { Casing } from "../validations/common";
4
- export declare const connectToSQLite: (credentials: SqliteCredentials) => Promise<SQLiteDB>;
5
- export declare const sqliteIntrospect: (credentials: SqliteCredentials, filters: string[], casing: Casing) => Promise<{
1
+ import type { SQLiteCliConfig, SQLiteConnectionConfig } from "./sqliteUtils";
2
+ import type { DrizzleDbClient } from "../../drivers";
3
+ export declare const connectToSQLite: (config: SQLiteConnectionConfig) => Promise<{
4
+ client: import("../../drivers").BetterSqlite;
5
+ } | {
6
+ client?: undefined;
7
+ }>;
8
+ export declare const sqliteIntrospect: (config: SQLiteCliConfig, filters: string[]) => Promise<{
6
9
  schema: {
10
+ id: string;
11
+ prevId: string;
12
+ version: "5";
13
+ dialect: "sqlite";
7
14
  tables: Record<string, {
8
15
  name: string;
9
16
  columns: Record<string, {
17
+ default?: any;
18
+ autoincrement?: boolean | undefined;
10
19
  name: string;
11
20
  type: string;
12
21
  primaryKey: boolean;
13
22
  notNull: boolean;
14
- default?: any;
15
- autoincrement?: boolean | undefined;
16
23
  }>;
17
24
  indexes: Record<string, {
25
+ where?: string | undefined;
18
26
  name: string;
19
27
  columns: string[];
20
28
  isUnique: boolean;
21
- where?: string | undefined;
22
29
  }>;
23
30
  foreignKeys: Record<string, {
31
+ onUpdate?: string | undefined;
32
+ onDelete?: string | undefined;
24
33
  name: string;
25
34
  tableFrom: string;
26
35
  columnsFrom: string[];
27
36
  tableTo: string;
28
37
  columnsTo: string[];
29
- onUpdate?: string | undefined;
30
- onDelete?: string | undefined;
31
38
  }>;
32
39
  compositePrimaryKeys: Record<string, {
33
- columns: string[];
34
40
  name?: string | undefined;
41
+ columns: string[];
35
42
  }>;
36
43
  uniqueConstraints: Record<string, {
37
44
  name: string;
38
45
  columns: string[];
39
46
  }>;
40
47
  }>;
41
- id: string;
42
- prevId: string;
43
- version: "5";
44
- dialect: "sqlite";
45
48
  _meta: {
46
49
  columns: Record<string, string>;
47
50
  tables: Record<string, string>;
@@ -55,46 +58,46 @@ export declare const sqliteIntrospect: (credentials: SqliteCredentials, filters:
55
58
  schemaEntry: string;
56
59
  };
57
60
  }>;
58
- export declare const sqlitePushIntrospect: (db: SQLiteDB, filters: string[]) => Promise<{
61
+ export declare const sqlitePushIntrospect: (client: DrizzleDbClient, filters: string[]) => Promise<{
59
62
  schema: {
63
+ id: string;
64
+ prevId: string;
65
+ version: "5";
66
+ dialect: "sqlite";
60
67
  tables: Record<string, {
61
68
  name: string;
62
69
  columns: Record<string, {
70
+ default?: any;
71
+ autoincrement?: boolean | undefined;
63
72
  name: string;
64
73
  type: string;
65
74
  primaryKey: boolean;
66
75
  notNull: boolean;
67
- default?: any;
68
- autoincrement?: boolean | undefined;
69
76
  }>;
70
77
  indexes: Record<string, {
78
+ where?: string | undefined;
71
79
  name: string;
72
80
  columns: string[];
73
81
  isUnique: boolean;
74
- where?: string | undefined;
75
82
  }>;
76
83
  foreignKeys: Record<string, {
84
+ onUpdate?: string | undefined;
85
+ onDelete?: string | undefined;
77
86
  name: string;
78
87
  tableFrom: string;
79
88
  columnsFrom: string[];
80
89
  tableTo: string;
81
90
  columnsTo: string[];
82
- onUpdate?: string | undefined;
83
- onDelete?: string | undefined;
84
91
  }>;
85
92
  compositePrimaryKeys: Record<string, {
86
- columns: string[];
87
93
  name?: string | undefined;
94
+ columns: string[];
88
95
  }>;
89
96
  uniqueConstraints: Record<string, {
90
97
  name: string;
91
98
  columns: string[];
92
99
  }>;
93
100
  }>;
94
- id: string;
95
- prevId: string;
96
- version: "5";
97
- dialect: "sqlite";
98
101
  _meta: {
99
102
  columns: Record<string, string>;
100
103
  tables: Record<string, string>;
@@ -1,10 +1,16 @@
1
- import { SQLiteSchemaInternal, SQLiteSchemaSquashed } from "../../serializer/sqliteSchema";
2
- import type { JsonStatement } from "../../jsonStatements";
3
- import type { DB } from "../../utils";
1
+ import { DrizzleDbClient } from "src/drivers";
2
+ import { JsonStatement } from "src/jsonStatements";
3
+ import { SQLiteSchemaInternal, SQLiteSchemaSquashed } from "src/serializer/sqliteSchema";
4
4
  export declare const _moveDataStatements: (tableName: string, json: SQLiteSchemaSquashed, dataLoss?: boolean) => string[];
5
5
  export declare const getOldTableName: (tableName: string, meta: SQLiteSchemaInternal["_meta"]) => string;
6
6
  export declare const getNewTableName: (tableName: string, meta: SQLiteSchemaInternal["_meta"]) => string;
7
- export declare const logSuggestionsAndReturn: (connection: DB, statements: JsonStatement[], json1: SQLiteSchemaSquashed, json2: SQLiteSchemaSquashed, meta: SQLiteSchemaInternal["_meta"]) => Promise<{
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<{
8
14
  statementsToExecute: string[];
9
15
  shouldAskForApprove: boolean;
10
16
  infoToPrint: string[];
@@ -0,0 +1,162 @@
1
+ import { TypeOf } from "zod";
2
+ import { configIntrospectSchema } from "./utils";
3
+ export declare const sqliteConnectionSchema: import("zod").ZodUnion<[import("zod").ZodObject<{
4
+ driver: import("zod").ZodLiteral<"turso">;
5
+ dbCredentials: import("zod").ZodObject<{
6
+ url: import("zod").ZodString;
7
+ authToken: import("zod").ZodOptional<import("zod").ZodString>;
8
+ }, "strip", import("zod").ZodTypeAny, {
9
+ authToken?: string | undefined;
10
+ url: string;
11
+ }, {
12
+ authToken?: string | undefined;
13
+ url: string;
14
+ }>;
15
+ }, "strip", import("zod").ZodTypeAny, {
16
+ driver: "turso";
17
+ dbCredentials: {
18
+ authToken?: string | undefined;
19
+ url: string;
20
+ };
21
+ }, {
22
+ driver: "turso";
23
+ dbCredentials: {
24
+ authToken?: string | undefined;
25
+ url: string;
26
+ };
27
+ }>, import("zod").ZodObject<{
28
+ driver: import("zod").ZodLiteral<"libsql">;
29
+ dbCredentials: import("zod").ZodObject<{
30
+ url: import("zod").ZodString;
31
+ }, "strip", import("zod").ZodTypeAny, {
32
+ url: string;
33
+ }, {
34
+ url: string;
35
+ }>;
36
+ }, "strip", import("zod").ZodTypeAny, {
37
+ driver: "libsql";
38
+ dbCredentials: {
39
+ url: string;
40
+ };
41
+ }, {
42
+ driver: "libsql";
43
+ dbCredentials: {
44
+ url: string;
45
+ };
46
+ }>, import("zod").ZodObject<{
47
+ driver: import("zod").ZodLiteral<"better-sqlite">;
48
+ dbCredentials: import("zod").ZodObject<{
49
+ url: import("zod").ZodString;
50
+ }, "strip", import("zod").ZodTypeAny, {
51
+ url: string;
52
+ }, {
53
+ url: string;
54
+ }>;
55
+ }, "strip", import("zod").ZodTypeAny, {
56
+ driver: "better-sqlite";
57
+ dbCredentials: {
58
+ url: string;
59
+ };
60
+ }, {
61
+ driver: "better-sqlite";
62
+ dbCredentials: {
63
+ url: string;
64
+ };
65
+ }>]>;
66
+ export declare const sqliteCliConfigSchema: import("zod").ZodIntersection<import("zod").ZodObject<{
67
+ schema: import("zod").ZodOptional<import("zod").ZodUnion<[import("zod").ZodString, import("zod").ZodArray<import("zod").ZodString, "many">]>>;
68
+ out: import("zod").ZodDefault<import("zod").ZodOptional<import("zod").ZodString>>;
69
+ breakpoints: import("zod").ZodDefault<import("zod").ZodBoolean>;
70
+ tablesFilter: import("zod").ZodOptional<import("zod").ZodUnion<[import("zod").ZodString, import("zod").ZodArray<import("zod").ZodString, "many">]>>;
71
+ schemaFilter: import("zod").ZodDefault<import("zod").ZodUnion<[import("zod").ZodString, import("zod").ZodArray<import("zod").ZodString, "many">]>>;
72
+ introspect: import("zod").ZodDefault<import("zod").ZodObject<{
73
+ casing: import("zod").ZodDefault<import("zod").ZodUnion<[import("zod").ZodLiteral<"camel">, import("zod").ZodLiteral<"preserve">]>>;
74
+ }, "strip", import("zod").ZodTypeAny, {
75
+ casing: "camel" | "preserve";
76
+ }, {
77
+ casing?: "camel" | "preserve" | undefined;
78
+ }>>;
79
+ }, "strip", import("zod").ZodTypeAny, {
80
+ schema?: string | string[] | undefined;
81
+ tablesFilter?: string | string[] | undefined;
82
+ out: string;
83
+ breakpoints: boolean;
84
+ schemaFilter: string | string[];
85
+ introspect: {
86
+ casing: "camel" | "preserve";
87
+ };
88
+ }, {
89
+ schema?: string | string[] | undefined;
90
+ out?: string | undefined;
91
+ breakpoints?: boolean | undefined;
92
+ tablesFilter?: string | string[] | undefined;
93
+ schemaFilter?: string | string[] | undefined;
94
+ introspect?: {
95
+ casing?: "camel" | "preserve" | undefined;
96
+ } | undefined;
97
+ }>, import("zod").ZodUnion<[import("zod").ZodObject<{
98
+ driver: import("zod").ZodLiteral<"turso">;
99
+ dbCredentials: import("zod").ZodObject<{
100
+ url: import("zod").ZodString;
101
+ authToken: import("zod").ZodOptional<import("zod").ZodString>;
102
+ }, "strip", import("zod").ZodTypeAny, {
103
+ authToken?: string | undefined;
104
+ url: string;
105
+ }, {
106
+ authToken?: string | undefined;
107
+ url: string;
108
+ }>;
109
+ }, "strip", import("zod").ZodTypeAny, {
110
+ driver: "turso";
111
+ dbCredentials: {
112
+ authToken?: string | undefined;
113
+ url: string;
114
+ };
115
+ }, {
116
+ driver: "turso";
117
+ dbCredentials: {
118
+ authToken?: string | undefined;
119
+ url: string;
120
+ };
121
+ }>, import("zod").ZodObject<{
122
+ driver: import("zod").ZodLiteral<"libsql">;
123
+ dbCredentials: import("zod").ZodObject<{
124
+ url: import("zod").ZodString;
125
+ }, "strip", import("zod").ZodTypeAny, {
126
+ url: string;
127
+ }, {
128
+ url: string;
129
+ }>;
130
+ }, "strip", import("zod").ZodTypeAny, {
131
+ driver: "libsql";
132
+ dbCredentials: {
133
+ url: string;
134
+ };
135
+ }, {
136
+ driver: "libsql";
137
+ dbCredentials: {
138
+ url: string;
139
+ };
140
+ }>, import("zod").ZodObject<{
141
+ driver: import("zod").ZodLiteral<"better-sqlite">;
142
+ dbCredentials: import("zod").ZodObject<{
143
+ url: import("zod").ZodString;
144
+ }, "strip", import("zod").ZodTypeAny, {
145
+ url: string;
146
+ }, {
147
+ url: string;
148
+ }>;
149
+ }, "strip", import("zod").ZodTypeAny, {
150
+ driver: "better-sqlite";
151
+ dbCredentials: {
152
+ url: string;
153
+ };
154
+ }, {
155
+ driver: "better-sqlite";
156
+ dbCredentials: {
157
+ url: string;
158
+ };
159
+ }>]>>;
160
+ export type SQLiteCliConfig = TypeOf<typeof sqliteCliConfigSchema>;
161
+ export type SQLiteConnectionConfig = TypeOf<typeof sqliteConnectionSchema>;
162
+ export { configIntrospectSchema };
@@ -0,0 +1,27 @@
1
+ import { Dialect } from "src/schemaValidator";
2
+ import { Named, NamedWithSchema } from "./migrate";
3
+ export declare const resolveSchemas: <T extends Named>(missingSchemas: T[], newSchemas: T[], predicate: (leftMissing: T[], created: T) => T | undefined) => {
4
+ created: T[];
5
+ renamed: {
6
+ from: T;
7
+ to: T;
8
+ }[];
9
+ deleted: T[];
10
+ };
11
+ export declare const resolveTables: <T extends NamedWithSchema>(missingTables: T[], newTables: T[], resolver: (leftMissing: T[], created: T) => T | undefined) => {
12
+ created: T[];
13
+ renamed: {
14
+ from: T;
15
+ to: T;
16
+ }[];
17
+ deleted: T[];
18
+ };
19
+ export declare const resolveColumns: <T extends Named>(missingColumns: T[], newColumns: T[], predicate: (leftMissing: T[], created: T) => T | undefined) => {
20
+ created: T[];
21
+ renamed: {
22
+ from: T;
23
+ to: T;
24
+ }[];
25
+ deleted: T[];
26
+ };
27
+ export declare const upgradeFolders: (dialect: Dialect, out: string) => void;