@rebasepro/server-postgres 0.25.0 → 0.25.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.
Files changed (114) hide show
  1. package/dist/{BranchService-iXXZeVYD.js → BranchService-ClklxyAQ.js} +66 -6
  2. package/dist/BranchService-ClklxyAQ.js.map +1 -0
  3. package/dist/backup/backup-cli.d.ts +40 -3
  4. package/dist/backup/backup-service.d.ts +11 -0
  5. package/dist/{backup-service-Bb39plam.js → backup-cli-gijeXe0u.js} +777 -10
  6. package/dist/backup-cli-gijeXe0u.js.map +1 -0
  7. package/dist/{boot-ddl-s_3Hkz94.js → boot-ddl-DYH95Qeg.js} +3 -3
  8. package/dist/{boot-ddl-s_3Hkz94.js.map → boot-ddl-DYH95Qeg.js.map} +1 -1
  9. package/dist/branch-argv.d.ts +15 -0
  10. package/dist/{cli-console-DQ_K-sdM.js → cli-console-CQrQ0lAY.js} +8 -9
  11. package/dist/{cli-console-DQ_K-sdM.js.map → cli-console-CQrQ0lAY.js.map} +1 -1
  12. package/dist/{cli-errors-DwQnNATs.js → cli-errors-DiA0XFIS.js} +38 -10
  13. package/dist/{cli-errors-DwQnNATs.js.map → cli-errors-DiA0XFIS.js.map} +1 -1
  14. package/dist/cli-errors.d.ts +14 -0
  15. package/dist/cli-flags.d.ts +51 -0
  16. package/dist/{cli-prompt-egtNKkZl.js → cli-prompt-DXG0yk-h.js} +39 -4
  17. package/dist/{cli-prompt-egtNKkZl.js.map → cli-prompt-DXG0yk-h.js.map} +1 -1
  18. package/dist/cli.js +44 -174
  19. package/dist/cli.js.map +1 -1
  20. package/dist/{column-plan-helpers-D_V4oaZh.js → column-plan-helpers-IG6uFb1s.js} +2 -2
  21. package/dist/{column-plan-helpers-D_V4oaZh.js.map → column-plan-helpers-IG6uFb1s.js.map} +1 -1
  22. package/dist/{connection-C938nR3E.js → connection-czvI7TZL.js} +57 -10
  23. package/dist/connection-czvI7TZL.js.map +1 -0
  24. package/dist/{databasePoolManager-Yqdw14wY.js → databasePoolManager-3stMNFL-.js} +4 -6
  25. package/dist/databasePoolManager-3stMNFL-.js.map +1 -0
  26. package/dist/db-command-line.d.ts +14 -0
  27. package/dist/{rls-bootstrap-sql-Bd-hJk08.js → db-subcommands-BPoHCxJR.js} +455 -3
  28. package/dist/db-subcommands-BPoHCxJR.js.map +1 -0
  29. package/dist/db-subcommands.d.ts +11 -0
  30. package/dist/{deferred-index-build-Cis_HoGn.js → deferred-index-build-BE0I6sYU.js} +8 -8
  31. package/dist/{deferred-index-build-Cis_HoGn.js.map → deferred-index-build-BE0I6sYU.js.map} +1 -1
  32. package/dist/{doctor-DvJH-IQG.js → doctor-BT--1kq3.js} +107 -11
  33. package/dist/doctor-BT--1kq3.js.map +1 -0
  34. package/dist/{ensure-collection-policies-CCqayoUz.js → ensure-collection-policies-BnGOURpG.js} +13 -10
  35. package/dist/ensure-collection-policies-BnGOURpG.js.map +1 -0
  36. package/dist/{ensure-collection-tables-DvvImXDe.js → ensure-collection-tables-Cet4650m.js} +9 -9
  37. package/dist/{ensure-collection-tables-DvvImXDe.js.map → ensure-collection-tables-Cet4650m.js.map} +1 -1
  38. package/dist/{ensure-tables-Dpgwx5sy.js → ensure-tables-l_OgFQjN.js} +5 -5
  39. package/dist/{ensure-tables-Dpgwx5sy.js.map → ensure-tables-l_OgFQjN.js.map} +1 -1
  40. package/dist/{enum-labels-kept-CUlUlRkO.js → enum-labels-kept-nheku1pB.js} +3 -3
  41. package/dist/{enum-labels-kept-CUlUlRkO.js.map → enum-labels-kept-nheku1pB.js.map} +1 -1
  42. package/dist/{generate-drizzle-schema-C3EAP9HE.js → generate-drizzle-schema-DC0BOUpn.js} +3 -3
  43. package/dist/{generate-drizzle-schema-C3EAP9HE.js.map → generate-drizzle-schema-DC0BOUpn.js.map} +1 -1
  44. package/dist/{generate-drizzle-schema-logic-DA3zM8zc.js → generate-drizzle-schema-logic-CPzCRD-8.js} +4 -4
  45. package/dist/{generate-drizzle-schema-logic-DA3zM8zc.js.map → generate-drizzle-schema-logic-CPzCRD-8.js.map} +1 -1
  46. package/dist/{generate-files-ClmOUHXj.js → generate-files-BP-4W_gm.js} +6 -6
  47. package/dist/{generate-files-ClmOUHXj.js.map → generate-files-BP-4W_gm.js.map} +1 -1
  48. package/dist/{generate-next-step-DCeS4LrJ.js → generate-next-step-DgK5BlBn.js} +2 -2
  49. package/dist/{generate-next-step-DCeS4LrJ.js.map → generate-next-step-DgK5BlBn.js.map} +1 -1
  50. package/dist/{generate-postgres-ddl-logic-4eUP4t8w.js → generate-postgres-ddl-logic-DPl1oH_z.js} +4 -4
  51. package/dist/{generate-postgres-ddl-logic-4eUP4t8w.js.map → generate-postgres-ddl-logic-DPl1oH_z.js.map} +1 -1
  52. package/dist/generated-schema-diff-eZCklRZQ.js +1025 -0
  53. package/dist/generated-schema-diff-eZCklRZQ.js.map +1 -0
  54. package/dist/{generated-schema-staleness-FlxM2i4i.js → generated-schema-staleness-BvNF3i-s.js} +2 -2
  55. package/dist/{generated-schema-staleness-FlxM2i4i.js.map → generated-schema-staleness-BvNF3i-s.js.map} +1 -1
  56. package/dist/index.d.ts +1 -0
  57. package/dist/index.es.js +70 -11
  58. package/dist/index.es.js.map +1 -1
  59. package/dist/{introspect-db-logic-CI5CU_n0.js → introspect-db-logic-DgQVzccW.js} +2 -2
  60. package/dist/{introspect-db-logic-CI5CU_n0.js.map → introspect-db-logic-DgQVzccW.js.map} +1 -1
  61. package/dist/migrate-policy-stamps-3eqfhes6.js +89 -0
  62. package/dist/migrate-policy-stamps-3eqfhes6.js.map +1 -0
  63. package/dist/{open-rebase-BKA7Nyoe.js → open-rebase-EmqVmS14.js} +51 -1020
  64. package/dist/open-rebase-EmqVmS14.js.map +1 -0
  65. package/dist/{pg-error-utils-Bv5n2PLn.js → pg-error-utils-CFEnm2m9.js} +2 -2
  66. package/dist/{pg-error-utils-Bv5n2PLn.js.map → pg-error-utils-CFEnm2m9.js.map} +1 -1
  67. package/dist/{plan-schema-CXOucCw-.js → plan-schema-Czf3q4-Q.js} +4 -4
  68. package/dist/{plan-schema-CXOucCw-.js.map → plan-schema-Czf3q4-Q.js.map} +1 -1
  69. package/dist/{policy-drift-vm0BcvcE.js → policy-drift-X4A-xAzv.js} +3 -3
  70. package/dist/{policy-drift-vm0BcvcE.js.map → policy-drift-X4A-xAzv.js.map} +1 -1
  71. package/dist/pool-disconnects.d.ts +28 -0
  72. package/dist/{push-index-prebuild-DIequ4bV.js → push-index-prebuild-COd7i6wm.js} +4 -4
  73. package/dist/{push-index-prebuild-DIequ4bV.js.map → push-index-prebuild-COd7i6wm.js.map} +1 -1
  74. package/dist/{push-legacy-renames-BqJut4F3.js → push-legacy-renames-CLgYYwPE.js} +4 -4
  75. package/dist/{push-legacy-renames-BqJut4F3.js.map → push-legacy-renames-CLgYYwPE.js.map} +1 -1
  76. package/dist/{push-policy-plan-CvX8hiPb.js → push-policy-plan-D2gpQsdv.js} +5 -5
  77. package/dist/{push-policy-plan-CvX8hiPb.js.map → push-policy-plan-D2gpQsdv.js.map} +1 -1
  78. package/dist/{render-ddl-CQNwZdse.js → render-ddl-4v88y-Gv.js} +4 -4
  79. package/dist/{render-ddl-CQNwZdse.js.map → render-ddl-4v88y-Gv.js.map} +1 -1
  80. package/dist/{rls-enforcement-D7P4-ZYX.js → rls-enforcement-DDyNoOSy.js} +2 -2
  81. package/dist/{rls-enforcement-D7P4-ZYX.js.map → rls-enforcement-DDyNoOSy.js.map} +1 -1
  82. package/dist/schema/doctor-cli.js +5 -5
  83. package/dist/schema/doctor.d.ts +20 -2
  84. package/dist/schema/ensure-collection-policies.d.ts +4 -1
  85. package/dist/schema/generate-drizzle-schema.js +1 -1
  86. package/dist/schema/generate-postgres-ddl.js +2 -2
  87. package/dist/schema/generated-schema-diff.d.ts +21 -0
  88. package/dist/schema/introspect-db.js +5 -6
  89. package/dist/schema/introspect-db.js.map +1 -1
  90. package/dist/schema/migrate-policy-stamps.d.ts +23 -0
  91. package/dist/schema/push-policy-plan.d.ts +5 -0
  92. package/dist/services/BranchService.d.ts +20 -2
  93. package/dist/services/pg-notify-listener.d.ts +2 -0
  94. package/dist/{source-Bv5KPeIx.js → source-fZb92pN8.js} +2 -2
  95. package/dist/{source-Bv5KPeIx.js.map → source-fZb92pN8.js.map} +1 -1
  96. package/dist/{vector-index-BFhyEaiz.js → vector-index-DsQ3V2d2.js} +2 -2
  97. package/dist/{vector-index-BFhyEaiz.js.map → vector-index-DsQ3V2d2.js.map} +1 -1
  98. package/dist/{websocket-MC0zTBar.js → websocket-BKZwsjmf.js} +18 -5
  99. package/dist/websocket-BKZwsjmf.js.map +1 -0
  100. package/package.json +7 -7
  101. package/dist/BranchService-iXXZeVYD.js.map +0 -1
  102. package/dist/backup-cli-B2CAn9fR.js +0 -647
  103. package/dist/backup-cli-B2CAn9fR.js.map +0 -1
  104. package/dist/backup-service-Bb39plam.js.map +0 -1
  105. package/dist/cli-flags-D-b0qL9T.js +0 -206
  106. package/dist/cli-flags-D-b0qL9T.js.map +0 -1
  107. package/dist/connection-C938nR3E.js.map +0 -1
  108. package/dist/databasePoolManager-Yqdw14wY.js.map +0 -1
  109. package/dist/doctor-DvJH-IQG.js.map +0 -1
  110. package/dist/ensure-collection-policies-CCqayoUz.js.map +0 -1
  111. package/dist/open-rebase-BKA7Nyoe.js.map +0 -1
  112. package/dist/rls-bootstrap-sql-Bd-hJk08.js.map +0 -1
  113. package/dist/rolldown-runtime-V7rFbMRe.js +0 -39
  114. package/dist/websocket-MC0zTBar.js.map +0 -1
@@ -1,6 +1,6 @@
1
1
  import { createRequire as __createRequire } from "module";
2
2
  __createRequire(import.meta.url);
3
- import { a as outWarn, i as outError, m as isRebaseIndexName, o as atlasExcludePattern, r as out, s as excludePatternParts, t as chalk } from "./source-Bv5KPeIx.js";
3
+ import { a as outWarn, i as outError, m as isRebaseIndexName, o as atlasExcludePattern, r as out, s as excludePatternParts, t as chalk } from "./source-fZb92pN8.js";
4
4
  import path from "path";
5
5
  import fs from "fs";
6
6
  import { fileURLToPath, pathToFileURL } from "url";
@@ -1292,7 +1292,7 @@ async function applySearchDdl(databaseUrl, sqlDir = generatedSqlDir()) {
1292
1292
  * `search` block, which is every project that has not opted in.
1293
1293
  */
1294
1294
  async function getSearchExcludes(collectionsPath) {
1295
- const { searchExcludePatterns } = await import("./generate-postgres-ddl-logic-4eUP4t8w.js").then((n) => n.o);
1295
+ const { searchExcludePatterns } = await import("./generate-postgres-ddl-logic-DPl1oH_z.js").then((n) => n.o);
1296
1296
  return searchExcludePatterns(await loadCollectionsForCli(collectionsPath));
1297
1297
  }
1298
1298
  /**
@@ -1379,7 +1379,7 @@ function readVectorDdl(sqlDir = generatedSqlDir()) {
1379
1379
  async function applyVectorDdl(databaseUrl, sqlDir = generatedSqlDir()) {
1380
1380
  const sql = readVectorDdl(sqlDir);
1381
1381
  if (!sql) return;
1382
- const { vectorExtensionHint } = await import("./vector-index-BFhyEaiz.js").then((n) => n.f);
1382
+ const { vectorExtensionHint } = await import("./vector-index-DsQ3V2d2.js").then((n) => n.f);
1383
1383
  try {
1384
1384
  await withAppClient(databaseUrl, (client) => client.query(sql));
1385
1385
  } catch (err) {
@@ -1397,7 +1397,7 @@ async function applyVectorDdl(databaseUrl, sqlDir = generatedSqlDir()) {
1397
1397
  * `vector` property, which is every project that has not opted in.
1398
1398
  */
1399
1399
  async function getVectorExcludes(collectionsPath) {
1400
- const { vectorExcludePatterns } = await import("./generate-postgres-ddl-logic-4eUP4t8w.js").then((n) => n.o);
1400
+ const { vectorExcludePatterns } = await import("./generate-postgres-ddl-logic-DPl1oH_z.js").then((n) => n.o);
1401
1401
  return vectorExcludePatterns(await loadCollectionsForCli(collectionsPath));
1402
1402
  }
1403
1403
  /**
@@ -1434,7 +1434,7 @@ async function applyTriggersDdl(databaseUrl, sqlDir = generatedSqlDir()) {
1434
1434
  }
1435
1435
  /** @see getSearchExcludes */
1436
1436
  async function getTriggerExcludes(collectionsPath) {
1437
- const { triggerExcludePatterns } = await import("./generate-postgres-ddl-logic-4eUP4t8w.js").then((n) => n.o);
1437
+ const { triggerExcludePatterns } = await import("./generate-postgres-ddl-logic-DPl1oH_z.js").then((n) => n.o);
1438
1438
  return triggerExcludePatterns(await loadCollectionsForCli(collectionsPath));
1439
1439
  }
1440
1440
  /**
@@ -1511,9 +1511,9 @@ async function getForeignIndexExcludes(databaseUrl, collectionsPath, deps = {})
1511
1511
  */
1512
1512
  async function managedIndexNames(collectionsPath) {
1513
1513
  const collections = await loadCollectionsForCli(collectionsPath);
1514
- const { searchExcludePatterns, vectorExcludePatterns } = await import("./generate-postgres-ddl-logic-4eUP4t8w.js").then((n) => n.o);
1515
- const { resolveColumnName } = await import("./column-plan-helpers-D_V4oaZh.js").then((n) => n.t);
1516
- const { buildCollectionIndexPlan } = await import("./source-Bv5KPeIx.js").then((n) => n.d);
1514
+ const { searchExcludePatterns, vectorExcludePatterns } = await import("./generate-postgres-ddl-logic-DPl1oH_z.js").then((n) => n.o);
1515
+ const { resolveColumnName } = await import("./column-plan-helpers-IG6uFb1s.js").then((n) => n.t);
1516
+ const { buildCollectionIndexPlan } = await import("./source-fZb92pN8.js").then((n) => n.d);
1517
1517
  const names = new Set(buildCollectionIndexPlan(collections, resolveColumnName).map((spec) => spec.indexName));
1518
1518
  for (const pattern of [...searchExcludePatterns(collections), ...vectorExcludePatterns(collections)]) {
1519
1519
  const object = excludePatternParts(pattern)?.[2];
@@ -2051,6 +2051,34 @@ function projectRebaseCommand(manager) {
2051
2051
  default: return "rebase";
2052
2052
  }
2053
2053
  }
2054
+ /** A PostgreSQL identifier, double-quoted, with any `"` in it doubled. */
2055
+ function sqlIdentifier(name) {
2056
+ return `"${name.replace(/"/g, "\"\"")}"`;
2057
+ }
2058
+ /**
2059
+ * `text` as one double-quoted `sh` word: `\`, `"`, `$` and a backtick are the
2060
+ * characters a double-quoted string does not take literally.
2061
+ */
2062
+ function shDoubleQuoted(text) {
2063
+ return `"${text.replace(/[\\"$`]/g, "\\$&")}"`;
2064
+ }
2065
+ /**
2066
+ * The backfill for a column that refused NOT NULL, as one line a POSIX shell
2067
+ * runs once the value is typed between its single quotes.
2068
+ *
2069
+ * The SQL is the shell's double-quoted word, so the value's own quotes are
2070
+ * SQL's: `'tbd'`, or `'O''Brien'` for a value with a quote in it, as SQL
2071
+ * writes one. It was the SQL in shell single quotes, and the first quote a
2072
+ * value was typed with ended the shell's: `= 'tbd'` reached psql as `= tbd`,
2073
+ * `column "tbd" does not exist`.
2074
+ *
2075
+ * `rebase db url`, not `$DATABASE_URL`: on the managed development database
2076
+ * `.env` leaves DATABASE_URL unset, and the shell has none.
2077
+ */
2078
+ function backfillCommand(table, column, manager) {
2079
+ const sql = `UPDATE ${sqlIdentifier(table)} SET ${sqlIdentifier(column)} = '…' WHERE ${sqlIdentifier(column)} IS NULL;`;
2080
+ return `psql "$(${projectRebaseCommand(manager)} db url)" -c ${shDoubleQuoted(sql)}`;
2081
+ }
2054
2082
  /**
2055
2083
  * The ways out, and only the ones that work for this column.
2056
2084
  *
@@ -2067,7 +2095,7 @@ function projectRebaseCommand(manager) {
2067
2095
  function formatNotNullViolationBanner(violation, rowCount, isNew = null, manager = detectProjectPackageManager()) {
2068
2096
  const { table, column } = violation;
2069
2097
  const rows = rowCount === null ? ` "${table}" already holds rows, and none of them has a value for "${column}".\n` : ` "${table}" already holds ${rowCount} row${rowCount === 1 ? "" : "s"}, and they have no value for "${column}".\n`;
2070
- const backfill = `Backfill by hand first, then push again:\n ${chalk.gray(`psql "$(${projectRebaseCommand(manager)} db url)" -c 'UPDATE "${table}" SET "${column}" = … WHERE "${column}" IS NULL;'`)}\n`;
2098
+ const backfill = `Backfill by hand first, then push again, with the value between the single quotes:\n ${chalk.gray(backfillCommand(table, column, manager))}\n`;
2071
2099
  const leaveOptional = `Leave it optional — take \`validation.required\` off the property.\n`;
2072
2100
  const defaultLine = (caveat) => `Give the property a default, so the push can backfill${caveat}:\n ${chalk.gray(`{ type: "string", defaultValue: "…", validation: { required: true } }`)}\n`;
2073
2101
  const remedies = isNew === false ? [backfill, leaveOptional] : isNew === true ? [
@@ -2358,4 +2386,4 @@ async function diagnoseAtlasFailure(context) {
2358
2386
  //#endregion
2359
2387
  export { forLibpq as $, getUndeclaredConstraintExcludes as A, withAppClient as B, dropDevDatabase as C, getSearchExcludes as D, getForeignIndexExcludes as E, queryUndeclarableConstraints as F, prepareGeneratedSqlDir as G, DESIRED_STATE_URL as H, readSearchDdl as I, detectDestructiveStatements as J, decidePushSafety as K, readTriggersDdl as L, loadCollectionsForCli as M, queryColumnTypes as N, getTableExcludes as O, queryGeneratedColumnDependencies as P, forAtlas as Q, readVectorDdl as R, diagnoseMissingBin as S, ensureDevDatabaseExists as T, GENERATED_SQL_DIR as U, workspaceMemberDir as V, generatedSqlDir as W, fromAlterTable as X, extractPlanStatements as Y, isSyncedPlan as Z, closeAppClients as _, diagnoseDbError as a, describeReinstallCommand as b, isEconnrefused as c, reportCommandFailure as d, redactConnectionPasswords as et, ExcludeIntrospectionError as f, atlasDevDatabaseUrl as g, applyVectorDdl as h, diagnoseAtlasFailure as i, getVectorExcludes as j, getTriggerExcludes as k, isSslNotEnabled as l, applyTriggersDdl as m, closedDatabaseName as n, extractCauseMessage as nt, formatForeignGeneratedColumnBanner as o, applySearchDdl as p, destructiveOptInFlag as q, deepestErrorMessage as r, isAuthFailure as s, checkDatabaseConnectivity as t, splitPassword as tt, parseHostInfo as u, describeBuildScriptRemedy as v, dropGeneratedColumns as w, detectProjectPackageManager as x, describeDevAddCommand as y, resolveLocalBin as z };
2360
2388
 
2361
- //# sourceMappingURL=cli-errors-DwQnNATs.js.map
2389
+ //# sourceMappingURL=cli-errors-DiA0XFIS.js.map