drizzle-kit 0.20.14-1f2c838 → 0.20.14-1f99bf7

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