@rebasepro/server-postgres 0.25.0-canary.g70dad01 → 0.25.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-DO_3_CXt.js → BranchService-iXXZeVYD.js} +133 -20
- package/dist/BranchService-iXXZeVYD.js.map +1 -0
- package/dist/backup/backup-service.d.ts +8 -3
- package/dist/backup/pg-tools.d.ts +13 -1
- package/dist/{backup-cli-Ap2WX2uW.js → backup-cli-B2CAn9fR.js} +3 -3
- package/dist/{backup-cli-Ap2WX2uW.js.map → backup-cli-B2CAn9fR.js.map} +1 -1
- package/dist/{backup-service-DytMimsL.js → backup-service-Bb39plam.js} +67 -10
- package/dist/backup-service-Bb39plam.js.map +1 -0
- package/dist/{boot-ddl-D1lMCZLd.js → boot-ddl-s_3Hkz94.js} +2 -2
- package/dist/{boot-ddl-D1lMCZLd.js.map → boot-ddl-s_3Hkz94.js.map} +1 -1
- package/dist/{cli-console-CQGsBzSY.js → cli-console-DQ_K-sdM.js} +4 -4
- package/dist/{cli-console-CQGsBzSY.js.map → cli-console-DQ_K-sdM.js.map} +1 -1
- package/dist/{cli-errors-CJTKAKax.js → cli-errors-DwQnNATs.js} +52 -2
- package/dist/{cli-errors-CJTKAKax.js.map → cli-errors-DwQnNATs.js.map} +1 -1
- package/dist/cli-errors.d.ts +10 -0
- package/dist/cli.js +29 -24
- package/dist/cli.js.map +1 -1
- package/dist/{deferred-index-build-BiTqxqdl.js → deferred-index-build-Cis_HoGn.js} +3 -3
- package/dist/{deferred-index-build-BiTqxqdl.js.map → deferred-index-build-Cis_HoGn.js.map} +1 -1
- package/dist/{doctor-N3J88BN_.js → doctor-DvJH-IQG.js} +2 -2
- package/dist/{doctor-N3J88BN_.js.map → doctor-DvJH-IQG.js.map} +1 -1
- package/dist/{ensure-collection-policies-CVP6kIPT.js → ensure-collection-policies-CCqayoUz.js} +4 -4
- package/dist/{ensure-collection-policies-CVP6kIPT.js.map → ensure-collection-policies-CCqayoUz.js.map} +1 -1
- package/dist/{ensure-collection-tables-1WVNALOW.js → ensure-collection-tables-DvvImXDe.js} +5 -5
- package/dist/{ensure-collection-tables-1WVNALOW.js.map → ensure-collection-tables-DvvImXDe.js.map} +1 -1
- package/dist/{ensure-tables-D-Nm2k3S.js → ensure-tables-Dpgwx5sy.js} +2 -2
- package/dist/{ensure-tables-D-Nm2k3S.js.map → ensure-tables-Dpgwx5sy.js.map} +1 -1
- package/dist/{enum-labels-kept-e_93v2Ic.js → enum-labels-kept-CUlUlRkO.js} +2 -2
- package/dist/{enum-labels-kept-e_93v2Ic.js.map → enum-labels-kept-CUlUlRkO.js.map} +1 -1
- package/dist/index.es.js +6 -6
- package/dist/{open-rebase-Cwnqo5LU.js → open-rebase-BKA7Nyoe.js} +21 -16
- package/dist/{open-rebase-Cwnqo5LU.js.map → open-rebase-BKA7Nyoe.js.map} +1 -1
- package/dist/{pg-error-utils-Cmo8wZPy.js → pg-error-utils-Bv5n2PLn.js} +2 -2
- package/dist/{pg-error-utils-Cmo8wZPy.js.map → pg-error-utils-Bv5n2PLn.js.map} +1 -1
- package/dist/{push-index-prebuild-SXRlWBjc.js → push-index-prebuild-DIequ4bV.js} +3 -3
- package/dist/{push-index-prebuild-SXRlWBjc.js.map → push-index-prebuild-DIequ4bV.js.map} +1 -1
- package/dist/{push-legacy-renames-B37yKDac.js → push-legacy-renames-BqJut4F3.js} +3 -3
- package/dist/{push-legacy-renames-B37yKDac.js.map → push-legacy-renames-BqJut4F3.js.map} +1 -1
- package/dist/{push-policy-plan-jXzHAWSu.js → push-policy-plan-CvX8hiPb.js} +2 -2
- package/dist/{push-policy-plan-jXzHAWSu.js.map → push-policy-plan-CvX8hiPb.js.map} +1 -1
- package/dist/schema/doctor-cli.js +2 -2
- package/dist/schema/introspect-db.js +1 -1
- package/dist/services/BranchService.d.ts +40 -4
- package/dist/{websocket-BT85Yv_G.js → websocket-MC0zTBar.js} +3 -3
- package/dist/{websocket-BT85Yv_G.js.map → websocket-MC0zTBar.js.map} +1 -1
- package/package.json +7 -7
- package/dist/BranchService-DO_3_CXt.js.map +0 -1
- package/dist/backup-service-DytMimsL.js.map +0 -1
package/dist/cli-errors.d.ts
CHANGED
|
@@ -20,6 +20,16 @@ export declare function isAuthFailure(err: unknown): boolean;
|
|
|
20
20
|
* with a plain local dev database). The fix is `?sslmode=disable` on the URL.
|
|
21
21
|
*/
|
|
22
22
|
export declare function isSslNotEnabled(err: unknown): boolean;
|
|
23
|
+
/**
|
|
24
|
+
* The database a connection was refused by because it is closed to new
|
|
25
|
+
* connections (`ALLOW_CONNECTIONS false`), or null.
|
|
26
|
+
*
|
|
27
|
+
* Postgres says it as `database "x" is not currently accepting connections`,
|
|
28
|
+
* SQLSTATE 55000. That code also covers failures that have nothing to do with
|
|
29
|
+
* connecting (`lastval is not yet defined in this session`), so the sentence is
|
|
30
|
+
* what is matched, through Drizzle's `cause` and a dual-stack `AggregateError`.
|
|
31
|
+
*/
|
|
32
|
+
export declare function closedDatabaseName(err: unknown): string | null;
|
|
23
33
|
/**
|
|
24
34
|
* Detect PostgreSQL "cannot drop ... because other objects depend on it"
|
|
25
35
|
* (error code 2BP01, dependent_objects_still_exist). This is the failure that
|
package/dist/cli.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createRequire as __createRequire } from "module";
|
|
2
2
|
__createRequire(import.meta.url);
|
|
3
3
|
import { i as __toESM } from "./rolldown-runtime-V7rFbMRe.js";
|
|
4
|
-
import {
|
|
4
|
+
import { 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 forAtlas, 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, et as redactConnectionPasswords, 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, v as describeBuildScriptRemedy, w as dropGeneratedColumns, x as detectProjectPackageManager, y as describeDevAddCommand, z as resolveLocalBin } from "./cli-errors-DwQnNATs.js";
|
|
5
5
|
import { a as outWarn, i as outError, o as atlasExcludePattern, r as out, s as excludePatternParts, t as chalk } from "./source-Bv5KPeIx.js";
|
|
6
6
|
import { t as nextStepAfterDbGenerate } from "./generate-next-step-DCeS4LrJ.js";
|
|
7
7
|
import { o as execa, r as dropLegacyAuthSchema, t as RLS_BOOTSTRAP_SQL } from "./rls-bootstrap-sql-Bd-hJk08.js";
|
|
@@ -1472,7 +1472,7 @@ async function runPluginCommand(args) {
|
|
|
1472
1472
|
else if (domain === "schema") await schemaCommand(subcommand, args);
|
|
1473
1473
|
else if (domain === "doctor") await doctorPluginCommand(args);
|
|
1474
1474
|
else if (domain === "console") {
|
|
1475
|
-
const { consoleCommand } = await import("./cli-console-
|
|
1475
|
+
const { consoleCommand } = await import("./cli-console-DQ_K-sdM.js");
|
|
1476
1476
|
process.exitCode = await consoleCommand(args);
|
|
1477
1477
|
} else {
|
|
1478
1478
|
outError(chalk.red(`Unknown domain command: ${domain}`));
|
|
@@ -1648,7 +1648,7 @@ async function dbCommand(subcommand, rawArgs) {
|
|
|
1648
1648
|
return;
|
|
1649
1649
|
}
|
|
1650
1650
|
if (subcommand === "backup" || subcommand === "restore" || subcommand === "backups") {
|
|
1651
|
-
const { backupCommand, restoreCommand, backupsCommand } = await import("./backup-cli-
|
|
1651
|
+
const { backupCommand, restoreCommand, backupsCommand } = await import("./backup-cli-B2CAn9fR.js");
|
|
1652
1652
|
if (subcommand === "backup" && backupActionOf(rawArgs) === "list") await backupsCommand(rawArgs);
|
|
1653
1653
|
else if (subcommand === "backup") await backupCommand(rawArgs);
|
|
1654
1654
|
else if (subcommand === "restore") await restoreCommand(rawArgs);
|
|
@@ -1979,8 +1979,8 @@ async function dbCommand(subcommand, rawArgs) {
|
|
|
1979
1979
|
async function renameLegacyForeignKeys(databaseUrl, collectionsPath, dryRun) {
|
|
1980
1980
|
let renames;
|
|
1981
1981
|
try {
|
|
1982
|
-
const { loadCollections } = await import("./doctor-
|
|
1983
|
-
const { legacyForeignKeyRenames } = await import("./push-legacy-renames-
|
|
1982
|
+
const { loadCollections } = await import("./doctor-DvJH-IQG.js").then((n) => n.t);
|
|
1983
|
+
const { legacyForeignKeyRenames } = await import("./push-legacy-renames-BqJut4F3.js");
|
|
1984
1984
|
const collections = await loadCollections(path.resolve(process.cwd(), collectionsPath));
|
|
1985
1985
|
renames = await withAppClient(databaseUrl, (client) => legacyForeignKeyRenames({ query: async (text) => ({ rows: (await client.query(text)).rows }) }, collections));
|
|
1986
1986
|
} catch {
|
|
@@ -1999,8 +1999,8 @@ async function renameLegacyForeignKeys(databaseUrl, collectionsPath, dryRun) {
|
|
|
1999
1999
|
/** Names the enum labels the database keeps after the collections dropped them. See `schema/enum-labels-kept.ts`. */
|
|
2000
2000
|
async function reportKeptEnumLabels(databaseUrl, collectionsPath) {
|
|
2001
2001
|
try {
|
|
2002
|
-
const { loadCollections } = await import("./doctor-
|
|
2003
|
-
const { keptEnumLabels, formatKeptEnumLabelsNotice } = await import("./enum-labels-kept-
|
|
2002
|
+
const { loadCollections } = await import("./doctor-DvJH-IQG.js").then((n) => n.t);
|
|
2003
|
+
const { keptEnumLabels, formatKeptEnumLabelsNotice } = await import("./enum-labels-kept-CUlUlRkO.js");
|
|
2004
2004
|
const collections = await loadCollections(path.resolve(process.cwd(), collectionsPath));
|
|
2005
2005
|
const kept = await withAppClient(databaseUrl, (client) => keptEnumLabels({ query: async (text) => ({ rows: (await client.query(text)).rows }) }, collections));
|
|
2006
2006
|
if (kept.length > 0) outWarn(chalk.yellow(formatKeptEnumLabelsNotice(kept)));
|
|
@@ -2009,8 +2009,8 @@ async function reportKeptEnumLabels(databaseUrl, collectionsPath) {
|
|
|
2009
2009
|
async function prebuildForeignKeyIndexes(databaseUrl, collectionsPath, dryRun) {
|
|
2010
2010
|
let missing;
|
|
2011
2011
|
try {
|
|
2012
|
-
const { loadCollections } = await import("./doctor-
|
|
2013
|
-
const { missingForeignKeyIndexes } = await import("./push-index-prebuild-
|
|
2012
|
+
const { loadCollections } = await import("./doctor-DvJH-IQG.js").then((n) => n.t);
|
|
2013
|
+
const { missingForeignKeyIndexes } = await import("./push-index-prebuild-DIequ4bV.js");
|
|
2014
2014
|
const collections = await loadCollections(path.resolve(process.cwd(), collectionsPath));
|
|
2015
2015
|
missing = await withAppClient(databaseUrl, (client) => missingForeignKeyIndexes({ query: async (text) => ({ rows: (await client.query(text)).rows }) }, collections));
|
|
2016
2016
|
} catch {
|
|
@@ -2020,7 +2020,7 @@ async function prebuildForeignKeyIndexes(databaseUrl, collectionsPath, dryRun) {
|
|
|
2020
2020
|
if (missing.length === 0 || dryRun) return names;
|
|
2021
2021
|
out(chalk.gray(` Building ${missing.length} foreign-key index(es) on existing tables first — CONCURRENTLY, so writes go on:`));
|
|
2022
2022
|
try {
|
|
2023
|
-
const { buildDeferredIndexes } = await import("./deferred-index-build-
|
|
2023
|
+
const { buildDeferredIndexes } = await import("./deferred-index-build-Cis_HoGn.js").then((n) => n.r);
|
|
2024
2024
|
const outcome = await withAppClient(databaseUrl, (client) => buildDeferredIndexes(async () => ({
|
|
2025
2025
|
dedicated: true,
|
|
2026
2026
|
query: async (text) => ({ rows: (await client.query(text)).rows }),
|
|
@@ -2068,8 +2068,8 @@ async function lockManagedTables(databaseUrl, collectionsPath) {
|
|
|
2068
2068
|
let unsecured;
|
|
2069
2069
|
let userRole;
|
|
2070
2070
|
try {
|
|
2071
|
-
const { lockCollectionTables } = await import("./ensure-collection-policies-
|
|
2072
|
-
const { loadCollections } = await import("./doctor-
|
|
2071
|
+
const { lockCollectionTables } = await import("./ensure-collection-policies-CCqayoUz.js");
|
|
2072
|
+
const { loadCollections } = await import("./doctor-DvJH-IQG.js").then((n) => n.t);
|
|
2073
2073
|
userRole = (await import("./rls-enforcement-D7P4-ZYX.js").then((n) => n.c)).REBASE_USER_ROLE;
|
|
2074
2074
|
const collections = await loadCollections(path.resolve(process.cwd(), collectionsPath));
|
|
2075
2075
|
({unsecured} = await withAppClient(databaseUrl, (client) => lockCollectionTables({ query: async (text) => ({ rows: (await client.query(text)).rows }) }, collections)));
|
|
@@ -2105,8 +2105,8 @@ async function lockManagedTables(databaseUrl, collectionsPath) {
|
|
|
2105
2105
|
async function ensureAuthTables(databaseUrl, collectionsPath) {
|
|
2106
2106
|
try {
|
|
2107
2107
|
const { drizzle } = await import("drizzle-orm/node-postgres");
|
|
2108
|
-
const { ensureAuthTablesExist } = await import("./ensure-tables-
|
|
2109
|
-
const { loadCollections } = await import("./doctor-
|
|
2108
|
+
const { ensureAuthTablesExist } = await import("./ensure-tables-Dpgwx5sy.js").then((n) => n.n);
|
|
2109
|
+
const { loadCollections } = await import("./doctor-DvJH-IQG.js").then((n) => n.t);
|
|
2110
2110
|
const authCollection = (await loadCollections(path.resolve(process.cwd(), collectionsPath))).find((c) => {
|
|
2111
2111
|
const a = c.auth;
|
|
2112
2112
|
return a === true || typeof a === "object" && a !== null && a.enabled === true;
|
|
@@ -2186,9 +2186,9 @@ async function applyPolicies(databaseUrl, collectionsPath) {
|
|
|
2186
2186
|
*/
|
|
2187
2187
|
async function policyStamping(databaseUrl, collectionsPath, policiesSql) {
|
|
2188
2188
|
try {
|
|
2189
|
-
const { loadCollections } = await import("./doctor-
|
|
2189
|
+
const { loadCollections } = await import("./doctor-DvJH-IQG.js").then((n) => n.t);
|
|
2190
2190
|
const { planCollectionPolicies } = await import("./generate-postgres-ddl-logic-4eUP4t8w.js").then((n) => n.o);
|
|
2191
|
-
const { policyStampSql } = await import("./ensure-collection-policies-
|
|
2191
|
+
const { policyStampSql } = await import("./ensure-collection-policies-CCqayoUz.js");
|
|
2192
2192
|
const { pinSearchPath } = await import("./connection-C938nR3E.js").then((n) => n.n);
|
|
2193
2193
|
return {
|
|
2194
2194
|
statements: stampableTables(planCollectionPolicies(await loadCollections(path.resolve(process.cwd(), collectionsPath))), policiesSql).map((plan) => policyStampSql(plan)).filter((statement) => statement !== void 0),
|
|
@@ -2206,8 +2206,8 @@ async function policyStamping(databaseUrl, collectionsPath, policiesSql) {
|
|
|
2206
2206
|
*/
|
|
2207
2207
|
async function readPolicyPushPlan(databaseUrl, collectionsPath) {
|
|
2208
2208
|
try {
|
|
2209
|
-
const { formatPolicyPushPlan, planPolicyPush, summarizePolicyPushPlan } = await import("./push-policy-plan-
|
|
2210
|
-
const { loadCollections } = await import("./doctor-
|
|
2209
|
+
const { formatPolicyPushPlan, planPolicyPush, summarizePolicyPushPlan } = await import("./push-policy-plan-CvX8hiPb.js");
|
|
2210
|
+
const { loadCollections } = await import("./doctor-DvJH-IQG.js").then((n) => n.t);
|
|
2211
2211
|
const { pinSearchPath } = await import("./connection-C938nR3E.js").then((n) => n.n);
|
|
2212
2212
|
const collections = await loadCollections(path.resolve(process.cwd(), collectionsPath));
|
|
2213
2213
|
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" }));
|
|
@@ -2236,7 +2236,7 @@ async function readPolicyPushPlan(databaseUrl, collectionsPath) {
|
|
|
2236
2236
|
async function reconcilePolicies(databaseUrl, collectionsPath) {
|
|
2237
2237
|
try {
|
|
2238
2238
|
const { checkPolicyDrift, dropOrphanedPolicies, formatPolicyDrift, hasDrift } = await import("./policy-drift-vm0BcvcE.js").then((n) => n.s);
|
|
2239
|
-
const { loadCollections } = await import("./doctor-
|
|
2239
|
+
const { loadCollections } = await import("./doctor-DvJH-IQG.js").then((n) => n.t);
|
|
2240
2240
|
const collections = await loadCollections(path.resolve(process.cwd(), collectionsPath));
|
|
2241
2241
|
await withAppClient(databaseUrl, async (client) => {
|
|
2242
2242
|
const drift = await checkPolicyDrift(client, collections);
|
|
@@ -2282,6 +2282,11 @@ var BRANCH_FLAGS = {
|
|
|
2282
2282
|
"--yes": Boolean,
|
|
2283
2283
|
"-y": "--yes"
|
|
2284
2284
|
};
|
|
2285
|
+
/** The source `branch create --from <source>` names, if it names one. */
|
|
2286
|
+
function createSource(rawArgs) {
|
|
2287
|
+
const at = rawArgs.indexOf("--from");
|
|
2288
|
+
return at !== -1 && rawArgs[at + 1] ? rawArgs[at + 1] : void 0;
|
|
2289
|
+
}
|
|
2285
2290
|
async function branchCommand(rawArgs) {
|
|
2286
2291
|
const branchAction = rawArgs[2];
|
|
2287
2292
|
if (!branchAction || branchAction === "--help") {
|
|
@@ -2314,9 +2319,11 @@ async function branchCommand(rawArgs) {
|
|
|
2314
2319
|
process.exit(1);
|
|
2315
2320
|
}
|
|
2316
2321
|
const { DatabasePoolManager } = await import("./databasePoolManager-Yqdw14wY.js").then((n) => n.n);
|
|
2317
|
-
const { BranchService } = await import("./BranchService-
|
|
2322
|
+
const { BranchService, reopenClosedDatabases, reopenedDatabasesNotice } = await import("./BranchService-iXXZeVYD.js").then((n) => n.n);
|
|
2318
2323
|
const { drizzle } = await import("drizzle-orm/node-postgres");
|
|
2319
2324
|
const { Pool } = await import("pg");
|
|
2325
|
+
const healed = await reopenClosedDatabases(databaseUrl, [branchAction === "create" ? createSource(rawArgs) : void 0, process.env[ACTIVE_BRANCH_DATABASE_ENV]]);
|
|
2326
|
+
for (const line of reopenedDatabasesNotice(healed)) outWarn(chalk.yellow(` ${line}`));
|
|
2320
2327
|
await checkDatabaseConnectivity(databaseUrl);
|
|
2321
2328
|
await closeAppClients();
|
|
2322
2329
|
const pool = new Pool({
|
|
@@ -2336,9 +2343,7 @@ async function branchCommand(rawArgs) {
|
|
|
2336
2343
|
out(chalk.gray(" Usage: rebase db branch create <name> [--from <source>]"));
|
|
2337
2344
|
process.exit(1);
|
|
2338
2345
|
}
|
|
2339
|
-
|
|
2340
|
-
const fromIdx = rawArgs.indexOf("--from");
|
|
2341
|
-
if (fromIdx !== -1 && rawArgs[fromIdx + 1]) source = rawArgs[fromIdx + 1];
|
|
2346
|
+
const source = createSource(rawArgs);
|
|
2342
2347
|
const force = rawArgs.includes("--force");
|
|
2343
2348
|
out("");
|
|
2344
2349
|
out(chalk.bold(" 🌿 Creating database branch..."));
|
|
@@ -2823,7 +2828,7 @@ async function schemaStaleCommand(rawArgs) {
|
|
|
2823
2828
|
const schemaFile = path.resolve(process.cwd(), outputPath);
|
|
2824
2829
|
const fix = Boolean(argsList["--fix"]);
|
|
2825
2830
|
const generatedExists = fs.existsSync(schemaFile);
|
|
2826
|
-
const { loadCollections } = await import("./doctor-
|
|
2831
|
+
const { loadCollections } = await import("./doctor-DvJH-IQG.js").then((n) => n.t);
|
|
2827
2832
|
const { findLegacyForeignKeyNames, compareGeneratedDeclarations, staleVerdict } = await import("./generated-schema-staleness-FlxM2i4i.js").then((n) => n.r);
|
|
2828
2833
|
const { generateSchema } = await import("./generate-drizzle-schema-logic-DA3zM8zc.js").then((n) => n.n);
|
|
2829
2834
|
const { relationalCollections } = await import("@rebasepro/common");
|