drizzle-kit 0.20.14-1f99bf7 → 0.20.14-3ab22ec

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. package/bin.cjs +36859 -33936
  2. package/cli/commands/migrate.d.ts +24 -24
  3. package/cli/commands/mysqlIntrospect.d.ts +8 -8
  4. package/cli/commands/mysqlPushUtils.d.ts +2 -2
  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 +3 -3
  12. package/cli/commands/sqliteUtils.d.ts +162 -0
  13. package/cli/commands/upFolders.d.ts +1 -1
  14. package/cli/commands/utils.d.ts +259 -14
  15. package/cli/validations/common.d.ts +7 -205
  16. package/cli/validations/mysql.d.ts +1 -6
  17. package/cli/validations/pg.d.ts +1 -6
  18. package/cli/views.d.ts +1 -1
  19. package/global.d.ts +1 -1
  20. package/index.d.mts +6 -8
  21. package/index.d.ts +6 -8
  22. package/index.js +0 -1
  23. package/introspect-mysql.d.ts +1 -1
  24. package/introspect-pg.d.ts +1 -1
  25. package/introspect-sqlite.d.ts +1 -1
  26. package/jsonStatements.d.ts +1 -1
  27. package/package.json +8 -5
  28. package/payload.js +1527 -1841
  29. package/payload.mjs +1531 -1844
  30. package/schemaValidator.d.ts +40 -40
  31. package/serializer/mysqlSchema.d.ts +616 -1854
  32. package/serializer/mysqlSerializer.d.ts +2 -2
  33. package/serializer/pgSchema.d.ts +684 -1009
  34. package/serializer/sqliteSchema.d.ts +570 -144
  35. package/serializer/sqliteSerializer.d.ts +2 -2
  36. package/snapshotsDiffer.d.ts +20 -24
  37. package/utils-studio.js +8 -21
  38. package/utils-studio.mjs +8 -20
  39. package/utils.d.ts +12 -12
  40. package/utils.js +735 -849
  41. package/utils.mjs +736 -849
  42. package/cli/validations/cli.d.ts +0 -104
  43. package/cli/validations/sqlite.d.ts +0 -382
@@ -1,6 +1,6 @@
1
1
  import type { SQLiteSchemaInternal } from "../serializer/sqliteSchema";
2
2
  import { AnySQLiteTable } from "drizzle-orm/sqlite-core";
3
- import type { IntrospectStage, IntrospectStatus } from "../cli/views";
4
- import type { DrizzleDbClient } from "../drivers";
3
+ import type { IntrospectStage, IntrospectStatus } from "src/cli/views";
4
+ import type { DrizzleDbClient } from "src/drivers";
5
5
  export declare const generateSqliteSnapshot: (tables: AnySQLiteTable[], enums: any[]) => SQLiteSchemaInternal;
6
6
  export declare const fromDatabase: (db: DrizzleDbClient, tablesFilter?: (table: string) => boolean, progressCallback?: ((stage: IntrospectStage, count: number, status: IntrospectStatus) => void) | undefined) => Promise<SQLiteSchemaInternal>;
@@ -1,9 +1,6 @@
1
1
  import { TypeOf, ZodTypeAny, z } from "zod";
2
2
  import { JsonStatement } from "./jsonStatements";
3
- import { CommonSquashedSchema } from "./schemaValidator";
4
- import { SQLiteSchema } from "./serializer/sqliteSchema";
5
- import { MySqlSchema } from "./serializer/mysqlSchema";
6
- import { PgSchema } from "./serializer/pgSchema";
3
+ import { CommonSquashedSchema, Dialect } from "./schemaValidator";
7
4
  export declare const makePatched: <T extends ZodTypeAny>(schema: T) => z.ZodUnion<[z.ZodObject<{
8
5
  type: z.ZodLiteral<"added">;
9
6
  value: T;
@@ -57,19 +54,19 @@ export declare const makePatched: <T extends ZodTypeAny>(schema: T) => z.ZodUnio
57
54
  }>[k_3_2]; } : never>]>;
58
55
  export declare const makeSelfOrPatched: <T extends ZodTypeAny>(schema: T) => z.ZodUnion<[z.ZodObject<{
59
56
  type: z.ZodLiteral<"none">;
60
- value: T;
57
+ value: z.ZodOptional<T>;
61
58
  }, "strip", ZodTypeAny, z.objectUtil.addQuestionMarks<{
62
59
  type: "none";
63
- value: T["_output"];
60
+ value: T["_output"] | undefined;
64
61
  }> extends infer T_1 ? { [k_1 in keyof T_1]: z.objectUtil.addQuestionMarks<{
65
62
  type: "none";
66
- value: T["_output"];
63
+ value: T["_output"] | undefined;
67
64
  }>[k_1]; } : never, z.objectUtil.addQuestionMarks<{
68
65
  type: "none";
69
- value: T["_input"];
66
+ value: T["_input"] | undefined;
70
67
  }> extends infer T_2 ? { [k_3 in keyof T_2]: z.objectUtil.addQuestionMarks<{
71
68
  type: "none";
72
- value: T["_input"];
69
+ value: T["_input"] | undefined;
73
70
  }>[k_3]; } : never>, z.ZodObject<{
74
71
  type: z.ZodLiteral<"added">;
75
72
  value: T;
@@ -564,13 +561,13 @@ export declare const alteredTableScheme: z.ZodObject<{
564
561
  name: z.ZodString;
565
562
  schema: z.ZodUnion<[z.ZodObject<{
566
563
  type: z.ZodLiteral<"none">;
567
- value: z.ZodString;
564
+ value: z.ZodOptional<z.ZodString>;
568
565
  }, "strip", ZodTypeAny, {
566
+ value?: string | undefined;
569
567
  type: "none";
570
- value: string;
571
568
  }, {
569
+ value?: string | undefined;
572
570
  type: "none";
573
- value: string;
574
571
  }>, z.ZodObject<{
575
572
  type: z.ZodLiteral<"added">;
576
573
  value: z.ZodString;
@@ -1036,8 +1033,8 @@ export declare const alteredTableScheme: z.ZodObject<{
1036
1033
  }, "strict", ZodTypeAny, {
1037
1034
  name: string;
1038
1035
  schema: {
1036
+ value?: string | undefined;
1039
1037
  type: "none";
1040
- value: string;
1041
1038
  } | {
1042
1039
  type: "added";
1043
1040
  value: string;
@@ -1167,8 +1164,8 @@ export declare const alteredTableScheme: z.ZodObject<{
1167
1164
  }, {
1168
1165
  name: string;
1169
1166
  schema: {
1167
+ value?: string | undefined;
1170
1168
  type: "none";
1171
- value: string;
1172
1169
  } | {
1173
1170
  type: "added";
1174
1171
  value: string;
@@ -1461,13 +1458,13 @@ export declare const diffResultScheme: z.ZodObject<{
1461
1458
  name: z.ZodString;
1462
1459
  schema: z.ZodUnion<[z.ZodObject<{
1463
1460
  type: z.ZodLiteral<"none">;
1464
- value: z.ZodString;
1461
+ value: z.ZodOptional<z.ZodString>;
1465
1462
  }, "strip", ZodTypeAny, {
1463
+ value?: string | undefined;
1466
1464
  type: "none";
1467
- value: string;
1468
1465
  }, {
1466
+ value?: string | undefined;
1469
1467
  type: "none";
1470
- value: string;
1471
1468
  }>, z.ZodObject<{
1472
1469
  type: z.ZodLiteral<"added">;
1473
1470
  value: z.ZodString;
@@ -1933,8 +1930,8 @@ export declare const diffResultScheme: z.ZodObject<{
1933
1930
  }, "strict", ZodTypeAny, {
1934
1931
  name: string;
1935
1932
  schema: {
1933
+ value?: string | undefined;
1936
1934
  type: "none";
1937
- value: string;
1938
1935
  } | {
1939
1936
  type: "added";
1940
1937
  value: string;
@@ -2064,8 +2061,8 @@ export declare const diffResultScheme: z.ZodObject<{
2064
2061
  }, {
2065
2062
  name: string;
2066
2063
  schema: {
2064
+ value?: string | undefined;
2067
2065
  type: "none";
2068
- value: string;
2069
2066
  } | {
2070
2067
  type: "added";
2071
2068
  value: string;
@@ -2272,8 +2269,8 @@ export declare const diffResultScheme: z.ZodObject<{
2272
2269
  alteredTablesWithColumns: {
2273
2270
  name: string;
2274
2271
  schema: {
2272
+ value?: string | undefined;
2275
2273
  type: "none";
2276
- value: string;
2277
2274
  } | {
2278
2275
  type: "added";
2279
2276
  value: string;
@@ -2460,8 +2457,8 @@ export declare const diffResultScheme: z.ZodObject<{
2460
2457
  alteredTablesWithColumns: {
2461
2458
  name: string;
2462
2459
  schema: {
2460
+ value?: string | undefined;
2463
2461
  type: "none";
2464
- value: string;
2465
2462
  } | {
2466
2463
  type: "added";
2467
2464
  value: string;
@@ -2647,12 +2644,11 @@ export interface ColumnsResolverOutput<T extends {
2647
2644
  }[];
2648
2645
  deleted: T[];
2649
2646
  }
2650
- export type SchemaFrom<D> = D extends "pg" ? PgSchema : D extends "mysql" ? MySqlSchema : D extends "sqlite" ? SQLiteSchema : undefined;
2651
- export declare const applySnapshotsDiff: <DIALECT extends "mysql" | "pg" | "sqlite" = "mysql" | "pg" | "sqlite">(json1: CommonSquashedSchema, json2: CommonSquashedSchema, dialect: DIALECT, schemasResolver: (input: TablesResolverInput<{
2647
+ export declare const applySnapshotsDiff: (json1: CommonSquashedSchema, json2: CommonSquashedSchema, dialect: Dialect, schemasResolver: (input: TablesResolverInput<{
2652
2648
  name: string;
2653
2649
  }>) => Promise<TablesResolverOutput<{
2654
2650
  name: string;
2655
- }>>, tablesResolver: (input: TablesResolverInput<Table>) => Promise<TablesResolverOutput<Table>>, columnsResolver: (input: ColumnsResolverInput<Column>) => Promise<ColumnsResolverOutput<Column>>, prevFull: SchemaFrom<DIALECT>, curFull: SchemaFrom<DIALECT>) => Promise<{
2651
+ }>>, tablesResolver: (input: TablesResolverInput<Table>) => Promise<TablesResolverOutput<Table>>, columnsResolver: (input: ColumnsResolverInput<Column>) => Promise<ColumnsResolverOutput<Column>>, prevFull?: any, curFull?: any) => Promise<{
2656
2652
  statements: JsonStatement[];
2657
2653
  sqlStatements: string[];
2658
2654
  _meta: {
package/utils-studio.js CHANGED
@@ -1,4 +1,3 @@
1
- "use strict";
2
1
  var __create = Object.create;
3
2
  var __defProp = Object.defineProperty;
4
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -1077,26 +1076,15 @@ var require_hanji = __commonJS({
1077
1076
  var import_hanji;
1078
1077
  var init_views = __esm({
1079
1078
  "src/cli/views.ts"() {
1080
- "use strict";
1081
1079
  init_source();
1082
1080
  import_hanji = __toESM(require_hanji());
1083
1081
  }
1084
1082
  });
1085
1083
 
1086
- // src/global.ts
1087
- var originUUID;
1088
- var init_global = __esm({
1089
- "src/global.ts"() {
1090
- "use strict";
1091
- originUUID = "00000000-0000-0000-0000-000000000000";
1092
- }
1093
- });
1094
-
1095
1084
  // src/serializer/index.ts
1096
1085
  var glob;
1097
1086
  var init_serializer = __esm({
1098
1087
  "src/serializer/index.ts"() {
1099
- "use strict";
1100
1088
  glob = __toESM(require("glob"));
1101
1089
  init_source();
1102
1090
  init_views();
@@ -1106,7 +1094,6 @@ var init_serializer = __esm({
1106
1094
  // src/cli/validations/outputs.ts
1107
1095
  var init_outputs = __esm({
1108
1096
  "src/cli/validations/outputs.ts"() {
1109
- "use strict";
1110
1097
  init_source();
1111
1098
  }
1112
1099
  });
@@ -1150,7 +1137,6 @@ function mapSqlToSqliteType(sqlType) {
1150
1137
  var import_drizzle_orm, import_sqlite_core2, dialect, fromDatabase;
1151
1138
  var init_sqliteSerializer = __esm({
1152
1139
  "src/serializer/sqliteSerializer.ts"() {
1153
- "use strict";
1154
1140
  import_drizzle_orm = require("drizzle-orm");
1155
1141
  import_sqlite_core2 = require("drizzle-orm/sqlite-core");
1156
1142
  init_serializer();
@@ -1569,7 +1555,6 @@ var require_brace_expansion = __commonJS({
1569
1555
  var import_pg_core2, import_pg_core3, import_drizzle_orm2, dialect2, trimChar, fromDatabase2, columnToDefault, defaultForColumn;
1570
1556
  var init_pgSerializer = __esm({
1571
1557
  "src/serializer/pgSerializer.ts"() {
1572
- "use strict";
1573
1558
  import_pg_core2 = require("drizzle-orm/pg-core");
1574
1559
  import_pg_core3 = require("drizzle-orm/pg-core");
1575
1560
  import_drizzle_orm2 = require("drizzle-orm");
@@ -1586,7 +1571,7 @@ var init_pgSerializer = __esm({
1586
1571
  --end;
1587
1572
  return start > 0 || end < str.length ? str.substring(start, end) : str.toString();
1588
1573
  };
1589
- fromDatabase2 = async (db, tablesFilter = () => true, schemaFilters, progressCallback) => {
1574
+ fromDatabase2 = async (db, tablesFilter = (table) => true, schemaFilters, progressCallback) => {
1590
1575
  const result = {};
1591
1576
  const internals = { tables: {} };
1592
1577
  const where = schemaFilters.map((t) => `table_schema = '${t}'`).join(" or ");
@@ -1913,7 +1898,7 @@ var init_pgSerializer = __esm({
1913
1898
  }
1914
1899
  const schemasObject = Object.fromEntries([...schemas].map((it) => [it, it]));
1915
1900
  return {
1916
- version: "6",
1901
+ version: "5",
1917
1902
  dialect: "pg",
1918
1903
  tables: result,
1919
1904
  enums: enumsToReturn,
@@ -1989,7 +1974,6 @@ var init_pgSerializer = __esm({
1989
1974
  var import_drizzle_orm4, DrizzleDbClient, DrizzleORMPgClient, TursoSqlite;
1990
1975
  var init_drivers = __esm({
1991
1976
  "src/drivers/index.ts"() {
1992
- "use strict";
1993
1977
  import_drizzle_orm4 = require("drizzle-orm");
1994
1978
  DrizzleDbClient = class {
1995
1979
  constructor(db) {
@@ -2182,7 +2166,11 @@ var sqliteSchemaToDrizzle = (schema) => {
2182
2166
 
2183
2167
  // src/cli/commands/sqliteIntrospect.ts
2184
2168
  init_views();
2185
- init_global();
2169
+
2170
+ // src/global.ts
2171
+ var originUUID = "00000000-0000-0000-0000-000000000000";
2172
+
2173
+ // src/cli/commands/sqliteIntrospect.ts
2186
2174
  init_sqliteSerializer();
2187
2175
 
2188
2176
  // node_modules/.pnpm/camelcase@7.0.1/node_modules/camelcase/index.js
@@ -2284,7 +2272,7 @@ String.prototype.camelCase = function() {
2284
2272
  return camelCase(String(this));
2285
2273
  };
2286
2274
  String.prototype.concatIf = function(it, condition) {
2287
- return condition ? `${this}${it}` : String(this);
2275
+ return condition ? `${this}${it}` : this;
2288
2276
  };
2289
2277
  Array.prototype.random = function() {
2290
2278
  return this[~~(Math.random() * this.length)];
@@ -3368,7 +3356,6 @@ var import_relations = require("drizzle-orm/relations");
3368
3356
  init_pgSerializer();
3369
3357
 
3370
3358
  // src/cli/commands/pgIntrospect.ts
3371
- init_global();
3372
3359
  var pgPushIntrospect = async (connection, filters, schemaFilters) => {
3373
3360
  const { client } = connection;
3374
3361
  const matchers = filters.map((it) => {
package/utils-studio.mjs CHANGED
@@ -1078,26 +1078,15 @@ var require_hanji = __commonJS({
1078
1078
  var import_hanji;
1079
1079
  var init_views = __esm({
1080
1080
  "src/cli/views.ts"() {
1081
- "use strict";
1082
1081
  init_source();
1083
1082
  import_hanji = __toESM(require_hanji());
1084
1083
  }
1085
1084
  });
1086
1085
 
1087
- // src/global.ts
1088
- var originUUID;
1089
- var init_global = __esm({
1090
- "src/global.ts"() {
1091
- "use strict";
1092
- originUUID = "00000000-0000-0000-0000-000000000000";
1093
- }
1094
- });
1095
-
1096
1086
  // src/serializer/index.ts
1097
1087
  import * as glob from "glob";
1098
1088
  var init_serializer = __esm({
1099
1089
  "src/serializer/index.ts"() {
1100
- "use strict";
1101
1090
  init_source();
1102
1091
  init_views();
1103
1092
  }
@@ -1106,7 +1095,6 @@ var init_serializer = __esm({
1106
1095
  // src/cli/validations/outputs.ts
1107
1096
  var init_outputs = __esm({
1108
1097
  "src/cli/validations/outputs.ts"() {
1109
- "use strict";
1110
1098
  init_source();
1111
1099
  }
1112
1100
  });
@@ -1157,7 +1145,6 @@ function mapSqlToSqliteType(sqlType) {
1157
1145
  var dialect, fromDatabase;
1158
1146
  var init_sqliteSerializer = __esm({
1159
1147
  "src/serializer/sqliteSerializer.ts"() {
1160
- "use strict";
1161
1148
  init_serializer();
1162
1149
  init_outputs();
1163
1150
  init_source();
@@ -1580,7 +1567,6 @@ import { is as is2, SQL as SQL2, getTableName as getTableName2 } from "drizzle-o
1580
1567
  var dialect2, trimChar, fromDatabase2, columnToDefault, defaultForColumn;
1581
1568
  var init_pgSerializer = __esm({
1582
1569
  "src/serializer/pgSerializer.ts"() {
1583
- "use strict";
1584
1570
  init_serializer();
1585
1571
  init_source();
1586
1572
  init_outputs();
@@ -1594,7 +1580,7 @@ var init_pgSerializer = __esm({
1594
1580
  --end;
1595
1581
  return start > 0 || end < str.length ? str.substring(start, end) : str.toString();
1596
1582
  };
1597
- fromDatabase2 = async (db, tablesFilter = () => true, schemaFilters, progressCallback) => {
1583
+ fromDatabase2 = async (db, tablesFilter = (table) => true, schemaFilters, progressCallback) => {
1598
1584
  const result = {};
1599
1585
  const internals = { tables: {} };
1600
1586
  const where = schemaFilters.map((t) => `table_schema = '${t}'`).join(" or ");
@@ -1921,7 +1907,7 @@ var init_pgSerializer = __esm({
1921
1907
  }
1922
1908
  const schemasObject = Object.fromEntries([...schemas].map((it) => [it, it]));
1923
1909
  return {
1924
- version: "6",
1910
+ version: "5",
1925
1911
  dialect: "pg",
1926
1912
  tables: result,
1927
1913
  enums: enumsToReturn,
@@ -1998,7 +1984,6 @@ import { sql } from "drizzle-orm";
1998
1984
  var DrizzleDbClient, DrizzleORMPgClient, TursoSqlite;
1999
1985
  var init_drivers = __esm({
2000
1986
  "src/drivers/index.ts"() {
2001
- "use strict";
2002
1987
  DrizzleDbClient = class {
2003
1988
  constructor(db) {
2004
1989
  this.db = db;
@@ -2215,7 +2200,11 @@ var sqliteSchemaToDrizzle = (schema) => {
2215
2200
 
2216
2201
  // src/cli/commands/sqliteIntrospect.ts
2217
2202
  init_views();
2218
- init_global();
2203
+
2204
+ // src/global.ts
2205
+ var originUUID = "00000000-0000-0000-0000-000000000000";
2206
+
2207
+ // src/cli/commands/sqliteIntrospect.ts
2219
2208
  init_sqliteSerializer();
2220
2209
 
2221
2210
  // node_modules/.pnpm/camelcase@7.0.1/node_modules/camelcase/index.js
@@ -2317,7 +2306,7 @@ String.prototype.camelCase = function() {
2317
2306
  return camelCase(String(this));
2318
2307
  };
2319
2308
  String.prototype.concatIf = function(it, condition) {
2320
- return condition ? `${this}${it}` : String(this);
2309
+ return condition ? `${this}${it}` : this;
2321
2310
  };
2322
2311
  Array.prototype.random = function() {
2323
2312
  return this[~~(Math.random() * this.length)];
@@ -3406,7 +3395,6 @@ import {
3406
3395
  init_pgSerializer();
3407
3396
 
3408
3397
  // src/cli/commands/pgIntrospect.ts
3409
- init_global();
3410
3398
  var pgPushIntrospect = async (connection, filters, schemaFilters) => {
3411
3399
  const { client } = connection;
3412
3400
  const matchers = filters.map((it) => {
package/utils.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import type { Dialect } from "./schemaValidator";
2
2
  import { NamedWithSchema } from "./cli/commands/migrate";
3
- export declare const assertV1OutFolder: (out: string) => void;
3
+ export declare const assertV1OutFolder: (out: string, dialect: Dialect | "{dialect}") => void;
4
4
  export type Journal = {
5
5
  version: string;
6
6
  dialect: Dialect;
@@ -50,9 +50,9 @@ export declare const prepareMigrationMeta: (schemas: {
50
50
  column: string;
51
51
  };
52
52
  }[]) => {
53
- schemas: Record<string, string>;
54
- tables: Record<string, string>;
55
- columns: Record<string, string>;
53
+ schemas: {};
54
+ tables: {};
55
+ columns: {};
56
56
  };
57
57
  export declare const schemaRenameKey: (it: string) => string;
58
58
  export declare const tableRenameKey: (it: NamedWithSchema) => string;
@@ -73,6 +73,10 @@ export declare const statementsForDiffs: (in1: any, in2: any) => Promise<{
73
73
  } | undefined>;
74
74
  } | undefined>;
75
75
  } | undefined;
76
+ id: string;
77
+ prevId: string;
78
+ version: "5";
79
+ dialect: "pg";
76
80
  tables: Record<string, {
77
81
  name: string;
78
82
  columns: Record<string, {
@@ -111,10 +115,6 @@ export declare const statementsForDiffs: (in1: any, in2: any) => Promise<{
111
115
  nullsNotDistinct: boolean;
112
116
  }>;
113
117
  }>;
114
- id: string;
115
- prevId: string;
116
- version: "6";
117
- dialect: "pg";
118
118
  schemas: Record<string, string>;
119
119
  _meta: {
120
120
  columns: Record<string, string>;
@@ -136,6 +136,10 @@ export declare const statementsForDiffs: (in1: any, in2: any) => Promise<{
136
136
  } | undefined>;
137
137
  } | undefined>;
138
138
  } | undefined;
139
+ id: string;
140
+ prevId: string;
141
+ version: "5";
142
+ dialect: "pg";
139
143
  tables: Record<string, {
140
144
  name: string;
141
145
  columns: Record<string, {
@@ -174,10 +178,6 @@ export declare const statementsForDiffs: (in1: any, in2: any) => Promise<{
174
178
  nullsNotDistinct: boolean;
175
179
  }>;
176
180
  }>;
177
- id: string;
178
- prevId: string;
179
- version: "6";
180
- dialect: "pg";
181
181
  schemas: Record<string, string>;
182
182
  _meta: {
183
183
  columns: Record<string, string>;