@rebasepro/server-postgres 0.30.0 → 0.31.0-canary.g902a0ce

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 (248) hide show
  1. package/README.md +11 -8
  2. package/dist/{BranchService-CrXvcES2.js → BranchService-USp1AvZB.js} +3 -3
  3. package/dist/{BranchService-CrXvcES2.js.map → BranchService-USp1AvZB.js.map} +1 -1
  4. package/dist/PostgresBackendDriver.d.ts +99 -54
  5. package/dist/PostgresBootstrapper.d.ts +12 -27
  6. package/dist/auth/ensure-tables.d.ts +16 -5
  7. package/dist/auth/schema-version.d.ts +2 -2
  8. package/dist/auth/services.d.ts +2 -3
  9. package/dist/{auth-users-columns-C72EMoDJ.js → auth-users-columns-BpfgbkxZ.js} +2 -16
  10. package/dist/auth-users-columns-BpfgbkxZ.js.map +1 -0
  11. package/dist/{backup-cli-CTKCOLpX.js → backup-cli-DbKyEj6c.js} +4 -4
  12. package/dist/{backup-cli-CTKCOLpX.js.map → backup-cli-DbKyEj6c.js.map} +1 -1
  13. package/dist/{boot-ddl-CqGIwSYx.js → boot-ddl-5H2bL_80.js} +2 -2
  14. package/dist/{boot-ddl-CqGIwSYx.js.map → boot-ddl-5H2bL_80.js.map} +1 -1
  15. package/dist/{cli-console-DBPw-oAz.js → cli-console-DsRgGSBR.js} +65 -39
  16. package/dist/cli-console-DsRgGSBR.js.map +1 -0
  17. package/dist/cli-console.d.ts +16 -13
  18. package/dist/cli-flags.d.ts +8 -9
  19. package/dist/cli-helpers.d.ts +15 -11
  20. package/dist/{cli-errors-DYTxnLbW.js → cli-schema-dir-CiN0ephV.js} +184 -70
  21. package/dist/cli-schema-dir-CiN0ephV.js.map +1 -0
  22. package/dist/cli-schema-dir.d.ts +64 -0
  23. package/dist/cli.js +192 -257
  24. package/dist/cli.js.map +1 -1
  25. package/dist/data-transformer.d.ts +50 -19
  26. package/dist/{database-preflight-iBpT7-vv.js → database-preflight-bfnIBnjM.js} +5 -5
  27. package/dist/database-preflight-bfnIBnjM.js.map +1 -0
  28. package/dist/{deferred-index-build-BCU9RoHK.js → deferred-index-build-CcSDA7wE.js} +69 -13
  29. package/dist/deferred-index-build-CcSDA7wE.js.map +1 -0
  30. package/dist/{ensure-collection-policies-Bo-_fDAy.js → ensure-policies-rRmXb5bt.js} +31 -31
  31. package/dist/ensure-policies-rRmXb5bt.js.map +1 -0
  32. package/dist/{ensure-collection-tables-DCJINkT_.js → ensure-tables-Bvm-F2wW.js} +44 -37
  33. package/dist/ensure-tables-Bvm-F2wW.js.map +1 -0
  34. package/dist/{ensure-tables-BPGaGh0y.js → ensure-tables-CC8p_AK3.js} +34 -29
  35. package/dist/ensure-tables-CC8p_AK3.js.map +1 -0
  36. package/dist/{enum-labels-kept-YAgOZS4I.js → enum-labels-kept-FlX9SHdf.js} +8 -8
  37. package/dist/enum-labels-kept-FlX9SHdf.js.map +1 -0
  38. package/dist/{generate-drizzle-schema-DcrFr7YX.js → generate-drizzle-schema-SJMXxzPI.js} +12 -12
  39. package/dist/generate-drizzle-schema-SJMXxzPI.js.map +1 -0
  40. package/dist/{generate-drizzle-schema-logic-LTLZvt6r.js → generate-drizzle-schema-logic-DL7R1rAF.js} +15 -8
  41. package/dist/generate-drizzle-schema-logic-DL7R1rAF.js.map +1 -0
  42. package/dist/{generate-files-CsaVzatS.js → generate-files-tlJ9_lGI.js} +23 -30
  43. package/dist/generate-files-tlJ9_lGI.js.map +1 -0
  44. package/dist/{generate-next-step-DgK5BlBn.js → generate-next-step-CO09dovd.js} +3 -3
  45. package/dist/generate-next-step-CO09dovd.js.map +1 -0
  46. package/dist/{generate-postgres-ddl-logic-Dg0bcENZ.js → generate-postgres-ddl-logic-B8huc03c.js} +51 -21
  47. package/dist/generate-postgres-ddl-logic-B8huc03c.js.map +1 -0
  48. package/dist/{generated-schema-diff-By4dxyTH.js → generated-schema-diff-DoT2dYDe.js} +297 -279
  49. package/dist/generated-schema-diff-DoT2dYDe.js.map +1 -0
  50. package/dist/{generated-schema-staleness-BvNF3i-s.js → generated-schema-staleness-YBVq2kTn.js} +21 -29
  51. package/dist/generated-schema-staleness-YBVq2kTn.js.map +1 -0
  52. package/dist/history/ensure-history-table.d.ts +22 -0
  53. package/dist/index.d.ts +8 -2
  54. package/dist/index.es.js +201 -25
  55. package/dist/index.es.js.map +1 -1
  56. package/dist/interfaces.d.ts +3 -4
  57. package/dist/{introspect-db-queries-DevUrzll.js → introspect-db-queries-BgiRQqtR.js} +7 -2
  58. package/dist/introspect-db-queries-BgiRQqtR.js.map +1 -0
  59. package/dist/introspect-tables-Cw_A-kk4.js +2086 -0
  60. package/dist/introspect-tables-Cw_A-kk4.js.map +1 -0
  61. package/dist/load-tables-B1Re74ng.js +92 -0
  62. package/dist/load-tables-B1Re74ng.js.map +1 -0
  63. package/dist/{migrate-baseline-CmWXL7qx.js → migrate-baseline-DZmekgpD.js} +19 -32
  64. package/dist/migrate-baseline-DZmekgpD.js.map +1 -0
  65. package/dist/{migrate-policy-stamps-BN_Qad6c.js → migrate-policy-stamps-B_acrUQB.js} +18 -19
  66. package/dist/migrate-policy-stamps-B_acrUQB.js.map +1 -0
  67. package/dist/model/PostgresTableRegistry.d.ts +159 -0
  68. package/dist/model/build-registry.d.ts +25 -0
  69. package/dist/model/refresh-relational-schema.d.ts +24 -0
  70. package/dist/model/runtime-table.d.ts +53 -0
  71. package/dist/{collections → model}/validate-relations.d.ts +15 -21
  72. package/dist/{open-rebase-40paQfVW.js → open-rebase-4kisUF_k.js} +3946 -3870
  73. package/dist/open-rebase-4kisUF_k.js.map +1 -0
  74. package/dist/open-rebase.d.ts +16 -15
  75. package/dist/{pg-error-utils-DJHjCF7-.js → pg-error-utils-BT5NzGFZ.js} +17 -20
  76. package/dist/pg-error-utils-BT5NzGFZ.js.map +1 -0
  77. package/dist/plan-schema-Hbtjhge3.js +1633 -0
  78. package/dist/plan-schema-Hbtjhge3.js.map +1 -0
  79. package/dist/{policy-drift-C-m0uWHH.js → policy-drift-BVMyqHSa.js} +29 -29
  80. package/dist/policy-drift-BVMyqHSa.js.map +1 -0
  81. package/dist/{push-index-adoption-Cp7oZxSl.js → push-index-adoption-hpHTyXMR.js} +7 -7
  82. package/dist/push-index-adoption-hpHTyXMR.js.map +1 -0
  83. package/dist/{push-index-prebuild-DbwKGtQT.js → push-index-prebuild-Bty9F7bD.js} +6 -6
  84. package/dist/push-index-prebuild-Bty9F7bD.js.map +1 -0
  85. package/dist/{push-kept-defaults-CLcgsEPt.js → push-kept-defaults-Bst4MDup.js} +13 -16
  86. package/dist/push-kept-defaults-Bst4MDup.js.map +1 -0
  87. package/dist/{push-legacy-renames-BthD0E9W.js → push-legacy-renames-bB4bM6br.js} +6 -6
  88. package/dist/push-legacy-renames-bB4bM6br.js.map +1 -0
  89. package/dist/{push-policy-plan-BgcrroxQ.js → push-policy-plan-BI8U4BOD.js} +11 -11
  90. package/dist/push-policy-plan-BI8U4BOD.js.map +1 -0
  91. package/dist/{render-ddl-Ci3S_SoI.js → render-ddl-D4n86NHz.js} +14 -7
  92. package/dist/render-ddl-D4n86NHz.js.map +1 -0
  93. package/dist/{request-role-cli-Dy1EgJU9.js → request-role-cli-BdRzdE87.js} +11 -11
  94. package/dist/{request-role-cli-Dy1EgJU9.js.map → request-role-cli-BdRzdE87.js.map} +1 -1
  95. package/dist/{request-role-migration-GHTJnPMV.js → request-role-migration-C8aq_TO3.js} +2 -2
  96. package/dist/{request-role-migration-GHTJnPMV.js.map → request-role-migration-C8aq_TO3.js.map} +1 -1
  97. package/dist/{rls-enforcement-Cc_UhOxb.js → rls-enforcement-DB5HHj96.js} +19 -19
  98. package/dist/rls-enforcement-DB5HHj96.js.map +1 -0
  99. package/dist/{rls-settings-BCGMIig3.js → rls-settings-CmGK2U0a.js} +2 -2
  100. package/dist/rls-settings-CmGK2U0a.js.map +1 -0
  101. package/dist/schema/auth-users-columns.d.ts +1 -11
  102. package/dist/schema/catalogue-schema.d.ts +33 -29
  103. package/dist/schema/classify-change.d.ts +23 -16
  104. package/dist/schema/column-type-drift.d.ts +16 -0
  105. package/dist/schema/config-relations.d.ts +10 -9
  106. package/dist/schema/deferred-index-build.d.ts +1 -1
  107. package/dist/schema/doctor-cli.js +1544 -66
  108. package/dist/schema/doctor-cli.js.map +1 -1
  109. package/dist/schema/doctor-database.d.ts +7 -7
  110. package/dist/schema/doctor-policy-checks.d.ts +4 -4
  111. package/dist/schema/doctor-search-scale.d.ts +14 -14
  112. package/dist/schema/doctor.d.ts +27 -27
  113. package/dist/schema/dynamic-tables.d.ts +6 -5
  114. package/dist/schema/{ensure-collection-policies.d.ts → ensure-policies.d.ts} +20 -20
  115. package/dist/schema/{ensure-collection-tables.d.ts → ensure-tables.d.ts} +11 -11
  116. package/dist/schema/enum-labels-kept.d.ts +6 -6
  117. package/dist/schema/generate-drizzle-schema-logic.d.ts +3 -3
  118. package/dist/schema/generate-drizzle-schema.js +1 -1
  119. package/dist/schema/generate-files.d.ts +6 -6
  120. package/dist/schema/generate-postgres-ddl-logic.d.ts +23 -20
  121. package/dist/schema/generate-postgres-ddl.js +11 -11
  122. package/dist/schema/generate-postgres-ddl.js.map +1 -1
  123. package/dist/schema/generate-schema-commit.d.ts +13 -8
  124. package/dist/schema/generated-schema-diff.d.ts +16 -16
  125. package/dist/schema/generated-schema-staleness.d.ts +11 -11
  126. package/dist/schema/index-adoption.d.ts +4 -4
  127. package/dist/schema/introspect-db-customization.d.ts +47 -0
  128. package/dist/schema/introspect-db-inference.d.ts +30 -9
  129. package/dist/schema/introspect-db-logic.d.ts +79 -110
  130. package/dist/schema/introspect-db-project.d.ts +15 -18
  131. package/dist/schema/introspect-db-queries.d.ts +1 -1
  132. package/dist/schema/introspect-db-search.d.ts +25 -4
  133. package/dist/schema/introspect-db-storage.d.ts +4 -74
  134. package/dist/schema/introspect-db.js +102 -90
  135. package/dist/schema/introspect-db.js.map +1 -1
  136. package/dist/schema/introspect-runtime.d.ts +47 -36
  137. package/dist/schema/introspect-tables.d.ts +182 -0
  138. package/dist/schema/load-tables.d.ts +55 -0
  139. package/dist/schema/migrate-policy-stamps.d.ts +4 -4
  140. package/dist/schema/migration-freshness.d.ts +13 -13
  141. package/dist/schema/plan/column-order.d.ts +82 -0
  142. package/dist/schema/plan/diff-plan.d.ts +9 -3
  143. package/dist/schema/plan/plan-schema.d.ts +55 -52
  144. package/dist/schema/plan/render-drizzle.d.ts +1 -1
  145. package/dist/schema/plan/types.d.ts +24 -15
  146. package/dist/schema/push-index-adoption.d.ts +3 -3
  147. package/dist/schema/push-index-prebuild.d.ts +3 -3
  148. package/dist/schema/push-kept-defaults.d.ts +7 -7
  149. package/dist/schema/push-legacy-renames.d.ts +3 -3
  150. package/dist/schema/push-policy-plan.d.ts +5 -5
  151. package/dist/schema/reconcile-schema.d.ts +5 -5
  152. package/dist/schema/relation-names.d.ts +15 -20
  153. package/dist/schema/render-outputs.d.ts +76 -0
  154. package/dist/schema/search-column.d.ts +11 -43
  155. package/dist/schema/{collection-index.d.ts → table-index.d.ts} +21 -42
  156. package/dist/schema/{collections-schema-version.d.ts → tables-schema-version.d.ts} +8 -2
  157. package/dist/schema/vector-index.d.ts +24 -28
  158. package/dist/{search-column-BM-GV6vH.js → search-column-BO-WND-B.js} +86 -149
  159. package/dist/search-column-BO-WND-B.js.map +1 -0
  160. package/dist/security/caller-sql-columns.d.ts +9 -6
  161. package/dist/security/policy-drift.d.ts +14 -14
  162. package/dist/security/rls-enforcement.d.ts +19 -25
  163. package/dist/security/rls-settings.d.ts +2 -2
  164. package/dist/security/served-table-protection.d.ts +125 -0
  165. package/dist/services/FetchService.d.ts +22 -133
  166. package/dist/services/PersistService.d.ts +6 -17
  167. package/dist/services/RelationService.d.ts +57 -106
  168. package/dist/services/RelationWriteService.d.ts +59 -66
  169. package/dist/services/cdc/identity-columns.d.ts +7 -5
  170. package/dist/services/cdc/junction-tables.d.ts +14 -14
  171. package/dist/services/collection-helpers.d.ts +52 -95
  172. package/dist/services/dataService.d.ts +15 -12
  173. package/dist/services/field-op-sql.d.ts +11 -9
  174. package/dist/services/field-viewer.d.ts +12 -11
  175. package/dist/services/hidden-columns.d.ts +30 -0
  176. package/dist/services/index.d.ts +1 -1
  177. package/dist/services/junction-writes.d.ts +37 -18
  178. package/dist/services/nested-path.d.ts +18 -18
  179. package/dist/services/read-field-access.d.ts +23 -7
  180. package/dist/services/read-scope.d.ts +10 -9
  181. package/dist/services/realtimeService.d.ts +25 -10
  182. package/dist/services/relation-tables.d.ts +97 -0
  183. package/dist/services/row-pipeline.d.ts +50 -69
  184. package/dist/services/soft-delete.d.ts +25 -24
  185. package/dist/services/table-hooks.d.ts +146 -0
  186. package/dist/services/view-access.d.ts +7 -7
  187. package/dist/services/write-transaction-scope.d.ts +1 -1
  188. package/dist/{source-fZb92pN8.js → source-VxbrQojV.js} +111 -79
  189. package/dist/source-VxbrQojV.js.map +1 -0
  190. package/dist/{collections-schema-version-D7bDI0PJ.js → tables-schema-version-YvZIBlOP.js} +12 -6
  191. package/dist/tables-schema-version-YvZIBlOP.js.map +1 -0
  192. package/dist/utils/drizzle-conditions.d.ts +70 -84
  193. package/dist/utils/pg-array-null-patch.d.ts +27 -10
  194. package/dist/utils/pg-error-utils.d.ts +4 -4
  195. package/dist/{vector-index-DsQ3V2d2.js → vector-index-VSh3ufTd.js} +62 -54
  196. package/dist/vector-index-VSh3ufTd.js.map +1 -0
  197. package/dist/{websocket-B7ex6AQM.js → websocket-BevXvwfo.js} +51 -40
  198. package/dist/websocket-BevXvwfo.js.map +1 -0
  199. package/dist/websocket.d.ts +2 -2
  200. package/package.json +7 -7
  201. package/dist/auth-users-columns-C72EMoDJ.js.map +0 -1
  202. package/dist/cli-collections-path.d.ts +0 -31
  203. package/dist/cli-console-DBPw-oAz.js.map +0 -1
  204. package/dist/cli-errors-DYTxnLbW.js.map +0 -1
  205. package/dist/collections/PostgresCollectionRegistry.d.ts +0 -47
  206. package/dist/collections/buildRegistry.d.ts +0 -27
  207. package/dist/collections-schema-version-D7bDI0PJ.js.map +0 -1
  208. package/dist/column-plan-helpers-BeSztMor.js +0 -161
  209. package/dist/column-plan-helpers-BeSztMor.js.map +0 -1
  210. package/dist/database-preflight-iBpT7-vv.js.map +0 -1
  211. package/dist/deferred-index-build-BCU9RoHK.js.map +0 -1
  212. package/dist/doctor-Kg1oUK0Q.js +0 -1458
  213. package/dist/doctor-Kg1oUK0Q.js.map +0 -1
  214. package/dist/ensure-collection-policies-Bo-_fDAy.js.map +0 -1
  215. package/dist/ensure-collection-tables-DCJINkT_.js.map +0 -1
  216. package/dist/ensure-tables-BPGaGh0y.js.map +0 -1
  217. package/dist/enum-labels-kept-YAgOZS4I.js.map +0 -1
  218. package/dist/generate-drizzle-schema-DcrFr7YX.js.map +0 -1
  219. package/dist/generate-drizzle-schema-logic-LTLZvt6r.js.map +0 -1
  220. package/dist/generate-files-CsaVzatS.js.map +0 -1
  221. package/dist/generate-next-step-DgK5BlBn.js.map +0 -1
  222. package/dist/generate-postgres-ddl-logic-Dg0bcENZ.js.map +0 -1
  223. package/dist/generated-schema-diff-By4dxyTH.js.map +0 -1
  224. package/dist/generated-schema-staleness-BvNF3i-s.js.map +0 -1
  225. package/dist/introspect-db-logic-DWqAEURB.js +0 -2047
  226. package/dist/introspect-db-logic-DWqAEURB.js.map +0 -1
  227. package/dist/introspect-db-queries-DevUrzll.js.map +0 -1
  228. package/dist/migrate-baseline-CmWXL7qx.js.map +0 -1
  229. package/dist/migrate-policy-stamps-BN_Qad6c.js.map +0 -1
  230. package/dist/open-rebase-40paQfVW.js.map +0 -1
  231. package/dist/pg-error-utils-DJHjCF7-.js.map +0 -1
  232. package/dist/plan-schema-vJd3UEmT.js +0 -1604
  233. package/dist/plan-schema-vJd3UEmT.js.map +0 -1
  234. package/dist/policy-drift-C-m0uWHH.js.map +0 -1
  235. package/dist/push-index-adoption-Cp7oZxSl.js.map +0 -1
  236. package/dist/push-index-prebuild-DbwKGtQT.js.map +0 -1
  237. package/dist/push-kept-defaults-CLcgsEPt.js.map +0 -1
  238. package/dist/push-legacy-renames-BthD0E9W.js.map +0 -1
  239. package/dist/push-policy-plan-BgcrroxQ.js.map +0 -1
  240. package/dist/render-ddl-Ci3S_SoI.js.map +0 -1
  241. package/dist/rls-enforcement-Cc_UhOxb.js.map +0 -1
  242. package/dist/rls-settings-BCGMIig3.js.map +0 -1
  243. package/dist/schema/column-plan-helpers.d.ts +0 -161
  244. package/dist/schema/introspect-db-naming.d.ts +0 -10
  245. package/dist/search-column-BM-GV6vH.js.map +0 -1
  246. package/dist/source-fZb92pN8.js.map +0 -1
  247. package/dist/vector-index-DsQ3V2d2.js.map +0 -1
  248. package/dist/websocket-B7ex6AQM.js.map +0 -1
@@ -1,8 +1,9 @@
1
1
  import { createRequire as __createRequire } from "module";
2
2
  __createRequire(import.meta.url);
3
3
  import { i as __exportAll } from "./cli-prompt-DXG0yk-h.js";
4
- 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";
5
- import { warnDeprecated } from "@rebasepro/common";
4
+ import { a as outWarn, d as isRebaseIndexName, i as outError, o as atlasExcludePattern, r as out, s as excludePatternParts, t as chalk } from "./source-VxbrQojV.js";
5
+ import { LEGACY_LAYOUT_REMEDY } from "@rebasepro/types";
6
+ import { resolveTableJunctions, warnDeprecated } from "@rebasepro/common";
6
7
  import path from "path";
7
8
  import fs from "fs";
8
9
  import { fileURLToPath, pathToFileURL } from "url";
@@ -850,7 +851,7 @@ function prepareGeneratedSqlDir(cwd = process.cwd(), options = {}) {
850
851
  const dir = generatedSqlDir(cwd);
851
852
  fs.mkdirSync(dir, { recursive: true });
852
853
  const ignore = path.join(dir, ".gitignore");
853
- if (!fs.existsSync(ignore)) fs.writeFileSync(ignore, "# Generated by `rebase db push` / `rebase db generate` from the collections.\n*\n");
854
+ if (!fs.existsSync(ignore)) fs.writeFileSync(ignore, "# Generated by `rebase db push` / `rebase db generate` from backend/schema.\n*\n");
854
855
  const removed = [];
855
856
  for (const name of GENERATED_SQL_FILES) {
856
857
  const legacy = path.join(cwd, "drizzle", name);
@@ -888,11 +889,10 @@ var cli_helpers_exports = /* @__PURE__ */ __exportAll({
888
889
  getSearchExcludes: () => getSearchExcludes,
889
890
  getTableExcludes: () => getTableExcludes,
890
891
  getTableIncludes: () => getTableIncludes,
891
- getTableIncludesFromCollections: () => getTableIncludesFromCollections,
892
+ getTableIncludesFromTables: () => getTableIncludesFromTables,
892
893
  getTriggerExcludes: () => getTriggerExcludes,
893
894
  getUndeclaredConstraintExcludes: () => getUndeclaredConstraintExcludes,
894
895
  getVectorExcludes: () => getVectorExcludes,
895
- loadCollectionsForCli: () => loadCollectionsForCli,
896
896
  queryColumnTypes: () => queryColumnTypes,
897
897
  queryExistingIndexes: () => queryExistingIndexes,
898
898
  queryExistingTables: () => queryExistingTables,
@@ -1105,51 +1105,35 @@ function resolveLocalBin(binName) {
1105
1105
  } catch {}
1106
1106
  return null;
1107
1107
  }
1108
- async function getTableIncludesFromCollections(allCollections) {
1109
- const { getTableName, relationalCollections, resolveJunctionSpecs } = await import("@rebasepro/common");
1110
- const { isPostgresCollectionConfig } = await import("@rebasepro/types");
1111
- const collections = relationalCollections(allCollections);
1108
+ /**
1109
+ * The tables Atlas may manage: every declared table (a view is Rebase's to
1110
+ * create and drop, `views.sql`, never Atlas's) and every junction, as
1111
+ * `schema.table`.
1112
+ */
1113
+ function getTableIncludesFromTables(descriptors) {
1112
1114
  const includes = [];
1113
- for (const col of collections) {
1114
- if (isPostgresCollectionConfig(col) && col.view) continue;
1115
- const tableName = getTableName(col);
1116
- const schema = isPostgresCollectionConfig(col) && col.schema ? col.schema : "public";
1117
- if (tableName) includes.push(`${schema}.${tableName}`);
1115
+ for (const descriptor of descriptors) {
1116
+ if (descriptor.kind === "view") continue;
1117
+ includes.push(`${descriptor.schema}.${descriptor.table}`);
1118
1118
  }
1119
- for (const junction of resolveJunctionSpecs(collections).values()) includes.push(`${junction.schema}.${junction.table}`);
1119
+ for (const junction of resolveTableJunctions(descriptors).values()) includes.push(`${junction.schema}.${junction.table}`);
1120
1120
  return Array.from(new Set(includes));
1121
1121
  }
1122
- async function getTableIncludes(collectionsPath) {
1123
- return getTableIncludesFromCollections(await loadCollectionsForCli(collectionsPath));
1122
+ async function getTableIncludes(schemaDir) {
1123
+ return getTableIncludesFromTables((await tablesIn(schemaDir)).map((table) => table.descriptor));
1124
1124
  }
1125
1125
  /**
1126
- * Load a project's collections the way the Atlas-facing commands need them.
1126
+ * The project's tables, for the Atlas-facing helpers below.
1127
1127
  *
1128
- * Deliberately forgiving — a file that fails to import is skipped rather than
1129
- * fatal — because the callers use this to *narrow* what Atlas may touch, and a
1130
- * hard failure here would block a push over an unrelated broken file. Callers
1131
- * that cannot tolerate a partial answer (the table excludes, which fail closed)
1132
- * check the result themselves.
1128
+ * Through the one loader every driver command uses (`loadTables`), and fatal
1129
+ * like it: these helpers decide what Atlas may touch, and a table dropped from
1130
+ * the answer because its module failed to import is a table Atlas is told to
1131
+ * leave alone — or, for the includes, one it plans to drop. Imported on first
1132
+ * use, so a command that never reaches here does not load the server package.
1133
1133
  */
1134
- /** Paths this process has already complained about. See {@link loadCollectionsForCli}. */
1135
- var warnedMissingCollectionsPaths = /* @__PURE__ */ new Set();
1136
- async function loadCollectionsForCli(collectionsPath) {
1137
- const resolvedPath = path.resolve(collectionsPath);
1138
- const collections = [];
1139
- if (!fs.existsSync(resolvedPath) && !warnedMissingCollectionsPaths.has(resolvedPath)) {
1140
- warnedMissingCollectionsPaths.add(resolvedPath);
1141
- outWarn(chalk.yellow(` ⚠ Collections path not found: "${collectionsPath}"\n Resolved to: ${resolvedPath}\n (relative to cwd: ${process.cwd()})\n Pass an absolute path, or a path relative to where you run the command.`));
1142
- }
1143
- if (fs.existsSync(resolvedPath)) {
1144
- if (fs.statSync(resolvedPath).isDirectory()) {
1145
- const files = fs.readdirSync(resolvedPath);
1146
- for (const file of files) if ((file.endsWith(".ts") || file.endsWith(".js")) && !file.includes(".test.") && !file.endsWith(".d.ts") && file !== "index.ts" && file !== "index.js") try {
1147
- const module = await import(pathToFileURL(path.join(resolvedPath, file)).href);
1148
- if (module && module.default) collections.push(module.default);
1149
- } catch {}
1150
- }
1151
- }
1152
- return collections;
1134
+ async function tablesIn(schemaDir) {
1135
+ const { loadTables } = await import("./load-tables-B1Re74ng.js").then((n) => n.i);
1136
+ return loadTables(schemaDir);
1153
1137
  }
1154
1138
  /**
1155
1139
  * The app database connections this process has open, by URL — one each.
@@ -1386,9 +1370,9 @@ async function applySearchDdl(databaseUrl, sqlDir = generatedSqlDir()) {
1386
1370
  * Returns an empty list — and so changes nothing — for a project with no
1387
1371
  * `search` block, which is every project that has not opted in.
1388
1372
  */
1389
- async function getSearchExcludes(collectionsPath) {
1390
- const { searchExcludePatterns } = await import("./generate-postgres-ddl-logic-Dg0bcENZ.js").then((n) => n.s);
1391
- return searchExcludePatterns(await loadCollectionsForCli(collectionsPath));
1373
+ async function getSearchExcludes(schemaDir) {
1374
+ const { searchExcludePatterns } = await import("./generate-postgres-ddl-logic-B8huc03c.js").then((n) => n.s);
1375
+ return searchExcludePatterns(await tablesIn(schemaDir));
1392
1376
  }
1393
1377
  /**
1394
1378
  * Every `generated column → column it reads` edge in the database.
@@ -1474,7 +1458,7 @@ function readVectorDdl(sqlDir = generatedSqlDir()) {
1474
1458
  async function applyVectorDdl(databaseUrl, sqlDir = generatedSqlDir()) {
1475
1459
  const sql = readVectorDdl(sqlDir);
1476
1460
  if (!sql) return;
1477
- const { vectorExtensionHint } = await import("./vector-index-DsQ3V2d2.js").then((n) => n.f);
1461
+ const { vectorExtensionHint } = await import("./vector-index-VSh3ufTd.js").then((n) => n.f);
1478
1462
  try {
1479
1463
  await withAppClient(databaseUrl, (client) => client.query(sql));
1480
1464
  } catch (err) {
@@ -1491,9 +1475,9 @@ async function applyVectorDdl(databaseUrl, sqlDir = generatedSqlDir()) {
1491
1475
  * Returns an empty list — and so changes nothing — for a project with no
1492
1476
  * `vector` property, which is every project that has not opted in.
1493
1477
  */
1494
- async function getVectorExcludes(collectionsPath) {
1495
- const { vectorExcludePatterns } = await import("./generate-postgres-ddl-logic-Dg0bcENZ.js").then((n) => n.s);
1496
- return vectorExcludePatterns(await loadCollectionsForCli(collectionsPath));
1478
+ async function getVectorExcludes(schemaDir) {
1479
+ const { vectorExcludePatterns } = await import("./generate-postgres-ddl-logic-B8huc03c.js").then((n) => n.s);
1480
+ return vectorExcludePatterns(await tablesIn(schemaDir));
1497
1481
  }
1498
1482
  /**
1499
1483
  * The generated SQL for the project's `autoValue: "on_update"` properties, if
@@ -1547,9 +1531,9 @@ async function applyViewsDdl(databaseUrl, sqlDir = generatedSqlDir()) {
1547
1531
  out(chalk.gray(" ✓ Applied views"));
1548
1532
  }
1549
1533
  /** @see getSearchExcludes */
1550
- async function getTriggerExcludes(collectionsPath) {
1551
- const { triggerExcludePatterns } = await import("./generate-postgres-ddl-logic-Dg0bcENZ.js").then((n) => n.s);
1552
- return triggerExcludePatterns(await loadCollectionsForCli(collectionsPath));
1534
+ async function getTriggerExcludes(schemaDir) {
1535
+ const { triggerExcludePatterns } = await import("./generate-postgres-ddl-logic-B8huc03c.js").then((n) => n.s);
1536
+ return triggerExcludePatterns(await tablesIn(schemaDir));
1553
1537
  }
1554
1538
  /**
1555
1539
  * Every index Postgres holds on a table, by its parts — never joined with `.`,
@@ -1605,9 +1589,9 @@ async function queryExistingIndexes(databaseUrl) {
1605
1589
  * spelled by `atlasExcludePattern`: a raw `orders_idx[v1]` is a glob that
1606
1590
  * matches `orders_idxv`, so that index was dropped with no prompt.
1607
1591
  */
1608
- async function getForeignIndexExcludes(databaseUrl, collectionsPath, deps = {}) {
1592
+ async function getForeignIndexExcludes(databaseUrl, schemaDir, deps = {}) {
1609
1593
  const queryIndexes = deps.queryExistingIndexes ?? queryExistingIndexes;
1610
- const managed = await (deps.getManagedIndexNames ?? managedIndexNames)(collectionsPath);
1594
+ const managed = await (deps.getManagedIndexNames ?? managedIndexNames)(schemaDir);
1611
1595
  let existing;
1612
1596
  try {
1613
1597
  existing = await queryIndexes(databaseUrl);
@@ -1620,16 +1604,15 @@ async function getForeignIndexExcludes(databaseUrl, collectionsPath, deps = {})
1620
1604
  }).map(({ schema, table, index }) => atlasExcludePattern(schema, table, index));
1621
1605
  }
1622
1606
  /**
1623
- * The index names the current collections would create — search, vector and
1607
+ * The index names the current tables would create — search, vector and
1624
1608
  * declared alike. Anything Atlas would emit is by definition not foreign.
1625
1609
  */
1626
- async function managedIndexNames(collectionsPath) {
1627
- const collections = await loadCollectionsForCli(collectionsPath);
1628
- const { searchExcludePatterns, vectorExcludePatterns } = await import("./generate-postgres-ddl-logic-Dg0bcENZ.js").then((n) => n.s);
1629
- const { resolveColumnName } = await import("./column-plan-helpers-BeSztMor.js").then((n) => n.t);
1630
- const { buildCollectionIndexPlan } = await import("./source-fZb92pN8.js").then((n) => n.d);
1631
- const names = new Set(buildCollectionIndexPlan(collections, resolveColumnName).map((spec) => spec.indexName));
1632
- for (const pattern of [...searchExcludePatterns(collections), ...vectorExcludePatterns(collections)]) {
1610
+ async function managedIndexNames(schemaDir) {
1611
+ const tables = await tablesIn(schemaDir);
1612
+ const { searchExcludePatterns, vectorExcludePatterns } = await import("./generate-postgres-ddl-logic-B8huc03c.js").then((n) => n.s);
1613
+ const { buildTableIndexSpecs } = await import("./source-VxbrQojV.js").then((n) => n._);
1614
+ const names = new Set(tables.flatMap((table) => buildTableIndexSpecs(table.descriptor)).map((spec) => spec.indexName));
1615
+ for (const pattern of [...searchExcludePatterns(tables), ...vectorExcludePatterns(tables)]) {
1633
1616
  const object = excludePatternParts(pattern)?.[2];
1634
1617
  if (object !== void 0) names.add(object);
1635
1618
  }
@@ -1696,10 +1679,10 @@ var ExcludeIntrospectionError = class extends Error {
1696
1679
  *
1697
1680
  * `deps` is injectable for tests; production uses the real pg-backed queries.
1698
1681
  */
1699
- async function getTableExcludes(databaseUrl, collectionsPath, deps = {}) {
1682
+ async function getTableExcludes(databaseUrl, schemaDir, deps = {}) {
1700
1683
  const getIncludes = deps.getIncludes ?? getTableIncludes;
1701
1684
  const queryTables = deps.queryExistingTables ?? queryExistingTables;
1702
- const includes = await getIncludes(collectionsPath);
1685
+ const includes = await getIncludes(schemaDir);
1703
1686
  const excludes = [
1704
1687
  "atlas_schema_revisions.*",
1705
1688
  "auth",
@@ -1952,7 +1935,7 @@ function formatDependencyDropBanner(manager = detectProjectPackageManager()) {
1952
1935
  because other objects still depend on it.
1953
1936
  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
1954
1937
 
1955
- ${chalk.yellow("The database may now be partially migrated.")} Atlas applies\n statements individually, so earlier changes in this push may\n already be committed while later ones failed.\n\n This commonly happens when a collection is removed but an enum\n type it defined is still referenced. To recover:\n\n 1. Inspect the leftover object named in the error above.\n 2. Drop it with CASCADE, e.g.:\n psql "$(${projectRebaseCommand(manager)} db url)" -c 'DROP TYPE "<name>" CASCADE;'\n 3. Re-run: ${chalk.bold.green("rebase db push")}\n\n Prefer a safe, versioned workflow? Use ${chalk.bold("rebase db generate")}\n + ${chalk.bold("rebase db migrate")} instead of push for destructive changes.\n\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n`;
1938
+ ${chalk.yellow("The database may now be partially migrated.")} Atlas applies\n statements individually, so earlier changes in this push may\n already be committed while later ones failed.\n\n This commonly happens when a table is removed but an enum\n type it defined is still referenced. To recover:\n\n 1. Inspect the leftover object named in the error above.\n 2. Drop it with CASCADE, e.g.:\n psql "$(${projectRebaseCommand(manager)} db url)" -c 'DROP TYPE "<name>" CASCADE;'\n 3. Re-run: ${chalk.bold.green("rebase db push")}\n\n Prefer a safe, versioned workflow? Use ${chalk.bold("rebase db generate")}\n + ${chalk.bold("rebase db migrate")} instead of push for destructive changes.\n\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n`;
1956
1939
  }
1957
1940
  /**
1958
1941
  * Pre-flight check: verify that the database is reachable before running
@@ -2346,7 +2329,7 @@ function formatGeneratedColumnRefusalBanner(refusal, blockers) {
2346
2329
  const drop = first ? `ALTER TABLE "${first.schema}"."${first.table}" DROP COLUMN "${first.column}";` : "ALTER TABLE … DROP COLUMN <the generated column>;";
2347
2330
  return "\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n ❌ A generated column reads a column this push retypes\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n\n" + named + ` PostgreSQL will not retype a column while a GENERATED ALWAYS AS …
2348
2331
  STORED expression reads it, and Atlas applies a push as one
2349
- transaction — ${chalk.yellow("nothing in this push was applied.")}\n\n A collection's ${chalk.bold("search")} column is dropped and rebuilt around the apply\n by the push itself. If that is the column named above, run the push\n again, and please report it: it should not have got this far.\n\n Any other generated column is yours. Drop it, push, and put it back\n with its original expression:\n\n ${chalk.gray(drop)}\n ${chalk.gray("rebase db push")}\n\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n`;
2332
+ transaction — ${chalk.yellow("nothing in this push was applied.")}\n\n A table's ${chalk.bold("search")} column is dropped and rebuilt around the apply\n by the push itself. If that is the column named above, run the push\n again, and please report it: it should not have got this far.\n\n Any other generated column is yours. Drop it, push, and put it back\n with its original expression:\n\n ${chalk.gray(drop)}\n ${chalk.gray("rebase db push")}\n\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n`;
2350
2333
  }
2351
2334
  /**
2352
2335
  * PostgreSQL refusing a retype it has no implicit cast for (42804): `string` →
@@ -2371,7 +2354,7 @@ function formatUncastableRetypeBanner(refusal) {
2371
2354
  const quotedColumn = `"${column.replace(/"/g, "\"\"")}"`;
2372
2355
  return `
2373
2356
  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
2374
- ❌ ${table}.${quotedColumn} cannot be converted to ${type} automatically\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n\n The collection now declares this column as ${type}, and PostgreSQL has\n no implicit conversion from what the column holds today. Atlas stops\n at the first such statement — ${chalk.yellow("nothing in this push was applied")}, and a\n --dry-run cannot show the rest of the plan until this one is settled.\n\n Three ways forward:\n\n 1. Convert the values yourself, saying how, then push again:\n ${chalk.gray(`ALTER TABLE ${table} ALTER COLUMN ${quotedColumn} TYPE ${type} USING ${quotedColumn}::${type};`)}\n ${chalk.gray("(adjust the USING expression to whatever turns each old value into a new one)")}\n 2. Add a new property for the new type, copy the values over with an\n UPDATE, then remove the old property.\n 3. Keep the column as it is — put the property's type back, or pin the\n database type with ${chalk.bold("columnType")}.\n\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n`;
2357
+ ❌ ${table}.${quotedColumn} cannot be converted to ${type} automatically\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n\n The table now declares this column as ${type}, and PostgreSQL has\n no implicit conversion from what the column holds today. Atlas stops\n at the first such statement — ${chalk.yellow("nothing in this push was applied")}, and a\n --dry-run cannot show the rest of the plan until this one is settled.\n\n Three ways forward:\n\n 1. Convert the values yourself, saying how, then push again:\n ${chalk.gray(`ALTER TABLE ${table} ALTER COLUMN ${quotedColumn} TYPE ${type} USING ${quotedColumn}::${type};`)}\n ${chalk.gray("(adjust the USING expression to whatever turns each old value into a new one)")}\n 2. Add a new property for the new type, copy the values over with an\n UPDATE, then remove the old property.\n 3. Keep the column as it is — put the property's type back, or pin the\n database type with ${chalk.bold("columnType")}.\n\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n`;
2375
2358
  }
2376
2359
  /**
2377
2360
  * A unique constraint or index PostgreSQL could not build because the rows
@@ -2467,7 +2450,7 @@ function formatForeignGeneratedColumnBanner(conflicts) {
2467
2450
  transaction — so this refusal would roll back every other statement
2468
2451
  in the push with it.
2469
2452
 
2470
- ${chalk.yellow("Nothing was applied.")} Rebase rebuilds the generated columns it made\n itself (a collection's ${chalk.bold("search")} block) around the apply. It has no\n definition for this one, and a dropped generated expression is not\n recoverable from anywhere but your own migration.\n\n Drop it, push, and put it back:\n\n ${chalk.gray(`ALTER TABLE "${first.schema}"."${first.table}" DROP COLUMN "${first.column}";`)}\n ${chalk.gray("rebase db push")}\n ${chalk.gray("-- then re-create the column with its original expression")}\n\n Or declare it through a ${chalk.bold("search")} block, and Rebase will own it.\n\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n`;
2453
+ ${chalk.yellow("Nothing was applied.")} Rebase rebuilds the generated columns it made\n itself (a table's ${chalk.bold("search")} block) around the apply. It has no\n definition for this one, and a dropped generated expression is not\n recoverable from anywhere but your own migration.\n\n Drop it, push, and put it back:\n\n ${chalk.gray(`ALTER TABLE "${first.schema}"."${first.table}" DROP COLUMN "${first.column}";`)}\n ${chalk.gray("rebase db push")}\n ${chalk.gray("-- then re-create the column with its original expression")}\n\n Or declare it through a ${chalk.bold("search")} block, and Rebase will own it.\n\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n`;
2471
2454
  }
2472
2455
  /**
2473
2456
  * The remedy for an Atlas invocation that failed, or `null`.
@@ -2498,6 +2481,137 @@ async function diagnoseAtlasFailure(context) {
2498
2481
  return null;
2499
2482
  }
2500
2483
  //#endregion
2501
- export { fromAlterTable as $, getTableExcludes as A, readVectorDdl as B, detectProjectPackageManager as C, ensureDevDatabaseExists as D, dropGeneratedColumns as E, queryColumnTypes as F, DESIRED_STATE_URL as G, resolveLocalBin as H, queryGeneratedColumnDependencies as I, prepareGeneratedSqlDir as J, GENERATED_SQL_DIR as K, queryUndeclarableConstraints as L, getUndeclaredConstraintExcludes as M, getVectorExcludes as N, getForeignIndexExcludes as O, loadCollectionsForCli as P, extractPlanStatements as Q, readSearchDdl as R, describeReinstallCommand as S, dropDevDatabase as T, withAppClient as U, readViewsDdl as V, workspaceMemberDir as W, destructiveOptInFlag as X, decidePushSafety as Y, detectDestructiveStatements as Z, atlasDevDatabaseUrl as _, diagnoseDbError as a, splitPassword as at, describeBuildScriptRemedy as b, isEconnrefused as c, reportCommandFailure as d, isSyncedPlan as et, ExcludeIntrospectionError as f, applyViewsDdl as g, applyVectorDdl as h, diagnoseAtlasFailure as i, redactConnectionPasswords as it, getTriggerExcludes as j, getSearchExcludes as k, isSslNotEnabled as l, applyTriggersDdl as m, closedDatabaseName as n, forAtlas as nt, formatForeignGeneratedColumnBanner as o, extractCauseMessage as ot, applySearchDdl as p, generatedSqlDir as q, deepestErrorMessage as r, forLibpq as rt, isAuthFailure as s, checkDatabaseConnectivity as t, warnIfYesApprovedDestructive as tt, parseHostInfo as u, cli_helpers_exports as v, diagnoseMissingBin as w, describeDevAddCommand as x, closeAppClients as y, readTriggersDdl as z };
2484
+ //#region src/cli-schema-dir.ts
2485
+ /**
2486
+ * `--schema-dir <dir>`, checked once, before anything is written.
2487
+ *
2488
+ * A directory that does not resolve must stop the command before either
2489
+ * generator runs. The previous flag (`--collections`) once warned and carried
2490
+ * on, four times over — `schemaCommand`, `generatePostgresDdlCommand` and the
2491
+ * Atlas argv assembly each re-enter the loader with the same line — and then
2492
+ * both generators wrote an *empty* schema: `drizzle/schema.sql` truncated to
2493
+ * `CREATE SCHEMA IF NOT EXISTS "rebase";`, `src/schema.generated.ts` to ten
2494
+ * lines. Both were committed artifacts then. The push that followed planned a
2495
+ * `DROP TABLE` for every table in the database, and the only thing between a
2496
+ * typo and that was the destructive gate.
2497
+ *
2498
+ * The loader itself (`loadTables`) answers a directory that is not there with
2499
+ * "no tables" — the headless layout, where the runtime introspects the
2500
+ * database. That is the right answer for the *default* directory and the wrong
2501
+ * one for a directory somebody typed, so the typed one is checked here.
2502
+ */
2503
+ /**
2504
+ * The schema directory the driver reads when the command line names none:
2505
+ * `schema`, relative to the driver's working directory — which is `backend/`,
2506
+ * so `backend/schema`. The CLI passes `--schema-dir <absolute dir>` only when a
2507
+ * project keeps its tables elsewhere (`rebase.json` `apps.<backend>.tables`).
2508
+ */
2509
+ var DEFAULT_SCHEMA_DIR = "schema";
2510
+ /**
2511
+ * Thrown rather than exited, so the tests can see it and the entry point owns
2512
+ * the exit code.
2513
+ *
2514
+ * `alreadyReported` is read by `reportCommandFailure`: the full diagnosis is on
2515
+ * stderr by the time this is thrown, and it is printed once.
2516
+ */
2517
+ var SchemaDirMissing = class extends Error {
2518
+ typed;
2519
+ resolved;
2520
+ alreadyReported = true;
2521
+ constructor(typed, resolved) {
2522
+ super(`Schema directory not found: "${typed}"`);
2523
+ this.typed = typed;
2524
+ this.resolved = resolved;
2525
+ this.name = "SchemaDirMissing";
2526
+ }
2527
+ };
2528
+ /**
2529
+ * The whole message, in one place, because it is printed by two callers.
2530
+ *
2531
+ * Names what was typed, what it resolved to, and the working directory it
2532
+ * resolved against — a relative `--schema-dir` is resolved against the cwd,
2533
+ * and the driver runs with `cwd: backend/`, so "the path is right and the
2534
+ * directory is wrong" is the commonest way to arrive here.
2535
+ */
2536
+ function describeMissingSchemaDir(typed, resolved) {
2537
+ return [
2538
+ chalk.red(`✗ Schema directory not found: "${typed}"`),
2539
+ chalk.gray(` Resolved to: ${resolved}`),
2540
+ chalk.gray(` (relative to cwd: ${process.cwd()})`),
2541
+ "",
2542
+ chalk.gray(" Nothing was generated and nothing was applied — a schema generated from a"),
2543
+ chalk.gray(" directory that is not there is an empty one, and applying it would drop"),
2544
+ chalk.gray(" every table it does not describe."),
2545
+ "",
2546
+ chalk.gray(" Pass the directory whose index.ts exports your tables (backend/schema), as an"),
2547
+ chalk.gray(" absolute path or one relative to where you run the command.")
2548
+ ].join("\n");
2549
+ }
2550
+ /**
2551
+ * Refuse a `--schema-dir` that does not exist.
2552
+ *
2553
+ * `null` means the flag was not given: the default (`schema`, relative to
2554
+ * `backend/`) is left to the loader, which reads a missing directory as "no
2555
+ * tables declared" — a headless project legitimately has none.
2556
+ */
2557
+ function assertSchemaDirExists(typed) {
2558
+ if (typed === null) return;
2559
+ const resolved = path.resolve(process.cwd(), typed);
2560
+ if (fs.existsSync(resolved)) return;
2561
+ outError("");
2562
+ outError(describeMissingSchemaDir(typed, resolved));
2563
+ outError("");
2564
+ throw new SchemaDirMissing(typed, resolved);
2565
+ }
2566
+ /**
2567
+ * The driver commands that read (or, `schema introspect`, write) the schema
2568
+ * directory — the ones `--schema-dir` belongs to, and the ones that used to
2569
+ * take `--collections`. Keyed as the
2570
+ * driver's argv starts: domain, then subcommand (or the bare domain for the
2571
+ * single-word commands). The CLI keeps its own list (`packages/cli`
2572
+ * `schema-dir.ts`) of when to pass the flag; `db migrate` reads the schema
2573
+ * too (it stamps the policies it applied).
2574
+ */
2575
+ var COMMANDS_READING_SCHEMA = /* @__PURE__ */ new Set([
2576
+ "db push",
2577
+ "db generate",
2578
+ "db migrate",
2579
+ "schema generate",
2580
+ "schema introspect",
2581
+ "schema stale",
2582
+ "doctor",
2583
+ "console"
2584
+ ]);
2585
+ /** Whether `args` (the driver's whole line) is a command that reads the schema directory. */
2586
+ function readsSchemaDir(args) {
2587
+ return COMMANDS_READING_SCHEMA.has(args[0] ?? "") || COMMANDS_READING_SCHEMA.has(`${args[0]} ${args[1]}`);
2588
+ }
2589
+ /**
2590
+ * The one line a removed `--collections` (or `-c`) flag is refused with.
2591
+ *
2592
+ * The flag named a `config/collections` directory of `defineCollection`
2593
+ * files, which nothing reads any more: tables live in `backend/schema`, the
2594
+ * driver reads it by default, and `--schema-dir` names another directory.
2595
+ * Refused rather than ignored — silently reading the default directory
2596
+ * instead of the one typed would generate (and push) a different schema.
2597
+ */
2598
+ function removedCollectionsFlagSentence(args) {
2599
+ if (!readsSchemaDir(args)) return null;
2600
+ const words = args.slice(1);
2601
+ const end = words.indexOf("--");
2602
+ const used = (end === -1 ? words : words.slice(0, end)).find((word) => word === "--collections" || word.startsWith("--collections=") || word === "-c");
2603
+ if (used === void 0) return null;
2604
+ return `${used.startsWith("--collections") ? "--collections" : "-c"} was removed: tables are read from backend/schema (\`defineTable\`), by default, and \`--schema-dir <dir>\` names another directory. Nothing was run. A project still on config/collections: ${LEGACY_LAYOUT_REMEDY}.`;
2605
+ }
2606
+ /**
2607
+ * Refuse a line that still passes `--collections`. Throws rather than exits,
2608
+ * like {@link assertSchemaDirExists}.
2609
+ */
2610
+ function assertNoCollectionsFlag(args) {
2611
+ const sentence = removedCollectionsFlagSentence(args);
2612
+ if (sentence !== null) throw new Error(sentence);
2613
+ }
2614
+ //#endregion
2615
+ export { detectDestructiveStatements as $, ensureDevDatabaseExists as A, readSearchDdl as B, describeBuildScriptRemedy as C, diagnoseMissingBin as D, detectProjectPackageManager as E, getUndeclaredConstraintExcludes as F, withAppClient as G, readVectorDdl as H, getVectorExcludes as I, GENERATED_SQL_DIR as J, workspaceMemberDir as K, queryColumnTypes as L, getSearchExcludes as M, getTableExcludes as N, dropDevDatabase as O, getTriggerExcludes as P, destructiveOptInFlag as Q, queryGeneratedColumnDependencies as R, closeAppClients as S, describeReinstallCommand as T, readViewsDdl as U, readTriggersDdl as V, resolveLocalBin as W, prepareGeneratedSqlDir as X, generatedSqlDir as Y, decidePushSafety as Z, applyTriggersDdl as _, closedDatabaseName as a, forLibpq as at, atlasDevDatabaseUrl as b, diagnoseDbError as c, extractCauseMessage as ct, isEconnrefused as d, extractPlanStatements as et, isSslNotEnabled as f, applySearchDdl as g, ExcludeIntrospectionError as h, checkDatabaseConnectivity as i, forAtlas as it, getForeignIndexExcludes as j, dropGeneratedColumns as k, formatForeignGeneratedColumnBanner as l, reportCommandFailure as m, assertNoCollectionsFlag as n, isSyncedPlan as nt, deepestErrorMessage as o, redactConnectionPasswords as ot, parseHostInfo as p, DESIRED_STATE_URL as q, assertSchemaDirExists as r, warnIfYesApprovedDestructive as rt, diagnoseAtlasFailure as s, splitPassword as st, DEFAULT_SCHEMA_DIR as t, fromAlterTable as tt, isAuthFailure as u, applyVectorDdl as v, describeDevAddCommand as w, cli_helpers_exports as x, applyViewsDdl as y, queryUndeclarableConstraints as z };
2502
2616
 
2503
- //# sourceMappingURL=cli-errors-DYTxnLbW.js.map
2617
+ //# sourceMappingURL=cli-schema-dir-CiN0ephV.js.map