drizzle-kit 0.23.2-eddab2e → 0.24.0-6205f01

Sign up to get free protection for your applications and to get access to all the features.
package/bin.cjs CHANGED
@@ -6561,6 +6561,9 @@ var init_sqliteSchema = __esm({
6561
6561
  });
6562
6562
 
6563
6563
  // src/utils.ts
6564
+ function isPgArrayType(sqlType) {
6565
+ return sqlType.match(/.*\[\d*\].*|.*\[\].*/g) !== null;
6566
+ }
6564
6567
  var import_fs, import_path, import_url, copy, objectValues, assertV1OutFolder, dryJournal, prepareOutFolder, validatorForDialect, validateWithReport, prepareMigrationFolder, prepareMigrationMeta, schemaRenameKey, tableRenameKey, columnRenameKey, normaliseSQLiteUrl;
6565
6568
  var init_utils = __esm({
6566
6569
  "src/utils.ts"() {
@@ -18107,7 +18110,7 @@ We have encountered a collision between the index name on columns ${source_defau
18107
18110
  onUpdate = true;
18108
18111
  }
18109
18112
  const newColumn = {
18110
- default: columnDefault === null ? void 0 : /^-?[\d.]+(?:e-?\d+)?$/.test(columnDefault) && !columnType.startsWith("decimal") ? Number(columnDefault) : isDefaultAnExpression ? clearDefaults(columnDefault, collation) : `'${columnDefault}'`,
18113
+ default: columnDefault === null ? void 0 : /^-?[\d.]+(?:e-?\d+)?$/.test(columnDefault) && !["decimal", "char", "varchar"].some((type) => columnType.startsWith(type)) ? Number(columnDefault) : isDefaultAnExpression ? clearDefaults(columnDefault, collation) : `'${columnDefault}'`,
18111
18114
  autoincrement: isAutoincrement,
18112
18115
  name: columnName,
18113
18116
  type: changedType,
@@ -18406,6 +18409,30 @@ function minRangeForIdentityBasedOn(columnType) {
18406
18409
  function stringFromDatabaseIdentityProperty(field) {
18407
18410
  return typeof field === "string" ? field : typeof field === "undefined" ? void 0 : typeof field === "bigint" ? field.toString() : String(field);
18408
18411
  }
18412
+ function buildArrayString(array, sqlType) {
18413
+ sqlType = sqlType.split("[")[0];
18414
+ const values = array.map((value) => {
18415
+ if (typeof value === "number" || typeof value === "bigint") {
18416
+ return value.toString();
18417
+ } else if (typeof value === "boolean") {
18418
+ return value ? "true" : "false";
18419
+ } else if (Array.isArray(value)) {
18420
+ return buildArrayString(value, sqlType);
18421
+ } else if (value instanceof Date) {
18422
+ if (sqlType === "date") {
18423
+ return `"${value.toISOString().split("T")[0]}"`;
18424
+ } else if (sqlType === "timestamp") {
18425
+ return `"${value.toISOString().replace("T", " ").slice(0, 23)}"`;
18426
+ } else {
18427
+ return `"${value.toISOString()}"`;
18428
+ }
18429
+ } else if (typeof value === "object") {
18430
+ return `"${JSON.stringify(value).replaceAll('"', '\\"')}"`;
18431
+ }
18432
+ return `"${value}"`;
18433
+ }).join(",");
18434
+ return `{${values}}`;
18435
+ }
18409
18436
  var import_drizzle_orm5, import_pg_core2, import_pg_core3, dialect5, indexName2, generatePgSnapshot, trimChar, fromDatabase2, columnToDefault, defaultForColumn;
18410
18437
  var init_pgSerializer = __esm({
18411
18438
  "src/serializer/pgSerializer.ts"() {
@@ -18416,6 +18443,7 @@ var init_pgSerializer = __esm({
18416
18443
  import_pg_core3 = require("drizzle-orm/pg-core");
18417
18444
  init_vector();
18418
18445
  init_outputs();
18446
+ init_utils();
18419
18447
  init_serializer();
18420
18448
  dialect5 = new import_pg_core2.PgDialect();
18421
18449
  indexName2 = (tableName, columns) => {
@@ -18524,6 +18552,11 @@ ${withStyle.errorWarning(`We've found duplicated unique constraint names in ${so
18524
18552
  } else {
18525
18553
  columnToSet.default = `'${column7.default.toISOString()}'`;
18526
18554
  }
18555
+ } else if (isPgArrayType(sqlTypeLowered) && Array.isArray(column7.default)) {
18556
+ columnToSet.default = `'${buildArrayString(
18557
+ column7.default,
18558
+ sqlTypeLowered
18559
+ )}'::${sqlTypeLowered}`;
18527
18560
  } else {
18528
18561
  columnToSet.default = column7.default;
18529
18562
  }
@@ -19570,7 +19603,7 @@ The unique constraint ${source_default.underline.blue(
19570
19603
  primaryKeys.forEach((it) => {
19571
19604
  if (it.columns.length > 1) {
19572
19605
  primaryKeysObject[it.getName()] = {
19573
- columns: it.columns.map((it2) => it2.name).sort(),
19606
+ columns: it.columns.map((it2) => it2.name),
19574
19607
  name: it.getName()
19575
19608
  };
19576
19609
  } else {
@@ -19696,7 +19729,6 @@ The unique constraint ${source_default.underline.blue(
19696
19729
  }
19697
19730
  for (const [key, value] of Object.entries(tableToPk)) {
19698
19731
  if (value.length > 1) {
19699
- value.sort();
19700
19732
  result[key].compositePrimaryKeys = {
19701
19733
  [`${key}_${value.join("_")}_pk`]: {
19702
19734
  columns: value,
@@ -75265,6 +75297,7 @@ var init_introspect_mysql = __esm({
75265
75297
  patched = patched.startsWith("datetime(") ? "datetime" : patched;
75266
75298
  patched = patched.startsWith("varbinary(") ? "varbinary" : patched;
75267
75299
  patched = patched.startsWith("int(") ? "int" : patched;
75300
+ patched = patched.startsWith("double(") ? "double" : patched;
75268
75301
  return patched;
75269
75302
  }).filter((type) => {
75270
75303
  return mysqlImportsList.has(type);
@@ -83369,7 +83402,7 @@ init_utils2();
83369
83402
  var version2 = async () => {
83370
83403
  const { npmVersion } = await ormCoreVersions();
83371
83404
  const ormVersion = npmVersion ? `drizzle-orm: v${npmVersion}` : "";
83372
- const envVersion = "0.23.2-eddab2e";
83405
+ const envVersion = "0.24.0-6205f01";
83373
83406
  const kitVersion = envVersion ? `v${envVersion}` : "--";
83374
83407
  const versions = `drizzle-kit: ${kitVersion}
83375
83408
  ${ormVersion}`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "drizzle-kit",
3
- "version": "0.23.2-eddab2e",
3
+ "version": "0.24.0-6205f01",
4
4
  "homepage": "https://orm.drizzle.team",
5
5
  "keywords": [
6
6
  "drizzle",
@@ -80,7 +80,7 @@
80
80
  "dockerode": "^3.3.4",
81
81
  "dotenv": "^16.0.3",
82
82
  "drizzle-kit": "0.21.2",
83
- "drizzle-orm": "0.32.1",
83
+ "drizzle-orm": "workspace:./drizzle-orm/dist",
84
84
  "env-paths": "^3.0.0",
85
85
  "esbuild-node-externals": "^1.9.0",
86
86
  "eslint": "^8.57.0",
package/utils.js CHANGED
@@ -568,6 +568,7 @@ __export(utils_exports, {
568
568
  columnRenameKey: () => columnRenameKey,
569
569
  copy: () => copy,
570
570
  dryJournal: () => dryJournal,
571
+ isPgArrayType: () => isPgArrayType,
571
572
  kloudMeta: () => kloudMeta,
572
573
  normaliseSQLiteUrl: () => normaliseSQLiteUrl,
573
574
  objectValues: () => objectValues,
@@ -5738,12 +5739,16 @@ var normaliseSQLiteUrl = (it, type) => {
5738
5739
  }
5739
5740
  assertUnreachable(type);
5740
5741
  };
5742
+ function isPgArrayType(sqlType) {
5743
+ return sqlType.match(/.*\[\d*\].*|.*\[\].*/g) !== null;
5744
+ }
5741
5745
  // Annotate the CommonJS export names for ESM import in node:
5742
5746
  0 && (module.exports = {
5743
5747
  assertV1OutFolder,
5744
5748
  columnRenameKey,
5745
5749
  copy,
5746
5750
  dryJournal,
5751
+ isPgArrayType,
5747
5752
  kloudMeta,
5748
5753
  normaliseSQLiteUrl,
5749
5754
  objectValues,
package/utils.mjs CHANGED
@@ -5720,11 +5720,15 @@ var normaliseSQLiteUrl = (it, type) => {
5720
5720
  }
5721
5721
  assertUnreachable(type);
5722
5722
  };
5723
+ function isPgArrayType(sqlType) {
5724
+ return sqlType.match(/.*\[\d*\].*|.*\[\].*/g) !== null;
5725
+ }
5723
5726
  export {
5724
5727
  assertV1OutFolder,
5725
5728
  columnRenameKey,
5726
5729
  copy,
5727
5730
  dryJournal,
5731
+ isPgArrayType,
5728
5732
  kloudMeta,
5729
5733
  normaliseSQLiteUrl,
5730
5734
  objectValues,