drizzle-kit 0.20.10-b4cd19e → 0.20.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. package/bin.cjs +5 -4
  2. package/package.json +1 -1
  3. package/utils.js +5 -4
package/bin.cjs CHANGED
@@ -12323,7 +12323,7 @@ ${withStyle.errorWarning(`We've found duplicated unique constraint names in ${so
12323
12323
  name,
12324
12324
  tableFrom,
12325
12325
  tableTo,
12326
- schemaTo,
12326
+ schemaTo: schemaTo ?? "public",
12327
12327
  columnsFrom,
12328
12328
  columnsTo,
12329
12329
  onDelete,
@@ -16186,7 +16186,7 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
16186
16186
  const fromColumnsString = columnsFrom.map((it) => `"${it}"`).join(",");
16187
16187
  const toColumnsString = columnsTo.map((it) => `"${it}"`).join(",");
16188
16188
  const tableNameWithSchema = statement.schema ? `"${statement.schema}"."${tableFrom}"` : `"${tableFrom}"`;
16189
- const tableToNameWithSchema = statement.schema ? `"${schemaTo}"."${tableTo}"` : `"${tableTo}"`;
16189
+ const tableToNameWithSchema = schemaTo ? `"${schemaTo}"."${tableTo}"` : `"${tableTo}"`;
16190
16190
  const alterStatement = `ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT "${name}" FOREIGN KEY (${fromColumnsString}) REFERENCES ${tableToNameWithSchema}(${toColumnsString})${onDeleteStatement}${onUpdateStatement}`;
16191
16191
  let sql2 = "DO $$ BEGIN\n";
16192
16192
  sql2 += " " + alterStatement + ";\n";
@@ -16245,8 +16245,9 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
16245
16245
  const onUpdateStatement = newFk.onUpdate ? ` ON UPDATE ${newFk.onUpdate}` : "";
16246
16246
  const fromColumnsString = newFk.columnsFrom.map((it) => `"${it}"`).join(",");
16247
16247
  const toColumnsString = newFk.columnsTo.map((it) => `"${it}"`).join(",");
16248
- const tableFromNameWithSchema = statement.schema ? `"${statement.schema}"."${newFk.tableFrom}"` : `"${newFk.tableFrom}"`;
16249
- const alterStatement = `ALTER TABLE ${tableFromNameWithSchema} ADD CONSTRAINT "${newFk.name}" FOREIGN KEY (${fromColumnsString}) REFERENCES "${newFk.tableTo}"(${toColumnsString})${onDeleteStatement}${onUpdateStatement}`;
16248
+ const tableFromNameWithSchema = oldFk.schemaTo ? `"${oldFk.schemaTo}"."${oldFk.tableFrom}"` : `"${oldFk.tableFrom}"`;
16249
+ const tableToNameWithSchema = newFk.schemaTo ? `"${newFk.schemaTo}"."${newFk.tableFrom}"` : `"${newFk.tableFrom}"`;
16250
+ const alterStatement = `ALTER TABLE ${tableFromNameWithSchema} ADD CONSTRAINT "${newFk.name}" FOREIGN KEY (${fromColumnsString}) REFERENCES ${tableToNameWithSchema}(${toColumnsString})${onDeleteStatement}${onUpdateStatement}`;
16250
16251
  sql2 += "DO $$ BEGIN\n";
16251
16252
  sql2 += " " + alterStatement + ";\n";
16252
16253
  sql2 += "EXCEPTION\n";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "drizzle-kit",
3
- "version": "0.20.10-b4cd19e",
3
+ "version": "0.20.10",
4
4
  "repository": "https://github.com/drizzle-team/drizzle-kit-mirror",
5
5
  "author": "Drizzle Team",
6
6
  "license": "MIT",
package/utils.js CHANGED
@@ -12048,7 +12048,7 @@ ${withStyle.errorWarning(`We've found duplicated unique constraint names in ${so
12048
12048
  name,
12049
12049
  tableFrom,
12050
12050
  tableTo,
12051
- schemaTo,
12051
+ schemaTo: schemaTo ?? "public",
12052
12052
  columnsFrom,
12053
12053
  columnsTo,
12054
12054
  onDelete,
@@ -15903,7 +15903,7 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
15903
15903
  const fromColumnsString = columnsFrom.map((it) => `"${it}"`).join(",");
15904
15904
  const toColumnsString = columnsTo.map((it) => `"${it}"`).join(",");
15905
15905
  const tableNameWithSchema = statement.schema ? `"${statement.schema}"."${tableFrom}"` : `"${tableFrom}"`;
15906
- const tableToNameWithSchema = statement.schema ? `"${schemaTo}"."${tableTo}"` : `"${tableTo}"`;
15906
+ const tableToNameWithSchema = schemaTo ? `"${schemaTo}"."${tableTo}"` : `"${tableTo}"`;
15907
15907
  const alterStatement = `ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT "${name}" FOREIGN KEY (${fromColumnsString}) REFERENCES ${tableToNameWithSchema}(${toColumnsString})${onDeleteStatement}${onUpdateStatement}`;
15908
15908
  let sql2 = "DO $$ BEGIN\n";
15909
15909
  sql2 += " " + alterStatement + ";\n";
@@ -15962,8 +15962,9 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
15962
15962
  const onUpdateStatement = newFk.onUpdate ? ` ON UPDATE ${newFk.onUpdate}` : "";
15963
15963
  const fromColumnsString = newFk.columnsFrom.map((it) => `"${it}"`).join(",");
15964
15964
  const toColumnsString = newFk.columnsTo.map((it) => `"${it}"`).join(",");
15965
- const tableFromNameWithSchema = statement.schema ? `"${statement.schema}"."${newFk.tableFrom}"` : `"${newFk.tableFrom}"`;
15966
- const alterStatement = `ALTER TABLE ${tableFromNameWithSchema} ADD CONSTRAINT "${newFk.name}" FOREIGN KEY (${fromColumnsString}) REFERENCES "${newFk.tableTo}"(${toColumnsString})${onDeleteStatement}${onUpdateStatement}`;
15965
+ const tableFromNameWithSchema = oldFk.schemaTo ? `"${oldFk.schemaTo}"."${oldFk.tableFrom}"` : `"${oldFk.tableFrom}"`;
15966
+ const tableToNameWithSchema = newFk.schemaTo ? `"${newFk.schemaTo}"."${newFk.tableFrom}"` : `"${newFk.tableFrom}"`;
15967
+ const alterStatement = `ALTER TABLE ${tableFromNameWithSchema} ADD CONSTRAINT "${newFk.name}" FOREIGN KEY (${fromColumnsString}) REFERENCES ${tableToNameWithSchema}(${toColumnsString})${onDeleteStatement}${onUpdateStatement}`;
15967
15968
  sql2 += "DO $$ BEGIN\n";
15968
15969
  sql2 += " " + alterStatement + ";\n";
15969
15970
  sql2 += "EXCEPTION\n";