@rebasepro/server-postgres 0.27.0 → 0.28.1
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-B9Lu8e-P.js → BranchService-BPssiD8_.js} +37 -11
- package/dist/BranchService-BPssiD8_.js.map +1 -0
- package/dist/auth/services.d.ts +19 -7
- package/dist/backup/pg-tools.d.ts +14 -0
- package/dist/backup/retention.d.ts +14 -1
- package/dist/{backup-cli-BZM2Fj1I.js → backup-cli-C1wcj-rc.js} +59 -11
- package/dist/backup-cli-C1wcj-rc.js.map +1 -0
- package/dist/{boot-ddl-yukSebLA.js → boot-ddl-CIGoIGcC.js} +2 -2
- package/dist/{boot-ddl-yukSebLA.js.map → boot-ddl-CIGoIGcC.js.map} +1 -1
- package/dist/branch-argv.d.ts +20 -0
- package/dist/{cli-console-BtzxzzvU.js → cli-console-C0FYkICX.js} +5 -5
- package/dist/{cli-console-BtzxzzvU.js.map → cli-console-C0FYkICX.js.map} +1 -1
- package/dist/{cli-errors-BBSJqlYX.js → cli-errors-DYets7cp.js} +5 -5
- package/dist/{cli-errors-BBSJqlYX.js.map → cli-errors-DYets7cp.js.map} +1 -1
- package/dist/cli.js +43 -41
- package/dist/cli.js.map +1 -1
- package/dist/data-transformer.d.ts +11 -1
- package/dist/{databasePoolManager-3stMNFL-.js → databasePoolManager-BjoVvuAq.js} +2 -2
- package/dist/databasePoolManager-BjoVvuAq.js.map +1 -0
- package/dist/{deferred-index-build-DRnoMq-O.js → deferred-index-build-BcJ_oulu.js} +5 -5
- package/dist/{deferred-index-build-DRnoMq-O.js.map → deferred-index-build-BcJ_oulu.js.map} +1 -1
- package/dist/{doctor-Cs6AtizY.js → doctor-TJApVglQ.js} +6 -6
- package/dist/{doctor-Cs6AtizY.js.map → doctor-TJApVglQ.js.map} +1 -1
- package/dist/{ensure-collection-policies-H8HN1Gbd.js → ensure-collection-policies-BNwSQfVx.js} +63 -25
- package/dist/ensure-collection-policies-BNwSQfVx.js.map +1 -0
- package/dist/{ensure-collection-tables-BeF1lArf.js → ensure-collection-tables-CSbgkTBx.js} +8 -9
- package/dist/{ensure-collection-tables-BeF1lArf.js.map → ensure-collection-tables-CSbgkTBx.js.map} +1 -1
- package/dist/{ensure-tables-DDkNaPN2.js → ensure-tables-CF-8zgYA.js} +3 -3
- package/dist/{ensure-tables-DDkNaPN2.js.map → ensure-tables-CF-8zgYA.js.map} +1 -1
- package/dist/{enum-labels-kept-B6loB2U_.js → enum-labels-kept-BCgFGAbJ.js} +3 -3
- package/dist/{enum-labels-kept-B6loB2U_.js.map → enum-labels-kept-BCgFGAbJ.js.map} +1 -1
- package/dist/{generate-drizzle-schema-D_O8_iyT.js → generate-drizzle-schema-BAIp9nKT.js} +2 -2
- package/dist/{generate-drizzle-schema-D_O8_iyT.js.map → generate-drizzle-schema-BAIp9nKT.js.map} +1 -1
- package/dist/{generate-drizzle-schema-logic-D0E64iwx.js → generate-drizzle-schema-logic-CVRmZjP3.js} +2 -2
- package/dist/{generate-drizzle-schema-logic-D0E64iwx.js.map → generate-drizzle-schema-logic-CVRmZjP3.js.map} +1 -1
- package/dist/{generate-files-BpgyRwhU.js → generate-files-DutUrsSS.js} +3 -3
- package/dist/{generate-files-BpgyRwhU.js.map → generate-files-DutUrsSS.js.map} +1 -1
- package/dist/{generate-postgres-ddl-logic-CogQBrzs.js → generate-postgres-ddl-logic-0rbAqwYT.js} +22 -10
- package/dist/generate-postgres-ddl-logic-0rbAqwYT.js.map +1 -0
- package/dist/{generated-schema-diff-X9NA2Vig.js → generated-schema-diff-ChFg6UxI.js} +13 -4
- package/dist/{generated-schema-diff-X9NA2Vig.js.map → generated-schema-diff-ChFg6UxI.js.map} +1 -1
- package/dist/history/HistoryService.d.ts +5 -0
- package/dist/index.es.js +14 -13
- package/dist/index.es.js.map +1 -1
- package/dist/{migrate-baseline-Bfk1LGC6.js → migrate-baseline-DPawvckr.js} +54 -11
- package/dist/{migrate-baseline-Bfk1LGC6.js.map → migrate-baseline-DPawvckr.js.map} +1 -1
- package/dist/{migrate-policy-stamps-DHxwcawC.js → migrate-policy-stamps-B-8vTSIm.js} +6 -6
- package/dist/{migrate-policy-stamps-DHxwcawC.js.map → migrate-policy-stamps-B-8vTSIm.js.map} +1 -1
- package/dist/{open-rebase-DZ5JbZpg.js → open-rebase-D9n8idex.js} +1436 -200
- package/dist/open-rebase-D9n8idex.js.map +1 -0
- package/dist/{pg-error-utils-BueZEJ0S.js → pg-error-utils-BIHfsGZL.js} +2 -2
- package/dist/{pg-error-utils-BueZEJ0S.js.map → pg-error-utils-BIHfsGZL.js.map} +1 -1
- package/dist/{plan-schema-YagMlmNE.js → plan-schema-DMVh77yb.js} +28 -1
- package/dist/plan-schema-DMVh77yb.js.map +1 -0
- package/dist/{policy-drift-Dqp_yFeE.js → policy-drift-0Cp4Lc0x.js} +13 -4
- package/dist/policy-drift-0Cp4Lc0x.js.map +1 -0
- package/dist/{push-index-prebuild-hVRrfTi-.js → push-index-prebuild-DR3P4yOw.js} +4 -4
- package/dist/{push-index-prebuild-hVRrfTi-.js.map → push-index-prebuild-DR3P4yOw.js.map} +1 -1
- package/dist/{push-kept-defaults-M_ZCcXuy.js → push-kept-defaults-BSqPzp0T.js} +2 -2
- package/dist/{push-kept-defaults-M_ZCcXuy.js.map → push-kept-defaults-BSqPzp0T.js.map} +1 -1
- package/dist/{push-legacy-renames-DcoAWmGt.js → push-legacy-renames-BIxBmVLl.js} +4 -4
- package/dist/{push-legacy-renames-DcoAWmGt.js.map → push-legacy-renames-BIxBmVLl.js.map} +1 -1
- package/dist/{push-policy-plan-Bq1bcb3Y.js → push-policy-plan-BHsasXa7.js} +4 -4
- package/dist/{push-policy-plan-Bq1bcb3Y.js.map → push-policy-plan-BHsasXa7.js.map} +1 -1
- package/dist/{render-ddl-D5jeXKR-.js → render-ddl-NpPPDACz.js} +20 -3
- package/dist/render-ddl-NpPPDACz.js.map +1 -0
- package/dist/schema/doctor-cli.js +3 -3
- package/dist/schema/ensure-collection-policies.d.ts +6 -4
- package/dist/schema/generate-drizzle-schema.js +1 -1
- package/dist/schema/generate-postgres-ddl-logic.d.ts +16 -0
- package/dist/schema/generate-postgres-ddl.js +1 -1
- package/dist/schema/generated-schema-diff.d.ts +6 -0
- package/dist/schema/introspect-db.js +1 -1
- package/dist/schema/plan/render-ddl.d.ts +11 -0
- package/dist/schema/reconcile-schema.d.ts +21 -0
- package/dist/security/policy-drift.d.ts +9 -1
- package/dist/services/BranchService.d.ts +6 -0
- package/dist/services/RelationService.d.ts +6 -6
- package/dist/services/cdc/CdcListener.d.ts +12 -0
- package/dist/services/cdc/WalCdcListener.d.ts +92 -0
- package/dist/services/cdc/pgoutput.d.ts +121 -0
- package/dist/services/cdc/wal-cdc.d.ts +29 -0
- package/dist/services/collection-helpers.d.ts +14 -0
- package/dist/services/junction-writes.d.ts +9 -1
- package/dist/services/nested-path.d.ts +2 -1
- package/dist/services/realtimeService.d.ts +47 -2
- package/dist/utils/drizzle-conditions.d.ts +11 -0
- package/dist/{websocket-C9Fx7iSx.js → websocket-D4wrzF3b.js} +6 -5
- package/dist/websocket-D4wrzF3b.js.map +1 -0
- package/package.json +7 -7
- package/dist/BranchService-B9Lu8e-P.js.map +0 -1
- package/dist/backup-cli-BZM2Fj1I.js.map +0 -1
- package/dist/databasePoolManager-3stMNFL-.js.map +0 -1
- package/dist/ensure-collection-policies-H8HN1Gbd.js.map +0 -1
- package/dist/generate-postgres-ddl-logic-CogQBrzs.js.map +0 -1
- package/dist/open-rebase-DZ5JbZpg.js.map +0 -1
- package/dist/plan-schema-YagMlmNE.js.map +0 -1
- package/dist/policy-drift-Dqp_yFeE.js.map +0 -1
- package/dist/render-ddl-D5jeXKR-.js.map +0 -1
- package/dist/websocket-C9Fx7iSx.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 forAtlas, A as getUndeclaredConstraintExcludes, B as withAppClient, C as dropDevDatabase, D as getSearchExcludes, E as getForeignIndexExcludes, F as queryUndeclarableConstraints, G as prepareGeneratedSqlDir, H as DESIRED_STATE_URL, I as readSearchDdl, J as detectDestructiveStatements, K as decidePushSafety, L as readTriggersDdl, M as loadCollectionsForCli, N as queryColumnTypes, O as getTableExcludes, P as queryGeneratedColumnDependencies, Q as warnIfYesApprovedDestructive, R as readVectorDdl, S as diagnoseMissingBin, T as ensureDevDatabaseExists, U as GENERATED_SQL_DIR, V as workspaceMemberDir, W as generatedSqlDir, X as fromAlterTable, Y as extractPlanStatements, Z as isSyncedPlan, _ as closeAppClients, a as diagnoseDbError, b as describeReinstallCommand, c as isEconnrefused, d as reportCommandFailure, f as ExcludeIntrospectionError, g as atlasDevDatabaseUrl, h as applyVectorDdl, i as diagnoseAtlasFailure, j as getVectorExcludes, k as getTriggerExcludes, l as isSslNotEnabled, m as applyTriggersDdl, o as formatForeignGeneratedColumnBanner, p as applySearchDdl, q as destructiveOptInFlag, s as isAuthFailure, t as checkDatabaseConnectivity, tt as redactConnectionPasswords, v as describeBuildScriptRemedy, w as dropGeneratedColumns, x as detectProjectPackageManager, y as describeDevAddCommand, z as resolveLocalBin } from "./cli-errors-
|
|
4
|
+
import { $ as forAtlas, A as getUndeclaredConstraintExcludes, B as withAppClient, C as dropDevDatabase, D as getSearchExcludes, E as getForeignIndexExcludes, F as queryUndeclarableConstraints, G as prepareGeneratedSqlDir, H as DESIRED_STATE_URL, I as readSearchDdl, J as detectDestructiveStatements, K as decidePushSafety, L as readTriggersDdl, M as loadCollectionsForCli, N as queryColumnTypes, O as getTableExcludes, P as queryGeneratedColumnDependencies, Q as warnIfYesApprovedDestructive, R as readVectorDdl, S as diagnoseMissingBin, T as ensureDevDatabaseExists, U as GENERATED_SQL_DIR, V as workspaceMemberDir, W as generatedSqlDir, X as fromAlterTable, Y as extractPlanStatements, Z as isSyncedPlan, _ as closeAppClients, a as diagnoseDbError, b as describeReinstallCommand, c as isEconnrefused, d as reportCommandFailure, f as ExcludeIntrospectionError, g as atlasDevDatabaseUrl, h as applyVectorDdl, i as diagnoseAtlasFailure, j as getVectorExcludes, k as getTriggerExcludes, l as isSslNotEnabled, m as applyTriggersDdl, o as formatForeignGeneratedColumnBanner, p as applySearchDdl, q as destructiveOptInFlag, s as isAuthFailure, t as checkDatabaseConnectivity, tt as redactConnectionPasswords, v as describeBuildScriptRemedy, w as dropGeneratedColumns, x as detectProjectPackageManager, y as describeDevAddCommand, z as resolveLocalBin } from "./cli-errors-DYets7cp.js";
|
|
5
5
|
import { a as outWarn, i as outError, o as atlasExcludePattern, r as out, s as excludePatternParts, t as chalk } from "./source-fZb92pN8.js";
|
|
6
6
|
import { t as nextStepAfterDbGenerate } from "./generate-next-step-DgK5BlBn.js";
|
|
7
|
-
import {
|
|
7
|
+
import { D as execa, S as RLS_BOOTSTRAP_SQL, 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 dropLegacyAuthSchema, x as resolveDriverSwitches } from "./migrate-baseline-DPawvckr.js";
|
|
8
8
|
import { formatRelativeTime } from "@rebasepro/utils";
|
|
9
9
|
import path from "path";
|
|
10
10
|
import fs from "fs";
|
|
@@ -1086,6 +1086,8 @@ function parseOlderThan(value) {
|
|
|
1086
1086
|
if (!Number.isFinite(amount)) return null;
|
|
1087
1087
|
return match[2]?.toLowerCase() === "w" ? amount * 7 : amount;
|
|
1088
1088
|
}
|
|
1089
|
+
/** Named the way `db push` names its scratch database: `<db>_dev_diff`. */
|
|
1090
|
+
var isAtlasScratch = (database) => database.endsWith("_dev_diff");
|
|
1089
1091
|
function planPrune(input, options = {}) {
|
|
1090
1092
|
const now = options.now ?? /* @__PURE__ */ new Date();
|
|
1091
1093
|
const present = new Set(input.databases);
|
|
@@ -1094,7 +1096,7 @@ function planPrune(input, options = {}) {
|
|
|
1094
1096
|
let active = null;
|
|
1095
1097
|
return {
|
|
1096
1098
|
staleRows: input.rows.filter((row) => !present.has(row.dbName)),
|
|
1097
|
-
orphanDatabases: input.databases.filter((name) => name.startsWith(input.branchPrefix) && !registered.has(name)).filter((name) => {
|
|
1099
|
+
orphanDatabases: input.databases.filter((name) => name.startsWith(input.branchPrefix) && !registered.has(name) && !isAtlasScratch(name)).filter((name) => {
|
|
1098
1100
|
if (!isActive(name)) return true;
|
|
1099
1101
|
active = {
|
|
1100
1102
|
name,
|
|
@@ -1113,7 +1115,7 @@ function planPrune(input, options = {}) {
|
|
|
1113
1115
|
};
|
|
1114
1116
|
return false;
|
|
1115
1117
|
}).sort((a, b) => b.ageDays - a.ageDays),
|
|
1116
|
-
devDiff: input.databases.filter((name) => name.
|
|
1118
|
+
devDiff: input.databases.filter((name) => isAtlasScratch(name) && !registered.has(name) && !isActive(name)).sort(),
|
|
1117
1119
|
active
|
|
1118
1120
|
};
|
|
1119
1121
|
}
|
|
@@ -1205,7 +1207,7 @@ function generatesInProcess() {
|
|
|
1205
1207
|
async function generateInProcess(what, label, run) {
|
|
1206
1208
|
let generators;
|
|
1207
1209
|
try {
|
|
1208
|
-
generators = await import("./generate-files-
|
|
1210
|
+
generators = await import("./generate-files-DutUrsSS.js").then((n) => n.t);
|
|
1209
1211
|
} catch (err) {
|
|
1210
1212
|
outError(chalk.red(`✗ Failed to run ${what}: ${err instanceof Error ? err.message : String(err)}`));
|
|
1211
1213
|
process.exit(1);
|
|
@@ -1252,7 +1254,7 @@ async function runPluginCommand(args) {
|
|
|
1252
1254
|
else if (domain === "schema") await schemaCommand(subcommand, args);
|
|
1253
1255
|
else if (domain === "doctor") await doctorPluginCommand(args);
|
|
1254
1256
|
else if (domain === "console") {
|
|
1255
|
-
const { consoleCommand } = await import("./cli-console-
|
|
1257
|
+
const { consoleCommand } = await import("./cli-console-C0FYkICX.js");
|
|
1256
1258
|
process.exitCode = await consoleCommand(args);
|
|
1257
1259
|
} else {
|
|
1258
1260
|
outError(chalk.red(`Unknown domain command: ${domain}`));
|
|
@@ -1419,7 +1421,7 @@ async function dbCommand(subcommand, rawArgs) {
|
|
|
1419
1421
|
return;
|
|
1420
1422
|
}
|
|
1421
1423
|
if (subcommand === "backup" || subcommand === "restore" || subcommand === "backups") {
|
|
1422
|
-
const { backupCommand, restoreCommand, backupsCommand } = await import("./backup-cli-
|
|
1424
|
+
const { backupCommand, restoreCommand, backupsCommand } = await import("./backup-cli-C1wcj-rc.js").then((n) => n.t);
|
|
1423
1425
|
if (subcommand === "backup" && backupActionOf(rawArgs) === "list") await backupsCommand(rawArgs);
|
|
1424
1426
|
else if (subcommand === "backup") await backupCommand(rawArgs);
|
|
1425
1427
|
else if (subcommand === "restore") await restoreCommand(rawArgs);
|
|
@@ -1466,7 +1468,7 @@ async function dbCommand(subcommand, rawArgs) {
|
|
|
1466
1468
|
}
|
|
1467
1469
|
const searchContent = readSearchDdl();
|
|
1468
1470
|
if (searchContent) {
|
|
1469
|
-
const { searchColumnDependencies } = await import("./generate-postgres-ddl-logic-
|
|
1471
|
+
const { searchColumnDependencies } = await import("./generate-postgres-ddl-logic-0rbAqwYT.js").then((n) => n.o);
|
|
1470
1472
|
const migrationConflicts = findGeneratedColumnConflicts(parseColumnMutations(migrationContent), searchColumnDependencies(await loadCollectionsForCli(collectionsPath)));
|
|
1471
1473
|
const preamble = migrationDropPreamble(migrationConflicts);
|
|
1472
1474
|
if (preamble) {
|
|
@@ -1734,7 +1736,7 @@ async function dbCommand(subcommand, rawArgs) {
|
|
|
1734
1736
|
if (databaseUrl) {
|
|
1735
1737
|
await ensureRlsUserRole(databaseUrl);
|
|
1736
1738
|
await retireLegacyAuthSchema(databaseUrl);
|
|
1737
|
-
const { stampMigratedPolicies } = await import("./migrate-policy-stamps-
|
|
1739
|
+
const { stampMigratedPolicies } = await import("./migrate-policy-stamps-B-8vTSIm.js");
|
|
1738
1740
|
await stampMigratedPolicies(databaseUrl, collectionsPath);
|
|
1739
1741
|
}
|
|
1740
1742
|
}
|
|
@@ -1762,8 +1764,8 @@ async function dbCommand(subcommand, rawArgs) {
|
|
|
1762
1764
|
* no such column reads nothing.
|
|
1763
1765
|
*/
|
|
1764
1766
|
async function keepDatabaseOwnedDefaults(databaseUrl, collectionsPath) {
|
|
1765
|
-
const { loadCollections } = await import("./doctor-
|
|
1766
|
-
const { databaseOwnedDefaultColumns, readKeptDefaults, withKeptDefaults } = await import("./push-kept-defaults-
|
|
1767
|
+
const { loadCollections } = await import("./doctor-TJApVglQ.js").then((n) => n.t);
|
|
1768
|
+
const { databaseOwnedDefaultColumns, readKeptDefaults, withKeptDefaults } = await import("./push-kept-defaults-BSqPzp0T.js");
|
|
1767
1769
|
const columns = databaseOwnedDefaultColumns(await loadCollections(path.resolve(process.cwd(), collectionsPath)));
|
|
1768
1770
|
if (columns.length === 0) return;
|
|
1769
1771
|
let kept;
|
|
@@ -1788,8 +1790,8 @@ async function keepDatabaseOwnedDefaults(databaseUrl, collectionsPath) {
|
|
|
1788
1790
|
async function renameLegacyForeignKeys(databaseUrl, collectionsPath, dryRun) {
|
|
1789
1791
|
let renames;
|
|
1790
1792
|
try {
|
|
1791
|
-
const { loadCollections } = await import("./doctor-
|
|
1792
|
-
const { legacyForeignKeyRenames } = await import("./push-legacy-renames-
|
|
1793
|
+
const { loadCollections } = await import("./doctor-TJApVglQ.js").then((n) => n.t);
|
|
1794
|
+
const { legacyForeignKeyRenames } = await import("./push-legacy-renames-BIxBmVLl.js");
|
|
1793
1795
|
const collections = await loadCollections(path.resolve(process.cwd(), collectionsPath));
|
|
1794
1796
|
renames = await withAppClient(databaseUrl, (client) => legacyForeignKeyRenames({ query: async (text) => ({ rows: (await client.query(text)).rows }) }, collections));
|
|
1795
1797
|
} catch {
|
|
@@ -1808,8 +1810,8 @@ async function renameLegacyForeignKeys(databaseUrl, collectionsPath, dryRun) {
|
|
|
1808
1810
|
/** Names the enum labels the database keeps after the collections dropped them. See `schema/enum-labels-kept.ts`. */
|
|
1809
1811
|
async function reportKeptEnumLabels(databaseUrl, collectionsPath) {
|
|
1810
1812
|
try {
|
|
1811
|
-
const { loadCollections } = await import("./doctor-
|
|
1812
|
-
const { keptEnumLabels, formatKeptEnumLabelsNotice } = await import("./enum-labels-kept-
|
|
1813
|
+
const { loadCollections } = await import("./doctor-TJApVglQ.js").then((n) => n.t);
|
|
1814
|
+
const { keptEnumLabels, formatKeptEnumLabelsNotice } = await import("./enum-labels-kept-BCgFGAbJ.js");
|
|
1813
1815
|
const collections = await loadCollections(path.resolve(process.cwd(), collectionsPath));
|
|
1814
1816
|
const kept = await withAppClient(databaseUrl, (client) => keptEnumLabels({ query: async (text) => ({ rows: (await client.query(text)).rows }) }, collections));
|
|
1815
1817
|
if (kept.length > 0) outWarn(chalk.yellow(formatKeptEnumLabelsNotice(kept)));
|
|
@@ -1818,8 +1820,8 @@ async function reportKeptEnumLabels(databaseUrl, collectionsPath) {
|
|
|
1818
1820
|
async function prebuildForeignKeyIndexes(databaseUrl, collectionsPath, dryRun) {
|
|
1819
1821
|
let missing;
|
|
1820
1822
|
try {
|
|
1821
|
-
const { loadCollections } = await import("./doctor-
|
|
1822
|
-
const { missingForeignKeyIndexes } = await import("./push-index-prebuild-
|
|
1823
|
+
const { loadCollections } = await import("./doctor-TJApVglQ.js").then((n) => n.t);
|
|
1824
|
+
const { missingForeignKeyIndexes } = await import("./push-index-prebuild-DR3P4yOw.js");
|
|
1823
1825
|
const collections = await loadCollections(path.resolve(process.cwd(), collectionsPath));
|
|
1824
1826
|
missing = await withAppClient(databaseUrl, (client) => missingForeignKeyIndexes({ query: async (text) => ({ rows: (await client.query(text)).rows }) }, collections));
|
|
1825
1827
|
} catch {
|
|
@@ -1829,7 +1831,7 @@ async function prebuildForeignKeyIndexes(databaseUrl, collectionsPath, dryRun) {
|
|
|
1829
1831
|
if (missing.length === 0 || dryRun) return names;
|
|
1830
1832
|
out(chalk.gray(` Building ${missing.length} foreign-key index(es) on existing tables first — CONCURRENTLY, so writes go on:`));
|
|
1831
1833
|
try {
|
|
1832
|
-
const { buildDeferredIndexes } = await import("./deferred-index-build-
|
|
1834
|
+
const { buildDeferredIndexes } = await import("./deferred-index-build-BcJ_oulu.js").then((n) => n.r);
|
|
1833
1835
|
const outcome = await withAppClient(databaseUrl, (client) => buildDeferredIndexes(async () => ({
|
|
1834
1836
|
dedicated: true,
|
|
1835
1837
|
query: async (text) => ({ rows: (await client.query(text)).rows }),
|
|
@@ -1877,8 +1879,8 @@ async function lockManagedTables(databaseUrl, collectionsPath) {
|
|
|
1877
1879
|
let unsecured;
|
|
1878
1880
|
let userRole;
|
|
1879
1881
|
try {
|
|
1880
|
-
const { lockCollectionTables } = await import("./ensure-collection-policies-
|
|
1881
|
-
const { loadCollections } = await import("./doctor-
|
|
1882
|
+
const { lockCollectionTables } = await import("./ensure-collection-policies-BNwSQfVx.js");
|
|
1883
|
+
const { loadCollections } = await import("./doctor-TJApVglQ.js").then((n) => n.t);
|
|
1882
1884
|
userRole = (await import("./rls-enforcement-BOHuHVlc.js").then((n) => n.l)).REBASE_USER_ROLE;
|
|
1883
1885
|
const collections = await loadCollections(path.resolve(process.cwd(), collectionsPath));
|
|
1884
1886
|
({unsecured} = await withAppClient(databaseUrl, (client) => lockCollectionTables({ query: async (text) => ({ rows: (await client.query(text)).rows }) }, collections)));
|
|
@@ -1914,8 +1916,8 @@ async function lockManagedTables(databaseUrl, collectionsPath) {
|
|
|
1914
1916
|
async function ensureAuthTables(databaseUrl, collectionsPath) {
|
|
1915
1917
|
try {
|
|
1916
1918
|
const { drizzle } = await import("drizzle-orm/node-postgres");
|
|
1917
|
-
const { ensureAuthTablesExist } = await import("./ensure-tables-
|
|
1918
|
-
const { loadCollections } = await import("./doctor-
|
|
1919
|
+
const { ensureAuthTablesExist } = await import("./ensure-tables-CF-8zgYA.js").then((n) => n.n);
|
|
1920
|
+
const { loadCollections } = await import("./doctor-TJApVglQ.js").then((n) => n.t);
|
|
1919
1921
|
const authCollection = (await loadCollections(path.resolve(process.cwd(), collectionsPath))).find((c) => {
|
|
1920
1922
|
const a = c.auth;
|
|
1921
1923
|
return a === true || typeof a === "object" && a !== null && a.enabled === true;
|
|
@@ -1995,9 +1997,9 @@ async function applyPolicies(databaseUrl, collectionsPath) {
|
|
|
1995
1997
|
*/
|
|
1996
1998
|
async function policyStamping(databaseUrl, collectionsPath, policiesSql) {
|
|
1997
1999
|
try {
|
|
1998
|
-
const { loadCollections } = await import("./doctor-
|
|
1999
|
-
const { planCollectionPolicies } = await import("./generate-postgres-ddl-logic-
|
|
2000
|
-
const { policyStampSql } = await import("./ensure-collection-policies-
|
|
2000
|
+
const { loadCollections } = await import("./doctor-TJApVglQ.js").then((n) => n.t);
|
|
2001
|
+
const { planCollectionPolicies } = await import("./generate-postgres-ddl-logic-0rbAqwYT.js").then((n) => n.o);
|
|
2002
|
+
const { policyStampSql } = await import("./ensure-collection-policies-BNwSQfVx.js");
|
|
2001
2003
|
const { pinSearchPath } = await import("./connection-czvI7TZL.js").then((n) => n.n);
|
|
2002
2004
|
return {
|
|
2003
2005
|
statements: stampableTables(planCollectionPolicies(await loadCollections(path.resolve(process.cwd(), collectionsPath))), policiesSql).map((plan) => policyStampSql(plan)).filter((statement) => statement !== void 0),
|
|
@@ -2015,8 +2017,8 @@ async function policyStamping(databaseUrl, collectionsPath, policiesSql) {
|
|
|
2015
2017
|
*/
|
|
2016
2018
|
async function readPolicyPushPlan(databaseUrl, collectionsPath) {
|
|
2017
2019
|
try {
|
|
2018
|
-
const { formatPolicyPushPlan, planPolicyPush, summarizePolicyPushPlan } = await import("./push-policy-plan-
|
|
2019
|
-
const { loadCollections } = await import("./doctor-
|
|
2020
|
+
const { formatPolicyPushPlan, planPolicyPush, summarizePolicyPushPlan } = await import("./push-policy-plan-BHsasXa7.js");
|
|
2021
|
+
const { loadCollections } = await import("./doctor-TJApVglQ.js").then((n) => n.t);
|
|
2020
2022
|
const { pinSearchPath } = await import("./connection-czvI7TZL.js").then((n) => n.n);
|
|
2021
2023
|
const collections = await loadCollections(path.resolve(process.cwd(), collectionsPath));
|
|
2022
2024
|
const plan = await withAppClient(databaseUrl, (client) => planPolicyPush({ query: async (text, values) => ({ rows: (await client.query(text, values)).rows }) }, collections, { searchPath: pinSearchPath(databaseUrl) === databaseUrl ? void 0 : "public" }));
|
|
@@ -2044,8 +2046,8 @@ async function readPolicyPushPlan(databaseUrl, collectionsPath) {
|
|
|
2044
2046
|
*/
|
|
2045
2047
|
async function reconcilePolicies(databaseUrl, collectionsPath) {
|
|
2046
2048
|
try {
|
|
2047
|
-
const { checkPolicyDrift, dropOrphanedPolicies, formatPolicyDrift, hasDrift } = await import("./policy-drift-
|
|
2048
|
-
const { loadCollections } = await import("./doctor-
|
|
2049
|
+
const { checkPolicyDrift, dropOrphanedPolicies, formatPolicyDrift, hasDrift } = await import("./policy-drift-0Cp4Lc0x.js").then((n) => n.s);
|
|
2050
|
+
const { loadCollections } = await import("./doctor-TJApVglQ.js").then((n) => n.t);
|
|
2049
2051
|
const collections = await loadCollections(path.resolve(process.cwd(), collectionsPath));
|
|
2050
2052
|
await withAppClient(databaseUrl, async (client) => {
|
|
2051
2053
|
const drift = await checkPolicyDrift(client, collections);
|
|
@@ -2095,8 +2097,7 @@ var BRANCH_FLAGS = {
|
|
|
2095
2097
|
};
|
|
2096
2098
|
/** The source `branch create --from <source>` names, if it names one. */
|
|
2097
2099
|
function createSource(rawArgs) {
|
|
2098
|
-
|
|
2099
|
-
return at !== -1 && rawArgs[at + 1] ? rawArgs[at + 1] : void 0;
|
|
2100
|
+
return branchSourceIn(rawArgs.slice(2));
|
|
2100
2101
|
}
|
|
2101
2102
|
async function branchCommand(rawArgs) {
|
|
2102
2103
|
const branchAction = rawArgs[2];
|
|
@@ -2112,7 +2113,8 @@ async function branchCommand(rawArgs) {
|
|
|
2112
2113
|
outError("");
|
|
2113
2114
|
outError(chalk.gray(` ${chalk.bold("rebase db branch")} takes one name. A branch name may contain letters,`));
|
|
2114
2115
|
outError(chalk.gray(" digits, underscores and hyphens — no spaces."));
|
|
2115
|
-
|
|
2116
|
+
const named = branchNameIn(rawArgs.slice(2));
|
|
2117
|
+
if (named) outError(chalk.gray(` Did you mean: ${chalk.cyan(redactConnectionPasswords(`rebase db branch ${branchAction} ${[named, ...extras].join("-")}`))}`));
|
|
2116
2118
|
outError("");
|
|
2117
2119
|
process.exit(1);
|
|
2118
2120
|
}
|
|
@@ -2130,8 +2132,8 @@ async function branchCommand(rawArgs) {
|
|
|
2130
2132
|
outError(chalk.red("✗ DATABASE_URL is not set. Make sure your .env file is configured."));
|
|
2131
2133
|
process.exit(1);
|
|
2132
2134
|
}
|
|
2133
|
-
const { DatabasePoolManager } = await import("./databasePoolManager-
|
|
2134
|
-
const { BranchService, reopenClosedDatabases, reopenedDatabasesNotice } = await import("./BranchService-
|
|
2135
|
+
const { DatabasePoolManager } = await import("./databasePoolManager-BjoVvuAq.js").then((n) => n.n);
|
|
2136
|
+
const { BranchService, reopenClosedDatabases, reopenedDatabasesNotice } = await import("./BranchService-BPssiD8_.js").then((n) => n.n);
|
|
2135
2137
|
const { drizzle } = await import("drizzle-orm/node-postgres");
|
|
2136
2138
|
const { Pool } = await import("pg");
|
|
2137
2139
|
const healed = await reopenClosedDatabases(databaseUrl, [branchAction === "create" ? createSource(rawArgs) : void 0, process.env[ACTIVE_BRANCH_DATABASE_ENV]]);
|
|
@@ -2149,7 +2151,7 @@ async function branchCommand(rawArgs) {
|
|
|
2149
2151
|
if (branchAction === "create" || branchAction === "delete" || branchAction === "prune") await branchService.ensureBranchMetadataTable();
|
|
2150
2152
|
switch (branchAction) {
|
|
2151
2153
|
case "create": {
|
|
2152
|
-
const name = rawArgs
|
|
2154
|
+
const name = branchNameIn(rawArgs.slice(2));
|
|
2153
2155
|
if (!name) {
|
|
2154
2156
|
outError(chalk.red("✗ Branch name is required."));
|
|
2155
2157
|
out(chalk.gray(" Usage: rebase db branch create <name> [--from <source>]"));
|
|
@@ -2193,7 +2195,7 @@ async function branchCommand(rawArgs) {
|
|
|
2193
2195
|
break;
|
|
2194
2196
|
}
|
|
2195
2197
|
case "delete": {
|
|
2196
|
-
const name = rawArgs
|
|
2198
|
+
const name = branchNameIn(rawArgs.slice(2));
|
|
2197
2199
|
if (!name) {
|
|
2198
2200
|
outError(chalk.red("✗ Branch name is required."));
|
|
2199
2201
|
out(chalk.gray(" Usage: rebase db branch delete <name>"));
|
|
@@ -2207,7 +2209,7 @@ async function branchCommand(rawArgs) {
|
|
|
2207
2209
|
break;
|
|
2208
2210
|
}
|
|
2209
2211
|
case "info": {
|
|
2210
|
-
const name = rawArgs
|
|
2212
|
+
const name = branchNameIn(rawArgs.slice(2));
|
|
2211
2213
|
if (!name) {
|
|
2212
2214
|
outError(chalk.red("✗ Branch name is required."));
|
|
2213
2215
|
out(chalk.gray(" Usage: rebase db branch info <name>"));
|
|
@@ -2230,14 +2232,14 @@ async function branchCommand(rawArgs) {
|
|
|
2230
2232
|
break;
|
|
2231
2233
|
}
|
|
2232
2234
|
case "diff": {
|
|
2233
|
-
const name = rawArgs
|
|
2235
|
+
const name = branchNameIn(rawArgs.slice(2));
|
|
2234
2236
|
if (!name || name.startsWith("-")) {
|
|
2235
2237
|
outError(chalk.red("✗ Branch name is required."));
|
|
2236
2238
|
out(chalk.gray(" Usage: rebase db branch diff <name> [--json] [--sample-limit <n>]"));
|
|
2237
2239
|
process.exit(1);
|
|
2238
2240
|
}
|
|
2239
2241
|
const parsed = (0, import_arg.default)(BRANCH_FLAGS, {
|
|
2240
|
-
argv: rawArgs.slice(
|
|
2242
|
+
argv: rawArgs.slice(3),
|
|
2241
2243
|
permissive: true
|
|
2242
2244
|
});
|
|
2243
2245
|
const { diffDatabaseBranch } = await import("./branch-diff-CxE4VlxT.js").then((n) => n.r);
|
|
@@ -2678,9 +2680,9 @@ async function schemaStaleCommand(rawArgs) {
|
|
|
2678
2680
|
const schemaFile = path.resolve(process.cwd(), outputPath);
|
|
2679
2681
|
const fix = Boolean(argsList["--fix"]);
|
|
2680
2682
|
const generatedExists = fs.existsSync(schemaFile);
|
|
2681
|
-
const { loadCollections } = await import("./doctor-
|
|
2683
|
+
const { loadCollections } = await import("./doctor-TJApVglQ.js").then((n) => n.t);
|
|
2682
2684
|
const { findLegacyForeignKeyNames, compareGeneratedDeclarations, staleVerdict } = await import("./generated-schema-staleness-BvNF3i-s.js").then((n) => n.r);
|
|
2683
|
-
const { generateSchema } = await import("./generate-drizzle-schema-logic-
|
|
2685
|
+
const { generateSchema } = await import("./generate-drizzle-schema-logic-CVRmZjP3.js").then((n) => n.n);
|
|
2684
2686
|
const { relationalCollections } = await import("@rebasepro/common");
|
|
2685
2687
|
let stale = [];
|
|
2686
2688
|
let differences = [];
|