drizzle-kit 0.20.4 → 0.20.5-c7dc2fe

Sign up to get free protection for your applications and to get access to all the features.
package/bin.cjs CHANGED
@@ -5067,10 +5067,11 @@ var init_pgSchema = __esm({
5067
5067
  return `${fk4.name};${fk4.tableFrom};${fk4.columnsFrom.join(",")};${fk4.tableTo};${fk4.columnsTo.join(",")};${fk4.onUpdate ?? ""};${fk4.onDelete ?? ""}`;
5068
5068
  },
5069
5069
  squashPK: (pk) => {
5070
- return `${pk.columns.join(",")}`;
5070
+ return `${pk.columns.join(",")};${pk.name}`;
5071
5071
  },
5072
5072
  unsquashPK: (pk) => {
5073
- return { name: "", columns: pk.split(",") };
5073
+ const splitted = pk.split(";");
5074
+ return { name: splitted[1], columns: splitted[0].split(",") };
5074
5075
  },
5075
5076
  squashUnique: (unq) => {
5076
5077
  return `${unq.name};${unq.columns.join(",")};${unq.nullsNotDistinct}`;
@@ -12189,8 +12190,8 @@ ${withStyle.errorWarning(`We've found duplicated unique constraint names in ${so
12189
12190
  });
12190
12191
  primaryKeys.map((pk) => {
12191
12192
  const columnNames = pk.columns.map((c) => c.name);
12192
- primaryKeysObject[`${tableName}_${columnNames.join("_")}`] = {
12193
- name: `${tableName}_${columnNames.join("_")}`,
12193
+ primaryKeysObject[pk.getName()] = {
12194
+ name: pk.getName(),
12194
12195
  columns: columnNames
12195
12196
  };
12196
12197
  });
@@ -12474,12 +12475,13 @@ ${withStyle.errorWarning(`We've found duplicated unique constraint names in ${so
12474
12475
  if (cprimaryKey.length > 1) {
12475
12476
  const tableCompositePkName = await db.query(
12476
12477
  `SELECT conname AS primary_key
12477
- FROM pg_constraint
12478
- WHERE contype = 'p'
12479
- AND connamespace = '${tableSchema}'::regnamespace
12480
- AND (conrelid::regclass::text = '"${tableName}"' OR conrelid::regclass::text = '${tableName}');`
12478
+ FROM pg_constraint join pg_class on (pg_class.oid = conrelid)
12479
+ WHERE contype = 'p'
12480
+ AND connamespace = $1::regnamespace
12481
+ AND pg_class.relname = $2;`,
12482
+ [tableSchema, tableName]
12481
12483
  );
12482
- primaryKeys[`${tableName}_${cprimaryKey.map((pk) => pk.column_name).join("_")}`] = {
12484
+ primaryKeys[tableCompositePkName[0].primary_key] = {
12483
12485
  name: tableCompositePkName[0].primary_key,
12484
12486
  columns: cprimaryKey.map((c) => c.column_name)
12485
12487
  };
@@ -16615,9 +16617,9 @@ var init_jsonStatements = __esm({
16615
16617
  schema: schema4,
16616
16618
  columns: Object.values(columns),
16617
16619
  compositePKs: Object.values(compositePrimaryKeys),
16618
- compositePkName: Object.values(compositePrimaryKeys).length > 0 ? json2.tables[name].compositePrimaryKeys[`${name}_${PgSquasher.unsquashPK(
16620
+ compositePkName: Object.values(compositePrimaryKeys).length > 0 ? json2.tables[name].compositePrimaryKeys[`${PgSquasher.unsquashPK(
16619
16621
  Object.values(compositePrimaryKeys)[0]
16620
- ).columns.join("_")}`].name : "",
16622
+ ).name}`].name : "",
16621
16623
  uniqueConstraints: Object.values(uniqueConstraints)
16622
16624
  };
16623
16625
  };
@@ -17085,7 +17087,7 @@ var init_jsonStatements = __esm({
17085
17087
  };
17086
17088
  prepareAddCompositePrimaryKeyPg = (tableName, schema4, pks, json2) => {
17087
17089
  return Object.values(pks).map((it) => {
17088
- const unsquashed = MySqlSquasher.unsquashPK(it);
17090
+ const unsquashed = PgSquasher.unsquashPK(it);
17089
17091
  return {
17090
17092
  type: "create_composite_pk",
17091
17093
  tableName,
@@ -17102,7 +17104,7 @@ var init_jsonStatements = __esm({
17102
17104
  tableName,
17103
17105
  data: it,
17104
17106
  schema: schema4,
17105
- constraintName: json1.tables[tableName].compositePrimaryKeys[`${tableName}_${PgSquasher.unsquashPK(it).columns.join("_")}`].name
17107
+ constraintName: json1.tables[tableName].compositePrimaryKeys[PgSquasher.unsquashPK(it).name].name
17106
17108
  };
17107
17109
  });
17108
17110
  };
@@ -17114,8 +17116,8 @@ var init_jsonStatements = __esm({
17114
17116
  old: it.__old,
17115
17117
  new: it.__new,
17116
17118
  schema: schema4,
17117
- oldConstraintName: json1.tables[tableName].compositePrimaryKeys[`${tableName}_${PgSquasher.unsquashPK(it.__old).columns.join("_")}`].name,
17118
- newConstraintName: json2.tables[tableName].compositePrimaryKeys[`${tableName}_${PgSquasher.unsquashPK(it.__new).columns.join("_")}`].name
17119
+ oldConstraintName: json1.tables[tableName].compositePrimaryKeys[PgSquasher.unsquashPK(it.__old).name].name,
17120
+ newConstraintName: json2.tables[tableName].compositePrimaryKeys[PgSquasher.unsquashPK(it.__new).name].name
17119
17121
  };
17120
17122
  });
17121
17123
  };
@@ -60141,7 +60143,7 @@ init_source();
60141
60143
  // package.json
60142
60144
  var package_default = {
60143
60145
  name: "drizzle-kit",
60144
- version: "0.20.4",
60146
+ version: "0.20.5",
60145
60147
  repository: "https://github.com/drizzle-team/drizzle-kit-mirror",
60146
60148
  author: "Drizzle Team",
60147
60149
  license: "MIT",
@@ -60151,7 +60153,7 @@ var package_default = {
60151
60153
  scripts: {
60152
60154
  "test:pg:push": "drizzle-kit push:pg",
60153
60155
  payload: "tsx ./dev/payload.ts",
60154
- "migrate:old": "drizzle-kit generate:pg --out ./dev/migrations-pg --schema ./dev/migrations-pg/schema.ts",
60156
+ "migrate:old": "drizzle-kit generate:pg --out ./dev/migrations-pg --schema ./dev/migrations-pg/schema2.ts",
60155
60157
  push: "node -r esbuild-register ./src/cli/index.ts push:mysql",
60156
60158
  "push:sqlite": "node -r ./src/loader.mjs ./src/cli/index.ts push:sqlite",
60157
60159
  try1: "tsx ./src/t.ts",
@@ -60202,6 +60204,7 @@ var package_default = {
60202
60204
  camelcase: "^7.0.1",
60203
60205
  chalk: "^5.2.0",
60204
60206
  commander: "^9.4.1",
60207
+ "drizzle-kit": "0.19.13",
60205
60208
  esbuild: "^0.18.6",
60206
60209
  "esbuild-register": "^3.4.2",
60207
60210
  glob: "^8.1.0",
@@ -60226,7 +60229,7 @@ var package_default = {
60226
60229
  "better-sqlite3": "^8.4.0",
60227
60230
  dockerode: "^3.3.4",
60228
60231
  dotenv: "^16.0.3",
60229
- "drizzle-orm": "0.29.0-d3b1c58",
60232
+ "drizzle-orm": "0.29.0",
60230
60233
  "esbuild-node-externals": "^1.9.0",
60231
60234
  eslint: "^8.29.0",
60232
60235
  "eslint-config-prettier": "^8.5.0",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "drizzle-kit",
3
- "version": "0.20.4",
3
+ "version": "0.20.5-c7dc2fe",
4
4
  "repository": "https://github.com/drizzle-team/drizzle-kit-mirror",
5
5
  "author": "Drizzle Team",
6
6
  "license": "MIT",
@@ -10,7 +10,7 @@
10
10
  "scripts": {
11
11
  "test:pg:push": "drizzle-kit push:pg",
12
12
  "payload": "tsx ./dev/payload.ts",
13
- "migrate:old": "drizzle-kit generate:pg --out ./dev/migrations-pg --schema ./dev/migrations-pg/schema.ts",
13
+ "migrate:old": "drizzle-kit generate:pg --out ./dev/migrations-pg --schema ./dev/migrations-pg/schema2.ts",
14
14
  "push": "node -r esbuild-register ./src/cli/index.ts push:mysql",
15
15
  "push:sqlite": "node -r ./src/loader.mjs ./src/cli/index.ts push:sqlite",
16
16
  "try1": "tsx ./src/t.ts",
@@ -61,6 +61,7 @@
61
61
  "camelcase": "^7.0.1",
62
62
  "chalk": "^5.2.0",
63
63
  "commander": "^9.4.1",
64
+ "drizzle-kit": "0.19.13",
64
65
  "esbuild": "^0.18.6",
65
66
  "esbuild-register": "^3.4.2",
66
67
  "glob": "^8.1.0",
@@ -85,7 +86,7 @@
85
86
  "better-sqlite3": "^8.4.0",
86
87
  "dockerode": "^3.3.4",
87
88
  "dotenv": "^16.0.3",
88
- "drizzle-orm": "0.29.0-d3b1c58",
89
+ "drizzle-orm": "0.29.0",
89
90
  "esbuild-node-externals": "^1.9.0",
90
91
  "eslint": "^8.29.0",
91
92
  "eslint-config-prettier": "^8.5.0",
package/utils-studio.js CHANGED
@@ -739,12 +739,13 @@ var init_pgSerializer = __esm({
739
739
  if (cprimaryKey.length > 1) {
740
740
  const tableCompositePkName = await db.query(
741
741
  `SELECT conname AS primary_key
742
- FROM pg_constraint
743
- WHERE contype = 'p'
744
- AND connamespace = '${tableSchema}'::regnamespace
745
- AND (conrelid::regclass::text = '"${tableName}"' OR conrelid::regclass::text = '${tableName}');`
742
+ FROM pg_constraint join pg_class on (pg_class.oid = conrelid)
743
+ WHERE contype = 'p'
744
+ AND connamespace = $1::regnamespace
745
+ AND pg_class.relname = $2;`,
746
+ [tableSchema, tableName]
746
747
  );
747
- primaryKeys[`${tableName}_${cprimaryKey.map((pk) => pk.column_name).join("_")}`] = {
748
+ primaryKeys[tableCompositePkName[0].primary_key] = {
748
749
  name: tableCompositePkName[0].primary_key,
749
750
  columns: cprimaryKey.map((c) => c.column_name)
750
751
  };
package/utils-studio.mjs CHANGED
@@ -771,12 +771,13 @@ var init_pgSerializer = __esm({
771
771
  if (cprimaryKey.length > 1) {
772
772
  const tableCompositePkName = await db.query(
773
773
  `SELECT conname AS primary_key
774
- FROM pg_constraint
775
- WHERE contype = 'p'
776
- AND connamespace = '${tableSchema}'::regnamespace
777
- AND (conrelid::regclass::text = '"${tableName}"' OR conrelid::regclass::text = '${tableName}');`
774
+ FROM pg_constraint join pg_class on (pg_class.oid = conrelid)
775
+ WHERE contype = 'p'
776
+ AND connamespace = $1::regnamespace
777
+ AND pg_class.relname = $2;`,
778
+ [tableSchema, tableName]
778
779
  );
779
- primaryKeys[`${tableName}_${cprimaryKey.map((pk) => pk.column_name).join("_")}`] = {
780
+ primaryKeys[tableCompositePkName[0].primary_key] = {
780
781
  name: tableCompositePkName[0].primary_key,
781
782
  columns: cprimaryKey.map((c) => c.column_name)
782
783
  };
package/utils.js CHANGED
@@ -4974,10 +4974,11 @@ var init_pgSchema = __esm({
4974
4974
  return `${fk4.name};${fk4.tableFrom};${fk4.columnsFrom.join(",")};${fk4.tableTo};${fk4.columnsTo.join(",")};${fk4.onUpdate ?? ""};${fk4.onDelete ?? ""}`;
4975
4975
  },
4976
4976
  squashPK: (pk) => {
4977
- return `${pk.columns.join(",")}`;
4977
+ return `${pk.columns.join(",")};${pk.name}`;
4978
4978
  },
4979
4979
  unsquashPK: (pk) => {
4980
- return { name: "", columns: pk.split(",") };
4980
+ const splitted = pk.split(";");
4981
+ return { name: splitted[1], columns: splitted[0].split(",") };
4981
4982
  },
4982
4983
  squashUnique: (unq) => {
4983
4984
  return `${unq.name};${unq.columns.join(",")};${unq.nullsNotDistinct}`;
@@ -11912,8 +11913,8 @@ ${withStyle.errorWarning(`We've found duplicated unique constraint names in ${so
11912
11913
  });
11913
11914
  primaryKeys.map((pk) => {
11914
11915
  const columnNames = pk.columns.map((c) => c.name);
11915
- primaryKeysObject[`${tableName}_${columnNames.join("_")}`] = {
11916
- name: `${tableName}_${columnNames.join("_")}`,
11916
+ primaryKeysObject[pk.getName()] = {
11917
+ name: pk.getName(),
11917
11918
  columns: columnNames
11918
11919
  };
11919
11920
  });
@@ -12197,12 +12198,13 @@ ${withStyle.errorWarning(`We've found duplicated unique constraint names in ${so
12197
12198
  if (cprimaryKey.length > 1) {
12198
12199
  const tableCompositePkName = await db.query(
12199
12200
  `SELECT conname AS primary_key
12200
- FROM pg_constraint
12201
- WHERE contype = 'p'
12202
- AND connamespace = '${tableSchema}'::regnamespace
12203
- AND (conrelid::regclass::text = '"${tableName}"' OR conrelid::regclass::text = '${tableName}');`
12201
+ FROM pg_constraint join pg_class on (pg_class.oid = conrelid)
12202
+ WHERE contype = 'p'
12203
+ AND connamespace = $1::regnamespace
12204
+ AND pg_class.relname = $2;`,
12205
+ [tableSchema, tableName]
12204
12206
  );
12205
- primaryKeys[`${tableName}_${cprimaryKey.map((pk) => pk.column_name).join("_")}`] = {
12207
+ primaryKeys[tableCompositePkName[0].primary_key] = {
12206
12208
  name: tableCompositePkName[0].primary_key,
12207
12209
  columns: cprimaryKey.map((c) => c.column_name)
12208
12210
  };
@@ -16338,9 +16340,9 @@ var init_jsonStatements = __esm({
16338
16340
  schema: schema4,
16339
16341
  columns: Object.values(columns),
16340
16342
  compositePKs: Object.values(compositePrimaryKeys),
16341
- compositePkName: Object.values(compositePrimaryKeys).length > 0 ? json2.tables[name].compositePrimaryKeys[`${name}_${PgSquasher.unsquashPK(
16343
+ compositePkName: Object.values(compositePrimaryKeys).length > 0 ? json2.tables[name].compositePrimaryKeys[`${PgSquasher.unsquashPK(
16342
16344
  Object.values(compositePrimaryKeys)[0]
16343
- ).columns.join("_")}`].name : "",
16345
+ ).name}`].name : "",
16344
16346
  uniqueConstraints: Object.values(uniqueConstraints)
16345
16347
  };
16346
16348
  };
@@ -16808,7 +16810,7 @@ var init_jsonStatements = __esm({
16808
16810
  };
16809
16811
  prepareAddCompositePrimaryKeyPg = (tableName, schema4, pks, json2) => {
16810
16812
  return Object.values(pks).map((it) => {
16811
- const unsquashed = MySqlSquasher.unsquashPK(it);
16813
+ const unsquashed = PgSquasher.unsquashPK(it);
16812
16814
  return {
16813
16815
  type: "create_composite_pk",
16814
16816
  tableName,
@@ -16825,7 +16827,7 @@ var init_jsonStatements = __esm({
16825
16827
  tableName,
16826
16828
  data: it,
16827
16829
  schema: schema4,
16828
- constraintName: json1.tables[tableName].compositePrimaryKeys[`${tableName}_${PgSquasher.unsquashPK(it).columns.join("_")}`].name
16830
+ constraintName: json1.tables[tableName].compositePrimaryKeys[PgSquasher.unsquashPK(it).name].name
16829
16831
  };
16830
16832
  });
16831
16833
  };
@@ -16837,8 +16839,8 @@ var init_jsonStatements = __esm({
16837
16839
  old: it.__old,
16838
16840
  new: it.__new,
16839
16841
  schema: schema4,
16840
- oldConstraintName: json1.tables[tableName].compositePrimaryKeys[`${tableName}_${PgSquasher.unsquashPK(it.__old).columns.join("_")}`].name,
16841
- newConstraintName: json2.tables[tableName].compositePrimaryKeys[`${tableName}_${PgSquasher.unsquashPK(it.__new).columns.join("_")}`].name
16842
+ oldConstraintName: json1.tables[tableName].compositePrimaryKeys[PgSquasher.unsquashPK(it.__old).name].name,
16843
+ newConstraintName: json2.tables[tableName].compositePrimaryKeys[PgSquasher.unsquashPK(it.__new).name].name
16842
16844
  };
16843
16845
  });
16844
16846
  };