pgterra 0.2.6 → 0.2.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +7 -17
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -24775,14 +24775,9 @@ class SchemaDiffer {
24775
24775
  }
24776
24776
  generateForeignKeyStatements(tableName, desiredConstraints, currentConstraints, droppedColumns = new Set) {
24777
24777
  const statements = [];
24778
- const currentMap = new Map(currentConstraints.map((c) => [
24779
- c.name || `fk_${c.columns.join("_")}_${c.referencedTable}`,
24780
- c
24781
- ]));
24782
- const desiredMap = new Map(desiredConstraints.map((c) => [
24783
- c.name || `fk_${c.columns.join("_")}_${c.referencedTable}`,
24784
- c
24785
- ]));
24778
+ const getFkStructuralKey = (c) => `${c.columns.join(",")}->${c.referencedTable}.${c.referencedColumns.join(",")}`;
24779
+ const currentMap = new Map(currentConstraints.map((c) => [getFkStructuralKey(c), c]));
24780
+ const desiredMap = new Map(desiredConstraints.map((c) => [getFkStructuralKey(c), c]));
24786
24781
  for (const [key, constraint] of currentMap) {
24787
24782
  if (!desiredMap.has(key)) {
24788
24783
  const dependsOnDroppedColumn = constraint.columns.some((col) => droppedColumns.has(col));
@@ -24979,14 +24974,9 @@ class SchemaDiffer {
24979
24974
  }
24980
24975
  }
24981
24976
  collectForeignKeyAlterations(desiredConstraints, currentConstraints, droppedColumns, alterations) {
24982
- const currentMap = new Map(currentConstraints.map((c) => [
24983
- c.name || `fk_${c.columns.join("_")}_${c.referencedTable}`,
24984
- c
24985
- ]));
24986
- const desiredMap = new Map(desiredConstraints.map((c) => [
24987
- c.name || `fk_${c.columns.join("_")}_${c.referencedTable}`,
24988
- c
24989
- ]));
24977
+ const getFkStructuralKey = (c) => `${c.columns.join(",")}->${c.referencedTable}.${c.referencedColumns.join(",")}`;
24978
+ const currentMap = new Map(currentConstraints.map((c) => [getFkStructuralKey(c), c]));
24979
+ const desiredMap = new Map(desiredConstraints.map((c) => [getFkStructuralKey(c), c]));
24990
24980
  for (const [key, constraint] of currentMap) {
24991
24981
  if (!desiredMap.has(key)) {
24992
24982
  const dependsOnDroppedColumn = constraint.columns.some((col) => droppedColumns.has(col));
@@ -25944,7 +25934,7 @@ async function applyCommand(options, config) {
25944
25934
  // package.json
25945
25935
  var package_default = {
25946
25936
  name: "pgterra",
25947
- version: "0.2.6",
25937
+ version: "0.2.7",
25948
25938
  description: "Declarative schema management for Postgres",
25949
25939
  keywords: [
25950
25940
  "postgres",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pgterra",
3
- "version": "0.2.6",
3
+ "version": "0.2.7",
4
4
  "description": "Declarative schema management for Postgres",
5
5
  "keywords": [
6
6
  "postgres",