@rebasepro/server-postgres 0.31.0 → 0.32.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-USp1AvZB.js → BranchService-C8LtpMho.js} +3 -3
- package/dist/{BranchService-USp1AvZB.js.map → BranchService-C8LtpMho.js.map} +1 -1
- package/dist/{backup-cli-DbKyEj6c.js → backup-cli-DtV6n3oB.js} +3 -3
- package/dist/{backup-cli-DbKyEj6c.js.map → backup-cli-DtV6n3oB.js.map} +1 -1
- package/dist/{boot-ddl-5H2bL_80.js → boot-ddl-CSYhSSZD.js} +2 -2
- package/dist/{boot-ddl-5H2bL_80.js.map → boot-ddl-CSYhSSZD.js.map} +1 -1
- package/dist/{cli-console-DsRgGSBR.js → cli-console-Cu1DzqvR.js} +4 -4
- package/dist/{cli-console-DsRgGSBR.js.map → cli-console-Cu1DzqvR.js.map} +1 -1
- package/dist/{cli-schema-dir-CiN0ephV.js → cli-schema-dir-DuZIsF2e.js} +5 -5
- package/dist/{cli-schema-dir-CiN0ephV.js.map → cli-schema-dir-DuZIsF2e.js.map} +1 -1
- package/dist/cli.js +124 -36
- package/dist/cli.js.map +1 -1
- package/dist/{database-preflight-bfnIBnjM.js → database-preflight-CyTCWlfc.js} +2 -2
- package/dist/{database-preflight-bfnIBnjM.js.map → database-preflight-CyTCWlfc.js.map} +1 -1
- package/dist/{deferred-index-build-CcSDA7wE.js → deferred-index-build-ueYVUBZc.js} +4 -4
- package/dist/{deferred-index-build-CcSDA7wE.js.map → deferred-index-build-ueYVUBZc.js.map} +1 -1
- package/dist/{ensure-policies-rRmXb5bt.js → ensure-policies-13mHWjBs.js} +7 -7
- package/dist/{ensure-policies-rRmXb5bt.js.map → ensure-policies-13mHWjBs.js.map} +1 -1
- package/dist/{ensure-tables-Bvm-F2wW.js → ensure-tables-B3Kh2RwT.js} +7 -7
- package/dist/{ensure-tables-Bvm-F2wW.js.map → ensure-tables-B3Kh2RwT.js.map} +1 -1
- package/dist/{ensure-tables-CC8p_AK3.js → ensure-tables-DM1U9AZK.js} +3 -3
- package/dist/{ensure-tables-CC8p_AK3.js.map → ensure-tables-DM1U9AZK.js.map} +1 -1
- package/dist/{enum-labels-kept-FlX9SHdf.js → enum-labels-kept-CJDVtX14.js} +2 -2
- package/dist/{enum-labels-kept-FlX9SHdf.js.map → enum-labels-kept-CJDVtX14.js.map} +1 -1
- package/dist/{generate-drizzle-schema-SJMXxzPI.js → generate-drizzle-schema-B-Mkf8UI.js} +2 -2
- package/dist/{generate-drizzle-schema-SJMXxzPI.js.map → generate-drizzle-schema-B-Mkf8UI.js.map} +1 -1
- package/dist/{generate-files-tlJ9_lGI.js → generate-files-8MUP8UHC.js} +2 -2
- package/dist/{generate-files-tlJ9_lGI.js.map → generate-files-8MUP8UHC.js.map} +1 -1
- package/dist/{generate-postgres-ddl-logic-B8huc03c.js → generate-postgres-ddl-logic-CQof4iFH.js} +89 -45
- package/dist/generate-postgres-ddl-logic-CQof4iFH.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.es.js +14 -14
- package/dist/{migrate-baseline-DZmekgpD.js → migrate-baseline-DnMlSDup.js} +9 -2
- package/dist/{migrate-baseline-DZmekgpD.js.map → migrate-baseline-DnMlSDup.js.map} +1 -1
- package/dist/{migrate-policy-stamps-B_acrUQB.js → migrate-policy-stamps-BpHyEFkk.js} +5 -5
- package/dist/{migrate-policy-stamps-B_acrUQB.js.map → migrate-policy-stamps-BpHyEFkk.js.map} +1 -1
- package/dist/{open-rebase-4kisUF_k.js → open-rebase-B2mAA7UE.js} +175 -38
- package/dist/open-rebase-B2mAA7UE.js.map +1 -0
- package/dist/{pg-error-utils-BT5NzGFZ.js → pg-error-utils-CpUiBkp-.js} +2 -2
- package/dist/{pg-error-utils-BT5NzGFZ.js.map → pg-error-utils-CpUiBkp-.js.map} +1 -1
- package/dist/{policy-drift-BVMyqHSa.js → policy-drift-C9xRcbsU.js} +4 -4
- package/dist/{policy-drift-BVMyqHSa.js.map → policy-drift-C9xRcbsU.js.map} +1 -1
- package/dist/{push-index-adoption-hpHTyXMR.js → push-index-adoption-D-ph6kBc.js} +2 -2
- package/dist/{push-index-adoption-hpHTyXMR.js.map → push-index-adoption-D-ph6kBc.js.map} +1 -1
- package/dist/{push-index-prebuild-Bty9F7bD.js → push-index-prebuild-DUKtH87s.js} +3 -3
- package/dist/{push-index-prebuild-Bty9F7bD.js.map → push-index-prebuild-DUKtH87s.js.map} +1 -1
- package/dist/{push-legacy-renames-bB4bM6br.js → push-legacy-renames-wLSsAg80.js} +3 -3
- package/dist/{push-legacy-renames-bB4bM6br.js.map → push-legacy-renames-wLSsAg80.js.map} +1 -1
- package/dist/{push-policy-plan-BI8U4BOD.js → push-policy-plan-I9RNoP_-.js} +3 -3
- package/dist/{push-policy-plan-BI8U4BOD.js.map → push-policy-plan-I9RNoP_-.js.map} +1 -1
- package/dist/{request-role-cli-BdRzdE87.js → request-role-cli-D9yWoeSl.js} +8 -8
- package/dist/{request-role-cli-BdRzdE87.js.map → request-role-cli-D9yWoeSl.js.map} +1 -1
- package/dist/{request-role-migration-C8aq_TO3.js → request-role-migration-DQLiYJ4c.js} +2 -2
- package/dist/{request-role-migration-C8aq_TO3.js.map → request-role-migration-DQLiYJ4c.js.map} +1 -1
- package/dist/{rls-enforcement-DB5HHj96.js → rls-enforcement-Cwh5SJRx.js} +2 -2
- package/dist/{rls-enforcement-DB5HHj96.js.map → rls-enforcement-Cwh5SJRx.js.map} +1 -1
- package/dist/schema/doctor-cli.js +5 -5
- package/dist/schema/generate-drizzle-schema.js +1 -1
- package/dist/schema/generate-postgres-ddl-logic.d.ts +51 -8
- package/dist/schema/generate-postgres-ddl.js +1 -1
- package/dist/schema/introspect-db.js +1 -1
- package/dist/services/cdc/capture-consumers.d.ts +65 -0
- package/dist/services/cdc/wal-cdc.d.ts +13 -0
- package/dist/services/realtimeService.d.ts +18 -2
- package/dist/{websocket-BevXvwfo.js → websocket-CSVNOYHC.js} +3 -3
- package/dist/{websocket-BevXvwfo.js.map → websocket-CSVNOYHC.js.map} +1 -1
- package/package.json +7 -7
- package/dist/generate-postgres-ddl-logic-B8huc03c.js.map +0 -1
- package/dist/open-rebase-4kisUF_k.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 detectDestructiveStatements, A as ensureDevDatabaseExists, B as readSearchDdl, C as describeBuildScriptRemedy, D as diagnoseMissingBin, E as detectProjectPackageManager, F as getUndeclaredConstraintExcludes, G as withAppClient, H as readVectorDdl, I as getVectorExcludes, J as GENERATED_SQL_DIR, K as workspaceMemberDir, L as queryColumnTypes, M as getSearchExcludes, N as getTableExcludes, O as dropDevDatabase, P as getTriggerExcludes, Q as destructiveOptInFlag, R as queryGeneratedColumnDependencies, S as closeAppClients, T as describeReinstallCommand, U as readViewsDdl, V as readTriggersDdl, W as resolveLocalBin, X as prepareGeneratedSqlDir, Y as generatedSqlDir, Z as decidePushSafety, _ as applyTriggersDdl, b as atlasDevDatabaseUrl, c as diagnoseDbError, d as isEconnrefused, et as extractPlanStatements, f as isSslNotEnabled, g as applySearchDdl, h as ExcludeIntrospectionError, i as checkDatabaseConnectivity, it as forAtlas, j as getForeignIndexExcludes, k as dropGeneratedColumns, l as formatForeignGeneratedColumnBanner, m as reportCommandFailure, n as assertNoCollectionsFlag, nt as isSyncedPlan, ot as redactConnectionPasswords, q as DESIRED_STATE_URL, r as assertSchemaDirExists, rt as warnIfYesApprovedDestructive, s as diagnoseAtlasFailure, tt as fromAlterTable, u as isAuthFailure, v as applyVectorDdl, w as describeDevAddCommand, y as applyViewsDdl, z as queryUndeclarableConstraints } from "./cli-schema-dir-
|
|
4
|
+
import { $ as detectDestructiveStatements, A as ensureDevDatabaseExists, B as readSearchDdl, C as describeBuildScriptRemedy, D as diagnoseMissingBin, E as detectProjectPackageManager, F as getUndeclaredConstraintExcludes, G as withAppClient, H as readVectorDdl, I as getVectorExcludes, J as GENERATED_SQL_DIR, K as workspaceMemberDir, L as queryColumnTypes, M as getSearchExcludes, N as getTableExcludes, O as dropDevDatabase, P as getTriggerExcludes, Q as destructiveOptInFlag, R as queryGeneratedColumnDependencies, S as closeAppClients, T as describeReinstallCommand, U as readViewsDdl, V as readTriggersDdl, W as resolveLocalBin, X as prepareGeneratedSqlDir, Y as generatedSqlDir, Z as decidePushSafety, _ as applyTriggersDdl, b as atlasDevDatabaseUrl, c as diagnoseDbError, d as isEconnrefused, et as extractPlanStatements, f as isSslNotEnabled, g as applySearchDdl, h as ExcludeIntrospectionError, i as checkDatabaseConnectivity, it as forAtlas, j as getForeignIndexExcludes, k as dropGeneratedColumns, l as formatForeignGeneratedColumnBanner, m as reportCommandFailure, n as assertNoCollectionsFlag, nt as isSyncedPlan, ot as redactConnectionPasswords, q as DESIRED_STATE_URL, r as assertSchemaDirExists, rt as warnIfYesApprovedDestructive, s as diagnoseAtlasFailure, tt as fromAlterTable, u as isAuthFailure, v as applyVectorDdl, w as describeDevAddCommand, y as applyViewsDdl, z as queryUndeclarableConstraints } from "./cli-schema-dir-DuZIsF2e.js";
|
|
5
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-VxbrQojV.js";
|
|
7
|
-
import { C as declaredIndexesIfNotExists, S as execa, b as resolveDriverSwitches, 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, w as indexAdoptionStatement, x as schemaDirIn, y as parseDriverLine } from "./migrate-baseline-
|
|
7
|
+
import { C as declaredIndexesIfNotExists, S as execa, b as resolveDriverSwitches, 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, w as indexAdoptionStatement, x as schemaDirIn, y as parseDriverLine } from "./migrate-baseline-DnMlSDup.js";
|
|
8
8
|
import { t as nextStepAfterDbGenerate } from "./generate-next-step-CO09dovd.js";
|
|
9
9
|
import { REBASE_ADMIN_ROLE, declaredRlsPolicyShape } from "@rebasepro/types";
|
|
10
10
|
import { formatRelativeTime } from "@rebasepro/utils";
|
|
@@ -1141,7 +1141,7 @@ function generatesInProcess() {
|
|
|
1141
1141
|
async function generateInProcess(what, label, run) {
|
|
1142
1142
|
let generators;
|
|
1143
1143
|
try {
|
|
1144
|
-
generators = await import("./generate-files-
|
|
1144
|
+
generators = await import("./generate-files-8MUP8UHC.js").then((n) => n.t);
|
|
1145
1145
|
} catch (err) {
|
|
1146
1146
|
outError(chalk.red(`✗ Failed to run ${what}: ${err instanceof Error ? err.message : String(err)}`));
|
|
1147
1147
|
process.exit(1);
|
|
@@ -1189,7 +1189,7 @@ async function runPluginCommand(args) {
|
|
|
1189
1189
|
else if (domain === "schema") await schemaCommand(subcommand, args);
|
|
1190
1190
|
else if (domain === "doctor") await doctorPluginCommand(args);
|
|
1191
1191
|
else if (domain === "console") {
|
|
1192
|
-
const { consoleCommand } = await import("./cli-console-
|
|
1192
|
+
const { consoleCommand } = await import("./cli-console-Cu1DzqvR.js");
|
|
1193
1193
|
process.exitCode = await consoleCommand(args);
|
|
1194
1194
|
} else {
|
|
1195
1195
|
outError(chalk.red(`Unknown domain command: ${domain}`));
|
|
@@ -1374,17 +1374,17 @@ async function dbCommand(subcommand, rawArgs) {
|
|
|
1374
1374
|
return;
|
|
1375
1375
|
}
|
|
1376
1376
|
if (subcommand === "request-role") {
|
|
1377
|
-
const { requestRoleCommand } = await import("./request-role-cli-
|
|
1377
|
+
const { requestRoleCommand } = await import("./request-role-cli-D9yWoeSl.js").then((n) => n.r);
|
|
1378
1378
|
await requestRoleCommand(rawArgs);
|
|
1379
1379
|
return;
|
|
1380
1380
|
}
|
|
1381
1381
|
if (subcommand === "provision") {
|
|
1382
|
-
const { provisionCommand } = await import("./request-role-cli-
|
|
1382
|
+
const { provisionCommand } = await import("./request-role-cli-D9yWoeSl.js").then((n) => n.r);
|
|
1383
1383
|
await provisionCommand(rawArgs);
|
|
1384
1384
|
return;
|
|
1385
1385
|
}
|
|
1386
1386
|
if (subcommand === "backup" || subcommand === "restore" || subcommand === "backups") {
|
|
1387
|
-
const { backupCommand, restoreCommand, backupsCommand } = await import("./backup-cli-
|
|
1387
|
+
const { backupCommand, restoreCommand, backupsCommand } = await import("./backup-cli-DtV6n3oB.js").then((n) => n.t);
|
|
1388
1388
|
if (subcommand === "backup" && backupActionOf(rawArgs) === "list") await backupsCommand(rawArgs);
|
|
1389
1389
|
else if (subcommand === "backup") await backupCommand(rawArgs);
|
|
1390
1390
|
else if (subcommand === "restore") await restoreCommand(rawArgs);
|
|
@@ -1432,7 +1432,7 @@ async function dbCommand(subcommand, rawArgs) {
|
|
|
1432
1432
|
}
|
|
1433
1433
|
const searchContent = readSearchDdl();
|
|
1434
1434
|
if (searchContent) {
|
|
1435
|
-
const { searchColumnDependencies } = await import("./generate-postgres-ddl-logic-
|
|
1435
|
+
const { searchColumnDependencies } = await import("./generate-postgres-ddl-logic-CQof4iFH.js").then((n) => n.s);
|
|
1436
1436
|
const { loadTables } = await import("./load-tables-B1Re74ng.js").then((n) => n.i);
|
|
1437
1437
|
const migrationConflicts = findGeneratedColumnConflicts(parseColumnMutations(migrationContent), searchColumnDependencies(await loadTables(schemaDir)));
|
|
1438
1438
|
const preamble = migrationDropPreamble(migrationConflicts);
|
|
@@ -1715,7 +1715,7 @@ async function dbCommand(subcommand, rawArgs) {
|
|
|
1715
1715
|
const adminRoleAvailable = await readAdminPoliciesLive(databaseUrl);
|
|
1716
1716
|
if (!adminRoleAvailable) await moveAdminPoliciesToPublic(databaseUrl, schemaDir);
|
|
1717
1717
|
await dropStaleCompanions(databaseUrl, schemaDir, adminRoleAvailable);
|
|
1718
|
-
const { stampMigratedPolicies } = await import("./migrate-policy-stamps-
|
|
1718
|
+
const { stampMigratedPolicies } = await import("./migrate-policy-stamps-BpHyEFkk.js");
|
|
1719
1719
|
await stampMigratedPolicies(databaseUrl, schemaDir, adminRoleAvailable);
|
|
1720
1720
|
}
|
|
1721
1721
|
}
|
|
@@ -1770,7 +1770,7 @@ async function renameLegacyForeignKeys(databaseUrl, schemaDir, dryRun) {
|
|
|
1770
1770
|
let renames;
|
|
1771
1771
|
try {
|
|
1772
1772
|
const { loadTables } = await import("./load-tables-B1Re74ng.js").then((n) => n.i);
|
|
1773
|
-
const { legacyForeignKeyRenames } = await import("./push-legacy-renames-
|
|
1773
|
+
const { legacyForeignKeyRenames } = await import("./push-legacy-renames-wLSsAg80.js");
|
|
1774
1774
|
const tables = await loadTables(schemaDir);
|
|
1775
1775
|
renames = await withAppClient(databaseUrl, (client) => legacyForeignKeyRenames({ query: async (text) => ({ rows: (await client.query(text)).rows }) }, tables));
|
|
1776
1776
|
} catch {
|
|
@@ -1791,7 +1791,7 @@ async function adoptIdenticalIndexes(databaseUrl, schemaDir, dryRun) {
|
|
|
1791
1791
|
let adoptions;
|
|
1792
1792
|
try {
|
|
1793
1793
|
const { loadTables } = await import("./load-tables-B1Re74ng.js").then((n) => n.i);
|
|
1794
|
-
const { pushIndexAdoptions } = await import("./push-index-adoption-
|
|
1794
|
+
const { pushIndexAdoptions } = await import("./push-index-adoption-D-ph6kBc.js");
|
|
1795
1795
|
const tables = await loadTables(schemaDir);
|
|
1796
1796
|
adoptions = await withAppClient(databaseUrl, (client) => pushIndexAdoptions({ query: async (text) => ({ rows: (await client.query(text)).rows }) }, tables));
|
|
1797
1797
|
} catch {
|
|
@@ -1810,7 +1810,7 @@ async function adoptIdenticalIndexes(databaseUrl, schemaDir, dryRun) {
|
|
|
1810
1810
|
async function reportKeptEnumLabels(databaseUrl, schemaDir) {
|
|
1811
1811
|
try {
|
|
1812
1812
|
const { loadTables } = await import("./load-tables-B1Re74ng.js").then((n) => n.i);
|
|
1813
|
-
const { keptEnumLabels, formatKeptEnumLabelsNotice } = await import("./enum-labels-kept-
|
|
1813
|
+
const { keptEnumLabels, formatKeptEnumLabelsNotice } = await import("./enum-labels-kept-CJDVtX14.js");
|
|
1814
1814
|
const tables = await loadTables(schemaDir);
|
|
1815
1815
|
const kept = await withAppClient(databaseUrl, (client) => keptEnumLabels({ query: async (text) => ({ rows: (await client.query(text)).rows }) }, tables));
|
|
1816
1816
|
if (kept.length > 0) outWarn(chalk.yellow(formatKeptEnumLabelsNotice(kept)));
|
|
@@ -1820,7 +1820,7 @@ async function prebuildForeignKeyIndexes(databaseUrl, schemaDir, dryRun) {
|
|
|
1820
1820
|
let missing;
|
|
1821
1821
|
try {
|
|
1822
1822
|
const { loadTables } = await import("./load-tables-B1Re74ng.js").then((n) => n.i);
|
|
1823
|
-
const { missingForeignKeyIndexes } = await import("./push-index-prebuild-
|
|
1823
|
+
const { missingForeignKeyIndexes } = await import("./push-index-prebuild-DUKtH87s.js");
|
|
1824
1824
|
const tables = await loadTables(schemaDir);
|
|
1825
1825
|
missing = await withAppClient(databaseUrl, (client) => missingForeignKeyIndexes({ query: async (text) => ({ rows: (await client.query(text)).rows }) }, tables));
|
|
1826
1826
|
} catch {
|
|
@@ -1830,7 +1830,7 @@ async function prebuildForeignKeyIndexes(databaseUrl, schemaDir, dryRun) {
|
|
|
1830
1830
|
if (missing.length === 0 || dryRun) return names;
|
|
1831
1831
|
out(chalk.gray(` Building ${missing.length} foreign-key index(es) on existing tables first — CONCURRENTLY, so writes go on:`));
|
|
1832
1832
|
try {
|
|
1833
|
-
const { buildDeferredIndexes } = await import("./deferred-index-build-
|
|
1833
|
+
const { buildDeferredIndexes } = await import("./deferred-index-build-ueYVUBZc.js").then((n) => n.r);
|
|
1834
1834
|
const outcome = await withAppClient(databaseUrl, (client) => buildDeferredIndexes(async () => ({
|
|
1835
1835
|
dedicated: true,
|
|
1836
1836
|
query: async (text) => ({ rows: (await client.query(text)).rows }),
|
|
@@ -1878,9 +1878,9 @@ async function lockManagedTables(databaseUrl, schemaDir) {
|
|
|
1878
1878
|
let unsecured;
|
|
1879
1879
|
let userRole;
|
|
1880
1880
|
try {
|
|
1881
|
-
const { lockTables } = await import("./ensure-policies-
|
|
1881
|
+
const { lockTables } = await import("./ensure-policies-13mHWjBs.js");
|
|
1882
1882
|
const { loadTables } = await import("./load-tables-B1Re74ng.js").then((n) => n.i);
|
|
1883
|
-
const { readRecordedRequestRoles } = await import("./rls-enforcement-
|
|
1883
|
+
const { readRecordedRequestRoles } = await import("./rls-enforcement-Cwh5SJRx.js").then((n) => n.y);
|
|
1884
1884
|
const { cliRlsSettings } = await import("./rls-settings-CmGK2U0a.js").then((n) => n.a);
|
|
1885
1885
|
const tables = await loadTables(schemaDir);
|
|
1886
1886
|
({unsecured, userRole} = await withAppClient(databaseUrl, async (client) => {
|
|
@@ -1944,7 +1944,7 @@ async function stampSchemaVersion(databaseUrl, schemaDir) {
|
|
|
1944
1944
|
async function ensureAuthTables(databaseUrl, schemaDir) {
|
|
1945
1945
|
try {
|
|
1946
1946
|
const { drizzle } = await import("drizzle-orm/node-postgres");
|
|
1947
|
-
const { ensureAuthTablesExist } = await import("./ensure-tables-
|
|
1947
|
+
const { ensureAuthTablesExist } = await import("./ensure-tables-DM1U9AZK.js").then((n) => n.n);
|
|
1948
1948
|
const { loadTableSchema } = await import("./load-tables-B1Re74ng.js").then((n) => n.i);
|
|
1949
1949
|
const { descriptors } = await loadTableSchema(schemaDir);
|
|
1950
1950
|
const authTable = descriptors.find((descriptor) => descriptor.auth !== void 0);
|
|
@@ -1963,7 +1963,7 @@ async function ensureRlsUserRole(databaseUrl) {
|
|
|
1963
1963
|
const schemas = ["public", "rebase"];
|
|
1964
1964
|
let rls;
|
|
1965
1965
|
try {
|
|
1966
|
-
rls = await import("./rls-enforcement-
|
|
1966
|
+
rls = await import("./rls-enforcement-Cwh5SJRx.js").then((n) => n.y);
|
|
1967
1967
|
} catch (err) {
|
|
1968
1968
|
outError(chalk.red(`\n ✗ Could not load the RLS provisioning module: ${err instanceof Error ? err.message : String(err)}`));
|
|
1969
1969
|
return;
|
|
@@ -2047,7 +2047,7 @@ async function applyPolicies(databaseUrl, schemaDir) {
|
|
|
2047
2047
|
*/
|
|
2048
2048
|
async function readAdminPoliciesLive(databaseUrl) {
|
|
2049
2049
|
try {
|
|
2050
|
-
const { adminPoliciesLiveForCli } = await import("./rls-enforcement-
|
|
2050
|
+
const { adminPoliciesLiveForCli } = await import("./rls-enforcement-Cwh5SJRx.js").then((n) => n.y);
|
|
2051
2051
|
return await withAppClient(databaseUrl, (client) => adminPoliciesLiveForCli(async (text) => (await client.query(text)).rows));
|
|
2052
2052
|
} catch {
|
|
2053
2053
|
return false;
|
|
@@ -2061,7 +2061,7 @@ async function readAdminPoliciesLive(databaseUrl) {
|
|
|
2061
2061
|
*/
|
|
2062
2062
|
async function dropStaleCompanions(databaseUrl, schemaDir, adminRoleAvailable) {
|
|
2063
2063
|
const { loadTables } = await import("./load-tables-B1Re74ng.js").then((n) => n.i);
|
|
2064
|
-
const { dropStaleAdminRequestCompanions } = await import("./policy-drift-
|
|
2064
|
+
const { dropStaleAdminRequestCompanions } = await import("./policy-drift-C9xRcbsU.js").then((n) => n.s);
|
|
2065
2065
|
const tables = await loadTables(schemaDir);
|
|
2066
2066
|
try {
|
|
2067
2067
|
const dropped = await withAppClient(databaseUrl, (client) => dropStaleAdminRequestCompanions(client, tables, { adminRoleAvailable }));
|
|
@@ -2080,7 +2080,7 @@ async function dropStaleCompanions(databaseUrl, schemaDir, adminRoleAvailable) {
|
|
|
2080
2080
|
*/
|
|
2081
2081
|
async function moveAdminPoliciesToPublic(databaseUrl, schemaDir) {
|
|
2082
2082
|
const { loadTables } = await import("./load-tables-B1Re74ng.js").then((n) => n.i);
|
|
2083
|
-
const { moveMigratedAdminPoliciesToPublic } = await import("./migrate-policy-stamps-
|
|
2083
|
+
const { moveMigratedAdminPoliciesToPublic } = await import("./migrate-policy-stamps-BpHyEFkk.js");
|
|
2084
2084
|
const tables = await loadTables(schemaDir);
|
|
2085
2085
|
try {
|
|
2086
2086
|
if (await withAppClient(databaseUrl, (client) => moveMigratedAdminPoliciesToPublic({ query: async (text, values) => ({ rows: (await client.query(text, values)).rows }) }, tables, (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}.`));
|
|
@@ -2102,7 +2102,7 @@ async function moveAdminPoliciesToPublic(databaseUrl, schemaDir) {
|
|
|
2102
2102
|
*/
|
|
2103
2103
|
async function policiesToPublic(schemaDir, policiesSql) {
|
|
2104
2104
|
const { loadTables } = await import("./load-tables-B1Re74ng.js").then((n) => n.i);
|
|
2105
|
-
const { planTablePolicies } = await import("./generate-postgres-ddl-logic-
|
|
2105
|
+
const { planTablePolicies } = await import("./generate-postgres-ddl-logic-CQof4iFH.js").then((n) => n.s);
|
|
2106
2106
|
const tables = await loadTables(schemaDir);
|
|
2107
2107
|
const fallback = new Map(planTablePolicies(tables, { adminRoleAvailable: false }).flatMap((plan) => plan.policies.map((policy) => [`${plan.qualified}.${policy.name}`, policy.statements])));
|
|
2108
2108
|
let sql = policiesSql;
|
|
@@ -2118,8 +2118,8 @@ async function policiesToPublic(schemaDir, policiesSql) {
|
|
|
2118
2118
|
async function policyStamping(databaseUrl, schemaDir, policiesSql, adminRoleAvailable = true) {
|
|
2119
2119
|
try {
|
|
2120
2120
|
const { loadTables } = await import("./load-tables-B1Re74ng.js").then((n) => n.i);
|
|
2121
|
-
const { planTablePolicies } = await import("./generate-postgres-ddl-logic-
|
|
2122
|
-
const { policyStampSql } = await import("./ensure-policies-
|
|
2121
|
+
const { planTablePolicies } = await import("./generate-postgres-ddl-logic-CQof4iFH.js").then((n) => n.s);
|
|
2122
|
+
const { policyStampSql } = await import("./ensure-policies-13mHWjBs.js");
|
|
2123
2123
|
const { pinSearchPath } = await import("./connection-C1zXTPJq.js").then((n) => n.r);
|
|
2124
2124
|
return {
|
|
2125
2125
|
statements: stampableTables(planTablePolicies(await loadTables(schemaDir), { adminRoleAvailable }), policiesSql).map((plan) => policyStampSql(plan)).filter((statement) => statement !== void 0),
|
|
@@ -2137,7 +2137,7 @@ async function policyStamping(databaseUrl, schemaDir, policiesSql, adminRoleAvai
|
|
|
2137
2137
|
*/
|
|
2138
2138
|
async function readPolicyPushPlan(databaseUrl, schemaDir) {
|
|
2139
2139
|
try {
|
|
2140
|
-
const { formatPolicyPushPlan, planPolicyPush, summarizePolicyPushPlan } = await import("./push-policy-plan-
|
|
2140
|
+
const { formatPolicyPushPlan, planPolicyPush, summarizePolicyPushPlan } = await import("./push-policy-plan-I9RNoP_-.js");
|
|
2141
2141
|
const { loadTables } = await import("./load-tables-B1Re74ng.js").then((n) => n.i);
|
|
2142
2142
|
const { pinSearchPath } = await import("./connection-C1zXTPJq.js").then((n) => n.r);
|
|
2143
2143
|
const tables = await loadTables(schemaDir);
|
|
@@ -2170,7 +2170,7 @@ async function readPolicyPushPlan(databaseUrl, schemaDir) {
|
|
|
2170
2170
|
*/
|
|
2171
2171
|
async function reconcilePolicies(databaseUrl, schemaDir) {
|
|
2172
2172
|
try {
|
|
2173
|
-
const { checkPolicyDrift, dropOrphanedPolicies, formatPolicyDrift, hasDrift } = await import("./policy-drift-
|
|
2173
|
+
const { checkPolicyDrift, dropOrphanedPolicies, formatPolicyDrift, hasDrift } = await import("./policy-drift-C9xRcbsU.js").then((n) => n.s);
|
|
2174
2174
|
const { loadTables } = await import("./load-tables-B1Re74ng.js").then((n) => n.i);
|
|
2175
2175
|
const tables = await loadTables(schemaDir);
|
|
2176
2176
|
const adminRoleAvailable = await readAdminPoliciesLive(databaseUrl);
|
|
@@ -2217,6 +2217,8 @@ var BRANCH_FLAGS = {
|
|
|
2217
2217
|
"--from": String,
|
|
2218
2218
|
"--json": Boolean,
|
|
2219
2219
|
"--sample-limit": Number,
|
|
2220
|
+
"--on-conflict": String,
|
|
2221
|
+
"--skip-blocked": Boolean,
|
|
2220
2222
|
"--yes": Boolean,
|
|
2221
2223
|
"-y": "--yes"
|
|
2222
2224
|
};
|
|
@@ -2258,7 +2260,7 @@ async function branchCommand(rawArgs) {
|
|
|
2258
2260
|
process.exit(1);
|
|
2259
2261
|
}
|
|
2260
2262
|
const { DatabasePoolManager } = await import("./databasePoolManager-DIjzlTK4.js").then((n) => n.n);
|
|
2261
|
-
const { BranchService, reopenClosedDatabases, reopenedDatabasesNotice } = await import("./BranchService-
|
|
2263
|
+
const { BranchService, reopenClosedDatabases, reopenedDatabasesNotice } = await import("./BranchService-C8LtpMho.js").then((n) => n.n);
|
|
2262
2264
|
const { drizzle } = await import("drizzle-orm/node-postgres");
|
|
2263
2265
|
const { Pool } = await import("pg");
|
|
2264
2266
|
const healed = await reopenClosedDatabases(databaseUrl, [branchAction === "create" ? createSource(rawArgs) : void 0, process.env[ACTIVE_BRANCH_DATABASE_ENV]]);
|
|
@@ -2272,6 +2274,13 @@ async function branchCommand(rawArgs) {
|
|
|
2272
2274
|
const db = drizzle(pool);
|
|
2273
2275
|
const poolManager = new DatabasePoolManager(databaseUrl);
|
|
2274
2276
|
const branchService = new BranchService(db, poolManager);
|
|
2277
|
+
const branchAdmin = () => ({
|
|
2278
|
+
executeSql: async (text, options) => (await poolManager.getPool(options?.database ?? poolManager.defaultDatabaseName).query(text, options?.params)).rows,
|
|
2279
|
+
createBranch: (branchName, options) => branchService.createBranch(branchName, options),
|
|
2280
|
+
deleteBranch: (branchName) => branchService.deleteBranch(branchName),
|
|
2281
|
+
listBranches: () => branchService.listBranches(),
|
|
2282
|
+
getBranchInfo: async (branchName) => await branchService.hasBranchRegistry() ? branchService.getBranchInfo(branchName) : void 0
|
|
2283
|
+
});
|
|
2275
2284
|
try {
|
|
2276
2285
|
if (branchAction === "create" || branchAction === "delete" || branchAction === "prune") await branchService.ensureBranchMetadataTable();
|
|
2277
2286
|
switch (branchAction) {
|
|
@@ -2326,6 +2335,20 @@ async function branchCommand(rawArgs) {
|
|
|
2326
2335
|
out(chalk.gray(" Usage: rebase db branch delete <name>"));
|
|
2327
2336
|
process.exit(1);
|
|
2328
2337
|
}
|
|
2338
|
+
if ((0, import_arg.default)(BRANCH_FLAGS, {
|
|
2339
|
+
argv: rawArgs.slice(3),
|
|
2340
|
+
permissive: true
|
|
2341
|
+
})["--yes"] !== true) {
|
|
2342
|
+
if (!process.stdin.isTTY) {
|
|
2343
|
+
outError(chalk.red(` ✗ Branch "${name}" was not deleted: there is no terminal to confirm on.`));
|
|
2344
|
+
outError(chalk.gray(" Re-run with --yes to delete it."));
|
|
2345
|
+
process.exit(1);
|
|
2346
|
+
}
|
|
2347
|
+
if (!await promptConfirm(` Delete branch "${name}" and its database? (y/N) `)) {
|
|
2348
|
+
out(chalk.gray(" Nothing was changed."));
|
|
2349
|
+
break;
|
|
2350
|
+
}
|
|
2351
|
+
}
|
|
2329
2352
|
out("");
|
|
2330
2353
|
out(chalk.bold(` 🗑️ Deleting branch "${name}"...`));
|
|
2331
2354
|
await branchService.deleteBranch(name, { force: rawArgs.includes("--force") });
|
|
@@ -2369,13 +2392,7 @@ async function branchCommand(rawArgs) {
|
|
|
2369
2392
|
});
|
|
2370
2393
|
const { diffDatabaseBranch } = await import("./branch-diff-CxE4VlxT.js").then((n) => n.r);
|
|
2371
2394
|
const { branchDiffReport } = await import("./branch-diff-report-DpvVf7hR.js");
|
|
2372
|
-
const admin =
|
|
2373
|
-
executeSql: async (text, options) => (await poolManager.getPool(options?.database ?? poolManager.defaultDatabaseName).query(text, options?.params)).rows,
|
|
2374
|
-
createBranch: (branchName, options) => branchService.createBranch(branchName, options),
|
|
2375
|
-
deleteBranch: (branchName) => branchService.deleteBranch(branchName),
|
|
2376
|
-
listBranches: () => branchService.listBranches(),
|
|
2377
|
-
getBranchInfo: async (branchName) => await branchService.hasBranchRegistry() ? branchService.getBranchInfo(branchName) : void 0
|
|
2378
|
-
};
|
|
2395
|
+
const admin = branchAdmin();
|
|
2379
2396
|
let diff;
|
|
2380
2397
|
try {
|
|
2381
2398
|
diff = await diffDatabaseBranch(admin, name, { sampleLimit: parsed["--sample-limit"] });
|
|
@@ -2391,6 +2408,72 @@ async function branchCommand(rawArgs) {
|
|
|
2391
2408
|
}
|
|
2392
2409
|
break;
|
|
2393
2410
|
}
|
|
2411
|
+
case "merge": {
|
|
2412
|
+
const name = branchNameIn(rawArgs.slice(2));
|
|
2413
|
+
if (!name || name.startsWith("-")) {
|
|
2414
|
+
outError(chalk.red("✗ Branch name is required."));
|
|
2415
|
+
out(chalk.gray(" Usage: rebase db branch merge <name> [--on-conflict abort|branch|target] [--skip-blocked] [--yes]"));
|
|
2416
|
+
process.exit(1);
|
|
2417
|
+
}
|
|
2418
|
+
const parsed = (0, import_arg.default)(BRANCH_FLAGS, {
|
|
2419
|
+
argv: rawArgs.slice(3),
|
|
2420
|
+
permissive: true
|
|
2421
|
+
});
|
|
2422
|
+
const onConflict = parsed["--on-conflict"] ?? "abort";
|
|
2423
|
+
if (onConflict !== "abort" && onConflict !== "branch" && onConflict !== "target") {
|
|
2424
|
+
outError(chalk.red(` ✗ --on-conflict takes abort, branch or target (got "${onConflict}").`));
|
|
2425
|
+
process.exit(1);
|
|
2426
|
+
}
|
|
2427
|
+
const { diffDatabaseBranch, mergeDatabaseBranch } = await import("./branch-diff-CxE4VlxT.js").then((n) => n.r);
|
|
2428
|
+
const { branchDiffReport } = await import("./branch-diff-report-DpvVf7hR.js");
|
|
2429
|
+
const admin = branchAdmin();
|
|
2430
|
+
let diff;
|
|
2431
|
+
try {
|
|
2432
|
+
diff = await diffDatabaseBranch(admin, name, { sampleLimit: parsed["--sample-limit"] });
|
|
2433
|
+
} catch (error) {
|
|
2434
|
+
outError(chalk.red(` ✗ ${error instanceof Error ? error.message : String(error)}`));
|
|
2435
|
+
process.exit(1);
|
|
2436
|
+
}
|
|
2437
|
+
out("");
|
|
2438
|
+
for (const line of branchDiffReport(diff)) out(` ${line}`);
|
|
2439
|
+
out("");
|
|
2440
|
+
if (parsed["--yes"] !== true) {
|
|
2441
|
+
if (!process.stdin.isTTY) {
|
|
2442
|
+
outError(chalk.red(` ✗ Branch "${name}" was not merged: there is no terminal to confirm on.`));
|
|
2443
|
+
outError(chalk.gray(" Read the diff above, then re-run with --yes to merge it."));
|
|
2444
|
+
process.exit(1);
|
|
2445
|
+
}
|
|
2446
|
+
if (!await promptConfirm(` Merge these rows from "${name}" into ${diff.targetDatabase}? (y/N) `)) {
|
|
2447
|
+
out(chalk.gray(" Nothing was merged."));
|
|
2448
|
+
out("");
|
|
2449
|
+
break;
|
|
2450
|
+
}
|
|
2451
|
+
}
|
|
2452
|
+
let result;
|
|
2453
|
+
try {
|
|
2454
|
+
result = await mergeDatabaseBranch(admin, name, {
|
|
2455
|
+
expectedFingerprint: diff.fingerprint,
|
|
2456
|
+
onConflict,
|
|
2457
|
+
skipBlocked: parsed["--skip-blocked"] === true,
|
|
2458
|
+
...parsed["--sample-limit"] !== void 0 ? { maxRowsPerTable: parsed["--sample-limit"] } : {}
|
|
2459
|
+
});
|
|
2460
|
+
} catch (error) {
|
|
2461
|
+
outError(chalk.red(` ✗ ${error instanceof Error ? error.message : String(error)}`));
|
|
2462
|
+
process.exit(1);
|
|
2463
|
+
}
|
|
2464
|
+
if (parsed["--json"] === true) {
|
|
2465
|
+
out(JSON.stringify(result, null, 2));
|
|
2466
|
+
break;
|
|
2467
|
+
}
|
|
2468
|
+
for (const table of result.tables) out(` ${chalk.green("✓")} ${table.schema}.${table.table} ${chalk.gray(`+${table.inserted} ~${table.updated} -${table.deleted}`)}`);
|
|
2469
|
+
for (const skipped of result.skipped) out(` ${chalk.yellow("○")} ${skipped.schema}.${skipped.table} ${chalk.gray(`not merged: ${typeof skipped.reason === "string" ? skipped.reason : JSON.stringify(skipped.reason)}`)}`);
|
|
2470
|
+
if (result.conflictsKept > 0) out(chalk.gray(` ${result.conflictsKept} row(s) both sides changed kept the target's version.`));
|
|
2471
|
+
if (result.schemaChangesNotMerged > 0) out(chalk.yellow(` ${result.schemaChangesNotMerged} schema or policy change(s) on the branch were not merged: apply them with migrations.`));
|
|
2472
|
+
for (const warning of result.warnings) out(chalk.yellow(` ⚠ ${warning}`));
|
|
2473
|
+
out(chalk.green(` ✓ Merged "${name}" into ${result.targetDatabase}.`));
|
|
2474
|
+
out("");
|
|
2475
|
+
break;
|
|
2476
|
+
}
|
|
2394
2477
|
case "prune": {
|
|
2395
2478
|
const parsed = (0, import_arg.default)(BRANCH_FLAGS, {
|
|
2396
2479
|
argv: rawArgs.slice(3),
|
|
@@ -2497,6 +2580,7 @@ ${chalk.green.bold("Commands")}
|
|
|
2497
2580
|
${chalk.blue.bold("delete")} <name> Delete a branch
|
|
2498
2581
|
${chalk.blue.bold("info")} <name> Show branch details
|
|
2499
2582
|
${chalk.blue.bold("diff")} <name> [--json] What the branch changed: schema, policies, rows
|
|
2583
|
+
${chalk.blue.bold("merge")} <name> Write the branch's row changes onto its parent, after the diff
|
|
2500
2584
|
${chalk.blue.bold("prune")} [--older-than <14|14d|2w>] Remove branches nothing is using
|
|
2501
2585
|
|
|
2502
2586
|
${chalk.green.bold("Why prune")}
|
|
@@ -2514,8 +2598,12 @@ ${chalk.green.bold("Options")}
|
|
|
2514
2598
|
to --sample-limit rows a table (default 100).
|
|
2515
2599
|
${chalk.blue.bold("--include-dev-diff")} Also prune the Atlas scratch databases
|
|
2516
2600
|
\`db push\` leaves behind.
|
|
2517
|
-
${chalk.blue.bold("--
|
|
2518
|
-
|
|
2601
|
+
${chalk.blue.bold("--on-conflict")} <abort|branch|target> merge: a row both sides changed — write nothing
|
|
2602
|
+
(abort, the default), take the branch's, or keep the parent's.
|
|
2603
|
+
${chalk.blue.bold("--skip-blocked")} merge: merge the tables that can be, skip the rest.
|
|
2604
|
+
${chalk.blue.bold("--sample-limit")} <n> diff/merge: rows compared per table (default 100).
|
|
2605
|
+
${chalk.blue.bold("--yes, -y")} Skip delete's, merge's and prune's prompt. Dropping
|
|
2606
|
+
a branch is not undoable, so this is the flag
|
|
2519
2607
|
a CI job passes and a person usually should not.
|
|
2520
2608
|
|
|
2521
2609
|
${chalk.green.bold("Examples")}
|