@akal/supaforge 0.0.45 → 0.0.47

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 (31) hide show
  1. package/dist/base-command.js +1 -1
  2. package/dist/{chunk-KTATU64Y.js → chunk-2XMRTAFX.js} +108 -17
  3. package/dist/{chunk-ZLNP3DUB.js → chunk-3SEVACCT.js} +9 -6
  4. package/dist/{chunk-KPU6G6BO.js → chunk-4TBYWXUK.js} +6 -8
  5. package/dist/{chunk-JVZYVZUH.js → chunk-CRUFF6K5.js} +5 -7
  6. package/dist/{chunk-4RD66RHF.js → chunk-CUGDLO2L.js} +10 -12
  7. package/dist/{chunk-EMRM4RIV.js → chunk-EB6PCOIL.js} +2 -2
  8. package/dist/{chunk-DUTPOR7P.js → chunk-EGXQ37PA.js} +37 -14
  9. package/dist/{chunk-R4FSOTB6.js → chunk-KBZUTGGF.js} +7 -7
  10. package/dist/{chunk-CKH6J7DI.js → chunk-TU5UIODX.js} +7 -5
  11. package/dist/{chunk-HGCTVCLV.js → chunk-UUDXVYEI.js} +7 -7
  12. package/dist/{chunk-YABERWV7.js → chunk-WNZCOYOK.js} +176 -46
  13. package/dist/{chunk-J64XMOXU.js → chunk-XTSFAUXI.js} +5 -5
  14. package/dist/{chunk-UPWUXQ24.js → chunk-YQLVRHJA.js} +2 -2
  15. package/dist/{chunk-USIOUMYL.js → chunk-YYS4FJ23.js} +141 -2
  16. package/dist/commands/clone.d.ts +14 -1
  17. package/dist/commands/clone.js +15 -5
  18. package/dist/commands/diff.js +8 -9
  19. package/dist/commands/hukam.js +8 -9
  20. package/dist/commands/mcp.js +7 -8
  21. package/dist/commands/migrate/baseline.js +1 -1
  22. package/dist/commands/migrate/create.js +6 -7
  23. package/dist/commands/migrate/list.js +1 -1
  24. package/dist/commands/migrate/run.js +5 -6
  25. package/dist/commands/report.js +1 -1
  26. package/dist/commands/restore.js +6 -7
  27. package/dist/commands/snapshot.js +4 -5
  28. package/dist/commands/sync.js +8 -9
  29. package/dist/index.js +11 -12
  30. package/package.json +2 -2
  31. package/dist/chunk-WK5YTINL.js +0 -121
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  BaseCommand
3
- } from "./chunk-CKH6J7DI.js";
3
+ } from "./chunk-TU5UIODX.js";
4
4
  import "./chunk-RC7ZU7OV.js";
5
5
  import "./chunk-KHXEES2M.js";
6
6
  import "./chunk-SQ52YBKK.js";
@@ -1,9 +1,11 @@
1
1
  import {
2
2
  captureSnapshot
3
- } from "./chunk-ZLNP3DUB.js";
3
+ } from "./chunk-3SEVACCT.js";
4
4
  import {
5
- checkPgDumpCompat
6
- } from "./chunk-USIOUMYL.js";
5
+ checkPgDumpCompat,
6
+ pgToolConnection,
7
+ splitSqlStatements
8
+ } from "./chunk-YYS4FJ23.js";
7
9
  import {
8
10
  newPgClient,
9
11
  pgQuery,
@@ -18,7 +20,7 @@ import {
18
20
 
19
21
  // src/branch.ts
20
22
  import { spawn } from "child_process";
21
- import { readFile, writeFile, mkdir } from "fs/promises";
23
+ import { readFile, writeFile as writeFile2, mkdir } from "fs/promises";
22
24
  import { resolve, dirname } from "path";
23
25
 
24
26
  // src/stubs.ts
@@ -87,6 +89,81 @@ CREATE TABLE IF NOT EXISTS storage.objects (
87
89
  `;
88
90
  var CLONE_STUBS_SQL = [AUTH_STUBS_SQL, STORAGE_STUBS_SQL].join("\n");
89
91
 
92
+ // src/clone-privileges.ts
93
+ import { execFile } from "child_process";
94
+ import { mkdtemp, rm, writeFile } from "fs/promises";
95
+ import { tmpdir } from "os";
96
+ import { join } from "path";
97
+ import { promisify } from "util";
98
+ var run = promisify(execFile);
99
+ function privilegeEntries(listing, excludeSchemas = []) {
100
+ const excluded = new Set(excludeSchemas);
101
+ return listing.split("\n").filter((line) => {
102
+ const m = /^\d+;\s+\d+\s+\d+\s+(?:DEFAULT\s+)?ACL\s+(\S+)\s+(.*)$/.exec(line);
103
+ if (!m) return false;
104
+ const [, schema, rest] = m;
105
+ const subject = schema === "-" ? /^SCHEMA\s+(\S+)/.exec(rest)?.[1] : schema;
106
+ return subject === void 0 || !excluded.has(subject);
107
+ });
108
+ }
109
+ function privilegeStatements(sql) {
110
+ const body = sql.split("\n").filter((line) => !line.startsWith("\\")).join("\n");
111
+ return splitSqlStatements(body).map((s) => s.split("\n").filter((line) => !/^\s*--/.test(line)).join("\n").trim()).filter(Boolean);
112
+ }
113
+ function missingRole(err) {
114
+ const e = err;
115
+ if (e.code !== "42704") return void 0;
116
+ return /^role "((?:[^"]|"")+)" does not exist$/.exec(e.message ?? "")?.[1];
117
+ }
118
+ var isSessionSetting = (sql) => /^SET\s/i.test(sql) || /^SELECT\s+pg_catalog\.set_config\(/i.test(sql);
119
+ async function applyPrivileges(dbUrl, statements) {
120
+ const result = { granted: 0, notGranted: [], failures: [] };
121
+ const client = newPgClient(dbUrl);
122
+ await client.connect();
123
+ try {
124
+ for (const sql of statements) {
125
+ try {
126
+ await client.query(sql);
127
+ if (!isSessionSetting(sql)) result.granted++;
128
+ } catch (err) {
129
+ if (isSessionSetting(sql)) continue;
130
+ const summary = sql.replace(/\s+/g, " ").replace(/;$/, "");
131
+ const role = missingRole(err);
132
+ if (role) result.notGranted.push({ role, statement: summary });
133
+ else result.failures.push({ object: summary, error: err.message });
134
+ }
135
+ }
136
+ } finally {
137
+ await client.end();
138
+ }
139
+ return result;
140
+ }
141
+ async function restorePrivileges(opts) {
142
+ const dir = await mkdtemp(join(tmpdir(), "supaforge-acl-"));
143
+ try {
144
+ const archive = join(dir, "schema.dump");
145
+ const list = join(dir, "acl.list");
146
+ const remote = pgToolConnection(opts.remoteUrl);
147
+ await run(opts.pgDumpPath, [
148
+ "--format=custom",
149
+ "--schema-only",
150
+ "--no-owner",
151
+ ...(opts.excludeSchemas ?? []).map((s) => `--exclude-schema=${s}`),
152
+ "--file",
153
+ archive,
154
+ remote.url
155
+ ], { maxBuffer: 64 * 1024 * 1024, env: remote.env });
156
+ const { stdout: listing } = await run(opts.pgRestorePath, ["--list", archive], { maxBuffer: 256 * 1024 * 1024 });
157
+ const entries = privilegeEntries(listing, opts.excludeSchemas);
158
+ if (entries.length === 0) return { granted: 0, notGranted: [], failures: [] };
159
+ await writeFile(list, entries.join("\n") + "\n");
160
+ const { stdout: sql } = await run(opts.pgRestorePath, ["--use-list", list, "--file", "-", archive], { maxBuffer: 256 * 1024 * 1024 });
161
+ return await applyPrivileges(opts.localDbUrl, privilegeStatements(sql));
162
+ } finally {
163
+ await rm(dir, { recursive: true, force: true });
164
+ }
165
+ }
166
+
90
167
  // src/branch.ts
91
168
  var BRANCH_DB_PREFIX = "supaforge_branch_";
92
169
  function branchDbName(name) {
@@ -134,7 +211,7 @@ async function loadManifest(cwd = process.cwd()) {
134
211
  async function saveManifest(manifest, cwd) {
135
212
  const p = await manifestPath(cwd);
136
213
  await mkdir(dirname(p), { recursive: true });
137
- await writeFile(p, JSON.stringify(manifest, null, 2) + "\n");
214
+ await writeFile2(p, JSON.stringify(manifest, null, 2) + "\n");
138
215
  }
139
216
  async function createBranch(opts) {
140
217
  const cwd = opts.cwd ?? process.cwd();
@@ -210,19 +287,19 @@ async function tryDumpRestore(sourceUrl, newDb, schemaOnly, pgDumpPath = "pg_dum
210
287
  } finally {
211
288
  await client.end();
212
289
  }
213
- const dumpArgs = ["--format=custom", "--no-owner", "--no-acl", sourceUrl];
290
+ const source = pgToolConnection(sourceUrl);
291
+ const dumpArgs = ["--format=custom", "--no-owner", source.url];
214
292
  if (schemaOnly) dumpArgs.unshift("--schema-only");
215
- const targetUrl = replaceDbName(sourceUrl, newDb);
293
+ const target = pgToolConnection(replaceDbName(sourceUrl, newDb));
216
294
  const restoreArgs = [
217
295
  "--format=custom",
218
296
  "--no-owner",
219
- "--no-acl",
220
- `--dbname=${targetUrl}`
297
+ `--dbname=${target.url}`
221
298
  ];
222
299
  try {
223
300
  await new Promise((resolve2, reject) => {
224
- const dump = spawn(pgDumpPath, dumpArgs, { stdio: ["ignore", "pipe", "pipe"] });
225
- const restore = spawn(pgRestorePath, restoreArgs, { stdio: [dump.stdout, "pipe", "pipe"] });
301
+ const dump = spawn(pgDumpPath, dumpArgs, { stdio: ["ignore", "pipe", "pipe"], env: source.env });
302
+ const restore = spawn(pgRestorePath, restoreArgs, { stdio: [dump.stdout, "pipe", "pipe"], env: target.env });
226
303
  let restoreStderr = "";
227
304
  restore.stderr?.on("data", (chunk) => {
228
305
  restoreStderr += chunk.toString();
@@ -406,18 +483,20 @@ async function cloneRemoteToLocal(opts) {
406
483
  dumpArgs.push(`--exclude-schema=${schema}`);
407
484
  }
408
485
  }
409
- dumpArgs.push(opts.remoteUrl);
486
+ const remote = pgToolConnection(opts.remoteUrl);
487
+ const local = pgToolConnection(localDbUrl);
488
+ dumpArgs.push(remote.url);
410
489
  const restoreArgs = [
411
490
  "--format=custom",
412
491
  "--no-owner",
413
492
  "--no-acl",
414
- `--dbname=${localDbUrl}`
493
+ `--dbname=${local.url}`
415
494
  ];
416
495
  let restoreLog = "";
417
496
  try {
418
497
  restoreLog = await new Promise((resolve2, reject) => {
419
- const dump = spawn(compat.pgDumpPath, dumpArgs, { stdio: ["ignore", "pipe", "pipe"] });
420
- const restore = spawn(compat.pgRestorePath, restoreArgs, { stdio: ["pipe", "pipe", "pipe"] });
498
+ const dump = spawn(compat.pgDumpPath, dumpArgs, { stdio: ["ignore", "pipe", "pipe"], env: remote.env });
499
+ const restore = spawn(compat.pgRestorePath, restoreArgs, { stdio: ["pipe", "pipe", "pipe"], env: local.env });
421
500
  let bytesTransferred = 0;
422
501
  dump.stdout.on("data", (chunk) => {
423
502
  bytesTransferred += chunk.length;
@@ -515,10 +594,22 @@ async function cloneRemoteToLocal(opts) {
515
594
  throw err;
516
595
  }
517
596
  const { failures, unavailable } = restoreFailures(restoreLog);
597
+ const privileges = await restorePrivileges({
598
+ pgDumpPath: compat.pgDumpPath,
599
+ pgRestorePath: compat.pgRestorePath,
600
+ remoteUrl: opts.remoteUrl,
601
+ localDbUrl,
602
+ excludeSchemas: opts.excludeSchemas
603
+ }).catch((err) => ({
604
+ granted: 0,
605
+ notGranted: [],
606
+ failures: [{ object: "the source's privileges", error: err.message.split("\n")[0] }]
607
+ }));
518
608
  return {
519
609
  url: localDbUrl,
520
- failures,
610
+ failures: [...failures, ...privileges.failures],
521
611
  unavailable,
612
+ notGranted: privileges.notGranted,
522
613
  extensionsInstalled: extensions.installed
523
614
  };
524
615
  }
@@ -653,4 +744,4 @@ export {
653
744
  isCloneDatabase,
654
745
  sourceLooksLikeCloneOf
655
746
  };
656
- //# sourceMappingURL=chunk-KTATU64Y.js.map
747
+ //# sourceMappingURL=chunk-2XMRTAFX.js.map
@@ -3,8 +3,9 @@ import {
3
3
  describeMissingPgDump,
4
4
  getServerMajorVersion,
5
5
  normalizeRoles,
6
+ pgToolConnection,
6
7
  resolvePgDumpPath
7
- } from "./chunk-USIOUMYL.js";
8
+ } from "./chunk-YYS4FJ23.js";
8
9
  import {
9
10
  Check,
10
11
  inRolledBackTransaction,
@@ -31,7 +32,7 @@ import {
31
32
  } from "./chunk-SQ52YBKK.js";
32
33
 
33
34
  // src/snapshot.ts
34
- import { mkdir, writeFile, readFile, readdir, rm } from "fs/promises";
35
+ import { mkdir, writeFile, readFile, readdir, rm, chmod } from "fs/promises";
35
36
  import { join, resolve } from "path";
36
37
  import { execFile as execFileCb } from "child_process";
37
38
  import { promisify } from "util";
@@ -604,7 +605,8 @@ async function captureSnapshot(options) {
604
605
  const cwd = options.cwd ?? process.cwd();
605
606
  const timestamp = generateTimestamp();
606
607
  const dir = options.outputDir ? join(resolve(options.outputDir), timestamp) : snapshotDir(cwd, timestamp);
607
- await mkdir(dir, { recursive: true });
608
+ await mkdir(dir, { recursive: true, mode: 448 });
609
+ await chmod(dir, 448);
608
610
  const queryFn = options.queryFn ?? pgQuery;
609
611
  const fetchFn = options.fetchFn ?? globalThis.fetch.bind(globalThis);
610
612
  const ignoreSchemas = options.config.ignoreSchemas ?? DEFAULT_IGNORE_SCHEMAS;
@@ -704,14 +706,15 @@ async function captureSchemaSql(dir, dbUrl, schemas) {
704
706
  sqlSkipReason: `${await describeMissingPgDump(serverMajor)} \u2014 schema.json was still captured, but restore cannot replay the schema`
705
707
  };
706
708
  }
709
+ const conn = pgToolConnection(dbUrl);
707
710
  const { stdout } = await execFile(resolved.path, [
708
- dbUrl,
711
+ conn.url,
709
712
  "--schema-only",
710
713
  "--no-owner",
711
714
  "--no-privileges",
712
715
  // Quoted: pg_dump reads --schema as a pattern, folding `App Data` to lower case.
713
716
  ...schemas.map((s) => `--schema=${quoteName(s)}`)
714
- ], { maxBuffer: 256 * 1024 * 1024, timeout: 3e5 });
717
+ ], { maxBuffer: 256 * 1024 * 1024, timeout: 3e5, env: conn.env });
715
718
  if (stdout.trim().length === 0) {
716
719
  return { sqlSkipReason: "pg_dump produced an empty schema dump" };
717
720
  }
@@ -1249,4 +1252,4 @@ export {
1249
1252
  DEFAULT_KEEP_COUNT,
1250
1253
  pruneSnapshots
1251
1254
  };
1252
- //# sourceMappingURL=chunk-ZLNP3DUB.js.map
1255
+ //# sourceMappingURL=chunk-3SEVACCT.js.map
@@ -1,15 +1,13 @@
1
- import {
2
- isCommentOnly,
3
- splitSqlStatements
4
- } from "./chunk-WK5YTINL.js";
5
1
  import {
6
2
  captureSnapshot,
7
3
  findLatestSnapshot,
8
4
  loadSnapshot
9
- } from "./chunk-ZLNP3DUB.js";
5
+ } from "./chunk-3SEVACCT.js";
10
6
  import {
11
- slugify
12
- } from "./chunk-USIOUMYL.js";
7
+ isCommentOnly,
8
+ slugify,
9
+ splitSqlStatements
10
+ } from "./chunk-YYS4FJ23.js";
13
11
  import {
14
12
  MIGRATIONS_SUBDIR,
15
13
  SUPAFORGE_DIR
@@ -245,4 +243,4 @@ export {
245
243
  loadMigrations,
246
244
  listMigrationFiles
247
245
  };
248
- //# sourceMappingURL=chunk-KPU6G6BO.js.map
246
+ //# sourceMappingURL=chunk-4TBYWXUK.js.map
@@ -1,18 +1,16 @@
1
1
  import {
2
2
  targetFingerprint,
3
3
  writtenAgainstLine
4
- } from "./chunk-UPWUXQ24.js";
4
+ } from "./chunk-YQLVRHJA.js";
5
5
  import {
6
6
  RolesCheck,
7
7
  isDestructiveSql,
8
8
  runDbDiff
9
- } from "./chunk-YABERWV7.js";
9
+ } from "./chunk-WNZCOYOK.js";
10
10
  import {
11
+ slugify,
11
12
  splitSqlStatements
12
- } from "./chunk-WK5YTINL.js";
13
- import {
14
- slugify
15
- } from "./chunk-USIOUMYL.js";
13
+ } from "./chunk-YYS4FJ23.js";
16
14
  import {
17
15
  DEFAULT_MIGRATIONS_DIR,
18
16
  pgQuery
@@ -91,4 +89,4 @@ export {
91
89
  writeMigrationFile,
92
90
  generateTimestamp
93
91
  };
94
- //# sourceMappingURL=chunk-JVZYVZUH.js.map
92
+ //# sourceMappingURL=chunk-CRUFF6K5.js.map
@@ -6,13 +6,13 @@ import {
6
6
  formatSkips,
7
7
  renderDetailed,
8
8
  renderSummary
9
- } from "./chunk-EMRM4RIV.js";
9
+ } from "./chunk-EB6PCOIL.js";
10
10
  import {
11
11
  createDefaultRegistry,
12
12
  proveBeforeApply,
13
13
  scan,
14
14
  summarizeByKind
15
- } from "./chunk-DUTPOR7P.js";
15
+ } from "./chunk-EGXQ37PA.js";
16
16
  import {
17
17
  CHECK_META,
18
18
  CHECK_NAMES,
@@ -24,27 +24,25 @@ import {
24
24
  psqlBeside,
25
25
  resolveTableFilter,
26
26
  withDatabase
27
- } from "./chunk-YABERWV7.js";
28
- import {
29
- isCommentOnly,
30
- splitSqlStatements
31
- } from "./chunk-WK5YTINL.js";
27
+ } from "./chunk-WNZCOYOK.js";
32
28
  import {
33
29
  renderTip
34
30
  } from "./chunk-RQCXGO37.js";
35
31
  import {
36
32
  BaseCommand
37
- } from "./chunk-CKH6J7DI.js";
33
+ } from "./chunk-TU5UIODX.js";
38
34
  import {
39
35
  isCloneDatabase,
40
36
  sourceLooksLikeCloneOf
41
- } from "./chunk-KTATU64Y.js";
37
+ } from "./chunk-2XMRTAFX.js";
42
38
  import {
43
39
  describeMissingPgDump,
44
40
  getServerMajorVersion,
41
+ isCommentOnly,
45
42
  parseFlagList,
46
- resolvePgDumpPath
47
- } from "./chunk-USIOUMYL.js";
43
+ resolvePgDumpPath,
44
+ splitSqlStatements
45
+ } from "./chunk-YYS4FJ23.js";
48
46
  import {
49
47
  Preflight,
50
48
  pgQuery,
@@ -756,4 +754,4 @@ export {
756
754
  inertApplyFlags,
757
755
  Diff
758
756
  };
759
- //# sourceMappingURL=chunk-4RD66RHF.js.map
757
+ //# sourceMappingURL=chunk-CUGDLO2L.js.map
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  CHECK_META,
3
3
  isComparisonCheck
4
- } from "./chunk-YABERWV7.js";
4
+ } from "./chunk-WNZCOYOK.js";
5
5
  import {
6
6
  CHECK_LINE_PADDING,
7
7
  bold,
@@ -241,4 +241,4 @@ export {
241
241
  renderDetailed,
242
242
  formatSkips
243
243
  };
244
- //# sourceMappingURL=chunk-EMRM4RIV.js.map
244
+ //# sourceMappingURL=chunk-EB6PCOIL.js.map
@@ -21,10 +21,7 @@ import {
21
21
  sqlToIssues,
22
22
  withPlatformExtensionCalls,
23
23
  withoutAbsentRoles
24
- } from "./chunk-YABERWV7.js";
25
- import {
26
- splitSqlStatements
27
- } from "./chunk-WK5YTINL.js";
24
+ } from "./chunk-WNZCOYOK.js";
28
25
  import {
29
26
  RealtimeCheck,
30
27
  createPolicySql,
@@ -36,7 +33,10 @@ import {
36
33
  readJsonArray,
37
34
  readJsonObject,
38
35
  schemaPolicySql
39
- } from "./chunk-ZLNP3DUB.js";
36
+ } from "./chunk-3SEVACCT.js";
37
+ import {
38
+ splitSqlStatements
39
+ } from "./chunk-YYS4FJ23.js";
40
40
  import {
41
41
  Check,
42
42
  CheckSkipped,
@@ -418,7 +418,8 @@ var SchemaCheck = class extends Check {
418
418
  let issues = sqlToIssues(result, "schema", ignoreSchemas, ignoredSchemaTables);
419
419
  const moves = platformExtensionMoves(issues);
420
420
  if (moves.length) {
421
- issues = withPlatformExtensionCalls(issues, moves, await this.extensionFunctions(ctx.target.dbUrl, moves));
421
+ const { owned, shadows } = await this.extensionFunctions(ctx.target.dbUrl, moves);
422
+ issues = withPlatformExtensionCalls(issues, moves, owned, shadows);
422
423
  }
423
424
  const roles = await this.targetRoles(ctx.target.dbUrl);
424
425
  return roles?.size ? withoutAbsentRoles(issues, roles) : issues;
@@ -440,25 +441,39 @@ var SchemaCheck = class extends Check {
440
441
  * DB error here never blocks the main schema diff.
441
442
  */
442
443
  /**
443
- * The functions each extension owns on the target, by name. Unreadable,
444
- * none: the calls are then left as the source wrote them.
444
+ * The functions each extension owns on the target, with how many arguments
445
+ * each takes, and the user's own functions of the same names in the schemas
446
+ * the source keeps those extensions in, which a call could mean instead.
447
+ * Unreadable, none: the calls are then left as the source wrote them.
445
448
  */
446
449
  async extensionFunctions(dbUrl, moves) {
447
450
  const owned = /* @__PURE__ */ new Map();
451
+ const shadows = [];
448
452
  try {
449
- const rows = await this.queryFn(dbUrl, `SELECT e.extname, p.proname
453
+ const rows = await this.queryFn(dbUrl, `SELECT e.extname, p.proname, p.pronargs, p.pronargdefaults, p.provariadic <> 0 AS variadic
450
454
  FROM pg_depend d
451
455
  JOIN pg_extension e ON e.oid = d.refobjid
452
456
  JOIN pg_proc p ON p.oid = d.objid
453
457
  WHERE d.classid = 'pg_proc'::regclass AND d.refclassid = 'pg_extension'::regclass
454
458
  AND d.deptype = 'e' AND e.extname = ANY($1)`, [moves.map((m) => m.name)]);
455
- for (const { extname, proname } of rows) {
456
- if (!owned.has(extname)) owned.set(extname, /* @__PURE__ */ new Set());
457
- owned.get(extname).add(proname);
459
+ for (const row of rows) {
460
+ const extname = String(row.extname);
461
+ if (!owned.has(extname)) owned.set(extname, []);
462
+ owned.get(extname).push(arity(row));
458
463
  }
464
+ const names = [...new Set(rows.map((r) => String(r.proname)))];
465
+ const others = await this.queryFn(
466
+ dbUrl,
467
+ `SELECT n.nspname, p.proname, p.pronargs, p.pronargdefaults, p.provariadic <> 0 AS variadic
468
+ FROM pg_proc p JOIN pg_namespace n ON n.oid = p.pronamespace
469
+ WHERE n.nspname = ANY($1) AND p.proname = ANY($2)
470
+ AND NOT EXISTS (SELECT FROM pg_depend d WHERE d.classid = 'pg_proc'::regclass AND d.objid = p.oid AND d.deptype = 'e')`,
471
+ [[...new Set(moves.map((m) => m.sourceSchema))], names]
472
+ );
473
+ for (const row of others) shadows.push({ schema: String(row.nspname), ...arity(row) });
459
474
  } catch {
460
475
  }
461
- return owned;
476
+ return { owned, shadows };
462
477
  }
463
478
  /** The target's roles, or undefined when they cannot be read. */
464
479
  async targetRoles(dbUrl) {
@@ -487,6 +502,14 @@ var SchemaCheck = class extends Check {
487
502
  }
488
503
  }
489
504
  };
505
+ function arity(row) {
506
+ const nargs = Number(row.pronargs ?? 0);
507
+ return {
508
+ name: String(row.proname),
509
+ minArgs: nargs - Number(row.pronargdefaults ?? 0),
510
+ maxArgs: row.variadic === true ? Infinity : nargs
511
+ };
512
+ }
490
513
 
491
514
  // src/checks/rls.ts
492
515
  var RlsCheck = class extends Check {
@@ -2444,4 +2467,4 @@ export {
2444
2467
  createDefaultRegistry,
2445
2468
  proveBeforeApply
2446
2469
  };
2447
- //# sourceMappingURL=chunk-DUTPOR7P.js.map
2470
+ //# sourceMappingURL=chunk-EGXQ37PA.js.map
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  loadMigrations
3
- } from "./chunk-KPU6G6BO.js";
3
+ } from "./chunk-4TBYWXUK.js";
4
4
  import {
5
5
  ensureMigrationsTable,
6
6
  getAppliedVersions
@@ -18,16 +18,16 @@ import {
18
18
  rolesNamedBy,
19
19
  sqlSkeleton,
20
20
  statementSubject
21
- } from "./chunk-YABERWV7.js";
21
+ } from "./chunk-WNZCOYOK.js";
22
+ import {
23
+ loadSnapshot
24
+ } from "./chunk-3SEVACCT.js";
22
25
  import {
23
26
  isCommentOnly,
24
27
  isPsqlMetaCommand,
25
28
  splitSqlStatements,
26
29
  stripPsqlMetaCommands
27
- } from "./chunk-WK5YTINL.js";
28
- import {
29
- loadSnapshot
30
- } from "./chunk-ZLNP3DUB.js";
30
+ } from "./chunk-YYS4FJ23.js";
31
31
  import {
32
32
  newPgClient,
33
33
  pgQuery,
@@ -900,4 +900,4 @@ export {
900
900
  previewMigrationRestore,
901
901
  summarizeStatement
902
902
  };
903
- //# sourceMappingURL=chunk-R4FSOTB6.js.map
903
+ //# sourceMappingURL=chunk-KBZUTGGF.js.map
@@ -22,7 +22,7 @@ import { formatWithOptions } from "util";
22
22
  import { Command } from "@oclif/core";
23
23
 
24
24
  // src/run-log.ts
25
- import { readFile, writeFile, mkdir, appendFile } from "fs/promises";
25
+ import { readFile, writeFile, mkdir, appendFile, chmod } from "fs/promises";
26
26
  import { homedir } from "os";
27
27
  import { join } from "path";
28
28
  function runLogPath() {
@@ -33,10 +33,12 @@ function runLogDir() {
33
33
  }
34
34
  async function appendRunLog(entry) {
35
35
  const dir = runLogDir();
36
- await mkdir(dir, { recursive: true });
36
+ await mkdir(dir, { recursive: true, mode: 448 });
37
37
  const path = runLogPath();
38
38
  const line = JSON.stringify(entry) + "\n";
39
- await appendFile(path, line, "utf8");
39
+ await appendFile(path, line, { encoding: "utf8", mode: 384 });
40
+ await chmod(path, 384).catch(() => {
41
+ });
40
42
  pruneRunLog(path).catch(() => {
41
43
  });
42
44
  }
@@ -60,7 +62,7 @@ async function pruneRunLog(path) {
60
62
  const lines = raw.split("\n").filter(Boolean);
61
63
  if (lines.length <= RUN_LOG_MAX_ENTRIES) return;
62
64
  const trimmed = lines.slice(lines.length - RUN_LOG_MAX_ENTRIES);
63
- await writeFile(path, trimmed.join("\n") + "\n", "utf8");
65
+ await writeFile(path, trimmed.join("\n") + "\n", { encoding: "utf8", mode: 384 });
64
66
  } catch {
65
67
  }
66
68
  }
@@ -211,4 +213,4 @@ export {
211
213
  readRunLog,
212
214
  BaseCommand
213
215
  };
214
- //# sourceMappingURL=chunk-CKH6J7DI.js.map
216
+ //# sourceMappingURL=chunk-TU5UIODX.js.map
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  targetFingerprint,
3
3
  writtenAgainst
4
- } from "./chunk-UPWUXQ24.js";
4
+ } from "./chunk-YQLVRHJA.js";
5
5
  import {
6
6
  ensureMigrationsTable,
7
7
  getAppliedVersions,
@@ -10,13 +10,13 @@ import {
10
10
  } from "./chunk-HWRRFF55.js";
11
11
  import {
12
12
  isDestructiveSql
13
- } from "./chunk-YABERWV7.js";
14
- import {
15
- splitSqlStatements
16
- } from "./chunk-WK5YTINL.js";
13
+ } from "./chunk-WNZCOYOK.js";
17
14
  import {
18
15
  BaseCommand
19
- } from "./chunk-CKH6J7DI.js";
16
+ } from "./chunk-TU5UIODX.js";
17
+ import {
18
+ splitSqlStatements
19
+ } from "./chunk-YYS4FJ23.js";
20
20
  import {
21
21
  DEFAULT_IGNORE_SCHEMAS,
22
22
  bold,
@@ -180,4 +180,4 @@ export {
180
180
  findDestructiveStatements,
181
181
  truncateSql
182
182
  };
183
- //# sourceMappingURL=chunk-HGCTVCLV.js.map
183
+ //# sourceMappingURL=chunk-UUDXVYEI.js.map