@rebasepro/server-postgres 0.29.2 → 0.30.0
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/dist/{BranchService-X9R505mP.js → BranchService-CrXvcES2.js} +3 -3
- package/dist/{BranchService-X9R505mP.js.map → BranchService-CrXvcES2.js.map} +1 -1
- package/dist/PostgresBootstrapper.d.ts +7 -0
- package/dist/{backup-cli-CwiJEp_J.js → backup-cli-CTKCOLpX.js} +3 -3
- package/dist/{backup-cli-CwiJEp_J.js.map → backup-cli-CTKCOLpX.js.map} +1 -1
- package/dist/{boot-ddl-CbZj9ovZ.js → boot-ddl-CqGIwSYx.js} +2 -2
- package/dist/{boot-ddl-CbZj9ovZ.js.map → boot-ddl-CqGIwSYx.js.map} +1 -1
- package/dist/{cli-console-DDkNetCz.js → cli-console-DBPw-oAz.js} +5 -5
- package/dist/{cli-console-DDkNetCz.js.map → cli-console-DBPw-oAz.js.map} +1 -1
- package/dist/{cli-errors-C73Qy7WJ.js → cli-errors-DYTxnLbW.js} +5 -5
- package/dist/{cli-errors-C73Qy7WJ.js.map → cli-errors-DYTxnLbW.js.map} +1 -1
- package/dist/cli.js +62 -42
- package/dist/cli.js.map +1 -1
- package/dist/{database-preflight-DIauc8i5.js → database-preflight-iBpT7-vv.js} +2 -2
- package/dist/{database-preflight-DIauc8i5.js.map → database-preflight-iBpT7-vv.js.map} +1 -1
- package/dist/{deferred-index-build-DDdnjaOW.js → deferred-index-build-BCU9RoHK.js} +6 -6
- package/dist/{deferred-index-build-DDdnjaOW.js.map → deferred-index-build-BCU9RoHK.js.map} +1 -1
- package/dist/{doctor-DwMXljiq.js → doctor-Kg1oUK0Q.js} +6 -6
- package/dist/{doctor-DwMXljiq.js.map → doctor-Kg1oUK0Q.js.map} +1 -1
- package/dist/{ensure-collection-policies-DJsOMpaI.js → ensure-collection-policies-Bo-_fDAy.js} +12 -12
- package/dist/ensure-collection-policies-Bo-_fDAy.js.map +1 -0
- package/dist/{ensure-collection-tables-h1mUO7Uu.js → ensure-collection-tables-DCJINkT_.js} +9 -9
- package/dist/{ensure-collection-tables-h1mUO7Uu.js.map → ensure-collection-tables-DCJINkT_.js.map} +1 -1
- package/dist/{ensure-tables-CUqYgMvo.js → ensure-tables-BPGaGh0y.js} +4 -4
- package/dist/{ensure-tables-CUqYgMvo.js.map → ensure-tables-BPGaGh0y.js.map} +1 -1
- package/dist/{enum-labels-kept-z7ustOl_.js → enum-labels-kept-YAgOZS4I.js} +3 -3
- package/dist/{enum-labels-kept-z7ustOl_.js.map → enum-labels-kept-YAgOZS4I.js.map} +1 -1
- package/dist/{generate-drizzle-schema-BIUqhSzh.js → generate-drizzle-schema-DcrFr7YX.js} +2 -2
- package/dist/{generate-drizzle-schema-BIUqhSzh.js.map → generate-drizzle-schema-DcrFr7YX.js.map} +1 -1
- package/dist/{generate-drizzle-schema-logic-BBXjxm5z.js → generate-drizzle-schema-logic-LTLZvt6r.js} +2 -2
- package/dist/{generate-drizzle-schema-logic-BBXjxm5z.js.map → generate-drizzle-schema-logic-LTLZvt6r.js.map} +1 -1
- package/dist/{generate-files-BkiRFoV1.js → generate-files-CsaVzatS.js} +3 -3
- package/dist/{generate-files-BkiRFoV1.js.map → generate-files-CsaVzatS.js.map} +1 -1
- package/dist/{generate-postgres-ddl-logic-G9PvjHrr.js → generate-postgres-ddl-logic-Dg0bcENZ.js} +39 -6
- package/dist/generate-postgres-ddl-logic-Dg0bcENZ.js.map +1 -0
- package/dist/{generated-schema-diff-D2soazQU.js → generated-schema-diff-By4dxyTH.js} +2 -2
- package/dist/{generated-schema-diff-D2soazQU.js.map → generated-schema-diff-By4dxyTH.js.map} +1 -1
- package/dist/index.es.js +12 -12
- package/dist/{migrate-baseline-CveNQli3.js → migrate-baseline-CmWXL7qx.js} +2 -2
- package/dist/{migrate-baseline-CveNQli3.js.map → migrate-baseline-CmWXL7qx.js.map} +1 -1
- package/dist/{migrate-policy-stamps-C4qbQ0jK.js → migrate-policy-stamps-BN_Qad6c.js} +6 -6
- package/dist/{migrate-policy-stamps-C4qbQ0jK.js.map → migrate-policy-stamps-BN_Qad6c.js.map} +1 -1
- package/dist/{open-rebase-Cvid3iwR.js → open-rebase-40paQfVW.js} +31 -24
- package/dist/{open-rebase-Cvid3iwR.js.map → open-rebase-40paQfVW.js.map} +1 -1
- package/dist/{pg-error-utils-80uTIHQs.js → pg-error-utils-DJHjCF7-.js} +2 -2
- package/dist/{pg-error-utils-80uTIHQs.js.map → pg-error-utils-DJHjCF7-.js.map} +1 -1
- package/dist/{plan-schema-CMhNYEYF.js → plan-schema-vJd3UEmT.js} +24 -9
- package/dist/plan-schema-vJd3UEmT.js.map +1 -0
- package/dist/{policy-drift-Bx6663KD.js → policy-drift-C-m0uWHH.js} +53 -8
- package/dist/policy-drift-C-m0uWHH.js.map +1 -0
- package/dist/{push-index-adoption-C-TpM445.js → push-index-adoption-Cp7oZxSl.js} +3 -3
- package/dist/{push-index-adoption-C-TpM445.js.map → push-index-adoption-Cp7oZxSl.js.map} +1 -1
- package/dist/{push-index-prebuild-xbpgZEJK.js → push-index-prebuild-DbwKGtQT.js} +4 -4
- package/dist/{push-index-prebuild-xbpgZEJK.js.map → push-index-prebuild-DbwKGtQT.js.map} +1 -1
- package/dist/{push-kept-defaults-D-JEv0Gn.js → push-kept-defaults-CLcgsEPt.js} +2 -2
- package/dist/{push-kept-defaults-D-JEv0Gn.js.map → push-kept-defaults-CLcgsEPt.js.map} +1 -1
- package/dist/{push-legacy-renames-7UKspspl.js → push-legacy-renames-BthD0E9W.js} +4 -4
- package/dist/{push-legacy-renames-7UKspspl.js.map → push-legacy-renames-BthD0E9W.js.map} +1 -1
- package/dist/{push-policy-plan-BOw5PtU8.js → push-policy-plan-BgcrroxQ.js} +3 -3
- package/dist/{push-policy-plan-BOw5PtU8.js.map → push-policy-plan-BgcrroxQ.js.map} +1 -1
- package/dist/{render-ddl-Di-fTGti.js → render-ddl-Ci3S_SoI.js} +23 -5
- package/dist/render-ddl-Ci3S_SoI.js.map +1 -0
- package/dist/{request-role-cli-Bxxskru9.js → request-role-cli-Dy1EgJU9.js} +8 -8
- package/dist/{request-role-cli-Bxxskru9.js.map → request-role-cli-Dy1EgJU9.js.map} +1 -1
- package/dist/{request-role-migration-BCW4v0rq.js → request-role-migration-GHTJnPMV.js} +2 -2
- package/dist/{request-role-migration-BCW4v0rq.js.map → request-role-migration-GHTJnPMV.js.map} +1 -1
- package/dist/{rls-bootstrap-sql-CxszeSc7.js → rls-bootstrap-sql-kPX4-MB1.js} +18 -3
- package/dist/rls-bootstrap-sql-kPX4-MB1.js.map +1 -0
- package/dist/{rls-enforcement-CyUCPDH8.js → rls-enforcement-Cc_UhOxb.js} +109 -6
- package/dist/rls-enforcement-Cc_UhOxb.js.map +1 -0
- package/dist/schema/doctor-cli.js +7 -7
- package/dist/schema/ensure-collection-policies.d.ts +8 -0
- package/dist/schema/generate-drizzle-schema.js +1 -1
- package/dist/schema/generate-postgres-ddl-logic.d.ts +9 -0
- package/dist/schema/generate-postgres-ddl.js +1 -1
- package/dist/schema/introspect-db.js +1 -1
- package/dist/schema/plan/types.d.ts +13 -0
- package/dist/schema/rls-bootstrap-sql.d.ts +6 -0
- package/dist/security/policy-drift.d.ts +13 -1
- package/dist/security/rls-enforcement.d.ts +31 -0
- package/dist/{websocket-BSYV_KSw.js → websocket-B7ex6AQM.js} +3 -3
- package/dist/{websocket-BSYV_KSw.js.map → websocket-B7ex6AQM.js.map} +1 -1
- package/package.json +7 -7
- package/dist/ensure-collection-policies-DJsOMpaI.js.map +0 -1
- package/dist/generate-postgres-ddl-logic-G9PvjHrr.js.map +0 -1
- package/dist/plan-schema-CMhNYEYF.js.map +0 -1
- package/dist/policy-drift-Bx6663KD.js.map +0 -1
- package/dist/render-ddl-Di-fTGti.js.map +0 -1
- package/dist/rls-bootstrap-sql-CxszeSc7.js.map +0 -1
- package/dist/rls-enforcement-CyUCPDH8.js.map +0 -1
package/dist/cli.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { createRequire as __createRequire } from "module";
|
|
2
2
|
__createRequire(import.meta.url);
|
|
3
3
|
import { n as require_arg, o as __toESM, t as promptConfirm } from "./cli-prompt-DXG0yk-h.js";
|
|
4
|
-
import { $ as fromAlterTable, A as getTableExcludes, B as readVectorDdl, C as detectProjectPackageManager, D as ensureDevDatabaseExists, E as dropGeneratedColumns, F as queryColumnTypes, G as DESIRED_STATE_URL, H as resolveLocalBin, I as queryGeneratedColumnDependencies, J as prepareGeneratedSqlDir, K as GENERATED_SQL_DIR, L as queryUndeclarableConstraints, M as getUndeclaredConstraintExcludes, N as getVectorExcludes, O as getForeignIndexExcludes, P as loadCollectionsForCli, Q as extractPlanStatements, R as readSearchDdl, S as describeReinstallCommand, T as dropDevDatabase, U as withAppClient, V as readViewsDdl, W as workspaceMemberDir, X as destructiveOptInFlag, Y as decidePushSafety, Z as detectDestructiveStatements, _ as atlasDevDatabaseUrl, a as diagnoseDbError, b as describeBuildScriptRemedy, c as isEconnrefused, d as reportCommandFailure, et as isSyncedPlan, f as ExcludeIntrospectionError, g as applyViewsDdl, h as applyVectorDdl, i as diagnoseAtlasFailure, it as redactConnectionPasswords, j as getTriggerExcludes, k as getSearchExcludes, l as isSslNotEnabled, m as applyTriggersDdl, nt as forAtlas, o as formatForeignGeneratedColumnBanner, p as applySearchDdl, q as generatedSqlDir, s as isAuthFailure, t as checkDatabaseConnectivity, tt as warnIfYesApprovedDestructive, w as diagnoseMissingBin, x as describeDevAddCommand, y as closeAppClients, z as readTriggersDdl } from "./cli-errors-
|
|
5
|
-
import {
|
|
4
|
+
import { $ as fromAlterTable, A as getTableExcludes, B as readVectorDdl, C as detectProjectPackageManager, D as ensureDevDatabaseExists, E as dropGeneratedColumns, F as queryColumnTypes, G as DESIRED_STATE_URL, H as resolveLocalBin, I as queryGeneratedColumnDependencies, J as prepareGeneratedSqlDir, K as GENERATED_SQL_DIR, L as queryUndeclarableConstraints, M as getUndeclaredConstraintExcludes, N as getVectorExcludes, O as getForeignIndexExcludes, P as loadCollectionsForCli, Q as extractPlanStatements, R as readSearchDdl, S as describeReinstallCommand, T as dropDevDatabase, U as withAppClient, V as readViewsDdl, W as workspaceMemberDir, X as destructiveOptInFlag, Y as decidePushSafety, Z as detectDestructiveStatements, _ as atlasDevDatabaseUrl, a as diagnoseDbError, b as describeBuildScriptRemedy, c as isEconnrefused, d as reportCommandFailure, et as isSyncedPlan, f as ExcludeIntrospectionError, g as applyViewsDdl, h as applyVectorDdl, i as diagnoseAtlasFailure, it as redactConnectionPasswords, j as getTriggerExcludes, k as getSearchExcludes, l as isSslNotEnabled, m as applyTriggersDdl, nt as forAtlas, o as formatForeignGeneratedColumnBanner, p as applySearchDdl, q as generatedSqlDir, s as isAuthFailure, t as checkDatabaseConnectivity, tt as warnIfYesApprovedDestructive, w as diagnoseMissingBin, x as describeDevAddCommand, y as closeAppClients, z as readTriggersDdl } from "./cli-errors-DYTxnLbW.js";
|
|
5
|
+
import { i as RLS_BOOTSTRAP_SQL, o as dropLegacyAuthSchema, r as REQUEST_ROLE_FUNCTION_SQL, t as ADMIN_POLICY_ROLE_SQL } from "./rls-bootstrap-sql-kPX4-MB1.js";
|
|
6
6
|
import { a as outWarn, i as outError, o as atlasExcludePattern, r as out, s as excludePatternParts, t as chalk } from "./source-fZb92pN8.js";
|
|
7
|
-
import { C as declaredIndexesIfNotExists, S as execa, b as parseDriverLine, c as isDriverDbSubcommand, d as branchNameIn, f as branchSourceIn, g as assertKnownFlags, i as latestRecordedMigration, l as backupActionOf, m as unexpectedBranchArgs, o as planBaseline, p as resolveBranchSwitches, r as describeBaselinePlan, s as DRIVER_DB_SUBCOMMANDS, t as baselineVersionProblem, v as collectionsPathIn, w as indexAdoptionStatement, x as resolveDriverSwitches } from "./migrate-baseline-
|
|
7
|
+
import { C as declaredIndexesIfNotExists, S as execa, b as parseDriverLine, c as isDriverDbSubcommand, d as branchNameIn, f as branchSourceIn, g as assertKnownFlags, i as latestRecordedMigration, l as backupActionOf, m as unexpectedBranchArgs, o as planBaseline, p as resolveBranchSwitches, r as describeBaselinePlan, s as DRIVER_DB_SUBCOMMANDS, t as baselineVersionProblem, v as collectionsPathIn, w as indexAdoptionStatement, x as resolveDriverSwitches } from "./migrate-baseline-CmWXL7qx.js";
|
|
8
8
|
import { t as nextStepAfterDbGenerate } from "./generate-next-step-DgK5BlBn.js";
|
|
9
9
|
import { REBASE_ADMIN_ROLE, declaredRlsPolicyShape } from "@rebasepro/types";
|
|
10
10
|
import { formatRelativeTime } from "@rebasepro/utils";
|
|
@@ -1217,7 +1217,7 @@ function generatesInProcess() {
|
|
|
1217
1217
|
async function generateInProcess(what, label, run) {
|
|
1218
1218
|
let generators;
|
|
1219
1219
|
try {
|
|
1220
|
-
generators = await import("./generate-files-
|
|
1220
|
+
generators = await import("./generate-files-CsaVzatS.js").then((n) => n.t);
|
|
1221
1221
|
} catch (err) {
|
|
1222
1222
|
outError(chalk.red(`✗ Failed to run ${what}: ${err instanceof Error ? err.message : String(err)}`));
|
|
1223
1223
|
process.exit(1);
|
|
@@ -1264,7 +1264,7 @@ async function runPluginCommand(args) {
|
|
|
1264
1264
|
else if (domain === "schema") await schemaCommand(subcommand, args);
|
|
1265
1265
|
else if (domain === "doctor") await doctorPluginCommand(args);
|
|
1266
1266
|
else if (domain === "console") {
|
|
1267
|
-
const { consoleCommand } = await import("./cli-console-
|
|
1267
|
+
const { consoleCommand } = await import("./cli-console-DBPw-oAz.js");
|
|
1268
1268
|
process.exitCode = await consoleCommand(args);
|
|
1269
1269
|
} else {
|
|
1270
1270
|
outError(chalk.red(`Unknown domain command: ${domain}`));
|
|
@@ -1450,17 +1450,17 @@ async function dbCommand(subcommand, rawArgs) {
|
|
|
1450
1450
|
return;
|
|
1451
1451
|
}
|
|
1452
1452
|
if (subcommand === "request-role") {
|
|
1453
|
-
const { requestRoleCommand } = await import("./request-role-cli-
|
|
1453
|
+
const { requestRoleCommand } = await import("./request-role-cli-Dy1EgJU9.js").then((n) => n.r);
|
|
1454
1454
|
await requestRoleCommand(rawArgs);
|
|
1455
1455
|
return;
|
|
1456
1456
|
}
|
|
1457
1457
|
if (subcommand === "provision") {
|
|
1458
|
-
const { provisionCommand } = await import("./request-role-cli-
|
|
1458
|
+
const { provisionCommand } = await import("./request-role-cli-Dy1EgJU9.js").then((n) => n.r);
|
|
1459
1459
|
await provisionCommand(rawArgs);
|
|
1460
1460
|
return;
|
|
1461
1461
|
}
|
|
1462
1462
|
if (subcommand === "backup" || subcommand === "restore" || subcommand === "backups") {
|
|
1463
|
-
const { backupCommand, restoreCommand, backupsCommand } = await import("./backup-cli-
|
|
1463
|
+
const { backupCommand, restoreCommand, backupsCommand } = await import("./backup-cli-CTKCOLpX.js").then((n) => n.t);
|
|
1464
1464
|
if (subcommand === "backup" && backupActionOf(rawArgs) === "list") await backupsCommand(rawArgs);
|
|
1465
1465
|
else if (subcommand === "backup") await backupCommand(rawArgs);
|
|
1466
1466
|
else if (subcommand === "restore") await restoreCommand(rawArgs);
|
|
@@ -1508,7 +1508,7 @@ async function dbCommand(subcommand, rawArgs) {
|
|
|
1508
1508
|
}
|
|
1509
1509
|
const searchContent = readSearchDdl();
|
|
1510
1510
|
if (searchContent) {
|
|
1511
|
-
const { searchColumnDependencies } = await import("./generate-postgres-ddl-logic-
|
|
1511
|
+
const { searchColumnDependencies } = await import("./generate-postgres-ddl-logic-Dg0bcENZ.js").then((n) => n.s);
|
|
1512
1512
|
const migrationConflicts = findGeneratedColumnConflicts(parseColumnMutations(migrationContent), searchColumnDependencies(await loadCollectionsForCli(collectionsPath)));
|
|
1513
1513
|
const preamble = migrationDropPreamble(migrationConflicts);
|
|
1514
1514
|
if (preamble) {
|
|
@@ -1788,7 +1788,8 @@ async function dbCommand(subcommand, rawArgs) {
|
|
|
1788
1788
|
await retireLegacyAuthSchema(databaseUrl);
|
|
1789
1789
|
const adminRoleAvailable = await readAdminPoliciesLive(databaseUrl);
|
|
1790
1790
|
if (!adminRoleAvailable) await moveAdminPoliciesToPublic(databaseUrl, collectionsPath);
|
|
1791
|
-
|
|
1791
|
+
await dropStaleCompanions(databaseUrl, collectionsPath, adminRoleAvailable);
|
|
1792
|
+
const { stampMigratedPolicies } = await import("./migrate-policy-stamps-BN_Qad6c.js");
|
|
1792
1793
|
await stampMigratedPolicies(databaseUrl, collectionsPath, adminRoleAvailable);
|
|
1793
1794
|
}
|
|
1794
1795
|
}
|
|
@@ -1816,8 +1817,8 @@ async function dbCommand(subcommand, rawArgs) {
|
|
|
1816
1817
|
* no such column reads nothing.
|
|
1817
1818
|
*/
|
|
1818
1819
|
async function keepDatabaseOwnedDefaults(databaseUrl, collectionsPath) {
|
|
1819
|
-
const { loadCollections } = await import("./doctor-
|
|
1820
|
-
const { databaseOwnedDefaultColumns, readKeptDefaults, withKeptDefaults } = await import("./push-kept-defaults-
|
|
1820
|
+
const { loadCollections } = await import("./doctor-Kg1oUK0Q.js").then((n) => n.t);
|
|
1821
|
+
const { databaseOwnedDefaultColumns, readKeptDefaults, withKeptDefaults } = await import("./push-kept-defaults-CLcgsEPt.js");
|
|
1821
1822
|
const columns = databaseOwnedDefaultColumns(await loadCollections(path.resolve(process.cwd(), collectionsPath)));
|
|
1822
1823
|
if (columns.length === 0) return;
|
|
1823
1824
|
let kept;
|
|
@@ -1842,8 +1843,8 @@ async function keepDatabaseOwnedDefaults(databaseUrl, collectionsPath) {
|
|
|
1842
1843
|
async function renameLegacyForeignKeys(databaseUrl, collectionsPath, dryRun) {
|
|
1843
1844
|
let renames;
|
|
1844
1845
|
try {
|
|
1845
|
-
const { loadCollections } = await import("./doctor-
|
|
1846
|
-
const { legacyForeignKeyRenames } = await import("./push-legacy-renames-
|
|
1846
|
+
const { loadCollections } = await import("./doctor-Kg1oUK0Q.js").then((n) => n.t);
|
|
1847
|
+
const { legacyForeignKeyRenames } = await import("./push-legacy-renames-BthD0E9W.js");
|
|
1847
1848
|
const collections = await loadCollections(path.resolve(process.cwd(), collectionsPath));
|
|
1848
1849
|
renames = await withAppClient(databaseUrl, (client) => legacyForeignKeyRenames({ query: async (text) => ({ rows: (await client.query(text)).rows }) }, collections));
|
|
1849
1850
|
} catch {
|
|
@@ -1863,8 +1864,8 @@ async function renameLegacyForeignKeys(databaseUrl, collectionsPath, dryRun) {
|
|
|
1863
1864
|
async function adoptIdenticalIndexes(databaseUrl, collectionsPath, dryRun) {
|
|
1864
1865
|
let adoptions;
|
|
1865
1866
|
try {
|
|
1866
|
-
const { loadCollections } = await import("./doctor-
|
|
1867
|
-
const { pushIndexAdoptions } = await import("./push-index-adoption-
|
|
1867
|
+
const { loadCollections } = await import("./doctor-Kg1oUK0Q.js").then((n) => n.t);
|
|
1868
|
+
const { pushIndexAdoptions } = await import("./push-index-adoption-Cp7oZxSl.js");
|
|
1868
1869
|
const collections = await loadCollections(path.resolve(process.cwd(), collectionsPath));
|
|
1869
1870
|
adoptions = await withAppClient(databaseUrl, (client) => pushIndexAdoptions({ query: async (text) => ({ rows: (await client.query(text)).rows }) }, collections));
|
|
1870
1871
|
} catch {
|
|
@@ -1882,8 +1883,8 @@ async function adoptIdenticalIndexes(databaseUrl, collectionsPath, dryRun) {
|
|
|
1882
1883
|
/** Names the enum labels the database keeps after the collections dropped them. See `schema/enum-labels-kept.ts`. */
|
|
1883
1884
|
async function reportKeptEnumLabels(databaseUrl, collectionsPath) {
|
|
1884
1885
|
try {
|
|
1885
|
-
const { loadCollections } = await import("./doctor-
|
|
1886
|
-
const { keptEnumLabels, formatKeptEnumLabelsNotice } = await import("./enum-labels-kept-
|
|
1886
|
+
const { loadCollections } = await import("./doctor-Kg1oUK0Q.js").then((n) => n.t);
|
|
1887
|
+
const { keptEnumLabels, formatKeptEnumLabelsNotice } = await import("./enum-labels-kept-YAgOZS4I.js");
|
|
1887
1888
|
const collections = await loadCollections(path.resolve(process.cwd(), collectionsPath));
|
|
1888
1889
|
const kept = await withAppClient(databaseUrl, (client) => keptEnumLabels({ query: async (text) => ({ rows: (await client.query(text)).rows }) }, collections));
|
|
1889
1890
|
if (kept.length > 0) outWarn(chalk.yellow(formatKeptEnumLabelsNotice(kept)));
|
|
@@ -1892,8 +1893,8 @@ async function reportKeptEnumLabels(databaseUrl, collectionsPath) {
|
|
|
1892
1893
|
async function prebuildForeignKeyIndexes(databaseUrl, collectionsPath, dryRun) {
|
|
1893
1894
|
let missing;
|
|
1894
1895
|
try {
|
|
1895
|
-
const { loadCollections } = await import("./doctor-
|
|
1896
|
-
const { missingForeignKeyIndexes } = await import("./push-index-prebuild-
|
|
1896
|
+
const { loadCollections } = await import("./doctor-Kg1oUK0Q.js").then((n) => n.t);
|
|
1897
|
+
const { missingForeignKeyIndexes } = await import("./push-index-prebuild-DbwKGtQT.js");
|
|
1897
1898
|
const collections = await loadCollections(path.resolve(process.cwd(), collectionsPath));
|
|
1898
1899
|
missing = await withAppClient(databaseUrl, (client) => missingForeignKeyIndexes({ query: async (text) => ({ rows: (await client.query(text)).rows }) }, collections));
|
|
1899
1900
|
} catch {
|
|
@@ -1903,7 +1904,7 @@ async function prebuildForeignKeyIndexes(databaseUrl, collectionsPath, dryRun) {
|
|
|
1903
1904
|
if (missing.length === 0 || dryRun) return names;
|
|
1904
1905
|
out(chalk.gray(` Building ${missing.length} foreign-key index(es) on existing tables first — CONCURRENTLY, so writes go on:`));
|
|
1905
1906
|
try {
|
|
1906
|
-
const { buildDeferredIndexes } = await import("./deferred-index-build-
|
|
1907
|
+
const { buildDeferredIndexes } = await import("./deferred-index-build-BCU9RoHK.js").then((n) => n.r);
|
|
1907
1908
|
const outcome = await withAppClient(databaseUrl, (client) => buildDeferredIndexes(async () => ({
|
|
1908
1909
|
dedicated: true,
|
|
1909
1910
|
query: async (text) => ({ rows: (await client.query(text)).rows }),
|
|
@@ -1951,9 +1952,9 @@ async function lockManagedTables(databaseUrl, collectionsPath) {
|
|
|
1951
1952
|
let unsecured;
|
|
1952
1953
|
let userRole;
|
|
1953
1954
|
try {
|
|
1954
|
-
const { lockCollectionTables } = await import("./ensure-collection-policies-
|
|
1955
|
-
const { loadCollections } = await import("./doctor-
|
|
1956
|
-
const { readRecordedRequestRoles } = await import("./rls-enforcement-
|
|
1955
|
+
const { lockCollectionTables } = await import("./ensure-collection-policies-Bo-_fDAy.js");
|
|
1956
|
+
const { loadCollections } = await import("./doctor-Kg1oUK0Q.js").then((n) => n.t);
|
|
1957
|
+
const { readRecordedRequestRoles } = await import("./rls-enforcement-Cc_UhOxb.js").then((n) => n.y);
|
|
1957
1958
|
const { cliRlsSettings } = await import("./rls-settings-BCGMIig3.js").then((n) => n.a);
|
|
1958
1959
|
const collections = await loadCollections(path.resolve(process.cwd(), collectionsPath));
|
|
1959
1960
|
({unsecured, userRole} = await withAppClient(databaseUrl, async (client) => {
|
|
@@ -1996,8 +1997,8 @@ async function lockManagedTables(databaseUrl, collectionsPath) {
|
|
|
1996
1997
|
async function ensureAuthTables(databaseUrl, collectionsPath) {
|
|
1997
1998
|
try {
|
|
1998
1999
|
const { drizzle } = await import("drizzle-orm/node-postgres");
|
|
1999
|
-
const { ensureAuthTablesExist } = await import("./ensure-tables-
|
|
2000
|
-
const { loadCollections } = await import("./doctor-
|
|
2000
|
+
const { ensureAuthTablesExist } = await import("./ensure-tables-BPGaGh0y.js").then((n) => n.n);
|
|
2001
|
+
const { loadCollections } = await import("./doctor-Kg1oUK0Q.js").then((n) => n.t);
|
|
2001
2002
|
const authCollection = (await loadCollections(path.resolve(process.cwd(), collectionsPath))).find((c) => {
|
|
2002
2003
|
const a = c.auth;
|
|
2003
2004
|
return a === true || typeof a === "object" && a !== null && a.enabled === true;
|
|
@@ -2017,7 +2018,7 @@ async function ensureRlsUserRole(databaseUrl) {
|
|
|
2017
2018
|
const schemas = ["public", "rebase"];
|
|
2018
2019
|
let rls;
|
|
2019
2020
|
try {
|
|
2020
|
-
rls = await import("./rls-enforcement-
|
|
2021
|
+
rls = await import("./rls-enforcement-Cc_UhOxb.js").then((n) => n.y);
|
|
2021
2022
|
} catch (err) {
|
|
2022
2023
|
outError(chalk.red(`\n ✗ Could not load the RLS provisioning module: ${err instanceof Error ? err.message : String(err)}`));
|
|
2023
2024
|
return;
|
|
@@ -2101,21 +2102,40 @@ async function applyPolicies(databaseUrl, collectionsPath) {
|
|
|
2101
2102
|
*/
|
|
2102
2103
|
async function readAdminPoliciesLive(databaseUrl) {
|
|
2103
2104
|
try {
|
|
2104
|
-
const { adminPoliciesLiveForCli } = await import("./rls-enforcement-
|
|
2105
|
+
const { adminPoliciesLiveForCli } = await import("./rls-enforcement-Cc_UhOxb.js").then((n) => n.y);
|
|
2105
2106
|
return await withAppClient(databaseUrl, (client) => adminPoliciesLiveForCli(async (text) => (await client.query(text)).rows));
|
|
2106
2107
|
} catch {
|
|
2107
2108
|
return false;
|
|
2108
2109
|
}
|
|
2109
2110
|
}
|
|
2110
2111
|
/**
|
|
2112
|
+
* After a migration: drop the admin-request companions no current rule earns
|
|
2113
|
+
* (`dropStaleAdminRequestCompanions`). Fatal when it fails — a stale one
|
|
2114
|
+
* admits every admin to every row, and a boot without provisioning never
|
|
2115
|
+
* takes it back.
|
|
2116
|
+
*/
|
|
2117
|
+
async function dropStaleCompanions(databaseUrl, collectionsPath, adminRoleAvailable) {
|
|
2118
|
+
const { loadCollections } = await import("./doctor-Kg1oUK0Q.js").then((n) => n.t);
|
|
2119
|
+
const { dropStaleAdminRequestCompanions } = await import("./policy-drift-C-m0uWHH.js").then((n) => n.s);
|
|
2120
|
+
const collections = await loadCollections(path.resolve(process.cwd(), collectionsPath));
|
|
2121
|
+
try {
|
|
2122
|
+
const dropped = await withAppClient(databaseUrl, (client) => dropStaleAdminRequestCompanions(client, collections, { adminRoleAvailable }));
|
|
2123
|
+
for (const p of dropped) out(chalk.gray(` ✓ Dropped stale admin-request policy "${p.name}" on ${p.schema}.${p.table}`));
|
|
2124
|
+
} catch (err) {
|
|
2125
|
+
outError(chalk.red(` ✗ Could not drop stale admin-request policies: ${err instanceof Error ? err.message : String(err)}`));
|
|
2126
|
+
outError(chalk.gray(" A rule changed since they were written, and they still admit every admin to every row. Run `rebase db push`, or boot the server with provisioning on."));
|
|
2127
|
+
process.exit(1);
|
|
2128
|
+
}
|
|
2129
|
+
}
|
|
2130
|
+
/**
|
|
2111
2131
|
* After a migration: the server-or-admin policies it wrote `TO rebase_admin`
|
|
2112
2132
|
* go `TO public` where the admin switch is not live, as `applyPolicies` writes
|
|
2113
2133
|
* them on a push. Fatal when it fails — those policies refuse every admin
|
|
2114
2134
|
* caller, and a boot without provisioning would leave them so.
|
|
2115
2135
|
*/
|
|
2116
2136
|
async function moveAdminPoliciesToPublic(databaseUrl, collectionsPath) {
|
|
2117
|
-
const { loadCollections } = await import("./doctor-
|
|
2118
|
-
const { moveMigratedAdminPoliciesToPublic } = await import("./migrate-policy-stamps-
|
|
2137
|
+
const { loadCollections } = await import("./doctor-Kg1oUK0Q.js").then((n) => n.t);
|
|
2138
|
+
const { moveMigratedAdminPoliciesToPublic } = await import("./migrate-policy-stamps-BN_Qad6c.js");
|
|
2119
2139
|
const collections = await loadCollections(path.resolve(process.cwd(), collectionsPath));
|
|
2120
2140
|
try {
|
|
2121
2141
|
if (await withAppClient(databaseUrl, (client) => moveMigratedAdminPoliciesToPublic({ query: async (text, values) => ({ rows: (await client.query(text, values)).rows }) }, collections, (message) => outWarn(chalk.yellow(` ⚠️ ${message}`)))) > 0) out(chalk.gray(` The server-or-admin policies are written TO public: the admin request roles are not set up for this database (\`rebase doctor --database\` says what is missing). A server boot that sets them up moves them TO ${REBASE_ADMIN_ROLE}.`));
|
|
@@ -2136,8 +2156,8 @@ async function moveAdminPoliciesToPublic(databaseUrl, collectionsPath) {
|
|
|
2136
2156
|
* rule that names `rebase_admin` itself is left exactly as written.
|
|
2137
2157
|
*/
|
|
2138
2158
|
async function policiesToPublic(collectionsPath, policiesSql) {
|
|
2139
|
-
const { loadCollections } = await import("./doctor-
|
|
2140
|
-
const { planCollectionPolicies } = await import("./generate-postgres-ddl-logic-
|
|
2159
|
+
const { loadCollections } = await import("./doctor-Kg1oUK0Q.js").then((n) => n.t);
|
|
2160
|
+
const { planCollectionPolicies } = await import("./generate-postgres-ddl-logic-Dg0bcENZ.js").then((n) => n.s);
|
|
2141
2161
|
const collections = await loadCollections(path.resolve(process.cwd(), collectionsPath));
|
|
2142
2162
|
const fallback = new Map(planCollectionPolicies(collections, { adminRoleAvailable: false }).flatMap((plan) => plan.policies.map((policy) => [`${plan.qualified}.${policy.name}`, policy.statements])));
|
|
2143
2163
|
let sql = policiesSql;
|
|
@@ -2152,9 +2172,9 @@ async function policiesToPublic(collectionsPath, policiesSql) {
|
|
|
2152
2172
|
}
|
|
2153
2173
|
async function policyStamping(databaseUrl, collectionsPath, policiesSql, adminRoleAvailable = true) {
|
|
2154
2174
|
try {
|
|
2155
|
-
const { loadCollections } = await import("./doctor-
|
|
2156
|
-
const { planCollectionPolicies } = await import("./generate-postgres-ddl-logic-
|
|
2157
|
-
const { policyStampSql } = await import("./ensure-collection-policies-
|
|
2175
|
+
const { loadCollections } = await import("./doctor-Kg1oUK0Q.js").then((n) => n.t);
|
|
2176
|
+
const { planCollectionPolicies } = await import("./generate-postgres-ddl-logic-Dg0bcENZ.js").then((n) => n.s);
|
|
2177
|
+
const { policyStampSql } = await import("./ensure-collection-policies-Bo-_fDAy.js");
|
|
2158
2178
|
const { pinSearchPath } = await import("./connection-C1zXTPJq.js").then((n) => n.r);
|
|
2159
2179
|
return {
|
|
2160
2180
|
statements: stampableTables(planCollectionPolicies(await loadCollections(path.resolve(process.cwd(), collectionsPath)), { adminRoleAvailable }), policiesSql).map((plan) => policyStampSql(plan)).filter((statement) => statement !== void 0),
|
|
@@ -2172,8 +2192,8 @@ async function policyStamping(databaseUrl, collectionsPath, policiesSql, adminRo
|
|
|
2172
2192
|
*/
|
|
2173
2193
|
async function readPolicyPushPlan(databaseUrl, collectionsPath) {
|
|
2174
2194
|
try {
|
|
2175
|
-
const { formatPolicyPushPlan, planPolicyPush, summarizePolicyPushPlan } = await import("./push-policy-plan-
|
|
2176
|
-
const { loadCollections } = await import("./doctor-
|
|
2195
|
+
const { formatPolicyPushPlan, planPolicyPush, summarizePolicyPushPlan } = await import("./push-policy-plan-BgcrroxQ.js");
|
|
2196
|
+
const { loadCollections } = await import("./doctor-Kg1oUK0Q.js").then((n) => n.t);
|
|
2177
2197
|
const { pinSearchPath } = await import("./connection-C1zXTPJq.js").then((n) => n.r);
|
|
2178
2198
|
const collections = await loadCollections(path.resolve(process.cwd(), collectionsPath));
|
|
2179
2199
|
const adminRoleAvailable = await readAdminPoliciesLive(databaseUrl);
|
|
@@ -2205,8 +2225,8 @@ async function readPolicyPushPlan(databaseUrl, collectionsPath) {
|
|
|
2205
2225
|
*/
|
|
2206
2226
|
async function reconcilePolicies(databaseUrl, collectionsPath) {
|
|
2207
2227
|
try {
|
|
2208
|
-
const { checkPolicyDrift, dropOrphanedPolicies, formatPolicyDrift, hasDrift } = await import("./policy-drift-
|
|
2209
|
-
const { loadCollections } = await import("./doctor-
|
|
2228
|
+
const { checkPolicyDrift, dropOrphanedPolicies, formatPolicyDrift, hasDrift } = await import("./policy-drift-C-m0uWHH.js").then((n) => n.s);
|
|
2229
|
+
const { loadCollections } = await import("./doctor-Kg1oUK0Q.js").then((n) => n.t);
|
|
2210
2230
|
const collections = await loadCollections(path.resolve(process.cwd(), collectionsPath));
|
|
2211
2231
|
const adminRoleAvailable = await readAdminPoliciesLive(databaseUrl);
|
|
2212
2232
|
await withAppClient(databaseUrl, async (client) => {
|
|
@@ -2293,7 +2313,7 @@ async function branchCommand(rawArgs) {
|
|
|
2293
2313
|
process.exit(1);
|
|
2294
2314
|
}
|
|
2295
2315
|
const { DatabasePoolManager } = await import("./databasePoolManager-DIjzlTK4.js").then((n) => n.n);
|
|
2296
|
-
const { BranchService, reopenClosedDatabases, reopenedDatabasesNotice } = await import("./BranchService-
|
|
2316
|
+
const { BranchService, reopenClosedDatabases, reopenedDatabasesNotice } = await import("./BranchService-CrXvcES2.js").then((n) => n.n);
|
|
2297
2317
|
const { drizzle } = await import("drizzle-orm/node-postgres");
|
|
2298
2318
|
const { Pool } = await import("pg");
|
|
2299
2319
|
const healed = await reopenClosedDatabases(databaseUrl, [branchAction === "create" ? createSource(rawArgs) : void 0, process.env[ACTIVE_BRANCH_DATABASE_ENV]]);
|
|
@@ -2840,9 +2860,9 @@ async function schemaStaleCommand(rawArgs) {
|
|
|
2840
2860
|
const schemaFile = path.resolve(process.cwd(), outputPath);
|
|
2841
2861
|
const fix = Boolean(argsList["--fix"]);
|
|
2842
2862
|
const generatedExists = fs.existsSync(schemaFile);
|
|
2843
|
-
const { loadCollections } = await import("./doctor-
|
|
2863
|
+
const { loadCollections } = await import("./doctor-Kg1oUK0Q.js").then((n) => n.t);
|
|
2844
2864
|
const { findLegacyForeignKeyNames, compareGeneratedDeclarations, staleVerdict } = await import("./generated-schema-staleness-BvNF3i-s.js").then((n) => n.r);
|
|
2845
|
-
const { generateSchema } = await import("./generate-drizzle-schema-logic-
|
|
2865
|
+
const { generateSchema } = await import("./generate-drizzle-schema-logic-LTLZvt6r.js").then((n) => n.n);
|
|
2846
2866
|
const { relationalCollections } = await import("@rebasepro/common");
|
|
2847
2867
|
let stale = [];
|
|
2848
2868
|
let differences = [];
|