drizzle-kit 0.24.0-6205f01 → 0.24.0-8d86512

Sign up to get free protection for your applications and to get access to all the features.
package/api.d.mts CHANGED
@@ -801,23 +801,28 @@ declare const pgSchema: zod.ZodObject<zod.objectUtil.extendShape<{
801
801
  isArray: zod.ZodOptional<zod.ZodBoolean>;
802
802
  dimensions: zod.ZodOptional<zod.ZodNumber>;
803
803
  rawType: zod.ZodOptional<zod.ZodString>;
804
+ isDefaultAnExpression: zod.ZodOptional<zod.ZodBoolean>;
804
805
  }, "strip", zod.ZodTypeAny, {
806
+ isDefaultAnExpression?: boolean | undefined;
805
807
  isArray?: boolean | undefined;
806
808
  dimensions?: number | undefined;
807
809
  rawType?: string | undefined;
808
810
  }, {
811
+ isDefaultAnExpression?: boolean | undefined;
809
812
  isArray?: boolean | undefined;
810
813
  dimensions?: number | undefined;
811
814
  rawType?: string | undefined;
812
815
  }>>>;
813
816
  }, "strip", zod.ZodTypeAny, {
814
817
  columns: Record<string, {
818
+ isDefaultAnExpression?: boolean | undefined;
815
819
  isArray?: boolean | undefined;
816
820
  dimensions?: number | undefined;
817
821
  rawType?: string | undefined;
818
822
  } | undefined>;
819
823
  }, {
820
824
  columns: Record<string, {
825
+ isDefaultAnExpression?: boolean | undefined;
821
826
  isArray?: boolean | undefined;
822
827
  dimensions?: number | undefined;
823
828
  rawType?: string | undefined;
@@ -826,6 +831,7 @@ declare const pgSchema: zod.ZodObject<zod.objectUtil.extendShape<{
826
831
  }, "strip", zod.ZodTypeAny, {
827
832
  tables: Record<string, {
828
833
  columns: Record<string, {
834
+ isDefaultAnExpression?: boolean | undefined;
829
835
  isArray?: boolean | undefined;
830
836
  dimensions?: number | undefined;
831
837
  rawType?: string | undefined;
@@ -834,6 +840,7 @@ declare const pgSchema: zod.ZodObject<zod.objectUtil.extendShape<{
834
840
  }, {
835
841
  tables: Record<string, {
836
842
  columns: Record<string, {
843
+ isDefaultAnExpression?: boolean | undefined;
837
844
  isArray?: boolean | undefined;
838
845
  dimensions?: number | undefined;
839
846
  rawType?: string | undefined;
@@ -936,6 +943,7 @@ declare const pgSchema: zod.ZodObject<zod.objectUtil.extendShape<{
936
943
  internal?: {
937
944
  tables: Record<string, {
938
945
  columns: Record<string, {
946
+ isDefaultAnExpression?: boolean | undefined;
939
947
  isArray?: boolean | undefined;
940
948
  dimensions?: number | undefined;
941
949
  rawType?: string | undefined;
@@ -1025,6 +1033,7 @@ declare const pgSchema: zod.ZodObject<zod.objectUtil.extendShape<{
1025
1033
  internal?: {
1026
1034
  tables: Record<string, {
1027
1035
  columns: Record<string, {
1036
+ isDefaultAnExpression?: boolean | undefined;
1028
1037
  isArray?: boolean | undefined;
1029
1038
  dimensions?: number | undefined;
1030
1039
  rawType?: string | undefined;
@@ -1506,6 +1515,7 @@ declare const upPgSnapshot: (snapshot: Record<string, unknown>) => {
1506
1515
  isArray?: boolean | undefined;
1507
1516
  dimensions?: number | undefined;
1508
1517
  rawType?: string | undefined;
1518
+ isDefaultAnExpression?: boolean | undefined;
1509
1519
  } | undefined>;
1510
1520
  } | undefined>;
1511
1521
  } | undefined;
package/api.d.ts CHANGED
@@ -801,23 +801,28 @@ declare const pgSchema: zod.ZodObject<zod.objectUtil.extendShape<{
801
801
  isArray: zod.ZodOptional<zod.ZodBoolean>;
802
802
  dimensions: zod.ZodOptional<zod.ZodNumber>;
803
803
  rawType: zod.ZodOptional<zod.ZodString>;
804
+ isDefaultAnExpression: zod.ZodOptional<zod.ZodBoolean>;
804
805
  }, "strip", zod.ZodTypeAny, {
806
+ isDefaultAnExpression?: boolean | undefined;
805
807
  isArray?: boolean | undefined;
806
808
  dimensions?: number | undefined;
807
809
  rawType?: string | undefined;
808
810
  }, {
811
+ isDefaultAnExpression?: boolean | undefined;
809
812
  isArray?: boolean | undefined;
810
813
  dimensions?: number | undefined;
811
814
  rawType?: string | undefined;
812
815
  }>>>;
813
816
  }, "strip", zod.ZodTypeAny, {
814
817
  columns: Record<string, {
818
+ isDefaultAnExpression?: boolean | undefined;
815
819
  isArray?: boolean | undefined;
816
820
  dimensions?: number | undefined;
817
821
  rawType?: string | undefined;
818
822
  } | undefined>;
819
823
  }, {
820
824
  columns: Record<string, {
825
+ isDefaultAnExpression?: boolean | undefined;
821
826
  isArray?: boolean | undefined;
822
827
  dimensions?: number | undefined;
823
828
  rawType?: string | undefined;
@@ -826,6 +831,7 @@ declare const pgSchema: zod.ZodObject<zod.objectUtil.extendShape<{
826
831
  }, "strip", zod.ZodTypeAny, {
827
832
  tables: Record<string, {
828
833
  columns: Record<string, {
834
+ isDefaultAnExpression?: boolean | undefined;
829
835
  isArray?: boolean | undefined;
830
836
  dimensions?: number | undefined;
831
837
  rawType?: string | undefined;
@@ -834,6 +840,7 @@ declare const pgSchema: zod.ZodObject<zod.objectUtil.extendShape<{
834
840
  }, {
835
841
  tables: Record<string, {
836
842
  columns: Record<string, {
843
+ isDefaultAnExpression?: boolean | undefined;
837
844
  isArray?: boolean | undefined;
838
845
  dimensions?: number | undefined;
839
846
  rawType?: string | undefined;
@@ -936,6 +943,7 @@ declare const pgSchema: zod.ZodObject<zod.objectUtil.extendShape<{
936
943
  internal?: {
937
944
  tables: Record<string, {
938
945
  columns: Record<string, {
946
+ isDefaultAnExpression?: boolean | undefined;
939
947
  isArray?: boolean | undefined;
940
948
  dimensions?: number | undefined;
941
949
  rawType?: string | undefined;
@@ -1025,6 +1033,7 @@ declare const pgSchema: zod.ZodObject<zod.objectUtil.extendShape<{
1025
1033
  internal?: {
1026
1034
  tables: Record<string, {
1027
1035
  columns: Record<string, {
1036
+ isDefaultAnExpression?: boolean | undefined;
1028
1037
  isArray?: boolean | undefined;
1029
1038
  dimensions?: number | undefined;
1030
1039
  rawType?: string | undefined;
@@ -1506,6 +1515,7 @@ declare const upPgSnapshot: (snapshot: Record<string, unknown>) => {
1506
1515
  isArray?: boolean | undefined;
1507
1516
  dimensions?: number | undefined;
1508
1517
  rawType?: string | undefined;
1518
+ isDefaultAnExpression?: boolean | undefined;
1509
1519
  } | undefined>;
1510
1520
  } | undefined>;
1511
1521
  } | undefined;
package/api.js CHANGED
@@ -7464,11 +7464,30 @@ var init_mysqlSchema = __esm({
7464
7464
  }
7465
7465
  });
7466
7466
 
7467
+ // src/extensions/vector.ts
7468
+ var vectorOps;
7469
+ var init_vector = __esm({
7470
+ "src/extensions/vector.ts"() {
7471
+ "use strict";
7472
+ vectorOps = [
7473
+ "vector_l2_ops",
7474
+ "vector_ip_ops",
7475
+ "vector_cosine_ops",
7476
+ "vector_l1_ops",
7477
+ "bit_hamming_ops",
7478
+ "bit_jaccard_ops",
7479
+ "halfvec_l2_ops",
7480
+ "sparsevec_l2_ops"
7481
+ ];
7482
+ }
7483
+ });
7484
+
7467
7485
  // src/serializer/pgSchema.ts
7468
7486
  var indexV2, columnV2, tableV2, enumSchemaV1, enumSchema, pgSchemaV2, references, columnV1, tableV1, pgSchemaV1, indexColumn, index2, indexV4, indexV5, indexV6, fk2, sequenceSchema, sequenceSquashed, columnV7, column2, columnSquashed, tableV32, compositePK2, uniqueConstraint2, tableV42, tableV5, tableV6, tableV7, table2, schemaHash2, kitInternals2, pgSchemaInternalV3, pgSchemaInternalV4, pgSchemaInternalV5, pgSchemaInternalV6, pgSchemaExternal, pgSchemaInternalV7, pgSchemaInternal, tableSquashed2, tableSquashedV42, pgSchemaSquashedV4, pgSchemaSquashedV6, pgSchemaSquashed, pgSchemaV3, pgSchemaV4, pgSchemaV5, pgSchemaV6, pgSchemaV7, pgSchema, backwardCompatiblePgSchema, PgSquasher, squashPgScheme, dryPg;
7469
7487
  var init_pgSchema = __esm({
7470
7488
  "src/serializer/pgSchema.ts"() {
7471
7489
  "use strict";
7490
+ init_vector();
7472
7491
  init_global();
7473
7492
  init_lib();
7474
7493
  indexV2 = objectType({
@@ -7715,7 +7734,8 @@ var init_pgSchema = __esm({
7715
7734
  objectType({
7716
7735
  isArray: booleanType().optional(),
7717
7736
  dimensions: numberType().optional(),
7718
- rawType: stringType().optional()
7737
+ rawType: stringType().optional(),
7738
+ isDefaultAnExpression: booleanType().optional()
7719
7739
  }).optional()
7720
7740
  )
7721
7741
  }).optional()
@@ -7853,7 +7873,7 @@ var init_pgSchema = __esm({
7853
7873
  squashIdx: (idx) => {
7854
7874
  index2.parse(idx);
7855
7875
  return `${idx.name};${idx.columns.map(
7856
- (c) => `${c.expression}--${c.isExpression}--${c.asc}--${c.nulls}--${c.opclass}`
7876
+ (c) => `${c.expression}--${c.isExpression}--${c.asc}--${c.nulls}--${c.opclass && vectorOps.includes(c.opclass) ? c.opclass : ""}`
7857
7877
  ).join(",,")};${idx.isUnique};${idx.concurrently};${idx.method};${idx.where};${JSON.stringify(idx.with)}`;
7858
7878
  },
7859
7879
  unsquashIdx: (input) => {
@@ -19373,7 +19393,7 @@ function jaccardDistance(column4, value) {
19373
19393
  }
19374
19394
  return sql`${column4} <%> ${value}`;
19375
19395
  }
19376
- var init_vector = __esm({
19396
+ var init_vector2 = __esm({
19377
19397
  "../drizzle-orm/dist/sql/functions/vector.js"() {
19378
19398
  "use strict";
19379
19399
  init_sql();
@@ -19385,7 +19405,7 @@ var init_functions = __esm({
19385
19405
  "../drizzle-orm/dist/sql/functions/index.js"() {
19386
19406
  "use strict";
19387
19407
  init_aggregate();
19388
- init_vector();
19408
+ init_vector2();
19389
19409
  }
19390
19410
  });
19391
19411
 
@@ -21049,7 +21069,7 @@ var init_sparsevec = __esm({
21049
21069
 
21050
21070
  // ../drizzle-orm/dist/pg-core/columns/vector_extension/vector.js
21051
21071
  var _a122, _b95, PgVectorBuilder, _a123, _b96, PgVector;
21052
- var init_vector2 = __esm({
21072
+ var init_vector3 = __esm({
21053
21073
  "../drizzle-orm/dist/pg-core/columns/vector_extension/vector.js"() {
21054
21074
  "use strict";
21055
21075
  init_entity();
@@ -21121,7 +21141,7 @@ var init_columns = __esm({
21121
21141
  init_bit();
21122
21142
  init_halfvec();
21123
21143
  init_sparsevec();
21124
- init_vector2();
21144
+ init_vector3();
21125
21145
  }
21126
21146
  });
21127
21147
 
@@ -24619,24 +24639,6 @@ var init_pg_core = __esm({
24619
24639
  }
24620
24640
  });
24621
24641
 
24622
- // src/extensions/vector.ts
24623
- var vectorOps;
24624
- var init_vector3 = __esm({
24625
- "src/extensions/vector.ts"() {
24626
- "use strict";
24627
- vectorOps = [
24628
- "vector_l2_ops",
24629
- "vector_ip_ops",
24630
- "vector_cosine_ops",
24631
- "vector_l1_ops",
24632
- "bit_hamming_ops",
24633
- "bit_jaccard_ops",
24634
- "halfvec_l2_ops",
24635
- "sparsevec_l2_ops"
24636
- ];
24637
- }
24638
- });
24639
-
24640
24642
  // src/serializer/pgSerializer.ts
24641
24643
  function stringFromIdentityProperty(field) {
24642
24644
  return typeof field === "string" ? field : typeof field === "undefined" ? void 0 : String(field);
@@ -24674,7 +24676,7 @@ function buildArrayString(array, sqlType) {
24674
24676
  }).join(",");
24675
24677
  return `{${values}}`;
24676
24678
  }
24677
- var dialect4, indexName, generatePgSnapshot, trimChar, fromDatabase, columnToDefault, defaultForColumn;
24679
+ var dialect4, indexName, generatePgSnapshot, trimChar, fromDatabase, columnToDefault, columnEnumNameToDefault, defaultForColumn;
24678
24680
  var init_pgSerializer = __esm({
24679
24681
  "src/serializer/pgSerializer.ts"() {
24680
24682
  "use strict";
@@ -24682,7 +24684,7 @@ var init_pgSerializer = __esm({
24682
24684
  init_dist();
24683
24685
  init_pg_core();
24684
24686
  init_pg_core();
24685
- init_vector3();
24687
+ init_vector();
24686
24688
  init_outputs();
24687
24689
  init_utils();
24688
24690
  init_serializer();
@@ -25142,7 +25144,7 @@ ${withStyle.errorWarning(
25142
25144
  WHEN 'int2'::regtype THEN 'smallserial'
25143
25145
  END
25144
25146
  ELSE format_type(a.atttypid, a.atttypmod)
25145
- END AS data_type, INFORMATION_SCHEMA.COLUMNS.table_name,
25147
+ END AS data_type, INFORMATION_SCHEMA.COLUMNS.table_name, ns.nspname as type_schema,
25146
25148
  pg_get_serial_sequence('"${tableSchema}"."${tableName}"', a.attname)::regclass as seq_name, INFORMATION_SCHEMA.COLUMNS.column_name,
25147
25149
  INFORMATION_SCHEMA.COLUMNS.column_default, INFORMATION_SCHEMA.COLUMNS.data_type as additional_dt,
25148
25150
  INFORMATION_SCHEMA.COLUMNS.udt_name as enum_name,
@@ -25153,6 +25155,7 @@ ${withStyle.errorWarning(
25153
25155
  INFORMATION_SCHEMA.COLUMNS.identity_cycle
25154
25156
  FROM pg_attribute a
25155
25157
  JOIN INFORMATION_SCHEMA.COLUMNS ON INFORMATION_SCHEMA.COLUMNS.column_name = a.attname
25158
+ JOIN pg_type t ON t.oid = a.atttypid LEFT JOIN pg_namespace ns ON ns.oid = t.typnamespace
25156
25159
  WHERE a.attrelid = '"${tableSchema}"."${tableName}"'::regclass and INFORMATION_SCHEMA.COLUMNS.table_name = '${tableName}' and INFORMATION_SCHEMA.COLUMNS.table_schema = '${tableSchema}'
25157
25160
  AND a.attnum > 0
25158
25161
  AND NOT a.attisdropped
@@ -25172,30 +25175,42 @@ ${withStyle.errorWarning(
25172
25175
  }
25173
25176
  const tableForeignKeys = await db.query(
25174
25177
  `SELECT
25175
- tc.table_schema,
25176
- tc.constraint_name,
25177
- tc.table_name,
25178
- kcu.column_name,
25179
- (
25180
- SELECT ccu.table_schema
25181
- FROM information_schema.constraint_column_usage ccu
25182
- WHERE ccu.constraint_name = tc.constraint_name
25183
- LIMIT 1
25184
- ) AS foreign_table_schema,
25185
- ccu.table_name AS foreign_table_name,
25186
- ccu.column_name AS foreign_column_name,
25187
- rc.delete_rule,
25188
- rc.update_rule
25189
- FROM
25190
- information_schema.table_constraints AS tc
25191
- JOIN information_schema.key_column_usage AS kcu
25192
- ON tc.constraint_name = kcu.constraint_name
25193
- AND tc.table_schema = kcu.table_schema
25194
- JOIN information_schema.constraint_column_usage AS ccu
25195
- ON ccu.constraint_name = tc.constraint_name
25196
- JOIN information_schema.referential_constraints AS rc
25197
- ON ccu.constraint_name = rc.constraint_name
25198
- WHERE tc.constraint_type = 'FOREIGN KEY' AND tc.table_name='${tableName}' and tc.table_schema='${tableSchema}';`
25178
+ con.contype AS constraint_type,
25179
+ nsp.nspname AS constraint_schema,
25180
+ con.conname AS constraint_name,
25181
+ rel.relname AS table_name,
25182
+ att.attname AS column_name,
25183
+ fnsp.nspname AS foreign_table_schema,
25184
+ frel.relname AS foreign_table_name,
25185
+ fatt.attname AS foreign_column_name,
25186
+ CASE con.confupdtype
25187
+ WHEN 'a' THEN 'NO ACTION'
25188
+ WHEN 'r' THEN 'RESTRICT'
25189
+ WHEN 'n' THEN 'SET NULL'
25190
+ WHEN 'c' THEN 'CASCADE'
25191
+ WHEN 'd' THEN 'SET DEFAULT'
25192
+ END AS update_rule,
25193
+ CASE con.confdeltype
25194
+ WHEN 'a' THEN 'NO ACTION'
25195
+ WHEN 'r' THEN 'RESTRICT'
25196
+ WHEN 'n' THEN 'SET NULL'
25197
+ WHEN 'c' THEN 'CASCADE'
25198
+ WHEN 'd' THEN 'SET DEFAULT'
25199
+ END AS delete_rule
25200
+ FROM
25201
+ pg_catalog.pg_constraint con
25202
+ JOIN pg_catalog.pg_class rel ON rel.oid = con.conrelid
25203
+ JOIN pg_catalog.pg_namespace nsp ON nsp.oid = con.connamespace
25204
+ LEFT JOIN pg_catalog.pg_attribute att ON att.attnum = ANY (con.conkey)
25205
+ AND att.attrelid = con.conrelid
25206
+ LEFT JOIN pg_catalog.pg_class frel ON frel.oid = con.confrelid
25207
+ LEFT JOIN pg_catalog.pg_namespace fnsp ON fnsp.oid = frel.relnamespace
25208
+ LEFT JOIN pg_catalog.pg_attribute fatt ON fatt.attnum = ANY (con.confkey)
25209
+ AND fatt.attrelid = con.confrelid
25210
+ WHERE
25211
+ nsp.nspname = '${tableSchema}'
25212
+ AND rel.relname = '${tableName}'
25213
+ AND con.contype IN ('f');`
25199
25214
  );
25200
25215
  foreignKeysCount += tableForeignKeys.length;
25201
25216
  if (progressCallback) {
@@ -25253,6 +25268,7 @@ ${withStyle.errorWarning(
25253
25268
  const columnDimensions = columnResponse.array_dimensions;
25254
25269
  const enumType2 = columnResponse.enum_name;
25255
25270
  let columnType = columnResponse.data_type;
25271
+ const typeSchema = columnResponse.type_schema;
25256
25272
  const isGenerated = columnResponse.is_generated === "ALWAYS";
25257
25273
  const generationExpression = columnResponse.generation_expression;
25258
25274
  const isIdentity = columnResponse.is_identity === "YES";
@@ -25284,6 +25300,25 @@ ${withStyle.errorWarning(
25284
25300
  };
25285
25301
  }
25286
25302
  const defaultValue = defaultForColumn(columnResponse);
25303
+ if (defaultValue === "NULL") {
25304
+ if (typeof internals.tables[tableName] === "undefined") {
25305
+ internals.tables[tableName] = {
25306
+ columns: {
25307
+ [columnName]: {
25308
+ isDefaultAnExpression: true
25309
+ }
25310
+ }
25311
+ };
25312
+ } else {
25313
+ if (typeof internals.tables[tableName].columns[columnName] === "undefined") {
25314
+ internals.tables[tableName].columns[columnName] = {
25315
+ isDefaultAnExpression: true
25316
+ };
25317
+ } else {
25318
+ internals.tables[tableName].columns[columnName].isDefaultAnExpression = true;
25319
+ }
25320
+ }
25321
+ }
25287
25322
  const isSerial = columnType === "serial";
25288
25323
  let columnTypeMapped = columnType;
25289
25324
  if (columnTypeMapped.startsWith("numeric(")) {
@@ -25329,7 +25364,7 @@ ${withStyle.errorWarning(
25329
25364
  // filter vectors, but in future we should filter any extension that was installed by user
25330
25365
  columnAdditionalDT === "USER-DEFINED" && !["vector", "geometry"].includes(enumType2) ? enumType2 : columnTypeMapped
25331
25366
  ),
25332
- typeSchema: enumsToReturn[`${tableSchema}.${enumType2}`] !== void 0 ? enumsToReturn[`${tableSchema}.${enumType2}`].schema : void 0,
25367
+ typeSchema: enumsToReturn[`${typeSchema}.${enumType2}`] !== void 0 ? enumsToReturn[`${typeSchema}.${enumType2}`].schema : void 0,
25333
25368
  primaryKey: primaryKey.length === 1 && cprimaryKey.length < 2,
25334
25369
  // default: isSerial ? undefined : defaultValue,
25335
25370
  notNull: columnResponse.is_nullable === "NO",
@@ -25503,11 +25538,11 @@ ${withStyle.errorWarning(
25503
25538
  columnToDefault = {
25504
25539
  "numeric(": "::numeric",
25505
25540
  // text: "::text",
25506
- // "character varying": "::character varying",
25541
+ "character varying": "::character varying",
25507
25542
  // "double precision": "::double precision",
25508
25543
  // "time with time zone": "::time with time zone",
25509
25544
  "time without time zone": "::time without time zone",
25510
- // "timestamp with time zone": "::timestamp with time zone",
25545
+ // 'timestamp with time zone': '::timestamp with time zone',
25511
25546
  "timestamp without time zone": "::timestamp without time zone",
25512
25547
  "timestamp(": "::timestamp without time zone",
25513
25548
  // date: "::date",
@@ -25521,6 +25556,12 @@ ${withStyle.errorWarning(
25521
25556
  // json: "::json",
25522
25557
  "character(": "::bpchar"
25523
25558
  };
25559
+ columnEnumNameToDefault = {
25560
+ timestamptz: "::timestamp with time zone",
25561
+ timestmap: "::time without time zone",
25562
+ time: "::time without time zone",
25563
+ timetz: "::time with time zone"
25564
+ };
25524
25565
  defaultForColumn = (column4) => {
25525
25566
  if (column4.column_default === null) {
25526
25567
  return void 0;
@@ -25529,19 +25570,33 @@ ${withStyle.errorWarning(
25529
25570
  return void 0;
25530
25571
  }
25531
25572
  const hasDifferentDefaultCast = Object.keys(columnToDefault).find((it) => column4.data_type.startsWith(it));
25573
+ const hasDifferentDefaultCastForEnum = Object.keys(columnEnumNameToDefault).find(
25574
+ (it) => column4.enum_name.startsWith(it)
25575
+ );
25532
25576
  const columnDefaultAsString = column4.column_default.toString();
25533
- if (columnDefaultAsString.endsWith(
25577
+ const endsWithEnumName = columnDefaultAsString.endsWith(
25578
+ hasDifferentDefaultCastForEnum ? columnEnumNameToDefault[hasDifferentDefaultCastForEnum] : column4.data_type
25579
+ );
25580
+ const endsWithTypeName = columnDefaultAsString.endsWith(
25534
25581
  hasDifferentDefaultCast ? columnToDefault[hasDifferentDefaultCast] : column4.data_type
25535
- )) {
25582
+ );
25583
+ if (endsWithTypeName || endsWithEnumName) {
25536
25584
  const nonPrefixPart = column4.column_default.length - (hasDifferentDefaultCast ? columnToDefault[hasDifferentDefaultCast] : `::${column4.data_type}`).length - 1;
25537
- const rt = column4.column_default.toString().substring(1, nonPrefixPart);
25585
+ let rt = column4.column_default.toString().substring(0, nonPrefixPart + 1);
25538
25586
  if (/^-?[\d.]+(?:e-?\d+)?$/.test(rt) && !column4.data_type.startsWith("numeric")) {
25539
25587
  return Number(rt);
25540
25588
  } else if (column4.data_type === "json" || column4.data_type === "jsonb") {
25589
+ if (rt.startsWith("'")) {
25590
+ rt = rt.slice(1, -1);
25591
+ }
25541
25592
  const jsonWithoutSpaces = JSON.stringify(JSON.parse(rt));
25542
25593
  return `'${jsonWithoutSpaces}'${hasDifferentDefaultCast ? columnToDefault[hasDifferentDefaultCast] : `::${column4.data_type}`}`;
25543
25594
  } else if (column4.data_type === "boolean") {
25544
25595
  return column4.column_default === "true";
25596
+ } else if (rt === "NULL") {
25597
+ return `NULL`;
25598
+ } else if (rt.startsWith("'") && rt.endsWith("'")) {
25599
+ return rt;
25545
25600
  } else {
25546
25601
  return `'${rt}'`;
25547
25602
  }
@@ -25550,8 +25605,10 @@ ${withStyle.errorWarning(
25550
25605
  return Number(columnDefaultAsString);
25551
25606
  } else if (column4.data_type === "boolean") {
25552
25607
  return column4.column_default === "true";
25608
+ } else if (columnDefaultAsString === "NULL") {
25609
+ return `NULL`;
25553
25610
  } else {
25554
- return `${columnDefaultAsString}`;
25611
+ return `${columnDefaultAsString.replace(/\\/g, "`\\")}`;
25555
25612
  }
25556
25613
  }
25557
25614
  };
@@ -33882,7 +33939,7 @@ var init_cli = __esm({
33882
33939
  extensionsFilters: literalType("postgis").array().optional(),
33883
33940
  introspectCasing: casing,
33884
33941
  breakpoints: booleanType().optional().default(true),
33885
- database: objectType({
33942
+ migrations: objectType({
33886
33943
  prefix: prefix.optional().default("index")
33887
33944
  }).optional()
33888
33945
  }).passthrough();