@akal/supaforge 0.0.33 → 0.0.34
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.
- package/README.md +39 -2
- package/dist/base-command.js +4 -3
- package/dist/{chunk-DMIWAJRB.js → chunk-3WKWPSFN.js} +6 -6
- package/dist/{chunk-GZREXCQZ.js → chunk-5STH2A6K.js} +17 -10
- package/dist/{chunk-6LJERPUN.js → chunk-6ERVCWLY.js} +20 -12
- package/dist/{chunk-GEHPTPNZ.js → chunk-7DL63NWP.js} +3 -3
- package/dist/{chunk-UWAVXC57.js → chunk-DQJSSTIJ.js} +39 -15
- package/dist/{chunk-ORQJVE57.js → chunk-EFKQOQGG.js} +15 -16
- package/dist/{chunk-7NAZGZPV.js → chunk-F46FFUKC.js} +16 -17
- package/dist/chunk-GQPGH6YR.js +50 -0
- package/dist/{chunk-6Q7MHFBM.js → chunk-HNJ6BNNZ.js} +2 -2
- package/dist/{chunk-MIRLB5JM.js → chunk-ICSCHS72.js} +66 -14
- package/dist/{chunk-6WAMNZLO.js → chunk-KNXHLVF7.js} +126 -4
- package/dist/{chunk-SQPCWGQO.js → chunk-MG3SFV5J.js} +22 -121
- package/dist/{chunk-BUOWHE36.js → chunk-N5VNNOA2.js} +37 -52
- package/dist/{chunk-3HGAV5CC.js → chunk-OB5GP7UB.js} +19 -16
- package/dist/{chunk-4IVN7QVY.js → chunk-PYAGSMFB.js} +23 -15
- package/dist/{chunk-SC2XHGIS.js → chunk-S5L4A3UR.js} +3 -3
- package/dist/{chunk-2SELREHW.js → chunk-TPX2MAO4.js} +7 -9
- package/dist/{chunk-NTUASFQ3.js → chunk-V2SBZERO.js} +4 -4
- package/dist/{chunk-G2DIPIYU.js → chunk-WK5YTINL.js} +29 -2
- package/dist/{chunk-BLKJWDTL.js → chunk-ZI435CAU.js} +2 -2
- package/dist/commands/clone.js +11 -11
- package/dist/commands/diff.d.ts +13 -1
- package/dist/commands/diff.js +19 -16
- package/dist/commands/hukam.js +15 -14
- package/dist/commands/init.js +5 -1
- package/dist/commands/mcp.js +15 -9
- package/dist/commands/migrate/baseline.js +5 -4
- package/dist/commands/migrate/create.js +8 -7
- package/dist/commands/migrate/list.js +6 -5
- package/dist/commands/migrate/run.js +8 -7
- package/dist/commands/report.js +5 -4
- package/dist/commands/restore.js +13 -12
- package/dist/commands/snapshot.d.ts +7 -0
- package/dist/commands/snapshot.js +36 -8
- package/dist/commands/sync.js +15 -14
- package/dist/index.js +14 -14
- package/package.json +2 -2
|
@@ -1,19 +1,17 @@
|
|
|
1
1
|
import {
|
|
2
2
|
splitSqlStatements
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-WK5YTINL.js";
|
|
4
4
|
import {
|
|
5
5
|
escapeRegex
|
|
6
6
|
} from "./chunk-DQQ5E563.js";
|
|
7
|
-
import {
|
|
8
|
-
DiagnosticError,
|
|
9
|
-
errMsg,
|
|
10
|
-
friendlyDbError
|
|
11
|
-
} from "./chunk-SQPCWGQO.js";
|
|
12
7
|
import {
|
|
13
8
|
DBDIFF_EXEC_TIMEOUT_MS,
|
|
14
9
|
DBDIFF_MAX_BUFFER,
|
|
10
|
+
DiagnosticError,
|
|
11
|
+
errMsg,
|
|
12
|
+
friendlyDbError,
|
|
15
13
|
schemaDiffIgnores
|
|
16
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-KNXHLVF7.js";
|
|
17
15
|
|
|
18
16
|
// src/dbdiff.ts
|
|
19
17
|
import { execFile } from "child_process";
|
|
@@ -412,7 +410,8 @@ var REPLACING_KINDS = {
|
|
|
412
410
|
AlterPolicy: "policy",
|
|
413
411
|
AlterTrigger: "trigger",
|
|
414
412
|
AlterView: "view",
|
|
415
|
-
AlterMatView: "view"
|
|
413
|
+
AlterMatView: "view",
|
|
414
|
+
AlterCollation: "collation"
|
|
416
415
|
};
|
|
417
416
|
|
|
418
417
|
// src/dbdiff.ts
|
|
@@ -585,7 +584,7 @@ var UP_MARKER = "-- ==================== UP ====================";
|
|
|
585
584
|
var DOWN_MARKER = "-- ==================== DOWN ====================";
|
|
586
585
|
var CREATE_FUNCTION = "create-function";
|
|
587
586
|
var DROP_FUNCTION = "drop-function";
|
|
588
|
-
var DROP_TYPES = ["drop", "drop-view", DROP_FUNCTION, "drop-trigger", "drop-type", "drop-sequence"];
|
|
587
|
+
var DROP_TYPES = ["drop", "drop-view", DROP_FUNCTION, "drop-trigger", "drop-type", "drop-sequence", "drop-collation"];
|
|
589
588
|
function isDestructiveSql(sql) {
|
|
590
589
|
return destructiveReason(sql) !== void 0;
|
|
591
590
|
}
|
|
@@ -789,8 +788,10 @@ function isCrossSchemaFkUnit(up, down, schemas, ignoredSchemaTables) {
|
|
|
789
788
|
}
|
|
790
789
|
function replacedObject(unit, statements) {
|
|
791
790
|
const kind = REPLACING_KINDS[unit.kind];
|
|
791
|
+
if (!kind) return void 0;
|
|
792
|
+
if (kind === "view") return replacedView(unit, statements);
|
|
792
793
|
const drop = statements.find((sql) => replaceablePart(sql)?.drop);
|
|
793
|
-
if (!
|
|
794
|
+
if (!drop) return void 0;
|
|
794
795
|
if (kind === "type") return { kind, name: unit.object };
|
|
795
796
|
const create = [...statements].reverse().find((sql) => replaceablePart(sql)?.drop === false) ?? drop;
|
|
796
797
|
return {
|
|
@@ -798,6 +799,15 @@ function replacedObject(unit, statements) {
|
|
|
798
799
|
name: kind === "routine" ? extractRoutineName(create) + extractRoutineArgs(drop) : REPLACEABLE_NAME[kind](create)
|
|
799
800
|
};
|
|
800
801
|
}
|
|
802
|
+
function replacedView(unit, statements) {
|
|
803
|
+
const views = statements.filter((sql) => replaceablePart(sql)?.kind === "view");
|
|
804
|
+
const own = (sql) => bareName2(REPLACEABLE_NAME.view(sql)) === bareName2(unit.object);
|
|
805
|
+
const create = views.find((sql) => replaceablePart(sql)?.drop === false && own(sql)) ?? views.filter((sql) => replaceablePart(sql)?.drop === false).pop();
|
|
806
|
+
const drop = views.find((sql) => replaceablePart(sql)?.drop && own(sql)) ?? views.find((sql) => replaceablePart(sql)?.drop);
|
|
807
|
+
const named2 = create ?? drop;
|
|
808
|
+
return named2 ? { kind: "view", name: REPLACEABLE_NAME.view(named2) } : void 0;
|
|
809
|
+
}
|
|
810
|
+
var bareName2 = (name) => name.slice(name.lastIndexOf(".") + 1).replace(/"/g, "").toLowerCase();
|
|
801
811
|
function leadStatement(unit, statements) {
|
|
802
812
|
if (unit.kind.startsWith("AlterTable")) {
|
|
803
813
|
const alter = statements.find((sql) => /^\s*ALTER\s+TABLE\b/i.test(sql));
|
|
@@ -898,7 +908,8 @@ var REPLACEABLE_NAME = {
|
|
|
898
908
|
policy: (sql) => policyLabel(sql),
|
|
899
909
|
// `schema.table.trigger`, for the same reason.
|
|
900
910
|
trigger: (sql) => triggerLabel(sql),
|
|
901
|
-
view: (sql) => extractQualifiedName(sql, AFTER.view)
|
|
911
|
+
view: (sql) => extractQualifiedName(sql, AFTER.view),
|
|
912
|
+
collation: (sql) => extractQualifiedName(sql, AFTER.collation)
|
|
902
913
|
};
|
|
903
914
|
var REPLACEABLE_REPORT = {
|
|
904
915
|
routine: { idPart: "function", label: "Function modified", what: "Function body" },
|
|
@@ -906,7 +917,8 @@ var REPLACEABLE_REPORT = {
|
|
|
906
917
|
sequence: { idPart: "sequence", label: "Sequence modified", what: "Sequence definition" },
|
|
907
918
|
policy: { idPart: "policy", label: "Policy modified", what: "Policy definition" },
|
|
908
919
|
trigger: { idPart: "trigger", label: "Trigger modified", what: "Trigger definition" },
|
|
909
|
-
view: { idPart: "view", label: "View modified", what: "View definition" }
|
|
920
|
+
view: { idPart: "view", label: "View modified", what: "View definition" },
|
|
921
|
+
collation: { idPart: "collation", label: "Collation modified", what: "Collation definition" }
|
|
910
922
|
};
|
|
911
923
|
function replaceablePart(sql) {
|
|
912
924
|
if (/^\s*DROP\s+POLICY\b/i.test(sql)) return { kind: "policy", drop: true };
|
|
@@ -928,6 +940,10 @@ function replaceablePart(sql) {
|
|
|
928
940
|
return { kind: "sequence", drop: false };
|
|
929
941
|
case "drop-sequence":
|
|
930
942
|
return { kind: "sequence", drop: true };
|
|
943
|
+
case "create-collation":
|
|
944
|
+
return { kind: "collation", drop: false };
|
|
945
|
+
case "drop-collation":
|
|
946
|
+
return { kind: "collation", drop: true };
|
|
931
947
|
default:
|
|
932
948
|
return void 0;
|
|
933
949
|
}
|
|
@@ -1037,45 +1053,7 @@ function hasBrokenRef(sql) {
|
|
|
1037
1053
|
}
|
|
1038
1054
|
function splitStatements(sql) {
|
|
1039
1055
|
if (!sql) return [];
|
|
1040
|
-
|
|
1041
|
-
let buf = "";
|
|
1042
|
-
let i = 0;
|
|
1043
|
-
while (i < sql.length) {
|
|
1044
|
-
if (sql[i] === "$") {
|
|
1045
|
-
const tagMatch = sql.slice(i + 1).match(/^([A-Za-z0-9_]*)\$/);
|
|
1046
|
-
if (tagMatch) {
|
|
1047
|
-
const tag = `$${tagMatch[1]}$`;
|
|
1048
|
-
const closeIdx = sql.indexOf(tag, i + tag.length);
|
|
1049
|
-
if (closeIdx !== -1) {
|
|
1050
|
-
buf += sql.slice(i, closeIdx + tag.length);
|
|
1051
|
-
i = closeIdx + tag.length;
|
|
1052
|
-
continue;
|
|
1053
|
-
}
|
|
1054
|
-
}
|
|
1055
|
-
}
|
|
1056
|
-
if (sql[i] === ";") {
|
|
1057
|
-
buf += ";";
|
|
1058
|
-
i++;
|
|
1059
|
-
let j = i;
|
|
1060
|
-
while (j < sql.length && (sql[j] === " " || sql[j] === " " || sql[j] === "\r")) j++;
|
|
1061
|
-
if (j >= sql.length || sql[j] === "\n") {
|
|
1062
|
-
const stmt = withoutLeadingComments(buf);
|
|
1063
|
-
if (stmt.length > 0) {
|
|
1064
|
-
statements.push(stmt);
|
|
1065
|
-
}
|
|
1066
|
-
buf = "";
|
|
1067
|
-
i = j < sql.length ? j + 1 : j;
|
|
1068
|
-
}
|
|
1069
|
-
continue;
|
|
1070
|
-
}
|
|
1071
|
-
buf += sql[i];
|
|
1072
|
-
i++;
|
|
1073
|
-
}
|
|
1074
|
-
const last = withoutLeadingComments(buf);
|
|
1075
|
-
if (last.length > 0) {
|
|
1076
|
-
statements.push(last.endsWith(";") ? last : `${last};`);
|
|
1077
|
-
}
|
|
1078
|
-
return statements;
|
|
1056
|
+
return splitSqlStatements(sql).map((statement) => withoutLeadingComments(statement)).filter((statement) => statement.length > 0).map((statement) => `${statement};`);
|
|
1079
1057
|
}
|
|
1080
1058
|
function withoutLeadingComments(chunk) {
|
|
1081
1059
|
return chunk.trim().replace(/^(?:--[^\n]*(?:\n|$)\s*)+/, "").trim();
|
|
@@ -1104,6 +1082,9 @@ function classifyStatement(sql) {
|
|
|
1104
1082
|
if (upper.startsWith("DROP TABLE")) return "drop";
|
|
1105
1083
|
if (upper.startsWith("CREATE INDEX") || upper.startsWith("CREATE UNIQUE INDEX")) return "create-index";
|
|
1106
1084
|
if (upper.startsWith("DROP INDEX")) return "drop";
|
|
1085
|
+
if (upper.startsWith("CREATE COLLATION")) return "create-collation";
|
|
1086
|
+
if (upper.startsWith("ALTER COLLATION")) return "alter-collation";
|
|
1087
|
+
if (upper.startsWith("DROP COLLATION")) return "drop-collation";
|
|
1107
1088
|
if (upper.startsWith("CREATE SEQUENCE")) return "create-sequence";
|
|
1108
1089
|
if (upper.startsWith("ALTER SEQUENCE")) return "alter-sequence";
|
|
1109
1090
|
if (upper.startsWith("DROP SEQUENCE")) return "drop-sequence";
|
|
@@ -1121,6 +1102,7 @@ var AFTER = {
|
|
|
1121
1102
|
table: /\bTABLE\s+(?:IF\s+(?:NOT\s+)?EXISTS\s+)?(?:ONLY\s+)?/i,
|
|
1122
1103
|
index: /\bINDEX\s+(?:CONCURRENTLY\s+)?(?:IF\s+(?:NOT\s+)?EXISTS\s+)?/i,
|
|
1123
1104
|
policy: /\bPOLICY\s+(?:IF\s+EXISTS\s+)?/i,
|
|
1105
|
+
collation: /\bCOLLATION\s+(?:IF\s+(?:NOT\s+)?EXISTS\s+)?/i,
|
|
1124
1106
|
on: /\bON\s+(?:ONLY\s+)?/i
|
|
1125
1107
|
};
|
|
1126
1108
|
var named = (head) => (sql) => extractQualifiedName(sql, head);
|
|
@@ -1193,6 +1175,9 @@ var SCHEMA_RULES = [
|
|
|
1193
1175
|
{ match: /^\s*COMMENT\s+ON\b/i, label: "Comment changed", name: commentLabel },
|
|
1194
1176
|
{ match: /^\s*CREATE\s+EXTENSION\b/i, label: "Extension missing", name: extensionLabel },
|
|
1195
1177
|
{ match: /^\s*DROP\s+EXTENSION\b/i, label: "Extra extension", name: extensionLabel },
|
|
1178
|
+
{ match: /^\s*CREATE\s+COLLATION\b/i, label: "Collation missing", name: named(AFTER.collation) },
|
|
1179
|
+
{ match: /^\s*ALTER\s+COLLATION\b/i, label: "Collation altered", name: named(AFTER.collation) },
|
|
1180
|
+
{ match: /^\s*DROP\s+COLLATION\b/i, label: "Extra collation", name: named(AFTER.collation) },
|
|
1196
1181
|
{ match: /^\s*CREATE\s+SEQUENCE\b/i, label: "Sequence missing", name: named(AFTER.sequence) },
|
|
1197
1182
|
{ match: /^\s*ALTER\s+SEQUENCE\b/i, label: "Sequence altered", name: named(AFTER.sequence) },
|
|
1198
1183
|
{ match: /^\s*DROP\s+SEQUENCE\b/i, label: "Extra sequence", name: named(AFTER.sequence) }
|
|
@@ -1308,4 +1293,4 @@ export {
|
|
|
1308
1293
|
destructiveReason,
|
|
1309
1294
|
sqlToIssues
|
|
1310
1295
|
};
|
|
1311
|
-
//# sourceMappingURL=chunk-
|
|
1296
|
+
//# sourceMappingURL=chunk-N5VNNOA2.js.map
|
|
@@ -4,16 +4,16 @@ import {
|
|
|
4
4
|
applyTableFilter,
|
|
5
5
|
isComparisonCheck,
|
|
6
6
|
resolveTableFilter
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-DQJSSTIJ.js";
|
|
8
8
|
import {
|
|
9
9
|
policyOnlyKeys,
|
|
10
10
|
runDbDiff,
|
|
11
11
|
sqlSkeleton,
|
|
12
12
|
sqlToIssues
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-N5VNNOA2.js";
|
|
14
14
|
import {
|
|
15
15
|
splitSqlStatements
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-WK5YTINL.js";
|
|
17
17
|
import {
|
|
18
18
|
RealtimeCheck,
|
|
19
19
|
createPolicySql,
|
|
@@ -21,13 +21,15 @@ import {
|
|
|
21
21
|
diffSchemaPolicies,
|
|
22
22
|
dropEquivalentPolicyChanges,
|
|
23
23
|
dropPolicySql,
|
|
24
|
+
httpStatus,
|
|
25
|
+
readJsonArray,
|
|
26
|
+
readJsonObject,
|
|
24
27
|
schemaPolicySql
|
|
25
|
-
} from "./chunk-
|
|
28
|
+
} from "./chunk-ICSCHS72.js";
|
|
26
29
|
import {
|
|
27
30
|
Check,
|
|
28
31
|
CheckSkipped,
|
|
29
32
|
MigrationsCheck,
|
|
30
|
-
friendlyDbError,
|
|
31
33
|
isCheckSkipped,
|
|
32
34
|
pgQuery,
|
|
33
35
|
quoteIdent,
|
|
@@ -35,7 +37,7 @@ import {
|
|
|
35
37
|
quoteName,
|
|
36
38
|
readOrAbsent,
|
|
37
39
|
sqlLiteral
|
|
38
|
-
} from "./chunk-
|
|
40
|
+
} from "./chunk-MG3SFV5J.js";
|
|
39
41
|
import {
|
|
40
42
|
DEFAULT_IGNORE_SCHEMAS,
|
|
41
43
|
SCORE_MAX,
|
|
@@ -44,8 +46,9 @@ import {
|
|
|
44
46
|
SCORE_PENALTY_INFO,
|
|
45
47
|
SCORE_PENALTY_WARNING,
|
|
46
48
|
STORAGE_LIST_LIMIT,
|
|
47
|
-
SUPABASE_MGMT_API
|
|
48
|
-
|
|
49
|
+
SUPABASE_MGMT_API,
|
|
50
|
+
friendlyDbError
|
|
51
|
+
} from "./chunk-KNXHLVF7.js";
|
|
49
52
|
|
|
50
53
|
// src/scoring.ts
|
|
51
54
|
function summarize(results) {
|
|
@@ -625,7 +628,7 @@ async function inventoryFunctionsViaStudio(studioUrl, ref, fetchFn) {
|
|
|
625
628
|
if (!listRes.ok) {
|
|
626
629
|
throw new Error(`Studio functions API returned ${listRes.status} for ${studioUrl}`);
|
|
627
630
|
}
|
|
628
|
-
const listed = await listRes
|
|
631
|
+
const listed = await readJsonArray(listRes, `The Studio functions API at ${studioUrl}`);
|
|
629
632
|
const out = [];
|
|
630
633
|
for (const fn of listed) {
|
|
631
634
|
if (!fn?.slug) continue;
|
|
@@ -698,8 +701,8 @@ var EdgeFunctionsCheck = class extends Check {
|
|
|
698
701
|
const res = await this.fetchFn(url, {
|
|
699
702
|
headers: { Authorization: `Bearer ${accessToken}` }
|
|
700
703
|
});
|
|
701
|
-
if (!res.ok) throw new Error(`Failed to list functions for ${projectRef}: ${res
|
|
702
|
-
return res
|
|
704
|
+
if (!res.ok) throw new Error(`Failed to list functions for ${projectRef}: HTTP ${httpStatus(res)}`);
|
|
705
|
+
return readJsonArray(res, `The Edge Function list of ${projectRef}`);
|
|
703
706
|
}
|
|
704
707
|
};
|
|
705
708
|
function makeDeleteAction(slug, targetRef, targetKey) {
|
|
@@ -1472,8 +1475,8 @@ var AuthCheck = class extends Check {
|
|
|
1472
1475
|
const res = await this.fetchFn(url, {
|
|
1473
1476
|
headers: { Authorization: `Bearer ${accessToken}` }
|
|
1474
1477
|
});
|
|
1475
|
-
if (!res.ok) throw new Error(`Failed to fetch auth config for ${projectRef}: ${res
|
|
1476
|
-
return res
|
|
1478
|
+
if (!res.ok) throw new Error(`Failed to fetch auth config for ${projectRef}: HTTP ${httpStatus(res)}`);
|
|
1479
|
+
return readJsonObject(res, `The auth config of ${projectRef}`);
|
|
1477
1480
|
}
|
|
1478
1481
|
/**
|
|
1479
1482
|
* GoTrue wants the service-role key in both `apikey` and `Authorization`.
|
|
@@ -1484,8 +1487,8 @@ var AuthCheck = class extends Check {
|
|
|
1484
1487
|
const res = await this.fetchFn(url, {
|
|
1485
1488
|
headers: { apikey: serviceKey, Authorization: `Bearer ${serviceKey}` }
|
|
1486
1489
|
});
|
|
1487
|
-
if (!res.ok) throw new Error(`Failed to fetch auth settings from ${apiUrl}: ${res
|
|
1488
|
-
const raw = await res
|
|
1490
|
+
if (!res.ok) throw new Error(`Failed to fetch auth settings from ${apiUrl}: HTTP ${httpStatus(res)}`);
|
|
1491
|
+
const raw = await readJsonObject(res, `The auth settings at ${apiUrl}`);
|
|
1489
1492
|
return normalizeGoTrueSettings(raw);
|
|
1490
1493
|
}
|
|
1491
1494
|
};
|
|
@@ -2070,4 +2073,4 @@ export {
|
|
|
2070
2073
|
CheckRegistry,
|
|
2071
2074
|
createDefaultRegistry
|
|
2072
2075
|
};
|
|
2073
|
-
//# sourceMappingURL=chunk-
|
|
2076
|
+
//# sourceMappingURL=chunk-OB5GP7UB.js.map
|
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
import {
|
|
2
2
|
sanitizeForReport
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-HNJ6BNNZ.js";
|
|
4
4
|
import {
|
|
5
5
|
coverage,
|
|
6
6
|
formatSkips,
|
|
7
7
|
renderDetailed,
|
|
8
8
|
renderSummary
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-7DL63NWP.js";
|
|
10
10
|
import {
|
|
11
11
|
createDefaultRegistry,
|
|
12
12
|
scan,
|
|
13
13
|
summarizeByKind
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-OB5GP7UB.js";
|
|
15
15
|
import {
|
|
16
16
|
comparedSchemas,
|
|
17
17
|
proofScope,
|
|
18
18
|
proveConvergence,
|
|
19
19
|
residualHeldBack
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-3WKWPSFN.js";
|
|
21
21
|
import {
|
|
22
22
|
CHECK_META,
|
|
23
23
|
CHECK_NAMES,
|
|
@@ -26,35 +26,35 @@ import {
|
|
|
26
26
|
planWork,
|
|
27
27
|
promote,
|
|
28
28
|
resolveTableFilter
|
|
29
|
-
} from "./chunk-
|
|
29
|
+
} from "./chunk-DQJSSTIJ.js";
|
|
30
30
|
import {
|
|
31
31
|
renderTip
|
|
32
|
-
} from "./chunk-
|
|
32
|
+
} from "./chunk-ZI435CAU.js";
|
|
33
33
|
import {
|
|
34
34
|
BaseCommand
|
|
35
|
-
} from "./chunk-
|
|
35
|
+
} from "./chunk-5STH2A6K.js";
|
|
36
36
|
import {
|
|
37
37
|
isCloneDatabase,
|
|
38
38
|
sourceLooksLikeCloneOf
|
|
39
|
-
} from "./chunk-
|
|
39
|
+
} from "./chunk-EFKQOQGG.js";
|
|
40
40
|
import {
|
|
41
41
|
parseFlagList
|
|
42
42
|
} from "./chunk-DQQ5E563.js";
|
|
43
43
|
import {
|
|
44
|
-
Preflight
|
|
45
|
-
|
|
46
|
-
redactUrls
|
|
47
|
-
} from "./chunk-SQPCWGQO.js";
|
|
44
|
+
Preflight
|
|
45
|
+
} from "./chunk-MG3SFV5J.js";
|
|
48
46
|
import {
|
|
49
47
|
CLONE_SKIP_FLAGS,
|
|
50
48
|
DEFAULT_IGNORE_SCHEMAS,
|
|
51
49
|
bold,
|
|
52
50
|
cmd,
|
|
51
|
+
describeFailure,
|
|
53
52
|
dim,
|
|
54
53
|
ok,
|
|
54
|
+
redactUrls,
|
|
55
55
|
schemaDiffIgnores,
|
|
56
56
|
warn
|
|
57
|
-
} from "./chunk-
|
|
57
|
+
} from "./chunk-KNXHLVF7.js";
|
|
58
58
|
|
|
59
59
|
// src/commands/diff.ts
|
|
60
60
|
import { Flags } from "@oclif/core";
|
|
@@ -143,6 +143,13 @@ var APPLY_ONLY_FLAGS = [
|
|
|
143
143
|
{ flag: "apply-posture", shapesThePlan: true },
|
|
144
144
|
{ flag: "allow-destructive", shapesThePlan: true }
|
|
145
145
|
];
|
|
146
|
+
function rollbackHint(errors) {
|
|
147
|
+
const replacing = errors.filter((e) => /-alter-(?:view|type)-\d+$/.test(e.issueId) || /depend(?:s)? on it|\b2BP01\b/i.test(e.error));
|
|
148
|
+
if (replacing.length > 0) {
|
|
149
|
+
return `Nothing was written. ${replacing.map((e) => e.issueId).join(", ")} replaces an object others depend on, so the other fixes were not applied without it: fix the cause above, or leave it out with ${cmd("--only")}.`;
|
|
150
|
+
}
|
|
151
|
+
return `Nothing was written. Re-run with ${cmd("--no-transaction")} to apply the fixes that do work.`;
|
|
152
|
+
}
|
|
146
153
|
function inertApplyFlags(flags) {
|
|
147
154
|
if (flags["apply"]) return [];
|
|
148
155
|
const dryRun = Boolean(flags["dry-run"]);
|
|
@@ -299,7 +306,7 @@ ${warn(`${result.errors.length} error(s):`)}`);
|
|
|
299
306
|
}
|
|
300
307
|
if (result.rolledBack) {
|
|
301
308
|
this.log(`
|
|
302
|
-
${dim(
|
|
309
|
+
${dim(rollbackHint(result.errors))}`);
|
|
303
310
|
}
|
|
304
311
|
}
|
|
305
312
|
if (dryRun) {
|
|
@@ -626,7 +633,8 @@ function stripError(c) {
|
|
|
626
633
|
}
|
|
627
634
|
|
|
628
635
|
export {
|
|
636
|
+
rollbackHint,
|
|
629
637
|
inertApplyFlags,
|
|
630
638
|
Diff
|
|
631
639
|
};
|
|
632
|
-
//# sourceMappingURL=chunk-
|
|
640
|
+
//# sourceMappingURL=chunk-PYAGSMFB.js.map
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
pgQuery,
|
|
3
3
|
readLocalMigrations
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-MG3SFV5J.js";
|
|
5
5
|
import {
|
|
6
6
|
MIGRATIONS_SCHEMA,
|
|
7
7
|
MIGRATIONS_TABLE
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-KNXHLVF7.js";
|
|
9
9
|
|
|
10
10
|
// src/migrate.ts
|
|
11
11
|
import { readFile } from "fs/promises";
|
|
@@ -119,4 +119,4 @@ export {
|
|
|
119
119
|
runMigration,
|
|
120
120
|
baselineMigrations
|
|
121
121
|
};
|
|
122
|
-
//# sourceMappingURL=chunk-
|
|
122
|
+
//# sourceMappingURL=chunk-S5L4A3UR.js.map
|
|
@@ -3,25 +3,23 @@ import {
|
|
|
3
3
|
getAppliedVersions,
|
|
4
4
|
getPendingMigrations,
|
|
5
5
|
runMigration
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-S5L4A3UR.js";
|
|
7
7
|
import {
|
|
8
8
|
isDestructiveSql
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-N5VNNOA2.js";
|
|
10
10
|
import {
|
|
11
11
|
splitSqlStatements
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-WK5YTINL.js";
|
|
13
13
|
import {
|
|
14
14
|
BaseCommand
|
|
15
|
-
} from "./chunk-
|
|
16
|
-
import {
|
|
17
|
-
errMsg
|
|
18
|
-
} from "./chunk-SQPCWGQO.js";
|
|
15
|
+
} from "./chunk-5STH2A6K.js";
|
|
19
16
|
import {
|
|
20
17
|
bold,
|
|
21
18
|
dim,
|
|
19
|
+
errMsg,
|
|
22
20
|
ok,
|
|
23
21
|
warn
|
|
24
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-KNXHLVF7.js";
|
|
25
23
|
|
|
26
24
|
// src/commands/migrate/run.ts
|
|
27
25
|
import { Flags } from "@oclif/core";
|
|
@@ -153,4 +151,4 @@ export {
|
|
|
153
151
|
findDestructiveStatements,
|
|
154
152
|
truncateSql
|
|
155
153
|
};
|
|
156
|
-
//# sourceMappingURL=chunk-
|
|
154
|
+
//# sourceMappingURL=chunk-TPX2MAO4.js.map
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import {
|
|
2
2
|
isCommentOnly,
|
|
3
3
|
splitSqlStatements
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-WK5YTINL.js";
|
|
5
5
|
import {
|
|
6
6
|
captureSnapshot,
|
|
7
7
|
findLatestSnapshot,
|
|
8
8
|
loadSnapshot
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-ICSCHS72.js";
|
|
10
10
|
import {
|
|
11
11
|
slugify
|
|
12
12
|
} from "./chunk-DQQ5E563.js";
|
|
13
13
|
import {
|
|
14
14
|
MIGRATIONS_SUBDIR,
|
|
15
15
|
SUPAFORGE_DIR
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-KNXHLVF7.js";
|
|
17
17
|
|
|
18
18
|
// src/migration.ts
|
|
19
19
|
import { mkdir, writeFile, readFile, readdir } from "fs/promises";
|
|
@@ -245,4 +245,4 @@ export {
|
|
|
245
245
|
loadMigrations,
|
|
246
246
|
listMigrationFiles
|
|
247
247
|
};
|
|
248
|
-
//# sourceMappingURL=chunk-
|
|
248
|
+
//# sourceMappingURL=chunk-V2SBZERO.js.map
|
|
@@ -1,10 +1,26 @@
|
|
|
1
1
|
// src/utils/sql-split.ts
|
|
2
|
+
var ROUTINE_HEAD = /^CREATE\s+(?:OR\s+REPLACE\s+)?(?:FUNCTION|PROCEDURE)\b/i;
|
|
3
|
+
function withoutLeadingComments(text) {
|
|
4
|
+
let rest = text.trimStart();
|
|
5
|
+
for (; ; ) {
|
|
6
|
+
if (rest.startsWith("--")) {
|
|
7
|
+
const newline = rest.indexOf("\n");
|
|
8
|
+
rest = newline === -1 ? "" : rest.slice(newline + 1).trimStart();
|
|
9
|
+
} else if (rest.startsWith("/*")) {
|
|
10
|
+
const close = rest.indexOf("*/");
|
|
11
|
+
rest = close === -1 ? "" : rest.slice(close + 2).trimStart();
|
|
12
|
+
} else {
|
|
13
|
+
return rest;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
2
17
|
var DOLLAR_TAG = /^\$(?:[A-Za-z_][A-Za-z0-9_]*)?\$/;
|
|
3
18
|
function splitSqlStatements(sql) {
|
|
4
19
|
const statements = [];
|
|
5
20
|
let start = 0;
|
|
6
21
|
let i = 0;
|
|
7
22
|
let blockDepth = 0;
|
|
23
|
+
let beginDepth = 0;
|
|
8
24
|
const push = (end) => {
|
|
9
25
|
const piece = sql.slice(start, end).trim();
|
|
10
26
|
if (piece.length > 0) statements.push(piece);
|
|
@@ -61,7 +77,18 @@ function splitSqlStatements(sql) {
|
|
|
61
77
|
i++;
|
|
62
78
|
continue;
|
|
63
79
|
}
|
|
64
|
-
if (ch
|
|
80
|
+
if (/[A-Za-z_]/.test(ch)) {
|
|
81
|
+
const word = /^[A-Za-z_][A-Za-z0-9_]*/.exec(sql.slice(i, i + 64))[0];
|
|
82
|
+
const upper = word.toUpperCase();
|
|
83
|
+
if ((upper === "BEGIN" || upper === "CASE") && ROUTINE_HEAD.test(withoutLeadingComments(sql.slice(start, i)))) {
|
|
84
|
+
beginDepth++;
|
|
85
|
+
} else if (upper === "END" && beginDepth > 0) {
|
|
86
|
+
beginDepth--;
|
|
87
|
+
}
|
|
88
|
+
i += word.length;
|
|
89
|
+
continue;
|
|
90
|
+
}
|
|
91
|
+
if (ch === ";" && beginDepth === 0) {
|
|
65
92
|
push(i);
|
|
66
93
|
i++;
|
|
67
94
|
start = i;
|
|
@@ -91,4 +118,4 @@ export {
|
|
|
91
118
|
stripPsqlMetaCommands,
|
|
92
119
|
isPsqlMetaCommand
|
|
93
120
|
};
|
|
94
|
-
//# sourceMappingURL=chunk-
|
|
121
|
+
//# sourceMappingURL=chunk-WK5YTINL.js.map
|
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
CLONE_SKIP_FLAGS,
|
|
3
3
|
cmd,
|
|
4
4
|
dim
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-KNXHLVF7.js";
|
|
6
6
|
|
|
7
7
|
// src/tips.ts
|
|
8
8
|
function applyTip(sourceIsClone, driftedChecks) {
|
|
@@ -150,4 +150,4 @@ function renderTip(ctx) {
|
|
|
150
150
|
export {
|
|
151
151
|
renderTip
|
|
152
152
|
};
|
|
153
|
-
//# sourceMappingURL=chunk-
|
|
153
|
+
//# sourceMappingURL=chunk-ZI435CAU.js.map
|
package/dist/commands/clone.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
renderTip
|
|
3
|
-
} from "../chunk-
|
|
3
|
+
} from "../chunk-ZI435CAU.js";
|
|
4
4
|
import {
|
|
5
5
|
BaseCommand
|
|
6
|
-
} from "../chunk-
|
|
6
|
+
} from "../chunk-5STH2A6K.js";
|
|
7
7
|
import {
|
|
8
8
|
addBranchToManifest,
|
|
9
9
|
cloneRemoteToLocal,
|
|
@@ -11,22 +11,21 @@ import {
|
|
|
11
11
|
listBranches,
|
|
12
12
|
reconcileClones,
|
|
13
13
|
replaceDbName
|
|
14
|
-
} from "../chunk-
|
|
14
|
+
} from "../chunk-EFKQOQGG.js";
|
|
15
15
|
import {
|
|
16
16
|
captureSnapshot,
|
|
17
17
|
checkPgDumpCompat,
|
|
18
18
|
formatSnapshotLayers
|
|
19
|
-
} from "../chunk-
|
|
19
|
+
} from "../chunk-ICSCHS72.js";
|
|
20
20
|
import "../chunk-DQQ5E563.js";
|
|
21
21
|
import {
|
|
22
22
|
DEFAULT_LOCAL_PORT,
|
|
23
23
|
LOCAL_PG_PASSWORD,
|
|
24
24
|
LOCAL_PG_USER,
|
|
25
|
-
|
|
26
|
-
pgClientConfig,
|
|
27
|
-
redactUrls,
|
|
25
|
+
newPgClient,
|
|
28
26
|
startLocalPg
|
|
29
|
-
} from "../chunk-
|
|
27
|
+
} from "../chunk-MG3SFV5J.js";
|
|
28
|
+
import "../chunk-GQPGH6YR.js";
|
|
30
29
|
import {
|
|
31
30
|
CLONE_EXTRA_EXCLUDE_SCHEMAS,
|
|
32
31
|
CLONE_SKIP_FLAGS,
|
|
@@ -36,16 +35,17 @@ import {
|
|
|
36
35
|
bold,
|
|
37
36
|
cmd,
|
|
38
37
|
dim,
|
|
38
|
+
errMsg,
|
|
39
39
|
loadConfig,
|
|
40
40
|
ok,
|
|
41
|
+
redactUrls,
|
|
41
42
|
warn
|
|
42
|
-
} from "../chunk-
|
|
43
|
+
} from "../chunk-KNXHLVF7.js";
|
|
43
44
|
|
|
44
45
|
// src/commands/clone.ts
|
|
45
46
|
import { writeFile, mkdir } from "fs/promises";
|
|
46
47
|
import { resolve } from "path";
|
|
47
48
|
import { Flags } from "@oclif/core";
|
|
48
|
-
import pg from "pg";
|
|
49
49
|
var CLONE_EXCLUDE_SCHEMAS = [.../* @__PURE__ */ new Set([
|
|
50
50
|
...DEFAULT_IGNORE_SCHEMAS,
|
|
51
51
|
...CLONE_EXTRA_EXCLUDE_SCHEMAS
|
|
@@ -211,7 +211,7 @@ var Clone = class _Clone extends BaseCommand {
|
|
|
211
211
|
});
|
|
212
212
|
pre.addCheck("Target database", async () => {
|
|
213
213
|
try {
|
|
214
|
-
const client =
|
|
214
|
+
const client = newPgClient(localBaseUrl);
|
|
215
215
|
await client.connect();
|
|
216
216
|
const { rows } = await client.query(
|
|
217
217
|
"SELECT 1 FROM pg_database WHERE datname = $1",
|
package/dist/commands/diff.d.ts
CHANGED
|
@@ -3,6 +3,18 @@ import { BaseCommand } from '../base-command.js';
|
|
|
3
3
|
import '@oclif/core';
|
|
4
4
|
import '../config-CTbeRlJk.js';
|
|
5
5
|
|
|
6
|
+
/**
|
|
7
|
+
* What to do after a rolled-back apply.
|
|
8
|
+
*
|
|
9
|
+
* Usually: apply the fixes that work without the one that failed. Not when
|
|
10
|
+
* the failure is replacing a view or type something else depends on — the
|
|
11
|
+
* others may be what depends on it, and applying them alone leaves the two
|
|
12
|
+
* out of step — so that one is named to fix or leave out instead.
|
|
13
|
+
*/
|
|
14
|
+
declare function rollbackHint(errors: ReadonlyArray<{
|
|
15
|
+
issueId: string;
|
|
16
|
+
error: string;
|
|
17
|
+
}>): string;
|
|
6
18
|
/** Which apply-only flags this invocation will silently ignore. */
|
|
7
19
|
declare function inertApplyFlags(flags: Record<string, unknown>): ReadonlyArray<{
|
|
8
20
|
flag: string;
|
|
@@ -78,4 +90,4 @@ declare class Diff extends BaseCommand {
|
|
|
78
90
|
private preflightBothDatabases;
|
|
79
91
|
}
|
|
80
92
|
|
|
81
|
-
export { Diff as default, inertApplyFlags };
|
|
93
|
+
export { Diff as default, inertApplyFlags, rollbackHint };
|
package/dist/commands/diff.js
CHANGED
|
@@ -1,23 +1,26 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Diff,
|
|
3
|
-
inertApplyFlags
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
import "../chunk-
|
|
7
|
-
import "../chunk-
|
|
8
|
-
import "../chunk-
|
|
9
|
-
import "../chunk-
|
|
10
|
-
import "../chunk-
|
|
11
|
-
import "../chunk-
|
|
12
|
-
import "../chunk-
|
|
13
|
-
import "../chunk-
|
|
14
|
-
import "../chunk-
|
|
15
|
-
import "../chunk-
|
|
3
|
+
inertApplyFlags,
|
|
4
|
+
rollbackHint
|
|
5
|
+
} from "../chunk-PYAGSMFB.js";
|
|
6
|
+
import "../chunk-HNJ6BNNZ.js";
|
|
7
|
+
import "../chunk-7DL63NWP.js";
|
|
8
|
+
import "../chunk-OB5GP7UB.js";
|
|
9
|
+
import "../chunk-3WKWPSFN.js";
|
|
10
|
+
import "../chunk-DQJSSTIJ.js";
|
|
11
|
+
import "../chunk-N5VNNOA2.js";
|
|
12
|
+
import "../chunk-WK5YTINL.js";
|
|
13
|
+
import "../chunk-ZI435CAU.js";
|
|
14
|
+
import "../chunk-5STH2A6K.js";
|
|
15
|
+
import "../chunk-EFKQOQGG.js";
|
|
16
|
+
import "../chunk-ICSCHS72.js";
|
|
16
17
|
import "../chunk-DQQ5E563.js";
|
|
17
|
-
import "../chunk-
|
|
18
|
-
import "../chunk-
|
|
18
|
+
import "../chunk-MG3SFV5J.js";
|
|
19
|
+
import "../chunk-GQPGH6YR.js";
|
|
20
|
+
import "../chunk-KNXHLVF7.js";
|
|
19
21
|
export {
|
|
20
22
|
Diff as default,
|
|
21
|
-
inertApplyFlags
|
|
23
|
+
inertApplyFlags,
|
|
24
|
+
rollbackHint
|
|
22
25
|
};
|
|
23
26
|
//# sourceMappingURL=diff.js.map
|