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

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
package/dist/cli.js CHANGED
@@ -1,11 +1,11 @@
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 fromAlterTable, A as getTableExcludes, B as readVectorDdl, C as detectProjectPackageManager, D as ensureDevDatabaseExists, E as dropGeneratedColumns, F as queryColumnTypes, G as DESIRED_STATE_URL, H as resolveLocalBin, I as queryGeneratedColumnDependencies, J as prepareGeneratedSqlDir, K as GENERATED_SQL_DIR, L as queryUndeclarableConstraints, M as getUndeclaredConstraintExcludes, N as getVectorExcludes, O as getForeignIndexExcludes, P as loadCollectionsForCli, Q as extractPlanStatements, R as readSearchDdl, S as describeReinstallCommand, T as dropDevDatabase, U as withAppClient, V as readViewsDdl, W as workspaceMemberDir, X as destructiveOptInFlag, Y as decidePushSafety, Z as detectDestructiveStatements, _ as atlasDevDatabaseUrl, a as diagnoseDbError, b as describeBuildScriptRemedy, c as isEconnrefused, d as reportCommandFailure, et as isSyncedPlan, f as ExcludeIntrospectionError, g as applyViewsDdl, h as applyVectorDdl, i as diagnoseAtlasFailure, it as redactConnectionPasswords, j as getTriggerExcludes, k as getSearchExcludes, l as isSslNotEnabled, m as applyTriggersDdl, nt as forAtlas, o as formatForeignGeneratedColumnBanner, p as applySearchDdl, q as generatedSqlDir, s as isAuthFailure, t as checkDatabaseConnectivity, tt as warnIfYesApprovedDestructive, w as diagnoseMissingBin, x as describeDevAddCommand, y as closeAppClients, z as readTriggersDdl } from "./cli-errors-DYTxnLbW.js";
4
+ import { $ as detectDestructiveStatements, A as ensureDevDatabaseExists, B as readSearchDdl, C as describeBuildScriptRemedy, D as diagnoseMissingBin, E as detectProjectPackageManager, F as getUndeclaredConstraintExcludes, G as withAppClient, H as readVectorDdl, I as getVectorExcludes, J as GENERATED_SQL_DIR, K as workspaceMemberDir, L as queryColumnTypes, M as getSearchExcludes, N as getTableExcludes, O as dropDevDatabase, P as getTriggerExcludes, Q as destructiveOptInFlag, R as queryGeneratedColumnDependencies, S as closeAppClients, T as describeReinstallCommand, U as readViewsDdl, V as readTriggersDdl, W as resolveLocalBin, X as prepareGeneratedSqlDir, Y as generatedSqlDir, Z as decidePushSafety, _ as applyTriggersDdl, b as atlasDevDatabaseUrl, c as diagnoseDbError, d as isEconnrefused, et as extractPlanStatements, f as isSslNotEnabled, g as applySearchDdl, h as ExcludeIntrospectionError, i as checkDatabaseConnectivity, it as forAtlas, j as getForeignIndexExcludes, k as dropGeneratedColumns, l as formatForeignGeneratedColumnBanner, m as reportCommandFailure, n as assertNoCollectionsFlag, nt as isSyncedPlan, ot as redactConnectionPasswords, q as DESIRED_STATE_URL, r as assertSchemaDirExists, rt as warnIfYesApprovedDestructive, s as diagnoseAtlasFailure, tt as fromAlterTable, u as isAuthFailure, v as applyVectorDdl, w as describeDevAddCommand, y as applyViewsDdl, z as queryUndeclarableConstraints } from "./cli-schema-dir-CiN0ephV.js";
5
5
  import { i as RLS_BOOTSTRAP_SQL, o as dropLegacyAuthSchema, r as REQUEST_ROLE_FUNCTION_SQL, t as ADMIN_POLICY_ROLE_SQL } from "./rls-bootstrap-sql-kPX4-MB1.js";
6
- import { a as outWarn, i as outError, o as atlasExcludePattern, r as out, s as excludePatternParts, t as chalk } from "./source-fZb92pN8.js";
7
- import { C as declaredIndexesIfNotExists, S as execa, 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 indexAdoptionStatement, x as resolveDriverSwitches } from "./migrate-baseline-CmWXL7qx.js";
8
- import { t as nextStepAfterDbGenerate } from "./generate-next-step-DgK5BlBn.js";
6
+ import { a as outWarn, i as outError, o as atlasExcludePattern, r as out, s as excludePatternParts, t as chalk } from "./source-VxbrQojV.js";
7
+ import { C as declaredIndexesIfNotExists, S as execa, b as resolveDriverSwitches, c as isDriverDbSubcommand, d as branchNameIn, f as branchSourceIn, g as assertKnownFlags, i as latestRecordedMigration, l as backupActionOf, m as unexpectedBranchArgs, o as planBaseline, p as resolveBranchSwitches, r as describeBaselinePlan, s as DRIVER_DB_SUBCOMMANDS, t as baselineVersionProblem, w as indexAdoptionStatement, x as schemaDirIn, y as parseDriverLine } from "./migrate-baseline-DZmekgpD.js";
8
+ import { t as nextStepAfterDbGenerate } from "./generate-next-step-CO09dovd.js";
9
9
  import { REBASE_ADMIN_ROLE, declaredRlsPolicyShape } from "@rebasepro/types";
10
10
  import { formatRelativeTime } from "@rebasepro/utils";
11
11
  import path from "path";
@@ -976,82 +976,6 @@ async function applyPoliciesFile(client, policiesSql, stamping) {
976
976
  };
977
977
  }
978
978
  //#endregion
979
- //#region src/cli-collections-path.ts
980
- /**
981
- * `--collections <dir>`, checked once, before anything is written.
982
- *
983
- * A path that does not resolve used to warn and carry on. Four times over —
984
- * `schemaCommand`, `generatePostgresDdlCommand` and the Atlas argv assembly
985
- * each re-enter the loader with the same line — and then both generators wrote
986
- * an *empty* schema: `drizzle/schema.sql` truncated to `CREATE SCHEMA IF NOT
987
- * EXISTS "rebase";`, `src/schema.generated.ts` to ten lines. Both were committed
988
- * artifacts then. The push that followed planned a `DROP TABLE` for every table in
989
- * the database, and the only thing between a typo and that was the destructive
990
- * gate.
991
- *
992
- * The check has to be here rather than inside `loadCollectionsForCli`, which is
993
- * deliberately forgiving: its callers use it to narrow what Atlas may touch,
994
- * and making a broken *file* fatal there would block a push over something
995
- * unrelated. "Does the directory the user named exist" is a different question,
996
- * it was answerable before the first write, and the code already knew.
997
- */
998
- /**
999
- * Thrown rather than exited, so the tests can see it and the entry point owns
1000
- * the exit code.
1001
- *
1002
- * `alreadyReported` is read by `reportCommandFailure`: the full diagnosis is on
1003
- * stderr by the time this is thrown, and the point of the whole change is that
1004
- * it is printed once.
1005
- */
1006
- var CollectionsPathMissing = class extends Error {
1007
- typed;
1008
- resolved;
1009
- alreadyReported = true;
1010
- constructor(typed, resolved) {
1011
- super(`Collections path not found: "${typed}"`);
1012
- this.typed = typed;
1013
- this.resolved = resolved;
1014
- this.name = "CollectionsPathMissing";
1015
- }
1016
- };
1017
- /**
1018
- * The whole message, in one place, because it is printed by two callers.
1019
- *
1020
- * Names what was typed, what it resolved to, and the working directory it
1021
- * resolved against — a relative `--collections` is resolved against the cwd,
1022
- * and the generated npm script runs with `cwd: backend/`, so "the path is
1023
- * right and the directory is wrong" is the commonest way to arrive here.
1024
- */
1025
- function describeMissingCollectionsPath(typed, resolved) {
1026
- return [
1027
- chalk.red(`✗ Collections path not found: "${typed}"`),
1028
- chalk.gray(` Resolved to: ${resolved}`),
1029
- chalk.gray(` (relative to cwd: ${process.cwd()})`),
1030
- "",
1031
- chalk.gray(" Nothing was generated and nothing was applied — a schema generated from a"),
1032
- chalk.gray(" directory that is not there is an empty one, and applying it would drop"),
1033
- chalk.gray(" every table it does not describe."),
1034
- "",
1035
- chalk.gray(" Pass an absolute path, or one relative to where you run the command.")
1036
- ].join("\n");
1037
- }
1038
- /**
1039
- * Refuse a `--collections` path that does not exist.
1040
- *
1041
- * `null` means the flag was not given: the default (`../config/collections`) is
1042
- * left to the loader, which warns and continues — a project may legitimately
1043
- * have no collections directory, and a headless scaffold does.
1044
- */
1045
- function assertCollectionsPathExists(typed) {
1046
- if (typed === null) return;
1047
- const resolved = path.resolve(process.cwd(), typed);
1048
- if (fs.existsSync(resolved)) return;
1049
- outError("");
1050
- outError(describeMissingCollectionsPath(typed, resolved));
1051
- outError("");
1052
- throw new CollectionsPathMissing(typed, resolved);
1053
- }
1054
- //#endregion
1055
979
  //#region src/branch-prune.ts
1056
980
  /**
1057
981
  * The variable the CLI hands the driver the database its checkout is switched
@@ -1150,7 +1074,7 @@ var __cliDirname = path.dirname(fileURLToPath(import.meta.url));
1150
1074
  * build, which is how the monorepo runs before `pnpm build`.
1151
1075
  *
1152
1076
  * **The interpreter is tsx either way, and that is not incidental.** These
1153
- * scripts load the *project's* collection files, which are TypeScript and
1077
+ * scripts load the *project's* table files (`backend/schema`), which are TypeScript and
1154
1078
  * import each other as `./authors.js` — the extension TypeScript tells you to
1155
1079
  * write. Node resolves that literally and fails on a file that does not exist;
1156
1080
  * tsx maps it back. Running the built `.js` under plain `node` therefore fails
@@ -1193,12 +1117,12 @@ function resolveChildScript(name) {
1193
1117
  }
1194
1118
  /** What to print when {@link resolveChildScript} cannot produce a command. */
1195
1119
  function childScriptError(what, reason) {
1196
- if (reason === "tsx") return `✗ Could not find the tsx binary, which ${what} needs to read your collection files. Install your project's dependencies and try again.`;
1120
+ if (reason === "tsx") return `✗ Could not find the tsx binary, which ${what} needs to read your table files (backend/schema). Install your project's dependencies and try again.`;
1197
1121
  return `✗ The driver's ${what} is missing. This copy of @rebasepro/server-postgres is incomplete — reinstall it, or run its build if you are working in the monorepo.`;
1198
1122
  }
1199
1123
  /**
1200
1124
  * Whether this process can run the generators itself — that is, whether it
1201
- * runs under tsx, the interpreter the project's collection files need (see
1125
+ * runs under tsx, the interpreter the project's table files need (see
1202
1126
  * {@link resolveChildScript}). `rebase` always starts the driver that way when
1203
1127
  * tsx is installed, which a scaffold guarantees; a driver started with plain
1204
1128
  * `node` keeps the child process, which brings its own tsx.
@@ -1217,7 +1141,7 @@ function generatesInProcess() {
1217
1141
  async function generateInProcess(what, label, run) {
1218
1142
  let generators;
1219
1143
  try {
1220
- generators = await import("./generate-files-CsaVzatS.js").then((n) => n.t);
1144
+ generators = await import("./generate-files-tlJ9_lGI.js").then((n) => n.t);
1221
1145
  } catch (err) {
1222
1146
  outError(chalk.red(`✗ Failed to run ${what}: ${err instanceof Error ? err.message : String(err)}`));
1223
1147
  process.exit(1);
@@ -1256,15 +1180,16 @@ async function runPluginCommand(args) {
1256
1180
  await loadEnv();
1257
1181
  const domain = args[0];
1258
1182
  const subcommand = args[1];
1183
+ assertNoCollectionsFlag(args);
1259
1184
  assertKnownFlags(domain, subcommand, args);
1260
1185
  args = resolveDriverSwitches(domain, subcommand, args);
1261
- assertCollectionsPathExists(collectionsPathIn(args));
1186
+ if (!(domain === "schema" && subcommand === "introspect")) assertSchemaDirExists(schemaDirIn(args));
1262
1187
  try {
1263
1188
  if (domain === "db") await scratchDatabase.around(() => dbCommand(subcommand, args));
1264
1189
  else if (domain === "schema") await schemaCommand(subcommand, args);
1265
1190
  else if (domain === "doctor") await doctorPluginCommand(args);
1266
1191
  else if (domain === "console") {
1267
- const { consoleCommand } = await import("./cli-console-DBPw-oAz.js");
1192
+ const { consoleCommand } = await import("./cli-console-DsRgGSBR.js");
1268
1193
  process.exitCode = await consoleCommand(args);
1269
1194
  } else {
1270
1195
  outError(chalk.red(`Unknown domain command: ${domain}`));
@@ -1310,11 +1235,11 @@ function latestMigrationVersion() {
1310
1235
  *
1311
1236
  * @returns true when a new migration survives and may be appended to.
1312
1237
  */
1313
- async function stripCarvedOutFromNewestMigration(collectionsPath) {
1238
+ async function stripCarvedOutFromNewestMigration(schemaDir) {
1314
1239
  const patterns = [
1315
- ...await getSearchExcludes(collectionsPath),
1316
- ...await getVectorExcludes(collectionsPath),
1317
- ...await getTriggerExcludes(collectionsPath)
1240
+ ...await getSearchExcludes(schemaDir),
1241
+ ...await getVectorExcludes(schemaDir),
1242
+ ...await getTriggerExcludes(schemaDir)
1318
1243
  ];
1319
1244
  if (patterns.length === 0) return true;
1320
1245
  const newest = listMigrationFiles().at(-1);
@@ -1340,7 +1265,7 @@ async function stripCarvedOutFromNewestMigration(collectionsPath) {
1340
1265
  "hash",
1341
1266
  "--dir",
1342
1267
  "file://drizzle/migrations"
1343
- ], collectionsPath);
1268
+ ], schemaDir);
1344
1269
  return !result.empty;
1345
1270
  }
1346
1271
  /**
@@ -1349,7 +1274,7 @@ async function stripCarvedOutFromNewestMigration(collectionsPath) {
1349
1274
  * name before applying it (`adoptIdenticalIndexes`) and the statement then
1350
1275
  * finds it there. Re-hashes the directory when it rewrote anything.
1351
1276
  */
1352
- async function makeDeclaredIndexesAdoptable(collectionsPath) {
1277
+ async function makeDeclaredIndexesAdoptable(schemaDir) {
1353
1278
  const newest = listMigrationFiles().at(-1);
1354
1279
  if (!newest) return;
1355
1280
  const file = path.resolve(process.cwd(), "drizzle", "migrations", newest);
@@ -1360,7 +1285,7 @@ async function makeDeclaredIndexesAdoptable(collectionsPath) {
1360
1285
  "hash",
1361
1286
  "--dir",
1362
1287
  "file://drizzle/migrations"
1363
- ], collectionsPath);
1288
+ ], schemaDir);
1364
1289
  }
1365
1290
  /**
1366
1291
  * One line per destructive statement, as `db push` prints them — shared by
@@ -1424,13 +1349,12 @@ async function reportDestructiveMigration(migrationSql, migrationFile, databaseU
1424
1349
  * this source, sees them.
1425
1350
  */
1426
1351
  var DB_FLAGS = {
1427
- "--collections": String,
1352
+ "--schema-dir": String,
1428
1353
  "--allow-destructive": Boolean,
1429
1354
  "--refuse-destructive": Boolean,
1430
1355
  "--dry-run": Boolean,
1431
1356
  "--yes": Boolean,
1432
1357
  "--baseline": String,
1433
- "-c": "--collections",
1434
1358
  "-y": "--yes"
1435
1359
  };
1436
1360
  async function dbCommand(subcommand, rawArgs) {
@@ -1450,17 +1374,17 @@ async function dbCommand(subcommand, rawArgs) {
1450
1374
  return;
1451
1375
  }
1452
1376
  if (subcommand === "request-role") {
1453
- const { requestRoleCommand } = await import("./request-role-cli-Dy1EgJU9.js").then((n) => n.r);
1377
+ const { requestRoleCommand } = await import("./request-role-cli-BdRzdE87.js").then((n) => n.r);
1454
1378
  await requestRoleCommand(rawArgs);
1455
1379
  return;
1456
1380
  }
1457
1381
  if (subcommand === "provision") {
1458
- const { provisionCommand } = await import("./request-role-cli-Dy1EgJU9.js").then((n) => n.r);
1382
+ const { provisionCommand } = await import("./request-role-cli-BdRzdE87.js").then((n) => n.r);
1459
1383
  await provisionCommand(rawArgs);
1460
1384
  return;
1461
1385
  }
1462
1386
  if (subcommand === "backup" || subcommand === "restore" || subcommand === "backups") {
1463
- const { backupCommand, restoreCommand, backupsCommand } = await import("./backup-cli-CTKCOLpX.js").then((n) => n.t);
1387
+ const { backupCommand, restoreCommand, backupsCommand } = await import("./backup-cli-DbKyEj6c.js").then((n) => n.t);
1464
1388
  if (subcommand === "backup" && backupActionOf(rawArgs) === "list") await backupsCommand(rawArgs);
1465
1389
  else if (subcommand === "backup") await backupCommand(rawArgs);
1466
1390
  else if (subcommand === "restore") await restoreCommand(rawArgs);
@@ -1468,11 +1392,11 @@ async function dbCommand(subcommand, rawArgs) {
1468
1392
  return;
1469
1393
  }
1470
1394
  const argsList = parseDriverLine(DB_FLAGS, rawArgs);
1471
- const collectionsPath = argsList["--collections"] || path.join("..", "config", "collections");
1395
+ const schemaDir = argsList["--schema-dir"] || "schema";
1472
1396
  if (subcommand === "generate") {
1473
1397
  out("");
1474
1398
  out(chalk.bold(" 📦 Rebase DB Generate"));
1475
- out(chalk.gray(" Step 1/2: Generating Drizzle schema & Postgres DDL from collections..."));
1399
+ out(chalk.gray(" Step 1/2: Generating Drizzle schema & Postgres DDL from backend/schema..."));
1476
1400
  out("");
1477
1401
  await schemaCommand("generate", rawArgs, { nextStep: false });
1478
1402
  await generatePostgresDdlCommand(rawArgs);
@@ -1488,10 +1412,10 @@ async function dbCommand(subcommand, rawArgs) {
1488
1412
  "file://drizzle/migrations",
1489
1413
  "--to",
1490
1414
  DESIRED_STATE_URL
1491
- ], collectionsPath);
1415
+ ], schemaDir);
1492
1416
  let wroteNewMigration = listMigrationFiles().length > migrationsBefore.length;
1493
- if (wroteNewMigration) wroteNewMigration = await stripCarvedOutFromNewestMigration(collectionsPath);
1494
- if (wroteNewMigration) await makeDeclaredIndexesAdoptable(collectionsPath);
1417
+ if (wroteNewMigration) wroteNewMigration = await stripCarvedOutFromNewestMigration(schemaDir);
1418
+ if (wroteNewMigration) await makeDeclaredIndexesAdoptable(schemaDir);
1495
1419
  const newestWritten = wroteNewMigration ? listMigrationFiles().at(-1) : void 0;
1496
1420
  if (newestWritten) await reportDestructiveMigration(fs.readFileSync(path.resolve(process.cwd(), "drizzle", "migrations", newestWritten), "utf-8"), newestWritten, process.env.DATABASE_URL);
1497
1421
  const migrationsDir = path.resolve(process.cwd(), "drizzle", "migrations");
@@ -1508,8 +1432,9 @@ async function dbCommand(subcommand, rawArgs) {
1508
1432
  }
1509
1433
  const searchContent = readSearchDdl();
1510
1434
  if (searchContent) {
1511
- const { searchColumnDependencies } = await import("./generate-postgres-ddl-logic-Dg0bcENZ.js").then((n) => n.s);
1512
- const migrationConflicts = findGeneratedColumnConflicts(parseColumnMutations(migrationContent), searchColumnDependencies(await loadCollectionsForCli(collectionsPath)));
1435
+ const { searchColumnDependencies } = await import("./generate-postgres-ddl-logic-B8huc03c.js").then((n) => n.s);
1436
+ const { loadTables } = await import("./load-tables-B1Re74ng.js").then((n) => n.i);
1437
+ const migrationConflicts = findGeneratedColumnConflicts(parseColumnMutations(migrationContent), searchColumnDependencies(await loadTables(schemaDir)));
1513
1438
  const preamble = migrationDropPreamble(migrationConflicts);
1514
1439
  if (preamble) {
1515
1440
  migrationContent = `${preamble}\n${migrationContent}`;
@@ -1539,7 +1464,7 @@ async function dbCommand(subcommand, rawArgs) {
1539
1464
  "hash",
1540
1465
  "--dir",
1541
1466
  "file://drizzle/migrations"
1542
- ], collectionsPath, { throwOnFailure: true });
1467
+ ], schemaDir, { throwOnFailure: true });
1543
1468
  out(chalk.gray(" ✓ Migration directory checksum updated successfully."));
1544
1469
  }
1545
1470
  }, async () => {
@@ -1547,7 +1472,7 @@ async function dbCommand(subcommand, rawArgs) {
1547
1472
  "hash",
1548
1473
  "--dir",
1549
1474
  "file://drizzle/migrations"
1550
- ], collectionsPath, { throwOnFailure: true });
1475
+ ], schemaDir, { throwOnFailure: true });
1551
1476
  });
1552
1477
  if (!finished.ok) {
1553
1478
  outError(chalk.red(`\n ✗ Could not finish ${newestSql}: ${finished.error}`));
@@ -1575,7 +1500,7 @@ async function dbCommand(subcommand, rawArgs) {
1575
1500
  out("");
1576
1501
  if (subcommand === "push") {
1577
1502
  const dryRun = argsList["--dry-run"] === true;
1578
- out(chalk.gray(dryRun ? " Step 1/3: Generating the Postgres DDL from collections (the plan's input)..." : " Step 1/3: Generating Drizzle schema & Postgres DDL from collections..."));
1503
+ out(chalk.gray(dryRun ? " Step 1/3: Generating the Postgres DDL from backend/schema (the plan's input)..." : " Step 1/3: Generating Drizzle schema & Postgres DDL from backend/schema..."));
1579
1504
  out("");
1580
1505
  if (dryRun) out(chalk.gray(" --dry-run: src/schema.generated.ts is left as it is."));
1581
1506
  else await schemaCommand("generate", rawArgs, { nextStep: false });
@@ -1585,23 +1510,23 @@ async function dbCommand(subcommand, rawArgs) {
1585
1510
  out("");
1586
1511
  const databaseUrl = process.env.DATABASE_URL;
1587
1512
  if (databaseUrl && !dryRun) await ensureAuthSchemaAndFunctions(databaseUrl);
1588
- if (databaseUrl) await renameLegacyForeignKeys(databaseUrl, collectionsPath, dryRun);
1589
- if (databaseUrl) await adoptIdenticalIndexes(databaseUrl, collectionsPath, dryRun);
1590
- const prebuilt = databaseUrl ? await prebuildForeignKeyIndexes(databaseUrl, collectionsPath, dryRun) : [];
1591
- if (databaseUrl) await keepDatabaseOwnedDefaults(databaseUrl, collectionsPath);
1513
+ if (databaseUrl) await renameLegacyForeignKeys(databaseUrl, schemaDir, dryRun);
1514
+ if (databaseUrl) await adoptIdenticalIndexes(databaseUrl, schemaDir, dryRun);
1515
+ const prebuilt = databaseUrl ? await prebuildForeignKeyIndexes(databaseUrl, schemaDir, dryRun) : [];
1516
+ if (databaseUrl) await keepDatabaseOwnedDefaults(databaseUrl, schemaDir);
1592
1517
  const plan = await runAtlas("schema", [
1593
1518
  "apply",
1594
1519
  "--to",
1595
1520
  DESIRED_STATE_URL,
1596
1521
  "--dry-run"
1597
- ], collectionsPath, { captureStdout: true });
1522
+ ], schemaDir, { captureStdout: true });
1598
1523
  const destructive = detectDestructiveStatements(plan, databaseUrl ? await queryColumnTypes(databaseUrl) : [], databaseUrl ? await queryUndeclarableConstraints(databaseUrl) : []);
1599
1524
  const unreadable = destructive.some((d) => d.kind === "UNREADABLE PLAN");
1600
1525
  const planStatements = extractPlanStatements(plan);
1601
1526
  const planListing = unreadable ? plan.trim() : planStatements.map((statement) => `${statement};`).join("\n");
1602
- const { managed: rebuildable, foreign: unowned } = partitionByOwnership(databaseUrl ? findGeneratedColumnConflicts(parseColumnMutations(plan), await queryGeneratedColumnDependencies(databaseUrl)) : [], collectionsPath ? await getSearchExcludes(collectionsPath) : []);
1603
- if (databaseUrl) await reportKeptEnumLabels(databaseUrl, collectionsPath);
1604
- const policyPlan = databaseUrl ? await readPolicyPushPlan(databaseUrl, collectionsPath) : void 0;
1527
+ const { managed: rebuildable, foreign: unowned } = partitionByOwnership(databaseUrl ? findGeneratedColumnConflicts(parseColumnMutations(plan), await queryGeneratedColumnDependencies(databaseUrl)) : [], schemaDir ? await getSearchExcludes(schemaDir) : []);
1528
+ if (databaseUrl) await reportKeptEnumLabels(databaseUrl, schemaDir);
1529
+ const policyPlan = databaseUrl ? await readPolicyPushPlan(databaseUrl, schemaDir) : void 0;
1605
1530
  const policyLines = policyPlan ?? {
1606
1531
  changes: [],
1607
1532
  notes: []
@@ -1622,7 +1547,7 @@ async function dbCommand(subcommand, rawArgs) {
1622
1547
  out("");
1623
1548
  }
1624
1549
  if (!schemaChanges && !rlsHeading) {
1625
- out(chalk.green(policyPlan ? " ✓ No changes: the database already matches these collections." : " ✓ No schema changes: the tables already match these collections."));
1550
+ out(chalk.green(policyPlan ? " ✓ No changes: the database already matches these tables." : " ✓ No schema changes: the tables already match backend/schema."));
1626
1551
  out("");
1627
1552
  }
1628
1553
  if (databaseUrl && !policyPlan) {
@@ -1712,7 +1637,7 @@ async function dbCommand(subcommand, rawArgs) {
1712
1637
  "--to",
1713
1638
  DESIRED_STATE_URL,
1714
1639
  "--auto-approve"
1715
- ], collectionsPath, {
1640
+ ], schemaDir, {
1716
1641
  throwOnFailure: true,
1717
1642
  omitPlanEcho: true
1718
1643
  });
@@ -1729,16 +1654,17 @@ async function dbCommand(subcommand, rawArgs) {
1729
1654
  outWarn(chalk.yellow(" ⚠️ DATABASE_URL not found in environment, skipping RLS policies application."));
1730
1655
  return;
1731
1656
  }
1732
- await lockManagedTables(databaseUrl, collectionsPath);
1733
- await ensureAuthTables(databaseUrl, collectionsPath);
1657
+ await lockManagedTables(databaseUrl, schemaDir);
1658
+ await ensureAuthTables(databaseUrl, schemaDir);
1734
1659
  await applyVectorDdl(databaseUrl);
1735
1660
  await applySearchDdl(databaseUrl);
1736
1661
  await applyTriggersDdl(databaseUrl);
1737
1662
  await applyViewsDdl(databaseUrl);
1738
1663
  await ensureRlsUserRole(databaseUrl);
1739
- await applyPolicies(databaseUrl, collectionsPath);
1740
- await reconcilePolicies(databaseUrl, collectionsPath);
1664
+ await applyPolicies(databaseUrl, schemaDir);
1665
+ await reconcilePolicies(databaseUrl, schemaDir);
1741
1666
  await retireLegacyAuthSchema(databaseUrl);
1667
+ await stampSchemaVersion(databaseUrl, schemaDir);
1742
1668
  }
1743
1669
  });
1744
1670
  } else if (subcommand === "migrate") {
@@ -1754,7 +1680,7 @@ async function dbCommand(subcommand, rawArgs) {
1754
1680
  const baselinePlan = baseline ? planBaseline(baseline, databaseUrl ? await latestRecordedMigration(databaseUrl) : null) : null;
1755
1681
  const atlasBaseline = baselinePlan?.kind === "atlas-baseline" ? baseline : void 0;
1756
1682
  if (argsList["--refuse-destructive"] === true) {
1757
- const plan = await runAtlas("migrate", [...migrateApplyArgs(argsList._, atlasBaseline), "--dry-run"], collectionsPath, { captureStdout: true });
1683
+ const plan = await runAtlas("migrate", [...migrateApplyArgs(argsList._, atlasBaseline), "--dry-run"], schemaDir, { captureStdout: true });
1758
1684
  const destructive = detectDestructiveStatements(plan, await columnTypesOrNone(databaseUrl), await constraintsOrNone(databaseUrl));
1759
1685
  if (destructive.length > 0) {
1760
1686
  outError(chalk.red(` ✗ Refusing to migrate: the pending migrations include ${destructive.length} destructive change(s):`));
@@ -1770,7 +1696,7 @@ async function dbCommand(subcommand, rawArgs) {
1770
1696
  }
1771
1697
  if (databaseUrl) {
1772
1698
  await ensureAuthSchemaAndFunctions(databaseUrl);
1773
- if (collectionsPath) await adoptIdenticalIndexes(databaseUrl, collectionsPath, false);
1699
+ if (schemaDir) await adoptIdenticalIndexes(databaseUrl, schemaDir, false);
1774
1700
  }
1775
1701
  if (baseline && baselinePlan) {
1776
1702
  out(chalk.gray(` ${describeBaselinePlan(baseline, baselinePlan)}`));
@@ -1780,17 +1706,17 @@ async function dbCommand(subcommand, rawArgs) {
1780
1706
  baseline,
1781
1707
  "--dir",
1782
1708
  "file://drizzle/migrations"
1783
- ], collectionsPath);
1709
+ ], schemaDir);
1784
1710
  }
1785
- await runAtlas("migrate", migrateApplyArgs(argsList._, atlasBaseline), collectionsPath);
1711
+ await runAtlas("migrate", migrateApplyArgs(argsList._, atlasBaseline), schemaDir);
1786
1712
  if (databaseUrl) {
1787
1713
  await ensureRlsUserRole(databaseUrl);
1788
1714
  await retireLegacyAuthSchema(databaseUrl);
1789
1715
  const adminRoleAvailable = await readAdminPoliciesLive(databaseUrl);
1790
- if (!adminRoleAvailable) await moveAdminPoliciesToPublic(databaseUrl, collectionsPath);
1791
- await dropStaleCompanions(databaseUrl, collectionsPath, adminRoleAvailable);
1792
- const { stampMigratedPolicies } = await import("./migrate-policy-stamps-BN_Qad6c.js");
1793
- await stampMigratedPolicies(databaseUrl, collectionsPath, adminRoleAvailable);
1716
+ if (!adminRoleAvailable) await moveAdminPoliciesToPublic(databaseUrl, schemaDir);
1717
+ await dropStaleCompanions(databaseUrl, schemaDir, adminRoleAvailable);
1718
+ const { stampMigratedPolicies } = await import("./migrate-policy-stamps-B_acrUQB.js");
1719
+ await stampMigratedPolicies(databaseUrl, schemaDir, adminRoleAvailable);
1794
1720
  }
1795
1721
  }
1796
1722
  out("");
@@ -1816,10 +1742,10 @@ async function dbCommand(subcommand, rawArgs) {
1816
1742
  * says "no DEFAULT", and the push would drop each of them. A project declaring
1817
1743
  * no such column reads nothing.
1818
1744
  */
1819
- async function keepDatabaseOwnedDefaults(databaseUrl, collectionsPath) {
1820
- const { loadCollections } = await import("./doctor-Kg1oUK0Q.js").then((n) => n.t);
1821
- const { databaseOwnedDefaultColumns, readKeptDefaults, withKeptDefaults } = await import("./push-kept-defaults-CLcgsEPt.js");
1822
- const columns = databaseOwnedDefaultColumns(await loadCollections(path.resolve(process.cwd(), collectionsPath)));
1745
+ async function keepDatabaseOwnedDefaults(databaseUrl, schemaDir) {
1746
+ const { loadTables } = await import("./load-tables-B1Re74ng.js").then((n) => n.i);
1747
+ const { databaseOwnedDefaultColumns, readKeptDefaults, withKeptDefaults } = await import("./push-kept-defaults-Bst4MDup.js");
1748
+ const columns = databaseOwnedDefaultColumns(await loadTables(schemaDir));
1823
1749
  if (columns.length === 0) return;
1824
1750
  let kept;
1825
1751
  try {
@@ -1840,13 +1766,13 @@ async function keepDatabaseOwnedDefaults(databaseUrl, collectionsPath) {
1840
1766
  out("");
1841
1767
  }
1842
1768
  /** Renames relation columns that carry their pre-0.13 derived name, as boot does; a dry-run only names them. */
1843
- async function renameLegacyForeignKeys(databaseUrl, collectionsPath, dryRun) {
1769
+ async function renameLegacyForeignKeys(databaseUrl, schemaDir, dryRun) {
1844
1770
  let renames;
1845
1771
  try {
1846
- const { loadCollections } = await import("./doctor-Kg1oUK0Q.js").then((n) => n.t);
1847
- const { legacyForeignKeyRenames } = await import("./push-legacy-renames-BthD0E9W.js");
1848
- const collections = await loadCollections(path.resolve(process.cwd(), collectionsPath));
1849
- renames = await withAppClient(databaseUrl, (client) => legacyForeignKeyRenames({ query: async (text) => ({ rows: (await client.query(text)).rows }) }, collections));
1772
+ const { loadTables } = await import("./load-tables-B1Re74ng.js").then((n) => n.i);
1773
+ const { legacyForeignKeyRenames } = await import("./push-legacy-renames-bB4bM6br.js");
1774
+ const tables = await loadTables(schemaDir);
1775
+ renames = await withAppClient(databaseUrl, (client) => legacyForeignKeyRenames({ query: async (text) => ({ rows: (await client.query(text)).rows }) }, tables));
1850
1776
  } catch {
1851
1777
  return;
1852
1778
  }
@@ -1861,13 +1787,13 @@ async function renameLegacyForeignKeys(databaseUrl, collectionsPath, dryRun) {
1861
1787
  out("");
1862
1788
  }
1863
1789
  /** Renames identical existing indexes to the declared ones' names, as boot does; a dry-run only names them. */
1864
- async function adoptIdenticalIndexes(databaseUrl, collectionsPath, dryRun) {
1790
+ async function adoptIdenticalIndexes(databaseUrl, schemaDir, dryRun) {
1865
1791
  let adoptions;
1866
1792
  try {
1867
- const { loadCollections } = await import("./doctor-Kg1oUK0Q.js").then((n) => n.t);
1868
- const { pushIndexAdoptions } = await import("./push-index-adoption-Cp7oZxSl.js");
1869
- const collections = await loadCollections(path.resolve(process.cwd(), collectionsPath));
1870
- adoptions = await withAppClient(databaseUrl, (client) => pushIndexAdoptions({ query: async (text) => ({ rows: (await client.query(text)).rows }) }, collections));
1793
+ const { loadTables } = await import("./load-tables-B1Re74ng.js").then((n) => n.i);
1794
+ const { pushIndexAdoptions } = await import("./push-index-adoption-hpHTyXMR.js");
1795
+ const tables = await loadTables(schemaDir);
1796
+ adoptions = await withAppClient(databaseUrl, (client) => pushIndexAdoptions({ query: async (text) => ({ rows: (await client.query(text)).rows }) }, tables));
1871
1797
  } catch {
1872
1798
  return;
1873
1799
  }
@@ -1880,23 +1806,23 @@ async function adoptIdenticalIndexes(databaseUrl, collectionsPath, dryRun) {
1880
1806
  });
1881
1807
  out("");
1882
1808
  }
1883
- /** Names the enum labels the database keeps after the collections dropped them. See `schema/enum-labels-kept.ts`. */
1884
- async function reportKeptEnumLabels(databaseUrl, collectionsPath) {
1809
+ /** Names the enum labels the database keeps after the tables dropped them. See `schema/enum-labels-kept.ts`. */
1810
+ async function reportKeptEnumLabels(databaseUrl, schemaDir) {
1885
1811
  try {
1886
- const { loadCollections } = await import("./doctor-Kg1oUK0Q.js").then((n) => n.t);
1887
- const { keptEnumLabels, formatKeptEnumLabelsNotice } = await import("./enum-labels-kept-YAgOZS4I.js");
1888
- const collections = await loadCollections(path.resolve(process.cwd(), collectionsPath));
1889
- const kept = await withAppClient(databaseUrl, (client) => keptEnumLabels({ query: async (text) => ({ rows: (await client.query(text)).rows }) }, collections));
1812
+ const { loadTables } = await import("./load-tables-B1Re74ng.js").then((n) => n.i);
1813
+ const { keptEnumLabels, formatKeptEnumLabelsNotice } = await import("./enum-labels-kept-FlX9SHdf.js");
1814
+ const tables = await loadTables(schemaDir);
1815
+ const kept = await withAppClient(databaseUrl, (client) => keptEnumLabels({ query: async (text) => ({ rows: (await client.query(text)).rows }) }, tables));
1890
1816
  if (kept.length > 0) outWarn(chalk.yellow(formatKeptEnumLabelsNotice(kept)));
1891
1817
  } catch {}
1892
1818
  }
1893
- async function prebuildForeignKeyIndexes(databaseUrl, collectionsPath, dryRun) {
1819
+ async function prebuildForeignKeyIndexes(databaseUrl, schemaDir, dryRun) {
1894
1820
  let missing;
1895
1821
  try {
1896
- const { loadCollections } = await import("./doctor-Kg1oUK0Q.js").then((n) => n.t);
1897
- const { missingForeignKeyIndexes } = await import("./push-index-prebuild-DbwKGtQT.js");
1898
- const collections = await loadCollections(path.resolve(process.cwd(), collectionsPath));
1899
- missing = await withAppClient(databaseUrl, (client) => missingForeignKeyIndexes({ query: async (text) => ({ rows: (await client.query(text)).rows }) }, collections));
1822
+ const { loadTables } = await import("./load-tables-B1Re74ng.js").then((n) => n.i);
1823
+ const { missingForeignKeyIndexes } = await import("./push-index-prebuild-Bty9F7bD.js");
1824
+ const tables = await loadTables(schemaDir);
1825
+ missing = await withAppClient(databaseUrl, (client) => missingForeignKeyIndexes({ query: async (text) => ({ rows: (await client.query(text)).rows }) }, tables));
1900
1826
  } catch {
1901
1827
  return [];
1902
1828
  }
@@ -1904,7 +1830,7 @@ async function prebuildForeignKeyIndexes(databaseUrl, collectionsPath, dryRun) {
1904
1830
  if (missing.length === 0 || dryRun) return names;
1905
1831
  out(chalk.gray(` Building ${missing.length} foreign-key index(es) on existing tables first — CONCURRENTLY, so writes go on:`));
1906
1832
  try {
1907
- const { buildDeferredIndexes } = await import("./deferred-index-build-BCU9RoHK.js").then((n) => n.r);
1833
+ const { buildDeferredIndexes } = await import("./deferred-index-build-CcSDA7wE.js").then((n) => n.r);
1908
1834
  const outcome = await withAppClient(databaseUrl, (client) => buildDeferredIndexes(async () => ({
1909
1835
  dedicated: true,
1910
1836
  query: async (text) => ({ rows: (await client.query(text)).rows }),
@@ -1931,7 +1857,7 @@ async function ensureAuthSchemaAndFunctions(databaseUrl) {
1931
1857
  }
1932
1858
  }
1933
1859
  /**
1934
- * Switch row-level security on for every table the collections declare, right
1860
+ * Switch row-level security on for every table backend/schema declares, right
1935
1861
  * after Atlas has applied the schema.
1936
1862
  *
1937
1863
  * Atlas cannot carry `ENABLE ROW LEVEL SECURITY` in `schema.sql`: its free tier
@@ -1948,26 +1874,26 @@ async function ensureAuthSchemaAndFunctions(databaseUrl) {
1948
1874
  * role provisioning at the end re-grants on every table in the schema, which
1949
1875
  * would undo the revoke that is the fallback here.
1950
1876
  */
1951
- async function lockManagedTables(databaseUrl, collectionsPath) {
1877
+ async function lockManagedTables(databaseUrl, schemaDir) {
1952
1878
  let unsecured;
1953
1879
  let userRole;
1954
1880
  try {
1955
- const { lockCollectionTables } = await import("./ensure-collection-policies-Bo-_fDAy.js");
1956
- const { loadCollections } = await import("./doctor-Kg1oUK0Q.js").then((n) => n.t);
1957
- const { readRecordedRequestRoles } = await import("./rls-enforcement-Cc_UhOxb.js").then((n) => n.y);
1958
- const { cliRlsSettings } = await import("./rls-settings-BCGMIig3.js").then((n) => n.a);
1959
- const collections = await loadCollections(path.resolve(process.cwd(), collectionsPath));
1881
+ const { lockTables } = await import("./ensure-policies-rRmXb5bt.js");
1882
+ const { loadTables } = await import("./load-tables-B1Re74ng.js").then((n) => n.i);
1883
+ const { readRecordedRequestRoles } = await import("./rls-enforcement-DB5HHj96.js").then((n) => n.y);
1884
+ const { cliRlsSettings } = await import("./rls-settings-CmGK2U0a.js").then((n) => n.a);
1885
+ const tables = await loadTables(schemaDir);
1960
1886
  ({unsecured, userRole} = await withAppClient(databaseUrl, async (client) => {
1961
1887
  const runSql = async (text) => (await client.query(text)).rows;
1962
1888
  const roles = cliRlsSettings(await readRecordedRequestRoles(runSql)).roles;
1963
1889
  return {
1964
- unsecured: (await lockCollectionTables({ query: async (text) => ({ rows: (await client.query(text)).rows }) }, collections)).unsecured,
1890
+ unsecured: (await lockTables({ query: async (text) => ({ rows: (await client.query(text)).rows }) }, tables)).unsecured,
1965
1891
  userRole: roles.join(", ")
1966
1892
  };
1967
1893
  }));
1968
1894
  } catch (err) {
1969
1895
  outError(chalk.red(`\n ✗ The schema was applied, but row-level security could not be switched on for its tables: ${err instanceof Error ? err.message : String(err)}`));
1970
- outError(chalk.gray(" A table this push created may be readable and writable by every authenticated request\n until it is. Re-run `rebase db push` — it locks every collection table before anything else."));
1896
+ outError(chalk.gray(" A table this push created may be readable and writable by every authenticated request\n until it is. Re-run `rebase db push` — it locks every declared table before anything else."));
1971
1897
  process.exit(1);
1972
1898
  }
1973
1899
  if (unsecured.length === 0) return;
@@ -1994,16 +1920,35 @@ async function lockManagedTables(databaseUrl, collectionsPath) {
1994
1920
  * `ensureAuthTablesExist` is idempotent (CREATE TABLE IF NOT EXISTS), so it is
1995
1921
  * safe to run on every push and harmless once the server has also created them.
1996
1922
  */
1997
- async function ensureAuthTables(databaseUrl, collectionsPath) {
1923
+ /**
1924
+ * Record the schema version this push applied, as a provisioning boot does
1925
+ * (`rebase.schema_meta`, key `collections_schema_version`), computed the way
1926
+ * the server computes it (`defaultDatabaseSchemaVersion`). Without it a
1927
+ * database a push provisioned read as unstamped to every process, and one a
1928
+ * pre-0.31 runtime stamped kept its `v1:` version, which every boot reports
1929
+ * as a mismatch — the restamp the server's message tells the operator to do
1930
+ * with `rebase db push`. Never fatal: the stamp is a diagnostic.
1931
+ */
1932
+ async function stampSchemaVersion(databaseUrl, schemaDir) {
1998
1933
  try {
1999
1934
  const { drizzle } = await import("drizzle-orm/node-postgres");
2000
- const { ensureAuthTablesExist } = await import("./ensure-tables-BPGaGh0y.js").then((n) => n.n);
2001
- const { loadCollections } = await import("./doctor-Kg1oUK0Q.js").then((n) => n.t);
2002
- const authCollection = (await loadCollections(path.resolve(process.cwd(), collectionsPath))).find((c) => {
2003
- const a = c.auth;
2004
- return a === true || typeof a === "object" && a !== null && a.enabled === true;
2005
- });
2006
- await withAppClient(databaseUrl, (client) => ensureAuthTablesExist(drizzle(client), authCollection));
1935
+ const { defaultDatabaseSchemaVersion, loadTableSchema } = await import("./load-tables-B1Re74ng.js").then((n) => n.i);
1936
+ const { stampTablesSchemaVersion, SCHEMA_META_SCHEMA } = await import("./tables-schema-version-YvZIBlOP.js");
1937
+ const version = defaultDatabaseSchemaVersion(await loadTableSchema(schemaDir));
1938
+ await withAppClient(databaseUrl, (client) => stampTablesSchemaVersion(drizzle(client), SCHEMA_META_SCHEMA, version));
1939
+ out(chalk.gray(` ✓ Stamped the schema version (${version}), so every process can check itself against this database.`));
1940
+ } catch (err) {
1941
+ outWarn(chalk.yellow(` ⚠️ Could not record the schema version: ${err instanceof Error ? err.message : String(err)}`));
1942
+ }
1943
+ }
1944
+ async function ensureAuthTables(databaseUrl, schemaDir) {
1945
+ try {
1946
+ const { drizzle } = await import("drizzle-orm/node-postgres");
1947
+ const { ensureAuthTablesExist } = await import("./ensure-tables-CC8p_AK3.js").then((n) => n.n);
1948
+ const { loadTableSchema } = await import("./load-tables-B1Re74ng.js").then((n) => n.i);
1949
+ const { descriptors } = await loadTableSchema(schemaDir);
1950
+ const authTable = descriptors.find((descriptor) => descriptor.auth !== void 0);
1951
+ await withAppClient(databaseUrl, (client) => ensureAuthTablesExist(drizzle(client), authTable));
2007
1952
  } catch (err) {
2008
1953
  outWarn(chalk.yellow(` ⚠️ Failed to ensure framework auth tables: ${err instanceof Error ? err.message : String(err)}`));
2009
1954
  }
@@ -2018,7 +1963,7 @@ async function ensureRlsUserRole(databaseUrl) {
2018
1963
  const schemas = ["public", "rebase"];
2019
1964
  let rls;
2020
1965
  try {
2021
- rls = await import("./rls-enforcement-Cc_UhOxb.js").then((n) => n.y);
1966
+ rls = await import("./rls-enforcement-DB5HHj96.js").then((n) => n.y);
2022
1967
  } catch (err) {
2023
1968
  outError(chalk.red(`\n ✗ Could not load the RLS provisioning module: ${err instanceof Error ? err.message : String(err)}`));
2024
1969
  return;
@@ -2032,7 +1977,7 @@ async function ensureRlsUserRole(databaseUrl) {
2032
1977
  connectionRole = posture.role;
2033
1978
  if (posture.privileged) {
2034
1979
  const recorded = await rls.readRecordedRequestRoles(runSql);
2035
- settings = (await import("./rls-settings-BCGMIig3.js").then((n) => n.a)).cliRlsSettings(recorded);
1980
+ settings = (await import("./rls-settings-CmGK2U0a.js").then((n) => n.a)).cliRlsSettings(recorded);
2036
1981
  rls.assertRecordedRequestRoles(settings.roles, recorded, await rls.roleHoldsTableGrants(runSql, schemas));
2037
1982
  if (recorded ? recorded.join(",") !== settings.roles.join(",") : settings.roles.join(",") !== rls.REBASE_USER_ROLE) await rls.recordRequestRoles(runSql, settings.roles);
2038
1983
  for (const role of settings.roles) await rls.ensureAppRole(runSql, schemas, {
@@ -2067,7 +2012,7 @@ async function retireLegacyAuthSchema(databaseUrl) {
2067
2012
  }));
2068
2013
  } catch {}
2069
2014
  }
2070
- async function applyPolicies(databaseUrl, collectionsPath) {
2015
+ async function applyPolicies(databaseUrl, schemaDir) {
2071
2016
  try {
2072
2017
  const policiesPath = path.join(generatedSqlDir(), "policies.sql");
2073
2018
  if (!fs.existsSync(policiesPath)) return;
@@ -2077,9 +2022,9 @@ async function applyPolicies(databaseUrl, collectionsPath) {
2077
2022
  const adminRoleAvailable = policiesContent.includes(`"${REBASE_ADMIN_ROLE}"`) ? await readAdminPoliciesLive(databaseUrl) : true;
2078
2023
  if (!adminRoleAvailable) {
2079
2024
  out(chalk.gray(` The server-or-admin policies are written TO public: the admin request roles are not set up for this database (\`rebase doctor --database\` says what is missing). A server boot that sets them up moves them TO ${REBASE_ADMIN_ROLE}.`));
2080
- policiesContent = (await policiesToPublic(collectionsPath, policiesContent)).split(`${ADMIN_POLICY_ROLE_SQL};`).join("");
2025
+ policiesContent = (await policiesToPublic(schemaDir, policiesContent)).split(`${ADMIN_POLICY_ROLE_SQL};`).join("");
2081
2026
  }
2082
- const stamping = await policyStamping(databaseUrl, collectionsPath, policiesContent, adminRoleAvailable);
2027
+ const stamping = await policyStamping(databaseUrl, schemaDir, policiesContent, adminRoleAvailable);
2083
2028
  const { stampError } = await withAppClient(databaseUrl, (client) => applyPoliciesFile(client, policiesContent, stamping));
2084
2029
  out(chalk.green(" ✓ RLS policies applied successfully."));
2085
2030
  if (stampError) outWarn(chalk.yellow(` ⚠️ The policies could not be stamped (${stampError}); the next boot applies them again.`));
@@ -2102,7 +2047,7 @@ async function applyPolicies(databaseUrl, collectionsPath) {
2102
2047
  */
2103
2048
  async function readAdminPoliciesLive(databaseUrl) {
2104
2049
  try {
2105
- const { adminPoliciesLiveForCli } = await import("./rls-enforcement-Cc_UhOxb.js").then((n) => n.y);
2050
+ const { adminPoliciesLiveForCli } = await import("./rls-enforcement-DB5HHj96.js").then((n) => n.y);
2106
2051
  return await withAppClient(databaseUrl, (client) => adminPoliciesLiveForCli(async (text) => (await client.query(text)).rows));
2107
2052
  } catch {
2108
2053
  return false;
@@ -2114,12 +2059,12 @@ async function readAdminPoliciesLive(databaseUrl) {
2114
2059
  * admits every admin to every row, and a boot without provisioning never
2115
2060
  * takes it back.
2116
2061
  */
2117
- async function dropStaleCompanions(databaseUrl, collectionsPath, adminRoleAvailable) {
2118
- const { loadCollections } = await import("./doctor-Kg1oUK0Q.js").then((n) => n.t);
2119
- const { dropStaleAdminRequestCompanions } = await import("./policy-drift-C-m0uWHH.js").then((n) => n.s);
2120
- const collections = await loadCollections(path.resolve(process.cwd(), collectionsPath));
2062
+ async function dropStaleCompanions(databaseUrl, schemaDir, adminRoleAvailable) {
2063
+ const { loadTables } = await import("./load-tables-B1Re74ng.js").then((n) => n.i);
2064
+ const { dropStaleAdminRequestCompanions } = await import("./policy-drift-BVMyqHSa.js").then((n) => n.s);
2065
+ const tables = await loadTables(schemaDir);
2121
2066
  try {
2122
- const dropped = await withAppClient(databaseUrl, (client) => dropStaleAdminRequestCompanions(client, collections, { adminRoleAvailable }));
2067
+ const dropped = await withAppClient(databaseUrl, (client) => dropStaleAdminRequestCompanions(client, tables, { adminRoleAvailable }));
2123
2068
  for (const p of dropped) out(chalk.gray(` ✓ Dropped stale admin-request policy "${p.name}" on ${p.schema}.${p.table}`));
2124
2069
  } catch (err) {
2125
2070
  outError(chalk.red(` ✗ Could not drop stale admin-request policies: ${err instanceof Error ? err.message : String(err)}`));
@@ -2133,12 +2078,12 @@ async function dropStaleCompanions(databaseUrl, collectionsPath, adminRoleAvaila
2133
2078
  * them on a push. Fatal when it fails — those policies refuse every admin
2134
2079
  * caller, and a boot without provisioning would leave them so.
2135
2080
  */
2136
- async function moveAdminPoliciesToPublic(databaseUrl, collectionsPath) {
2137
- const { loadCollections } = await import("./doctor-Kg1oUK0Q.js").then((n) => n.t);
2138
- const { moveMigratedAdminPoliciesToPublic } = await import("./migrate-policy-stamps-BN_Qad6c.js");
2139
- const collections = await loadCollections(path.resolve(process.cwd(), collectionsPath));
2081
+ async function moveAdminPoliciesToPublic(databaseUrl, schemaDir) {
2082
+ const { loadTables } = await import("./load-tables-B1Re74ng.js").then((n) => n.i);
2083
+ const { moveMigratedAdminPoliciesToPublic } = await import("./migrate-policy-stamps-B_acrUQB.js");
2084
+ const tables = await loadTables(schemaDir);
2140
2085
  try {
2141
- if (await withAppClient(databaseUrl, (client) => moveMigratedAdminPoliciesToPublic({ query: async (text, values) => ({ rows: (await client.query(text, values)).rows }) }, collections, (message) => outWarn(chalk.yellow(` ⚠️ ${message}`)))) > 0) out(chalk.gray(` The server-or-admin policies are written TO public: the admin request roles are not set up for this database (\`rebase doctor --database\` says what is missing). A server boot that sets them up moves them TO ${REBASE_ADMIN_ROLE}.`));
2086
+ if (await withAppClient(databaseUrl, (client) => moveMigratedAdminPoliciesToPublic({ query: async (text, values) => ({ rows: (await client.query(text, values)).rows }) }, tables, (message) => outWarn(chalk.yellow(` ⚠️ ${message}`)))) > 0) out(chalk.gray(` The server-or-admin policies are written TO public: the admin request roles are not set up for this database (\`rebase doctor --database\` says what is missing). A server boot that sets them up moves them TO ${REBASE_ADMIN_ROLE}.`));
2142
2087
  } catch (err) {
2143
2088
  outError(chalk.red(` ✗ Could not write the server-or-admin policies TO public: ${err instanceof Error ? err.message : String(err)}`));
2144
2089
  outError(chalk.gray(` They are TO ${REBASE_ADMIN_ROLE}, which admin requests cannot use here, so admins read no rows. Run \`rebase db push\` or boot the server with provisioning on.`));
@@ -2147,7 +2092,7 @@ async function moveAdminPoliciesToPublic(databaseUrl, collectionsPath) {
2147
2092
  }
2148
2093
  /**
2149
2094
  * The stamps a boot looks for, for the policies `policies.sql` is about to
2150
- * create — see `applyPoliciesFile`. None when the collections cannot be read
2095
+ * create — see `applyPoliciesFile`. None when the tables cannot be read
2151
2096
  * here, which costs only the shortcut: the next boot re-applies, as before.
2152
2097
  */
2153
2098
  /**
@@ -2155,13 +2100,13 @@ async function moveAdminPoliciesToPublic(databaseUrl, collectionsPath) {
2155
2100
  * rewritten `TO public` — statement for statement, from the two plans, so a
2156
2101
  * rule that names `rebase_admin` itself is left exactly as written.
2157
2102
  */
2158
- async function policiesToPublic(collectionsPath, policiesSql) {
2159
- const { loadCollections } = await import("./doctor-Kg1oUK0Q.js").then((n) => n.t);
2160
- const { planCollectionPolicies } = await import("./generate-postgres-ddl-logic-Dg0bcENZ.js").then((n) => n.s);
2161
- const collections = await loadCollections(path.resolve(process.cwd(), collectionsPath));
2162
- const fallback = new Map(planCollectionPolicies(collections, { adminRoleAvailable: false }).flatMap((plan) => plan.policies.map((policy) => [`${plan.qualified}.${policy.name}`, policy.statements])));
2103
+ async function policiesToPublic(schemaDir, policiesSql) {
2104
+ const { loadTables } = await import("./load-tables-B1Re74ng.js").then((n) => n.i);
2105
+ const { planTablePolicies } = await import("./generate-postgres-ddl-logic-B8huc03c.js").then((n) => n.s);
2106
+ const tables = await loadTables(schemaDir);
2107
+ const fallback = new Map(planTablePolicies(tables, { adminRoleAvailable: false }).flatMap((plan) => plan.policies.map((policy) => [`${plan.qualified}.${policy.name}`, policy.statements])));
2163
2108
  let sql = policiesSql;
2164
- for (const plan of planCollectionPolicies(collections)) for (const policy of plan.policies) {
2109
+ for (const plan of planTablePolicies(tables)) for (const policy of plan.policies) {
2165
2110
  if (!policy.adminTarget) continue;
2166
2111
  const replacement = fallback.get(`${plan.qualified}.${policy.name}`) ?? [];
2167
2112
  policy.statements.forEach((statement, i) => {
@@ -2170,14 +2115,14 @@ async function policiesToPublic(collectionsPath, policiesSql) {
2170
2115
  }
2171
2116
  return sql;
2172
2117
  }
2173
- async function policyStamping(databaseUrl, collectionsPath, policiesSql, adminRoleAvailable = true) {
2118
+ async function policyStamping(databaseUrl, schemaDir, policiesSql, adminRoleAvailable = true) {
2174
2119
  try {
2175
- const { loadCollections } = await import("./doctor-Kg1oUK0Q.js").then((n) => n.t);
2176
- const { planCollectionPolicies } = await import("./generate-postgres-ddl-logic-Dg0bcENZ.js").then((n) => n.s);
2177
- const { policyStampSql } = await import("./ensure-collection-policies-Bo-_fDAy.js");
2120
+ const { loadTables } = await import("./load-tables-B1Re74ng.js").then((n) => n.i);
2121
+ const { planTablePolicies } = await import("./generate-postgres-ddl-logic-B8huc03c.js").then((n) => n.s);
2122
+ const { policyStampSql } = await import("./ensure-policies-rRmXb5bt.js");
2178
2123
  const { pinSearchPath } = await import("./connection-C1zXTPJq.js").then((n) => n.r);
2179
2124
  return {
2180
- statements: stampableTables(planCollectionPolicies(await loadCollections(path.resolve(process.cwd(), collectionsPath)), { adminRoleAvailable }), policiesSql).map((plan) => policyStampSql(plan)).filter((statement) => statement !== void 0),
2125
+ statements: stampableTables(planTablePolicies(await loadTables(schemaDir), { adminRoleAvailable }), policiesSql).map((plan) => policyStampSql(plan)).filter((statement) => statement !== void 0),
2181
2126
  searchPath: pinSearchPath(databaseUrl) === databaseUrl ? void 0 : "public"
2182
2127
  };
2183
2128
  } catch {
@@ -2185,19 +2130,19 @@ async function policyStamping(databaseUrl, collectionsPath, policiesSql, adminRo
2185
2130
  }
2186
2131
  }
2187
2132
  /**
2188
- * `planPolicyPush` for this database and these collections, read under the
2133
+ * `planPolicyPush` for this database and these tables, read under the
2189
2134
  * `search_path` the push stamps policies under, as the lines the dry run
2190
2135
  * prints and the one the push does; `undefined`, having said why, when it
2191
2136
  * cannot be read.
2192
2137
  */
2193
- async function readPolicyPushPlan(databaseUrl, collectionsPath) {
2138
+ async function readPolicyPushPlan(databaseUrl, schemaDir) {
2194
2139
  try {
2195
- const { formatPolicyPushPlan, planPolicyPush, summarizePolicyPushPlan } = await import("./push-policy-plan-BgcrroxQ.js");
2196
- const { loadCollections } = await import("./doctor-Kg1oUK0Q.js").then((n) => n.t);
2140
+ const { formatPolicyPushPlan, planPolicyPush, summarizePolicyPushPlan } = await import("./push-policy-plan-BI8U4BOD.js");
2141
+ const { loadTables } = await import("./load-tables-B1Re74ng.js").then((n) => n.i);
2197
2142
  const { pinSearchPath } = await import("./connection-C1zXTPJq.js").then((n) => n.r);
2198
- const collections = await loadCollections(path.resolve(process.cwd(), collectionsPath));
2143
+ const tables = await loadTables(schemaDir);
2199
2144
  const adminRoleAvailable = await readAdminPoliciesLive(databaseUrl);
2200
- const plan = await withAppClient(databaseUrl, (client) => planPolicyPush({ query: async (text, values) => ({ rows: (await client.query(text, values)).rows }) }, collections, {
2145
+ const plan = await withAppClient(databaseUrl, (client) => planPolicyPush({ query: async (text, values) => ({ rows: (await client.query(text, values)).rows }) }, tables, {
2201
2146
  searchPath: pinSearchPath(databaseUrl) === databaseUrl ? void 0 : "public",
2202
2147
  adminRoleAvailable
2203
2148
  }));
@@ -2223,21 +2168,21 @@ async function readPolicyPushPlan(databaseUrl, collectionsPath) {
2223
2168
  * drift check then sees exactly the set that should survive, and anything else
2224
2169
  * on a managed table is by definition left over.
2225
2170
  */
2226
- async function reconcilePolicies(databaseUrl, collectionsPath) {
2171
+ async function reconcilePolicies(databaseUrl, schemaDir) {
2227
2172
  try {
2228
- const { checkPolicyDrift, dropOrphanedPolicies, formatPolicyDrift, hasDrift } = await import("./policy-drift-C-m0uWHH.js").then((n) => n.s);
2229
- const { loadCollections } = await import("./doctor-Kg1oUK0Q.js").then((n) => n.t);
2230
- const collections = await loadCollections(path.resolve(process.cwd(), collectionsPath));
2173
+ const { checkPolicyDrift, dropOrphanedPolicies, formatPolicyDrift, hasDrift } = await import("./policy-drift-BVMyqHSa.js").then((n) => n.s);
2174
+ const { loadTables } = await import("./load-tables-B1Re74ng.js").then((n) => n.i);
2175
+ const tables = await loadTables(schemaDir);
2231
2176
  const adminRoleAvailable = await readAdminPoliciesLive(databaseUrl);
2232
2177
  await withAppClient(databaseUrl, async (client) => {
2233
- const drift = await checkPolicyDrift(client, collections, { adminRoleAvailable });
2234
- const { dropped, kept } = await dropOrphanedPolicies(client, drift, collections);
2178
+ const drift = await checkPolicyDrift(client, tables, { adminRoleAvailable });
2179
+ const { dropped, kept } = await dropOrphanedPolicies(client, drift, tables);
2235
2180
  for (const p of dropped) out(chalk.gray(` ✓ Dropped superseded policy "${p.name}" on ${p.schema}.${p.table}`));
2236
2181
  if (dropped.length > 0) out(chalk.green(` ✓ Removed ${dropped.length} superseded RLS ${dropped.length === 1 ? "policy" : "policies"}.`));
2237
2182
  if (kept.length > 0) {
2238
- outWarn(chalk.yellow(" ⚠️ Policies in the database that no collection describes:"));
2183
+ outWarn(chalk.yellow(" ⚠️ Policies in the database that no table describes:"));
2239
2184
  for (const p of kept) outWarn(chalk.yellow(` • ${p.schema}.${p.table} → "${p.name}" (${p.command} TO ${p.roles.join(", ")})`));
2240
- outWarn(chalk.yellow(" Each is still in force. To keep one, describe it in its collection's `securityRules`"));
2185
+ outWarn(chalk.yellow(" Each is still in force. To keep one, describe it in its table's `rls` (backend/schema)"));
2241
2186
  outWarn(chalk.yellow(" (Studio's RLS view imports it); if it is stale, drop it by hand."));
2242
2187
  }
2243
2188
  const remaining = {
@@ -2245,7 +2190,7 @@ async function reconcilePolicies(databaseUrl, collectionsPath) {
2245
2190
  orphaned: kept
2246
2191
  };
2247
2192
  if (hasDrift(remaining) && (remaining.missing.length > 0 || remaining.diverged.length > 0)) {
2248
- outWarn(chalk.yellow(" ⚠️ RLS policies do not match your collections:"));
2193
+ outWarn(chalk.yellow(" ⚠️ RLS policies do not match your tables:"));
2249
2194
  outWarn(formatPolicyDrift({
2250
2195
  ...remaining,
2251
2196
  orphaned: []
@@ -2313,7 +2258,7 @@ async function branchCommand(rawArgs) {
2313
2258
  process.exit(1);
2314
2259
  }
2315
2260
  const { DatabasePoolManager } = await import("./databasePoolManager-DIjzlTK4.js").then((n) => n.n);
2316
- const { BranchService, reopenClosedDatabases, reopenedDatabasesNotice } = await import("./BranchService-CrXvcES2.js").then((n) => n.n);
2261
+ const { BranchService, reopenClosedDatabases, reopenedDatabasesNotice } = await import("./BranchService-USp1AvZB.js").then((n) => n.n);
2317
2262
  const { drizzle } = await import("drizzle-orm/node-postgres");
2318
2263
  const { Pool } = await import("pg");
2319
2264
  const healed = await reopenClosedDatabases(databaseUrl, [branchAction === "create" ? createSource(rawArgs) : void 0, process.env[ACTIVE_BRANCH_DATABASE_ENV]]);
@@ -2616,7 +2561,7 @@ var scratchDatabase = new ScratchDatabase({
2616
2561
  create: ensureDevDatabaseExists,
2617
2562
  drop: dropDevDatabase
2618
2563
  });
2619
- async function runAtlas(domain, args, collectionsPath, opts = {}) {
2564
+ async function runAtlas(domain, args, schemaDir, opts = {}) {
2620
2565
  const atlasBin = resolveLocalBin("atlas");
2621
2566
  if (!atlasBin) {
2622
2567
  outError(chalk.red("\n✗ The atlas binary is missing, so the schema cannot be applied.\n"));
@@ -2680,12 +2625,12 @@ async function runAtlas(domain, args, collectionsPath, opts = {}) {
2680
2625
  const atlasUrl = forAtlas(databaseUrl);
2681
2626
  const atlasDevUrl = forAtlas(devDatabaseUrl);
2682
2627
  const excludes = [];
2683
- if (collectionsPath && acceptsExcludeFlag(domain, args)) {
2684
- excludes.push(...await getSearchExcludes(collectionsPath));
2685
- excludes.push(...await getVectorExcludes(collectionsPath));
2686
- excludes.push(...await getTriggerExcludes(collectionsPath));
2628
+ if (schemaDir && acceptsExcludeFlag(domain, args)) {
2629
+ excludes.push(...await getSearchExcludes(schemaDir));
2630
+ excludes.push(...await getVectorExcludes(schemaDir));
2631
+ excludes.push(...await getTriggerExcludes(schemaDir));
2687
2632
  try {
2688
- excludes.push(...await getTableExcludes(databaseUrl, collectionsPath));
2633
+ excludes.push(...await getTableExcludes(databaseUrl, schemaDir));
2689
2634
  } catch (err) {
2690
2635
  if (err instanceof ExcludeIntrospectionError) {
2691
2636
  outError(chalk.red("\n✗ Aborting push: could not determine which tables to protect."));
@@ -2698,7 +2643,7 @@ async function runAtlas(domain, args, collectionsPath, opts = {}) {
2698
2643
  throw err;
2699
2644
  }
2700
2645
  try {
2701
- excludes.push(...await getForeignIndexExcludes(databaseUrl, collectionsPath));
2646
+ excludes.push(...await getForeignIndexExcludes(databaseUrl, schemaDir));
2702
2647
  } catch (err) {
2703
2648
  if (err instanceof ExcludeIntrospectionError) {
2704
2649
  outError(chalk.red("\n✗ Aborting push: could not determine which indexes to protect."));
@@ -2779,9 +2724,8 @@ async function runAtlas(domain, args, collectionsPath, opts = {}) {
2779
2724
  }
2780
2725
  async function generatePostgresDdlCommand(rawArgs, options = {}) {
2781
2726
  const argsList = (0, import_arg.default)({
2782
- "--collections": String,
2727
+ "--schema-dir": String,
2783
2728
  "--output": String,
2784
- "-c": "--collections",
2785
2729
  "-o": "--output"
2786
2730
  }, {
2787
2731
  argv: rawArgs.slice(2),
@@ -2792,7 +2736,7 @@ async function generatePostgresDdlCommand(rawArgs, options = {}) {
2792
2736
  outError(chalk.red(childScriptError("DDL generator", ddl.reason)));
2793
2737
  process.exit(1);
2794
2738
  }
2795
- const collectionsPath = argsList["--collections"] || path.join("..", "config", "collections");
2739
+ const schemaDir = argsList["--schema-dir"] || "schema";
2796
2740
  const outputPath = argsList["--output"] || path.join(".rebase/sql", "schema.sql");
2797
2741
  if (!argsList["--output"]) {
2798
2742
  const retire = options.retireLegacyCopies !== false;
@@ -2803,7 +2747,7 @@ async function generatePostgresDdlCommand(rawArgs, options = {}) {
2803
2747
  if (!ddl) {
2804
2748
  await generateInProcess("Postgres DDL generator", "Postgres DDL", async ({ writePostgresDdl }) => {
2805
2749
  await writePostgresDdl({
2806
- collectionsPath: path.resolve(process.cwd(), collectionsPath),
2750
+ schemaDir: path.resolve(process.cwd(), schemaDir),
2807
2751
  outputPath: path.resolve(process.cwd(), outputPath)
2808
2752
  });
2809
2753
  });
@@ -2812,7 +2756,7 @@ async function generatePostgresDdlCommand(rawArgs, options = {}) {
2812
2756
  const cmdParts = [
2813
2757
  ddl.bin,
2814
2758
  ...ddl.args,
2815
- `--collections=${collectionsPath}`,
2759
+ `--schema-dir=${schemaDir}`,
2816
2760
  `--output=${outputPath}`
2817
2761
  ];
2818
2762
  try {
@@ -2845,34 +2789,31 @@ async function generatePostgresDdlCommand(rawArgs, options = {}) {
2845
2789
  */
2846
2790
  async function schemaStaleCommand(rawArgs) {
2847
2791
  const argsList = (0, import_arg.default)({
2848
- "--collections": String,
2792
+ "--schema-dir": String,
2849
2793
  "--output": String,
2850
2794
  "--fix": Boolean,
2851
- "-c": "--collections",
2852
2795
  "-o": "--output",
2853
2796
  "--out": "--output"
2854
2797
  }, {
2855
2798
  argv: rawArgs.slice(2),
2856
2799
  permissive: true
2857
2800
  });
2858
- const collectionsPath = argsList["--collections"] || path.join("..", "config", "collections");
2801
+ const schemaDir = argsList["--schema-dir"] || "schema";
2859
2802
  const outputPath = argsList["--output"] || path.join("src", "schema.generated.ts");
2860
2803
  const schemaFile = path.resolve(process.cwd(), outputPath);
2861
2804
  const fix = Boolean(argsList["--fix"]);
2862
2805
  const generatedExists = fs.existsSync(schemaFile);
2863
- const { loadCollections } = await import("./doctor-Kg1oUK0Q.js").then((n) => n.t);
2864
- const { findLegacyForeignKeyNames, compareGeneratedDeclarations, staleVerdict } = await import("./generated-schema-staleness-BvNF3i-s.js").then((n) => n.r);
2865
- const { generateSchema } = await import("./generate-drizzle-schema-logic-LTLZvt6r.js").then((n) => n.n);
2866
- const { relationalCollections } = await import("@rebasepro/common");
2806
+ const { loadTables } = await import("./load-tables-B1Re74ng.js").then((n) => n.i);
2807
+ const { findLegacyForeignKeyNames, compareGeneratedDeclarations, staleVerdict } = await import("./generated-schema-staleness-YBVq2kTn.js").then((n) => n.r);
2808
+ const { generateSchema } = await import("./generate-drizzle-schema-logic-DL7R1rAF.js").then((n) => n.n);
2867
2809
  let stale = [];
2868
2810
  let differences = [];
2869
2811
  let unreadable;
2870
2812
  if (generatedExists) try {
2871
- const collections = await loadCollections(path.resolve(process.cwd(), collectionsPath));
2813
+ const tables = await loadTables(schemaDir);
2872
2814
  const onDisk = fs.readFileSync(schemaFile, "utf8");
2873
- stale = findLegacyForeignKeyNames(onDisk, collections);
2874
- const postgresCollections = relationalCollections(collections);
2875
- if (postgresCollections.length > 0) differences = compareGeneratedDeclarations(generateSchema(postgresCollections), onDisk);
2815
+ stale = findLegacyForeignKeyNames(onDisk, tables.map((table) => table.descriptor));
2816
+ if (tables.length > 0) differences = compareGeneratedDeclarations(generateSchema(tables), onDisk);
2876
2817
  } catch (err) {
2877
2818
  unreadable = err instanceof Error ? err.message : String(err);
2878
2819
  const { logger } = await import("@rebasepro/server");
@@ -2896,7 +2837,7 @@ async function schemaStaleCommand(rawArgs) {
2896
2837
  await schemaCommand("generate", [
2897
2838
  "schema",
2898
2839
  "generate",
2899
- `--collections=${collectionsPath}`,
2840
+ `--schema-dir=${schemaDir}`,
2900
2841
  `--output=${outputPath}`
2901
2842
  ]);
2902
2843
  }
@@ -2914,10 +2855,9 @@ async function schemaCommand(subcommand, rawArgs, options = {}) {
2914
2855
  }
2915
2856
  if (subcommand === "generate") {
2916
2857
  const argsList = (0, import_arg.default)({
2917
- "--collections": String,
2858
+ "--schema-dir": String,
2918
2859
  "--output": String,
2919
2860
  "--watch": Boolean,
2920
- "-c": "--collections",
2921
2861
  "-o": "--output",
2922
2862
  "--out": "--output",
2923
2863
  "-w": "--watch"
@@ -2925,7 +2865,7 @@ async function schemaCommand(subcommand, rawArgs, options = {}) {
2925
2865
  argv: rawArgs.slice(2),
2926
2866
  permissive: true
2927
2867
  });
2928
- const collectionsPath = argsList["--collections"] || path.join("..", "config", "collections");
2868
+ const schemaDir = argsList["--schema-dir"] || "schema";
2929
2869
  const outputPath = argsList["--output"] || path.join("src", "schema.generated.ts");
2930
2870
  const watch = argsList["--watch"] || false;
2931
2871
  if (!watch && generatesInProcess()) {
@@ -2934,7 +2874,7 @@ async function schemaCommand(subcommand, rawArgs, options = {}) {
2934
2874
  out("");
2935
2875
  await generateInProcess("schema generator", "Drizzle schema", async ({ writeDrizzleSchema }) => {
2936
2876
  await writeDrizzleSchema({
2937
- collectionsPath: path.resolve(process.cwd(), collectionsPath),
2877
+ schemaDir: path.resolve(process.cwd(), schemaDir),
2938
2878
  outputPath: path.resolve(process.cwd(), outputPath),
2939
2879
  nextStep: options.nextStep
2940
2880
  });
@@ -2952,7 +2892,7 @@ async function schemaCommand(subcommand, rawArgs, options = {}) {
2952
2892
  const cmdParts = [
2953
2893
  generator.bin,
2954
2894
  ...generator.args,
2955
- `--collections=${collectionsPath}`,
2895
+ `--schema-dir=${schemaDir}`,
2956
2896
  `--output=${outputPath}`
2957
2897
  ];
2958
2898
  if (watch) cmdParts.push("--watch");
@@ -2970,15 +2910,11 @@ async function schemaCommand(subcommand, rawArgs, options = {}) {
2970
2910
  }
2971
2911
  } else if (subcommand === "introspect") {
2972
2912
  const argsList = (0, import_arg.default)({
2973
- "--output": String,
2974
- "--collections": String,
2913
+ "--schema-dir": String,
2975
2914
  "--force": Boolean,
2976
2915
  "--schema": String,
2977
2916
  "--data-inference": Boolean,
2978
2917
  "--no-data-inference": Boolean,
2979
- "-o": "--output",
2980
- "--out": "--output",
2981
- "-c": "--collections",
2982
2918
  "-f": "--force"
2983
2919
  }, {
2984
2920
  argv: rawArgs.slice(2),
@@ -2989,14 +2925,14 @@ async function schemaCommand(subcommand, rawArgs, options = {}) {
2989
2925
  outError(chalk.red(childScriptError("introspection script", introspect.reason)));
2990
2926
  process.exit(1);
2991
2927
  }
2992
- const outputPath = argsList["--output"] || argsList["--collections"] || path.join("..", "config", "collections");
2928
+ const schemaDir = argsList["--schema-dir"] || "schema";
2993
2929
  out("");
2994
2930
  out(chalk.bold(" 🔍 Rebase Schema Introspector"));
2995
2931
  out("");
2996
2932
  const cmdParts = [
2997
2933
  introspect.bin,
2998
2934
  ...introspect.args,
2999
- `--output=${outputPath}`,
2935
+ `--schema-dir=${schemaDir}`,
3000
2936
  ...argsList["--force"] ? ["--force"] : [],
3001
2937
  ...argsList["--schema"] ? [`--schema=${argsList["--schema"]}`] : [],
3002
2938
  ...argsList["--data-inference"] ? ["--data-inference"] : [],
@@ -3019,12 +2955,11 @@ async function schemaCommand(subcommand, rawArgs, options = {}) {
3019
2955
  }
3020
2956
  async function doctorPluginCommand(rawArgs) {
3021
2957
  const parsedArgs = (0, import_arg.default)({
3022
- "--collections": String,
2958
+ "--schema-dir": String,
3023
2959
  "--schema": String,
3024
2960
  "--sdk": String,
3025
2961
  "--policies": Boolean,
3026
2962
  "--database": Boolean,
3027
- "-c": "--collections",
3028
2963
  "-s": "--schema",
3029
2964
  "-k": "--sdk"
3030
2965
  }, {
@@ -3036,13 +2971,13 @@ async function doctorPluginCommand(rawArgs) {
3036
2971
  outError(chalk.red(childScriptError("doctor script", doctor.reason)));
3037
2972
  process.exit(1);
3038
2973
  }
3039
- const collectionsPath = parsedArgs["--collections"] || path.join("..", "config", "collections");
2974
+ const schemaDir = parsedArgs["--schema-dir"] || "schema";
3040
2975
  const schemaPath = parsedArgs["--schema"] || path.join("src", "schema.generated.ts");
3041
2976
  const sdkPath = parsedArgs["--sdk"] || path.join("..", "generated", "sdk", "database.types.ts");
3042
2977
  const cmdParts = [
3043
2978
  doctor.bin,
3044
2979
  ...doctor.args,
3045
- `--collections=${collectionsPath}`,
2980
+ `--schema-dir=${schemaDir}`,
3046
2981
  `--schema=${schemaPath}`,
3047
2982
  `--sdk=${sdkPath}`,
3048
2983
  ...parsedArgs["--policies"] ? ["--policies"] : [],