pgterra 0.2.9 → 0.2.10

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 +20 -3
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -21340,7 +21340,7 @@ function extractAllConstraints(tableElts, tableName) {
21340
21340
  checkConstraints.push(check);
21341
21341
  } else if (contype === "CONSTR_UNIQUE") {
21342
21342
  uniqueConstraints.push({
21343
- name: c.Constraint.conname || `${colName}_unique`,
21343
+ name: c.Constraint.conname,
21344
21344
  columns: [colName]
21345
21345
  });
21346
21346
  } else if (contype === "CONSTR_FOREIGN") {
@@ -25031,6 +25031,23 @@ class SchemaDiffer {
25031
25031
  if (alterations.length === 0) {
25032
25032
  return "";
25033
25033
  }
25034
+ const operationPriority = {
25035
+ drop_foreign_key: 0,
25036
+ drop_unique: 1,
25037
+ drop_check: 2,
25038
+ drop_primary_key: 3,
25039
+ drop_column: 4,
25040
+ alter_column_type: 10,
25041
+ alter_column_set_default: 11,
25042
+ alter_column_drop_default: 12,
25043
+ alter_column_set_not_null: 13,
25044
+ alter_column_drop_not_null: 14,
25045
+ add_column: 20,
25046
+ add_primary_key: 21,
25047
+ add_check: 22,
25048
+ add_unique: 23,
25049
+ add_foreign_key: 24
25050
+ };
25034
25051
  const sorted = [...alterations].sort((a, b) => {
25035
25052
  const isADrop = a.type.startsWith("drop_");
25036
25053
  const isBDrop = b.type.startsWith("drop_");
@@ -25038,7 +25055,7 @@ class SchemaDiffer {
25038
25055
  return -1;
25039
25056
  if (!isADrop && isBDrop)
25040
25057
  return 1;
25041
- return 0;
25058
+ return (operationPriority[a.type] ?? 99) - (operationPriority[b.type] ?? 99);
25042
25059
  });
25043
25060
  const builder = new SQLBuilder().p("ALTER TABLE").table(table.name, table.schema);
25044
25061
  builder.indentIn();
@@ -25929,7 +25946,7 @@ async function applyCommand(options, config) {
25929
25946
  // package.json
25930
25947
  var package_default = {
25931
25948
  name: "pgterra",
25932
- version: "0.2.9",
25949
+ version: "0.2.10",
25933
25950
  description: "Declarative schema management for Postgres",
25934
25951
  keywords: [
25935
25952
  "postgres",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pgterra",
3
- "version": "0.2.9",
3
+ "version": "0.2.10",
4
4
  "description": "Declarative schema management for Postgres",
5
5
  "keywords": [
6
6
  "postgres",