drizzle-kit 0.24.0 → 0.24.1-3d751e8

Sign up to get free protection for your applications and to get access to all the features.
package/api.mjs CHANGED
@@ -7469,11 +7469,30 @@ var init_mysqlSchema = __esm({
7469
7469
  }
7470
7470
  });
7471
7471
 
7472
+ // src/extensions/vector.ts
7473
+ var vectorOps;
7474
+ var init_vector = __esm({
7475
+ "src/extensions/vector.ts"() {
7476
+ "use strict";
7477
+ vectorOps = [
7478
+ "vector_l2_ops",
7479
+ "vector_ip_ops",
7480
+ "vector_cosine_ops",
7481
+ "vector_l1_ops",
7482
+ "bit_hamming_ops",
7483
+ "bit_jaccard_ops",
7484
+ "halfvec_l2_ops",
7485
+ "sparsevec_l2_ops"
7486
+ ];
7487
+ }
7488
+ });
7489
+
7472
7490
  // src/serializer/pgSchema.ts
7473
7491
  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;
7474
7492
  var init_pgSchema = __esm({
7475
7493
  "src/serializer/pgSchema.ts"() {
7476
7494
  "use strict";
7495
+ init_vector();
7477
7496
  init_global();
7478
7497
  init_lib();
7479
7498
  indexV2 = objectType({
@@ -7720,7 +7739,8 @@ var init_pgSchema = __esm({
7720
7739
  objectType({
7721
7740
  isArray: booleanType().optional(),
7722
7741
  dimensions: numberType().optional(),
7723
- rawType: stringType().optional()
7742
+ rawType: stringType().optional(),
7743
+ isDefaultAnExpression: booleanType().optional()
7724
7744
  }).optional()
7725
7745
  )
7726
7746
  }).optional()
@@ -7858,7 +7878,7 @@ var init_pgSchema = __esm({
7858
7878
  squashIdx: (idx) => {
7859
7879
  index2.parse(idx);
7860
7880
  return `${idx.name};${idx.columns.map(
7861
- (c) => `${c.expression}--${c.isExpression}--${c.asc}--${c.nulls}--${c.opclass}`
7881
+ (c) => `${c.expression}--${c.isExpression}--${c.asc}--${c.nulls}--${c.opclass && vectorOps.includes(c.opclass) ? c.opclass : ""}`
7862
7882
  ).join(",,")};${idx.isUnique};${idx.concurrently};${idx.method};${idx.where};${JSON.stringify(idx.with)}`;
7863
7883
  },
7864
7884
  unsquashIdx: (input) => {
@@ -11507,7 +11527,7 @@ var init_sqlgenerator = __esm({
11507
11527
  isPgNativeType = (it) => {
11508
11528
  if (pgNativeTypes.has(it)) return true;
11509
11529
  const toCheck = it.replace(/ /g, "");
11510
- return toCheck.startsWith("varchar(") || toCheck.startsWith("char(") || toCheck.startsWith("numeric(") || toCheck.startsWith("timestamp(") || toCheck.startsWith("intervalyear(") || toCheck.startsWith("intervalmonth(") || toCheck.startsWith("intervalday(") || toCheck.startsWith("intervalhour(") || toCheck.startsWith("intervalminute(") || toCheck.startsWith("intervalsecond(") || toCheck.startsWith("intervalyeartomonth(") || toCheck.startsWith("intervaldaytohour(") || toCheck.startsWith("intervaldaytominute(") || toCheck.startsWith("intervaldaytosecond(") || toCheck.startsWith("intervalhourtominute(") || toCheck.startsWith("intervalhourtosecond(") || toCheck.startsWith("intervalminutetosecond(") || toCheck.startsWith("vector(") || toCheck.startsWith("geometry(") || /^(\w+)(\[\d*])+$/.test(it);
11530
+ return toCheck.startsWith("varchar(") || toCheck.startsWith("char(") || toCheck.startsWith("numeric(") || toCheck.startsWith("timestamp(") || toCheck.startsWith("doubleprecision[") || toCheck.startsWith("intervalyear(") || toCheck.startsWith("intervalmonth(") || toCheck.startsWith("intervalday(") || toCheck.startsWith("intervalhour(") || toCheck.startsWith("intervalminute(") || toCheck.startsWith("intervalsecond(") || toCheck.startsWith("intervalyeartomonth(") || toCheck.startsWith("intervaldaytohour(") || toCheck.startsWith("intervaldaytominute(") || toCheck.startsWith("intervaldaytosecond(") || toCheck.startsWith("intervalhourtominute(") || toCheck.startsWith("intervalhourtosecond(") || toCheck.startsWith("intervalminutetosecond(") || toCheck.startsWith("vector(") || toCheck.startsWith("geometry(") || /^(\w+)(\[\d*])+$/.test(it);
11511
11531
  };
11512
11532
  Convertor = class {
11513
11533
  };
@@ -15850,7 +15870,7 @@ var init_schemaValidator = __esm({
15850
15870
  });
15851
15871
 
15852
15872
  // src/cli/validations/common.ts
15853
- var sqliteDriversLiterals, prefixes, prefix, sqliteDriver, postgresDriver, driver, configMigrations, configCommonSchema, casing, introspectParams, configIntrospectCliSchema, configGenerateSchema, configPushSchema;
15873
+ var sqliteDriversLiterals, postgresqlDriversLiterals, prefixes, prefix, sqliteDriver, postgresDriver, driver, configMigrations, configCommonSchema, casing, introspectParams, configIntrospectCliSchema, configGenerateSchema, configPushSchema;
15854
15874
  var init_common = __esm({
15855
15875
  "src/cli/validations/common.ts"() {
15856
15876
  "use strict";
@@ -15862,6 +15882,10 @@ var init_common = __esm({
15862
15882
  literalType("d1-http"),
15863
15883
  literalType("expo")
15864
15884
  ];
15885
+ postgresqlDriversLiterals = [
15886
+ literalType("aws-data-api"),
15887
+ literalType("pglite")
15888
+ ];
15865
15889
  prefixes = [
15866
15890
  "index",
15867
15891
  "timestamp",
@@ -15874,7 +15898,7 @@ var init_common = __esm({
15874
15898
  const _2 = "";
15875
15899
  }
15876
15900
  sqliteDriver = unionType(sqliteDriversLiterals);
15877
- postgresDriver = literalType("aws-data-api");
15901
+ postgresDriver = unionType(postgresqlDriversLiterals);
15878
15902
  driver = unionType([sqliteDriver, postgresDriver]);
15879
15903
  configMigrations = objectType({
15880
15904
  table: stringType().optional(),
@@ -19378,7 +19402,7 @@ function jaccardDistance(column4, value) {
19378
19402
  }
19379
19403
  return sql`${column4} <%> ${value}`;
19380
19404
  }
19381
- var init_vector = __esm({
19405
+ var init_vector2 = __esm({
19382
19406
  "../drizzle-orm/dist/sql/functions/vector.js"() {
19383
19407
  "use strict";
19384
19408
  init_sql();
@@ -19390,7 +19414,7 @@ var init_functions = __esm({
19390
19414
  "../drizzle-orm/dist/sql/functions/index.js"() {
19391
19415
  "use strict";
19392
19416
  init_aggregate();
19393
- init_vector();
19417
+ init_vector2();
19394
19418
  }
19395
19419
  });
19396
19420
 
@@ -21054,7 +21078,7 @@ var init_sparsevec = __esm({
21054
21078
 
21055
21079
  // ../drizzle-orm/dist/pg-core/columns/vector_extension/vector.js
21056
21080
  var _a122, _b95, PgVectorBuilder, _a123, _b96, PgVector;
21057
- var init_vector2 = __esm({
21081
+ var init_vector3 = __esm({
21058
21082
  "../drizzle-orm/dist/pg-core/columns/vector_extension/vector.js"() {
21059
21083
  "use strict";
21060
21084
  init_entity();
@@ -21126,7 +21150,7 @@ var init_columns = __esm({
21126
21150
  init_bit();
21127
21151
  init_halfvec();
21128
21152
  init_sparsevec();
21129
- init_vector2();
21153
+ init_vector3();
21130
21154
  }
21131
21155
  });
21132
21156
 
@@ -24624,24 +24648,6 @@ var init_pg_core = __esm({
24624
24648
  }
24625
24649
  });
24626
24650
 
24627
- // src/extensions/vector.ts
24628
- var vectorOps;
24629
- var init_vector3 = __esm({
24630
- "src/extensions/vector.ts"() {
24631
- "use strict";
24632
- vectorOps = [
24633
- "vector_l2_ops",
24634
- "vector_ip_ops",
24635
- "vector_cosine_ops",
24636
- "vector_l1_ops",
24637
- "bit_hamming_ops",
24638
- "bit_jaccard_ops",
24639
- "halfvec_l2_ops",
24640
- "sparsevec_l2_ops"
24641
- ];
24642
- }
24643
- });
24644
-
24645
24651
  // src/serializer/pgSerializer.ts
24646
24652
  function stringFromIdentityProperty(field) {
24647
24653
  return typeof field === "string" ? field : typeof field === "undefined" ? void 0 : String(field);
@@ -24679,7 +24685,7 @@ function buildArrayString(array, sqlType) {
24679
24685
  }).join(",");
24680
24686
  return `{${values}}`;
24681
24687
  }
24682
- var dialect4, indexName, generatePgSnapshot, trimChar, fromDatabase, columnToDefault, defaultForColumn;
24688
+ var dialect4, indexName, generatePgSnapshot, trimChar, fromDatabase, defaultForColumn;
24683
24689
  var init_pgSerializer = __esm({
24684
24690
  "src/serializer/pgSerializer.ts"() {
24685
24691
  "use strict";
@@ -24687,7 +24693,7 @@ var init_pgSerializer = __esm({
24687
24693
  init_dist();
24688
24694
  init_pg_core();
24689
24695
  init_pg_core();
24690
- init_vector3();
24696
+ init_vector();
24691
24697
  init_outputs();
24692
24698
  init_utils();
24693
24699
  init_serializer();
@@ -24800,7 +24806,7 @@ ${withStyle.errorWarning(`We've found duplicated unique constraint names in ${so
24800
24806
  columnToSet.default = `'${buildArrayString(
24801
24807
  column4.default,
24802
24808
  sqlTypeLowered
24803
- )}'::${sqlTypeLowered}`;
24809
+ )}'`;
24804
24810
  } else {
24805
24811
  columnToSet.default = column4.default;
24806
24812
  }
@@ -25147,7 +25153,7 @@ ${withStyle.errorWarning(
25147
25153
  WHEN 'int2'::regtype THEN 'smallserial'
25148
25154
  END
25149
25155
  ELSE format_type(a.atttypid, a.atttypmod)
25150
- END AS data_type, INFORMATION_SCHEMA.COLUMNS.table_name,
25156
+ END AS data_type, INFORMATION_SCHEMA.COLUMNS.table_name, ns.nspname as type_schema,
25151
25157
  pg_get_serial_sequence('"${tableSchema}"."${tableName}"', a.attname)::regclass as seq_name, INFORMATION_SCHEMA.COLUMNS.column_name,
25152
25158
  INFORMATION_SCHEMA.COLUMNS.column_default, INFORMATION_SCHEMA.COLUMNS.data_type as additional_dt,
25153
25159
  INFORMATION_SCHEMA.COLUMNS.udt_name as enum_name,
@@ -25158,6 +25164,7 @@ ${withStyle.errorWarning(
25158
25164
  INFORMATION_SCHEMA.COLUMNS.identity_cycle
25159
25165
  FROM pg_attribute a
25160
25166
  JOIN INFORMATION_SCHEMA.COLUMNS ON INFORMATION_SCHEMA.COLUMNS.column_name = a.attname
25167
+ JOIN pg_type t ON t.oid = a.atttypid LEFT JOIN pg_namespace ns ON ns.oid = t.typnamespace
25161
25168
  WHERE a.attrelid = '"${tableSchema}"."${tableName}"'::regclass and INFORMATION_SCHEMA.COLUMNS.table_name = '${tableName}' and INFORMATION_SCHEMA.COLUMNS.table_schema = '${tableSchema}'
25162
25169
  AND a.attnum > 0
25163
25170
  AND NOT a.attisdropped
@@ -25177,30 +25184,42 @@ ${withStyle.errorWarning(
25177
25184
  }
25178
25185
  const tableForeignKeys = await db.query(
25179
25186
  `SELECT
25180
- tc.table_schema,
25181
- tc.constraint_name,
25182
- tc.table_name,
25183
- kcu.column_name,
25184
- (
25185
- SELECT ccu.table_schema
25186
- FROM information_schema.constraint_column_usage ccu
25187
- WHERE ccu.constraint_name = tc.constraint_name
25188
- LIMIT 1
25189
- ) AS foreign_table_schema,
25190
- ccu.table_name AS foreign_table_name,
25191
- ccu.column_name AS foreign_column_name,
25192
- rc.delete_rule,
25193
- rc.update_rule
25194
- FROM
25195
- information_schema.table_constraints AS tc
25196
- JOIN information_schema.key_column_usage AS kcu
25197
- ON tc.constraint_name = kcu.constraint_name
25198
- AND tc.table_schema = kcu.table_schema
25199
- JOIN information_schema.constraint_column_usage AS ccu
25200
- ON ccu.constraint_name = tc.constraint_name
25201
- JOIN information_schema.referential_constraints AS rc
25202
- ON ccu.constraint_name = rc.constraint_name
25203
- WHERE tc.constraint_type = 'FOREIGN KEY' AND tc.table_name='${tableName}' and tc.table_schema='${tableSchema}';`
25187
+ con.contype AS constraint_type,
25188
+ nsp.nspname AS constraint_schema,
25189
+ con.conname AS constraint_name,
25190
+ rel.relname AS table_name,
25191
+ att.attname AS column_name,
25192
+ fnsp.nspname AS foreign_table_schema,
25193
+ frel.relname AS foreign_table_name,
25194
+ fatt.attname AS foreign_column_name,
25195
+ CASE con.confupdtype
25196
+ WHEN 'a' THEN 'NO ACTION'
25197
+ WHEN 'r' THEN 'RESTRICT'
25198
+ WHEN 'n' THEN 'SET NULL'
25199
+ WHEN 'c' THEN 'CASCADE'
25200
+ WHEN 'd' THEN 'SET DEFAULT'
25201
+ END AS update_rule,
25202
+ CASE con.confdeltype
25203
+ WHEN 'a' THEN 'NO ACTION'
25204
+ WHEN 'r' THEN 'RESTRICT'
25205
+ WHEN 'n' THEN 'SET NULL'
25206
+ WHEN 'c' THEN 'CASCADE'
25207
+ WHEN 'd' THEN 'SET DEFAULT'
25208
+ END AS delete_rule
25209
+ FROM
25210
+ pg_catalog.pg_constraint con
25211
+ JOIN pg_catalog.pg_class rel ON rel.oid = con.conrelid
25212
+ JOIN pg_catalog.pg_namespace nsp ON nsp.oid = con.connamespace
25213
+ LEFT JOIN pg_catalog.pg_attribute att ON att.attnum = ANY (con.conkey)
25214
+ AND att.attrelid = con.conrelid
25215
+ LEFT JOIN pg_catalog.pg_class frel ON frel.oid = con.confrelid
25216
+ LEFT JOIN pg_catalog.pg_namespace fnsp ON fnsp.oid = frel.relnamespace
25217
+ LEFT JOIN pg_catalog.pg_attribute fatt ON fatt.attnum = ANY (con.confkey)
25218
+ AND fatt.attrelid = con.confrelid
25219
+ WHERE
25220
+ nsp.nspname = '${tableSchema}'
25221
+ AND rel.relname = '${tableName}'
25222
+ AND con.contype IN ('f');`
25204
25223
  );
25205
25224
  foreignKeysCount += tableForeignKeys.length;
25206
25225
  if (progressCallback) {
@@ -25212,8 +25231,8 @@ ${withStyle.errorWarning(
25212
25231
  const columnTo = fk4.foreign_column_name;
25213
25232
  const schemaTo = fk4.foreign_table_schema;
25214
25233
  const foreignKeyName = fk4.constraint_name;
25215
- const onUpdate = fk4.update_rule.toLowerCase();
25216
- const onDelete = fk4.delete_rule.toLowerCase();
25234
+ const onUpdate = fk4.update_rule?.toLowerCase();
25235
+ const onDelete = fk4.delete_rule?.toLowerCase();
25217
25236
  if (typeof foreignKeysToReturn[foreignKeyName] !== "undefined") {
25218
25237
  foreignKeysToReturn[foreignKeyName].columnsFrom.push(columnFrom);
25219
25238
  foreignKeysToReturn[foreignKeyName].columnsTo.push(columnTo);
@@ -25258,6 +25277,8 @@ ${withStyle.errorWarning(
25258
25277
  const columnDimensions = columnResponse.array_dimensions;
25259
25278
  const enumType2 = columnResponse.enum_name;
25260
25279
  let columnType = columnResponse.data_type;
25280
+ const typeSchema = columnResponse.type_schema;
25281
+ const defaultValueRes = columnResponse.column_default;
25261
25282
  const isGenerated = columnResponse.is_generated === "ALWAYS";
25262
25283
  const generationExpression = columnResponse.generation_expression;
25263
25284
  const isIdentity = columnResponse.is_identity === "YES";
@@ -25288,12 +25309,7 @@ ${withStyle.errorWarning(
25288
25309
  columns: cprimaryKey.map((c) => c.column_name)
25289
25310
  };
25290
25311
  }
25291
- const defaultValue = defaultForColumn(columnResponse);
25292
- const isSerial = columnType === "serial";
25293
25312
  let columnTypeMapped = columnType;
25294
- if (columnTypeMapped.startsWith("numeric(")) {
25295
- columnTypeMapped = columnTypeMapped.replace(",", ", ");
25296
- }
25297
25313
  if (columnAdditionalDT === "ARRAY") {
25298
25314
  if (typeof internals.tables[tableName] === "undefined") {
25299
25315
  internals.tables[tableName] = {
@@ -25321,6 +25337,34 @@ ${withStyle.errorWarning(
25321
25337
  }
25322
25338
  }
25323
25339
  }
25340
+ const defaultValue = defaultForColumn(
25341
+ columnResponse,
25342
+ internals,
25343
+ tableName
25344
+ );
25345
+ if (defaultValue === "NULL" || defaultValueRes && defaultValueRes.startsWith("(") && defaultValueRes.endsWith(")")) {
25346
+ if (typeof internals.tables[tableName] === "undefined") {
25347
+ internals.tables[tableName] = {
25348
+ columns: {
25349
+ [columnName]: {
25350
+ isDefaultAnExpression: true
25351
+ }
25352
+ }
25353
+ };
25354
+ } else {
25355
+ if (typeof internals.tables[tableName].columns[columnName] === "undefined") {
25356
+ internals.tables[tableName].columns[columnName] = {
25357
+ isDefaultAnExpression: true
25358
+ };
25359
+ } else {
25360
+ internals.tables[tableName].columns[columnName].isDefaultAnExpression = true;
25361
+ }
25362
+ }
25363
+ }
25364
+ const isSerial = columnType === "serial";
25365
+ if (columnTypeMapped.startsWith("numeric(")) {
25366
+ columnTypeMapped = columnTypeMapped.replace(",", ", ");
25367
+ }
25324
25368
  if (columnAdditionalDT === "ARRAY") {
25325
25369
  for (let i = 1; i < Number(columnDimensions); i++) {
25326
25370
  columnTypeMapped += "[]";
@@ -25334,7 +25378,7 @@ ${withStyle.errorWarning(
25334
25378
  // filter vectors, but in future we should filter any extension that was installed by user
25335
25379
  columnAdditionalDT === "USER-DEFINED" && !["vector", "geometry"].includes(enumType2) ? enumType2 : columnTypeMapped
25336
25380
  ),
25337
- typeSchema: enumsToReturn[`${tableSchema}.${enumType2}`] !== void 0 ? enumsToReturn[`${tableSchema}.${enumType2}`].schema : void 0,
25381
+ typeSchema: enumsToReturn[`${typeSchema}.${enumType2}`] !== void 0 ? enumsToReturn[`${typeSchema}.${enumType2}`].schema : void 0,
25338
25382
  primaryKey: primaryKey.length === 1 && cprimaryKey.length < 2,
25339
25383
  // default: isSerial ? undefined : defaultValue,
25340
25384
  notNull: columnResponse.is_nullable === "NO",
@@ -25352,7 +25396,7 @@ ${withStyle.errorWarning(
25352
25396
  } : void 0
25353
25397
  };
25354
25398
  if (identityName) {
25355
- delete sequencesToReturn[`${tableSchema}.${identityName}`];
25399
+ delete sequencesToReturn[`${tableSchema}.${identityName.startsWith('"') && identityName.endsWith('"') ? identityName.slice(1, -1) : identityName}`];
25356
25400
  delete sequencesToReturn[identityName];
25357
25401
  }
25358
25402
  if (!isSerial && typeof defaultValue !== "undefined") {
@@ -25505,59 +25549,71 @@ ${withStyle.errorWarning(
25505
25549
  internal: internals
25506
25550
  };
25507
25551
  };
25508
- columnToDefault = {
25509
- "numeric(": "::numeric",
25510
- // text: "::text",
25511
- // "character varying": "::character varying",
25512
- // "double precision": "::double precision",
25513
- // "time with time zone": "::time with time zone",
25514
- "time without time zone": "::time without time zone",
25515
- // "timestamp with time zone": "::timestamp with time zone",
25516
- "timestamp without time zone": "::timestamp without time zone",
25517
- "timestamp(": "::timestamp without time zone",
25518
- // date: "::date",
25519
- // interval: "::interval",
25520
- // character: "::bpchar",
25521
- // macaddr8: "::macaddr8",
25522
- // macaddr: "::macaddr",
25523
- // inet: "::inet",
25524
- // cidr: "::cidr",
25525
- // jsonb: "::jsonb",
25526
- // json: "::json",
25527
- "character(": "::bpchar"
25528
- };
25529
- defaultForColumn = (column4) => {
25552
+ defaultForColumn = (column4, internals, tableName) => {
25553
+ const columnName = column4.attname;
25554
+ const isArray = internals?.tables[tableName]?.columns[columnName]?.isArray ?? false;
25530
25555
  if (column4.column_default === null) {
25531
25556
  return void 0;
25532
25557
  }
25533
25558
  if (column4.data_type === "serial" || column4.data_type === "smallserial" || column4.data_type === "bigserial") {
25534
25559
  return void 0;
25535
25560
  }
25536
- const hasDifferentDefaultCast = Object.keys(columnToDefault).find((it) => column4.data_type.startsWith(it));
25561
+ if (column4.column_default.endsWith("[]")) {
25562
+ column4.column_default = column4.column_default.slice(0, -2);
25563
+ }
25564
+ column4.column_default = column4.column_default.replace(/::(.*?)(?<![^\w"])(?=$)/, "");
25537
25565
  const columnDefaultAsString = column4.column_default.toString();
25538
- if (columnDefaultAsString.endsWith(
25539
- hasDifferentDefaultCast ? columnToDefault[hasDifferentDefaultCast] : column4.data_type
25540
- )) {
25541
- const nonPrefixPart = column4.column_default.length - (hasDifferentDefaultCast ? columnToDefault[hasDifferentDefaultCast] : `::${column4.data_type}`).length - 1;
25542
- const rt = column4.column_default.toString().substring(1, nonPrefixPart);
25543
- if (/^-?[\d.]+(?:e-?\d+)?$/.test(rt) && !column4.data_type.startsWith("numeric")) {
25544
- return Number(rt);
25545
- } else if (column4.data_type === "json" || column4.data_type === "jsonb") {
25546
- const jsonWithoutSpaces = JSON.stringify(JSON.parse(rt));
25547
- return `'${jsonWithoutSpaces}'${hasDifferentDefaultCast ? columnToDefault[hasDifferentDefaultCast] : `::${column4.data_type}`}`;
25548
- } else if (column4.data_type === "boolean") {
25549
- return column4.column_default === "true";
25550
- } else {
25551
- return `'${rt}'`;
25552
- }
25553
- } else {
25554
- if (/^-?[\d.]+(?:e-?\d+)?$/.test(columnDefaultAsString) && !column4.data_type.startsWith("numeric")) {
25566
+ if (isArray) {
25567
+ return `'{${columnDefaultAsString.slice(2, -2).split(/\s*,\s*/g).map((value) => {
25568
+ if (["integer", "smallint", "bigint", "double precision", "real"].includes(column4.data_type.slice(0, -2))) {
25569
+ return value;
25570
+ } else if (column4.data_type.startsWith("timestamp")) {
25571
+ return `${value}`;
25572
+ } else if (column4.data_type.slice(0, -2) === "interval") {
25573
+ return value.replaceAll('"', `"`);
25574
+ } else if (column4.data_type.slice(0, -2) === "boolean") {
25575
+ return value === "t" ? "true" : "false";
25576
+ } else if (["json", "jsonb"].includes(column4.data_type.slice(0, -2))) {
25577
+ return JSON.stringify(JSON.stringify(JSON.parse(JSON.parse(value)), null, 0));
25578
+ } else {
25579
+ return `"${value}"`;
25580
+ }
25581
+ }).join(",")}}'`;
25582
+ }
25583
+ if (["integer", "smallint", "bigint", "double precision", "real"].includes(column4.data_type)) {
25584
+ if (/^-?[\d.]+(?:e-?\d+)?$/.test(columnDefaultAsString)) {
25555
25585
  return Number(columnDefaultAsString);
25556
- } else if (column4.data_type === "boolean") {
25557
- return column4.column_default === "true";
25558
25586
  } else {
25559
- return `${columnDefaultAsString}`;
25587
+ if (typeof internals.tables[tableName] === "undefined") {
25588
+ internals.tables[tableName] = {
25589
+ columns: {
25590
+ [columnName]: {
25591
+ isDefaultAnExpression: true
25592
+ }
25593
+ }
25594
+ };
25595
+ } else {
25596
+ if (typeof internals.tables[tableName].columns[columnName] === "undefined") {
25597
+ internals.tables[tableName].columns[columnName] = {
25598
+ isDefaultAnExpression: true
25599
+ };
25600
+ } else {
25601
+ internals.tables[tableName].columns[columnName].isDefaultAnExpression = true;
25602
+ }
25603
+ }
25604
+ return columnDefaultAsString;
25560
25605
  }
25606
+ } else if (column4.data_type === "json" || column4.data_type === "jsonb") {
25607
+ const jsonWithoutSpaces = JSON.stringify(JSON.parse(columnDefaultAsString.slice(1, -1)));
25608
+ return `'${jsonWithoutSpaces}'::${column4.data_type}`;
25609
+ } else if (column4.data_type === "boolean") {
25610
+ return column4.column_default === "true";
25611
+ } else if (columnDefaultAsString === "NULL") {
25612
+ return `NULL`;
25613
+ } else if (columnDefaultAsString.startsWith("'") && columnDefaultAsString.endsWith("'")) {
25614
+ return columnDefaultAsString;
25615
+ } else {
25616
+ return `${columnDefaultAsString.replace(/\\/g, "`\\")}`;
25561
25617
  }
25562
25618
  };
25563
25619
  }
@@ -33885,9 +33941,9 @@ var init_cli = __esm({
33885
33941
  tablesFilter: unionType([stringType(), stringType().array()]).optional(),
33886
33942
  schemaFilter: unionType([stringType(), stringType().array()]).optional().default(["public"]),
33887
33943
  extensionsFilters: literalType("postgis").array().optional(),
33888
- introspectCasing: casing,
33944
+ casing,
33889
33945
  breakpoints: booleanType().optional().default(true),
33890
- database: objectType({
33946
+ migrations: objectType({
33891
33947
  prefix: prefix.optional().default("index")
33892
33948
  }).optional()
33893
33949
  }).passthrough();
@@ -33981,6 +34037,10 @@ var init_postgres = __esm({
33981
34037
  database: stringType().min(1),
33982
34038
  secretArn: stringType().min(1),
33983
34039
  resourceArn: stringType().min(1)
34040
+ }),
34041
+ objectType({
34042
+ driver: literalType("pglite"),
34043
+ url: stringType().min(1)
33984
34044
  })
33985
34045
  ]);
33986
34046
  }