drizzle-kit 0.23.2-ab12f1d → 0.23.2-d486e9b

Sign up to get free protection for your applications and to get access to all the features.
Files changed (6) hide show
  1. package/api.js +438 -394
  2. package/api.mjs +438 -394
  3. package/bin.cjs +36 -3
  4. package/package.json +2 -2
  5. package/utils.js +5 -0
  6. package/utils.mjs +4 -0
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"() {
@@ -17680,7 +17683,6 @@ var init_utils4 = __esm({
17680
17683
  const defaultJsonConfigExists = (0, import_fs2.existsSync)(
17681
17684
  (0, import_path2.join)((0, import_path2.resolve)("drizzle.config.json"))
17682
17685
  );
17683
- console.log("defaultTsConfigExists", (0, import_path2.join)((0, import_path2.resolve)("drizzle.config.ts")));
17684
17686
  const defaultConfigPath = defaultTsConfigExists ? "drizzle.config.ts" : defaultJsConfigExists ? "drizzle.config.js" : "drizzle.config.json";
17685
17687
  if (!configPath) {
17686
17688
  console.log(
@@ -18108,7 +18110,7 @@ We have encountered a collision between the index name on columns ${source_defau
18108
18110
  onUpdate = true;
18109
18111
  }
18110
18112
  const newColumn = {
18111
- 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}'`,
18112
18114
  autoincrement: isAutoincrement,
18113
18115
  name: columnName,
18114
18116
  type: changedType,
@@ -18407,6 +18409,30 @@ function minRangeForIdentityBasedOn(columnType) {
18407
18409
  function stringFromDatabaseIdentityProperty(field) {
18408
18410
  return typeof field === "string" ? field : typeof field === "undefined" ? void 0 : typeof field === "bigint" ? field.toString() : String(field);
18409
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
+ }
18410
18436
  var import_drizzle_orm5, import_pg_core2, import_pg_core3, dialect5, indexName2, generatePgSnapshot, trimChar, fromDatabase2, columnToDefault, defaultForColumn;
18411
18437
  var init_pgSerializer = __esm({
18412
18438
  "src/serializer/pgSerializer.ts"() {
@@ -18417,6 +18443,7 @@ var init_pgSerializer = __esm({
18417
18443
  import_pg_core3 = require("drizzle-orm/pg-core");
18418
18444
  init_vector();
18419
18445
  init_outputs();
18446
+ init_utils();
18420
18447
  init_serializer();
18421
18448
  dialect5 = new import_pg_core2.PgDialect();
18422
18449
  indexName2 = (tableName, columns) => {
@@ -18525,6 +18552,11 @@ ${withStyle.errorWarning(`We've found duplicated unique constraint names in ${so
18525
18552
  } else {
18526
18553
  columnToSet.default = `'${column7.default.toISOString()}'`;
18527
18554
  }
18555
+ } else if (isPgArrayType(sqlTypeLowered) && Array.isArray(column7.default)) {
18556
+ columnToSet.default = `'${buildArrayString(
18557
+ column7.default,
18558
+ sqlTypeLowered
18559
+ )}'::${sqlTypeLowered}`;
18528
18560
  } else {
18529
18561
  columnToSet.default = column7.default;
18530
18562
  }
@@ -75266,6 +75298,7 @@ var init_introspect_mysql = __esm({
75266
75298
  patched = patched.startsWith("datetime(") ? "datetime" : patched;
75267
75299
  patched = patched.startsWith("varbinary(") ? "varbinary" : patched;
75268
75300
  patched = patched.startsWith("int(") ? "int" : patched;
75301
+ patched = patched.startsWith("double(") ? "double" : patched;
75269
75302
  return patched;
75270
75303
  }).filter((type) => {
75271
75304
  return mysqlImportsList.has(type);
@@ -83370,7 +83403,7 @@ init_utils2();
83370
83403
  var version2 = async () => {
83371
83404
  const { npmVersion } = await ormCoreVersions();
83372
83405
  const ormVersion = npmVersion ? `drizzle-orm: v${npmVersion}` : "";
83373
- const envVersion = "0.23.2-ab12f1d";
83406
+ const envVersion = "0.23.2-d486e9b";
83374
83407
  const kitVersion = envVersion ? `v${envVersion}` : "--";
83375
83408
  const versions = `drizzle-kit: ${kitVersion}
83376
83409
  ${ormVersion}`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "drizzle-kit",
3
- "version": "0.23.2-ab12f1d",
3
+ "version": "0.23.2-d486e9b",
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,