@vrplatform/kysely 1.3.45-stage.4368 → 1.3.45-stage.43703848639

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 (335) hide show
  1. package/build/.data.tar +2 -2
  2. package/build/main/camel-case/index.d.ts +4 -4
  3. package/build/main/camel-case/index.js +3 -2
  4. package/build/main/camel-case/index.js.map +1 -1
  5. package/build/main/connect-handoff.d.ts +12 -0
  6. package/build/main/connect-handoff.js +73 -0
  7. package/build/main/connect-handoff.js.map +1 -0
  8. package/build/main/control-plane/index.d.ts +413 -14
  9. package/build/main/control-plane/index.js +71 -0
  10. package/build/main/control-plane/index.js.map +1 -1
  11. package/build/main/domain.d.ts +4 -0
  12. package/build/main/domain.js +3 -0
  13. package/build/main/domain.js.map +1 -0
  14. package/build/main/error.d.ts +2 -1
  15. package/build/main/error.js +2 -1
  16. package/build/main/error.js.map +1 -1
  17. package/build/main/index.d.ts +57 -15
  18. package/build/main/index.js +498 -66
  19. package/build/main/index.js.map +1 -1
  20. package/build/main/isomorphic.d.ts +6 -6
  21. package/build/main/isomorphic.js +4 -8
  22. package/build/main/isomorphic.js.map +1 -1
  23. package/build/main/local/digest.d.ts +3 -3
  24. package/build/main/local/digest.js.map +1 -1
  25. package/build/main/local/generate.js +15 -13
  26. package/build/main/local/generate.js.map +1 -1
  27. package/build/main/local/index.d.ts +5 -1
  28. package/build/main/local/index.js +346 -12
  29. package/build/main/local/index.js.map +1 -1
  30. package/build/main/local/prune-pulled-schema.js +4 -1
  31. package/build/main/local/prune-pulled-schema.js.map +1 -1
  32. package/build/main/migration-source.d.ts +4 -0
  33. package/build/main/migration-source.js +45 -0
  34. package/build/main/migration-source.js.map +1 -0
  35. package/build/main/migration.d.ts +7 -0
  36. package/build/main/migration.js +11 -0
  37. package/build/main/migration.js.map +1 -0
  38. package/build/main/pganalyze-comment-plugin/comment-transformer.js +3 -1
  39. package/build/main/pganalyze-comment-plugin/comment-transformer.js.map +1 -1
  40. package/build/main/pganalyze-comment-plugin/index.js.map +1 -1
  41. package/build/main/plugins.d.ts +2 -2
  42. package/build/main/plugins.js.map +1 -1
  43. package/build/main/postgres-error.d.ts +9 -0
  44. package/build/main/postgres-error.js +28 -0
  45. package/build/main/postgres-error.js.map +1 -0
  46. package/build/main/query/index.d.ts +1 -0
  47. package/build/main/query/index.js +1 -0
  48. package/build/main/query/index.js.map +1 -1
  49. package/build/main/query/listing/status.d.ts +2 -12
  50. package/build/main/query/listing/status.js +35 -20
  51. package/build/main/query/listing/status.js.map +1 -1
  52. package/build/main/query/tenant/billing-partner.d.ts +4 -0
  53. package/build/main/query/tenant/billing-partner.js +8 -0
  54. package/build/main/query/tenant/billing-partner.js.map +1 -0
  55. package/build/main/query/tenant/feature-enabled.d.ts +6 -0
  56. package/build/main/query/tenant/feature-enabled.js +30 -0
  57. package/build/main/query/tenant/feature-enabled.js.map +1 -0
  58. package/build/main/query/tenant/index.d.ts +4 -0
  59. package/build/main/query/tenant/index.js +21 -0
  60. package/build/main/query/tenant/index.js.map +1 -0
  61. package/build/main/query/tenant/status.d.ts +9 -0
  62. package/build/main/query/tenant/status.js +32 -0
  63. package/build/main/query/tenant/status.js.map +1 -0
  64. package/build/main/query/tenant/where-uuid-in.d.ts +2 -0
  65. package/build/main/query/tenant/where-uuid-in.js +14 -0
  66. package/build/main/query/tenant/where-uuid-in.js.map +1 -0
  67. package/build/main/regional.d.ts +31 -4
  68. package/build/main/regional.js +69 -8
  69. package/build/main/regional.js.map +1 -1
  70. package/build/main/test/index.d.ts +21 -11
  71. package/build/main/test/index.js +31 -26
  72. package/build/main/test/index.js.map +1 -1
  73. package/build/main/transaction.d.ts +3 -3
  74. package/build/main/transaction.js.map +1 -1
  75. package/build/main/v1.generated.d.ts +1333 -90
  76. package/build/main/v1.generated.js.map +1 -1
  77. package/build/migrations-v2/0000000000000-baseline.ts +5 -0
  78. package/build/migrations-v2/0000000000001-public-audit-events-v2.ts +137 -0
  79. package/build/migrations-v2/0000000000002-audit-recovery-watermarks.ts +30 -0
  80. package/build/migrations-v2/0000000000003-audit-effect-recovery-watermark.ts +13 -0
  81. package/build/migrations-v2/0000000000004-audit-event-projected-at.ts +15 -0
  82. package/build/migrations-v2/0000000000005-audit-recovery-indexes.ts +63 -0
  83. package/build/migrations-v2/0000000000006-audit-action-public-event-projected-at.ts +22 -0
  84. package/build/migrations-v2/0000000000007-audit-action-public-event-projected-at-backfill.ts +35 -0
  85. package/build/migrations-v2/0000000000008-global-user-attribution.ts +33 -0
  86. package/build/migrations-v2/0000000000008-team-issue-rule-state.ts +52 -0
  87. package/build/migrations-v2/0000000000009-reservation-issue-projections.ts +45 -0
  88. package/build/migrations-v2/0000000000010-bank-rule-application-bank-record-delete-cascade.ts +26 -0
  89. package/build/migrations-v2/0000000000011-guest-balance-journal-entry-lookup-index.ts +25 -0
  90. package/build/migrations-v2/0000000000012-trial-free-analytics-billing-status.ts +72 -0
  91. package/build/migrations-v2/0000000000013-ui-permission-bundles.ts +45 -0
  92. package/build/migrations-v2/0000000000014-ui-permission-bundle-top-up.ts +32 -0
  93. package/build/migrations-v2/0000000000015-durable-flow-events.ts +163 -0
  94. package/build/migrations-v2/0000000000016-billing-listing-facts.ts +539 -0
  95. package/build/migrations-v2/0000000000016-managed-team-access.ts +34 -0
  96. package/build/migrations-v2/0000000000017-drop-trial-until.ts +42 -0
  97. package/build/migrations-v2/0000000000017-webhook-secret-reencryption-failures.ts +18 -0
  98. package/build/migrations-v2/0000000000018-accounting-integrity-monitoring.ts +276 -0
  99. package/build/migrations-v2/0000000000018-durable-flow-event-sensitive-input.ts +28 -0
  100. package/build/migrations-v2/0000000000019-accounting-integrity-run-shards.ts +26 -0
  101. package/build/migrations-v2/0000000000019-asynchronous-operations.ts +736 -0
  102. package/build/migrations-v2/0000000000020-accounting-integrity-case-classification.ts +52 -0
  103. package/build/migrations-v2/0000000000021-payment-line-classification-monitor-indexes.ts +31 -0
  104. package/build/migrations-v2/0000000000022-accounting-integrity-controlled-repairs.ts +281 -0
  105. package/build/migrations-v2/0000000000023-line-classification-usage.ts +325 -0
  106. package/build/migrations-v2/0000000000024-tenant-region-migration.ts +108 -0
  107. package/build/migrations-v2/0000000000025-partner-ach-denial-default.ts +30 -0
  108. package/build/migrations-v2/0000000000026-line-classification-usage-capture.ts +399 -0
  109. package/build/migrations-v2/0000000000027-payout-replacement-chain.ts +27 -0
  110. package/build/migrations-v2/0000000000028-accounting-integrity-operator-workflow.ts +108 -0
  111. package/build/migrations-v2/0000000000029-accounting-integrity-definition-artifacts.ts +40 -0
  112. package/build/migrations-v2/0000000000030-accounting-integrity-review-metadata-compatibility.ts +49 -0
  113. package/build/migrations-v2/0000000000031-ui-permission-role-simplification.ts +70 -0
  114. package/build/migrations-v2/0000000000032-tenant-delete-ownership-cascades.ts +44 -0
  115. package/build/migrations-v2/0000000000033-plaid-connect-session-telemetry.ts +31 -0
  116. package/build/migrations-v2/0000000000033-reservation-issue-seed-bucket-index.ts +19 -0
  117. package/build/migrations-v2/0000000000034-retire-recent-classification-indexes.ts +29 -0
  118. package/build/migrations-v2/0000000000035-core-change-autovacuum.ts +24 -0
  119. package/build/migrations-v2/0000000000036-journal-entry-inactive-reason-constraint.ts +33 -0
  120. package/build/migrations-v2/0000000000037-journal-entry-inactive-reasons.ts +19 -0
  121. package/build/{migrations/0000000000023-journal-entry-currency-mismatch-reason.ts → migrations-v2/0000000000038-journal-entry-group-inactive-reason.ts} +4 -4
  122. package/build/migrations-v2/0000000000039-reservation-guest-breakdown.ts +19 -0
  123. package/build/migrations-v2/0000000000040-csv-import-source-identity-index.ts +23 -0
  124. package/build/migrations-v2/0000000000041-payment-returns.ts +38 -0
  125. package/build/migrations-v2/0000000000042-operation-resource-types.ts +609 -0
  126. package/build/migrations-v2/0000000000043-reservation-journal-freshness.ts +149 -0
  127. package/build/migrations-v2/0000000000044-reservation-journal-freshness-backfill.ts +254 -0
  128. package/build/migrations-v2/0000000000045-reservation-journal-freshness-revision-repair.ts +83 -0
  129. package/build/migrations-v2/0000000000046-materialized-reservation-journal-operations.ts +709 -0
  130. package/build/migrations-v2/0000000000047-public-audit-completion.ts +77 -0
  131. package/build/migrations-v2/0000000000048-reservation-journal-full-refresh-repair.ts +136 -0
  132. package/build/migrations-v2/0000000000049-queued-journal-operation-failures.ts +60 -0
  133. package/build/migrations-v2/0000000000050-connection-oauth-state.ts +43 -0
  134. package/build/migrations-v2/0000000000051-owner-statement-email-delivery.ts +134 -0
  135. package/build/migrations-v2/0000000000052-fee-journal-lock-skip-operations.ts +59 -0
  136. package/build/migrations-v2/0000000000053-fee-journal-lock-skip-null-attempt.ts +44 -0
  137. package/build/migrations-v2/0000000000054-journal-refresh-issue-codes.ts +16 -0
  138. package/build/migrations-v2/0000000000055-tenant-billing-subscription.ts +8 -0
  139. package/build/migrations-v2/0000000000056-journal-operation-failure-precedence.ts +306 -0
  140. package/build/migrations-v2/0000000000057-journal-invalidation-failure-code.ts +28 -0
  141. package/build/migrations-v2/0000000000058-journal-invalidation-locked-failure.ts +16 -0
  142. package/build/migrations-v2/0000000000059-billing-active-listing-cross-region-partner.ts +135 -0
  143. package/build/migrations-v2/0000000000060-accounting-integrity-change-driven.ts +99 -0
  144. package/build/migrations-v2/0000000000061-tenant-pending-onboarding-status.ts +37 -0
  145. package/build/migrations-v2/0000000000062-statement-payout-operations.ts +16 -0
  146. package/build/migrations-v2/0000000000063-missing-account-assignments-issue-code.ts +13 -0
  147. package/build/migrations-v2/0000000000064-journal-invalidation-source-lookup-index.ts +26 -0
  148. package/build/migrations-v2/0000000000065-hasura-connection-event-credentials.ts +42 -0
  149. package/build/migrations-v2/0000000000066-recurring-fee-listing-subscription-match-by.ts +51 -0
  150. package/build/migrations-v2/0000000000067-connection-credential-metadata.ts +60 -0
  151. package/build/migrations-v2/0000000000068-connection-credential-version.ts +34 -0
  152. package/build/migrations-v2/0000000000069-owner-statement-contact-email-delivery.ts +84 -0
  153. package/build/migrations-v2/0000000000070-payment-writer-compatibility.ts +69 -0
  154. package/build/migrations-v2/0000000000071-payments.ts +532 -0
  155. package/build/migrations-v2/0000000000072-journal-entry-payment-index.ts +21 -0
  156. package/build/migrations-v2/0000000000073-batch-invalidation-operation-registration.ts +74 -0
  157. package/build/migrations-v2/0000000000074-owner-statement-email-history.ts +34 -0
  158. package/build/migrations-v2/0000000000075-tenant-deletion-lookup-indexes.ts +46 -0
  159. package/build/migrations-v2/0000000000076-tenant-onboarding-not-null.ts +23 -0
  160. package/build/migrations-v2/0000000000077-payment-writer-statement-attachment.ts +92 -0
  161. package/build/migrations-v2/0000000000078-trigger-timeout-indexes.ts +44 -0
  162. package/build/migrations-v2/0000000000079-core-change-tenant-statistics.ts +26 -0
  163. package/build/migrations-v2/0000000000080-drop-legacy-tracking-event.ts +60 -0
  164. package/build/migrations-v2/0000000000081-recurring-fee-planner-operation-status.ts +35 -0
  165. package/build/migrations-v2/0000000000082-reservation-search-trigram-indexes.ts +54 -0
  166. package/build/migrations-v2/0000000000083-journal-entry-deposit-lookup-index.ts +31 -0
  167. package/build/migrations-v2/0000000000084-journal-entry-reservation-revenue-indexes.ts +57 -0
  168. package/build/migrations-v2/0000000000085-owner-statement-link-email-template.ts +23 -0
  169. package/build/migrations-v2/0000000000086-contact-payment-setup.ts +72 -0
  170. package/build/migrations-v2/0000000000087-address-delete-fk-indexes.ts +30 -0
  171. package/build/migrations-v2/0000000000088-owner-statement-email-switch.ts +76 -0
  172. package/build/migrations-v2/0000000000089-contact-bank-details-requested-at.ts +21 -0
  173. package/build/migrations-v2/0000000000090-contact-bank-account-api-key.ts +22 -0
  174. package/build/migrations-v2/0000000000091-contact-bank-details-request.ts +78 -0
  175. package/build/migrations-v2/0000000000092-payment-provider-reference.ts +22 -0
  176. package/build/migrations-v2/0000000000093-payment-reversal-offline-undo.ts +18 -0
  177. package/build/migrations-v2/0000000000094-reservation-status-checkout-index.ts +37 -0
  178. package/build/migrations-v2/0000000000095-payment-batches.ts +196 -0
  179. package/build/migrations-v2/0000000000096-guide-ongoing-tasks-issue-codes.ts +26 -0
  180. package/build/migrations-v2/0000000000097-reservation-line-mapping-suggestions.ts +53 -0
  181. package/build/migrations-v2/0000000000098-cancelled-reservation-balances-issue-code.ts +13 -0
  182. package/build/migrations-v2/0000000000099-contact-bank-account-request-source.ts +28 -0
  183. package/build/migrations-v2/0000000000100-drop-regional-feature-flags.ts +105 -0
  184. package/build/migrations-v2/0000000000101-bank-record-match-source.ts +45 -0
  185. package/build/migrations-v2/0000000000102-owner-statement-email-one-template.ts +63 -0
  186. package/build/migrations-v2/0000000000103-reservation-line-mapping-update-operation.ts +10 -0
  187. package/build/migrations-v2/0000000000104-export-job-payment-batch-pdf.ts +12 -0
  188. package/build/migrations-v2/0000000000105-drop-regional-token.ts +60 -0
  189. package/build/migrations-v2/0000000000106-incremental-audit-action-source.ts +158 -0
  190. package/build/migrations-v2/0000000000107-audit-mutation-transaction-insert-index.ts +44 -0
  191. package/build/migrations-v2/0000000000108-reservation-stay-type.ts +24 -0
  192. package/build/migrations-v2/0000000000109-long-term-liabilities-category-order.ts +21 -0
  193. package/build/migrations-v2/0000000000110-pms-sync-failures-issue-code.ts +13 -0
  194. package/build/migrations-v2/0000000000110-reservation-line-type-taxable.ts +21 -0
  195. package/build/migrations-v2/0000000000111-reservation-line-type-suggestion-taxable.ts +20 -0
  196. package/build/migrations-v2/0000000000112-contact-payment-method-outside-default.ts +44 -0
  197. package/build/migrations-v2/0000000000113-merchant-fee-reference-assignment.ts +25 -0
  198. package/build/migrations-v2/0000000000114-recurring-fee-nights-filter.ts +32 -0
  199. package/build/migrations-v2/0000000000115-bank-records-with-suggested-rule-issue-code.ts +13 -0
  200. package/build/migrations-v2/0000000000116-guest-review.ts +45 -0
  201. package/build/migrations-v2/0000000000117-ramp-external-funding-accounts.ts +91 -0
  202. package/build/migrations-v2/0000000000118-pm-payout-assignment.ts +25 -0
  203. package/build/migrations-v2/0000000000119-chart-of-accounts-classifications.ts +46 -0
  204. package/build/migrations-v2/0000000000120-feedback.ts +41 -0
  205. package/build/migrations-v2/0000000000121-source-owner-block-calendar-index.ts +43 -0
  206. package/build/migrations-v2/0000000000122-recurring-fee-stay-types-filter.ts +20 -0
  207. package/build/migrations-v2/0000000000123-reservation-owner-stay-type-index.ts +40 -0
  208. package/build/migrations-v2/0000000000124-remove-tenant-test-and-billable-columns.ts +63 -0
  209. package/build/migrations-v2/0000000000125-ramp-application.ts +56 -0
  210. package/build/migrations-v2/0000000000126-advanced-deposits-update-operation.ts +10 -0
  211. package/build/migrations-v2/0000000000127-contact-1099-tax-details.ts +46 -0
  212. package/build/migrations-v2/0000000000128-tax-1099-email-templates.ts +36 -0
  213. package/build/migrations-v2/0000000000129-tenant-locked-at.ts +18 -0
  214. package/build/migrations-v2/0000000000130-second-factor-reset.ts +65 -0
  215. package/build/migrations-v2/0000000000131-payout-hold.ts +49 -0
  216. package/build/migrations-v2/0000000000132-member-invite-approval.ts +62 -0
  217. package/build/migrations-v2/0000000000133-audit-action-client-ip.ts +38 -0
  218. package/build/migrations-v2/0000000000134-drop-orphaned-hasura-triggers.ts +39 -0
  219. package/build/migrations-v2/0000000000135-drop-orphaned-hasura-triggers-literal.ts +42 -0
  220. package/build/migrations-v2/0000000000136-drop-all-hasura-triggers.ts +43 -0
  221. package/build/migrations-v2/0000000000137-webhook-event.ts +57 -0
  222. package/build/module/camel-case/index.d.ts +4 -4
  223. package/build/module/camel-case/index.js +4 -3
  224. package/build/module/camel-case/index.js.map +1 -1
  225. package/build/module/connect-handoff.d.ts +12 -0
  226. package/build/module/connect-handoff.js +70 -0
  227. package/build/module/connect-handoff.js.map +1 -0
  228. package/build/module/control-plane/index.d.ts +413 -14
  229. package/build/module/control-plane/index.js +58 -1
  230. package/build/module/control-plane/index.js.map +1 -1
  231. package/build/module/domain.d.ts +4 -0
  232. package/build/module/domain.js +2 -0
  233. package/build/module/domain.js.map +1 -0
  234. package/build/module/error.d.ts +2 -1
  235. package/build/module/error.js +3 -1
  236. package/build/module/error.js.map +1 -1
  237. package/build/module/index.d.ts +57 -15
  238. package/build/module/index.js +496 -64
  239. package/build/module/index.js.map +1 -1
  240. package/build/module/isomorphic.d.ts +6 -6
  241. package/build/module/isomorphic.js +2 -7
  242. package/build/module/isomorphic.js.map +1 -1
  243. package/build/module/local/digest.d.ts +3 -3
  244. package/build/module/local/digest.js.map +1 -1
  245. package/build/module/local/generate.js +15 -13
  246. package/build/module/local/generate.js.map +1 -1
  247. package/build/module/local/index.d.ts +5 -1
  248. package/build/module/local/index.js +347 -13
  249. package/build/module/local/index.js.map +1 -1
  250. package/build/module/local/prune-pulled-schema.js +4 -1
  251. package/build/module/local/prune-pulled-schema.js.map +1 -1
  252. package/build/module/migration-source.d.ts +4 -0
  253. package/build/module/migration-source.js +42 -0
  254. package/build/module/migration-source.js.map +1 -0
  255. package/build/module/migration.d.ts +7 -0
  256. package/build/module/migration.js +8 -0
  257. package/build/module/migration.js.map +1 -0
  258. package/build/module/pganalyze-comment-plugin/comment-transformer.js +3 -1
  259. package/build/module/pganalyze-comment-plugin/comment-transformer.js.map +1 -1
  260. package/build/module/plugins.d.ts +2 -2
  261. package/build/module/plugins.js.map +1 -1
  262. package/build/module/postgres-error.d.ts +9 -0
  263. package/build/module/postgres-error.js +24 -0
  264. package/build/module/postgres-error.js.map +1 -0
  265. package/build/module/query/index.d.ts +1 -0
  266. package/build/module/query/index.js +1 -0
  267. package/build/module/query/index.js.map +1 -1
  268. package/build/module/query/listing/status.d.ts +2 -12
  269. package/build/module/query/listing/status.js +35 -18
  270. package/build/module/query/listing/status.js.map +1 -1
  271. package/build/module/query/tenant/billing-partner.d.ts +4 -0
  272. package/build/module/query/tenant/billing-partner.js +5 -0
  273. package/build/module/query/tenant/billing-partner.js.map +1 -0
  274. package/build/module/query/tenant/feature-enabled.d.ts +6 -0
  275. package/build/module/query/tenant/feature-enabled.js +27 -0
  276. package/build/module/query/tenant/feature-enabled.js.map +1 -0
  277. package/build/module/query/tenant/index.d.ts +4 -0
  278. package/build/module/query/tenant/index.js +5 -0
  279. package/build/module/query/tenant/index.js.map +1 -0
  280. package/build/module/query/tenant/status.d.ts +9 -0
  281. package/build/module/query/tenant/status.js +28 -0
  282. package/build/module/query/tenant/status.js.map +1 -0
  283. package/build/module/query/tenant/where-uuid-in.d.ts +2 -0
  284. package/build/module/query/tenant/where-uuid-in.js +11 -0
  285. package/build/module/query/tenant/where-uuid-in.js.map +1 -0
  286. package/build/module/regional.d.ts +31 -4
  287. package/build/module/regional.js +68 -8
  288. package/build/module/regional.js.map +1 -1
  289. package/build/module/test/index.d.ts +21 -11
  290. package/build/module/test/index.js +31 -26
  291. package/build/module/test/index.js.map +1 -1
  292. package/build/module/transaction.d.ts +3 -3
  293. package/build/module/transaction.js.map +1 -1
  294. package/build/module/v1.generated.d.ts +1333 -90
  295. package/build/module/v1.generated.js.map +1 -1
  296. package/package.json +19 -16
  297. package/build/migrations/0000000000001-init.ts +0 -5
  298. package/build/migrations/0000000000009-drop-store-schema.ts +0 -14
  299. package/build/migrations/0000000000010-bank-rules.ts +0 -190
  300. package/build/migrations/0000000000011-bank-rule-line-adjustments.ts +0 -65
  301. package/build/migrations/0000000000012-bank-rule-conditions.ts +0 -45
  302. package/build/migrations/0000000000013-bank-rule-name-unique.ts +0 -15
  303. package/build/migrations/0000000000014-bank-rule-drop-legacy-conditions.ts +0 -41
  304. package/build/migrations/0000000000015-booking-channel-logo-dev-provider.ts +0 -70
  305. package/build/migrations/0000000000016-owner-statement-draft-status.ts +0 -22
  306. package/build/migrations/0000000000017-tenant-migration-markers.ts +0 -18
  307. package/build/migrations/0000000000018-security-deposits-payable-category.ts +0 -63
  308. package/build/migrations/0000000000019-tenant-app-settings.ts +0 -76
  309. package/build/migrations/0000000000020-operating-opening-trial-balance.ts +0 -36
  310. package/build/migrations/0000000000021-audit-foreign-key-indexes.ts +0 -77
  311. package/build/migrations/0000000000022-opening-trial-balance-combined-columns.ts +0 -30
  312. package/build/migrations/0000000000024-listing-parent.ts +0 -37
  313. package/build/migrations/0000000000025-journal-entry-parent-listing.ts +0 -26
  314. package/build/migrations/0000000000026-booking-channel-logo-slots.ts +0 -89
  315. package/build/migrations/0000000000027-list-browse-performance-indexes.ts +0 -52
  316. package/build/migrations/0000000000028-flow-setting-status-jsonb.ts +0 -20
  317. package/build/migrations/0000000000029-tenant-slug.ts +0 -328
  318. package/build/migrations/0000000000030-pms-accounting-windows.ts +0 -50
  319. package/build/migrations/0000000000031-owner-statement-projection-listing-revision.ts +0 -20
  320. package/build/migrations/0000000000032-flow-event-listening.ts +0 -28
  321. package/build/migrations/0000000000033-opening-trial-balance-transaction.ts +0 -272
  322. package/build/migrations/0000000000034-historic-general-ledger.ts +0 -24
  323. package/build/migrations/0000000000035-tenant-regional-placement.ts +0 -37
  324. package/build/migrations/0000000000036-control-plane-projection-events.ts +0 -43
  325. package/build/migrations/0000000000037-tenant-guide-onboarding.ts +0 -21
  326. package/build/migrations/0000000000038-tracking-event-analytics-sink.ts +0 -31
  327. package/build/migrations/0000000000039-crunchy-region.ts +0 -86
  328. package/build/migrations/0000000000040-hostaway-region.ts +0 -72
  329. package/build/migrations/0000000000041-audit-tenant-fk.ts +0 -66
  330. package/build/migrations/0000000000042-ramp-staging-connect-params.ts +0 -35
  331. package/build/migrations/0000000000043-gl-pms-accounting-window-guard.ts +0 -125
  332. package/build/migrations/0000000000044-tenant-cross-region-fks.ts +0 -45
  333. package/build/migrations/0000000000045-cloudflare-region-env.ts +0 -100
  334. package/build/migrations/0000000000046-control-plane-outbox-alias.ts +0 -46
  335. package/build/migrations/0000000000047-ramp-contact-last-4-digits.ts +0 -16
@@ -0,0 +1,46 @@
1
+ import type { Kysely } from 'kysely';
2
+ import { sql } from 'kysely';
3
+
4
+ export async function up(db: Kysely<unknown>): Promise<void> {
5
+ await sql`set local lock_timeout = '5s'`.execute(db);
6
+ // These lookup indexes scan existing multi-million-row tables.
7
+ await sql`set local statement_timeout = '10min'`.execute(db);
8
+
9
+ await sql`
10
+ create index if not exists reservation_journal_invalidation_covered_effect_idx
11
+ on accounting.reservation_journal_invalidation (covered_by_effect_id)
12
+ where covered_by_effect_id is not null
13
+ `.execute(db);
14
+ await sql`
15
+ create index if not exists reservation_journal_statement_impact_listing_idx
16
+ on accounting.reservation_journal_statement_impact (listing_id)
17
+ `.execute(db);
18
+ // The stale-only index cannot cover foreign-key checks for every tenant row.
19
+ await sql`
20
+ create index if not exists reservation_journal_state_tenant_idx
21
+ on accounting.reservation_journal_state (tenant_id)
22
+ `.execute(db);
23
+ await sql`
24
+ create index if not exists owner_statement_previous_idx
25
+ on public.owner_statement (previous_owner_statement_id)
26
+ where previous_owner_statement_id is not null
27
+ `.execute(db);
28
+ }
29
+
30
+ export async function down(db: Kysely<unknown>): Promise<void> {
31
+ await sql`set local lock_timeout = '5s'`.execute(db);
32
+ await sql`set local statement_timeout = '60s'`.execute(db);
33
+
34
+ await sql`
35
+ drop index if exists public.owner_statement_previous_idx
36
+ `.execute(db);
37
+ await sql`
38
+ drop index if exists accounting.reservation_journal_state_tenant_idx
39
+ `.execute(db);
40
+ await sql`
41
+ drop index if exists accounting.reservation_journal_statement_impact_listing_idx
42
+ `.execute(db);
43
+ await sql`
44
+ drop index if exists accounting.reservation_journal_invalidation_covered_effect_idx
45
+ `.execute(db);
46
+ }
@@ -0,0 +1,23 @@
1
+ import type { Kysely } from 'kysely';
2
+ import { sql } from 'kysely';
3
+
4
+ export async function up(db: Kysely<unknown>): Promise<void> {
5
+ await sql`set local lock_timeout = '5s'`.execute(db);
6
+ await sql`
7
+ update public.tenant set is_onboarding = false where is_onboarding is null
8
+ `.execute(db);
9
+ // Finish deferred tenant guards before altering the table they still reference.
10
+ await sql`set constraints all immediate`.execute(db);
11
+ await sql`
12
+ alter table public.tenant
13
+ alter column is_onboarding set default false,
14
+ alter column is_onboarding set not null
15
+ `.execute(db);
16
+ }
17
+
18
+ export async function down(db: Kysely<unknown>): Promise<void> {
19
+ await sql`set local lock_timeout = '5s'`.execute(db);
20
+ await sql`
21
+ alter table public.tenant alter column is_onboarding drop not null
22
+ `.execute(db);
23
+ }
@@ -0,0 +1,92 @@
1
+ import type { Kysely } from 'kysely';
2
+ import { sql } from 'kysely';
3
+
4
+ // Owner statement attach and detach only move the statement columns. They hold no
5
+ // payment evidence, so deployments without the payments writer may change them.
6
+ // txn_code is generated and still null in NEW inside a BEFORE trigger.
7
+ export async function up(db: Kysely<unknown>): Promise<void> {
8
+ await sql`set local lock_timeout = '5s'`.execute(db);
9
+ await sql`set local statement_timeout = '60s'`.execute(db);
10
+ await sql`
11
+ create or replace function accounting.require_payment_writer() returns trigger
12
+ language plpgsql as $$
13
+ declare
14
+ target record;
15
+ has_payments boolean;
16
+ begin
17
+ if current_setting('accounting.payment_writer_version', true) = '1'
18
+ or to_regclass('accounting.payment') is null then
19
+ if tg_op = 'DELETE' then return old; else return new; end if;
20
+ end if;
21
+ if tg_op = 'UPDATE' and tg_table_name = 'journal_entry'
22
+ and to_jsonb(new) - array['attached_to_owner_statement_id', 'listing_ownership_period_id',
23
+ 'updated_at', 'txn_code']
24
+ = to_jsonb(old) - array['attached_to_owner_statement_id', 'listing_ownership_period_id',
25
+ 'updated_at', 'txn_code'] then
26
+ return new;
27
+ end if;
28
+ for target in
29
+ select distinct (value ->> 'tenant_id')::uuid as tenant_id,
30
+ (case when tg_table_name = 'transaction' then value ->> 'id'
31
+ else value ->> 'transaction_id' end)::uuid as transaction_id
32
+ from jsonb_array_elements(jsonb_build_array(to_jsonb(old), to_jsonb(new)))
33
+ where value is not null and value <> 'null'::jsonb
34
+ order by tenant_id, transaction_id
35
+ loop
36
+ if target.transaction_id is null then continue; end if;
37
+ -- Payment creation locks this same row before inserting its evidence.
38
+ perform id from accounting.transaction
39
+ where id = target.transaction_id and tenant_id = target.tenant_id for update;
40
+ execute 'select exists (select 1 from accounting.payment
41
+ where tenant_id = $1 and transaction_id = $2)'
42
+ into has_payments using target.tenant_id, target.transaction_id;
43
+ if has_payments then
44
+ raise exception using errcode = '23514', constraint = 'payment_writer_compatibility',
45
+ message = 'This transaction requires a deployment with payments support',
46
+ detail = jsonb_build_object('tenantId', target.tenant_id,
47
+ 'transactionId', target.transaction_id)::text;
48
+ end if;
49
+ end loop;
50
+ if tg_op = 'DELETE' then return old; else return new; end if;
51
+ end $$
52
+ `.execute(db);
53
+ }
54
+
55
+ export async function down(db: Kysely<unknown>): Promise<void> {
56
+ await sql`
57
+ create or replace function accounting.require_payment_writer() returns trigger
58
+ language plpgsql as $$
59
+ declare
60
+ target record;
61
+ has_payments boolean;
62
+ begin
63
+ if current_setting('accounting.payment_writer_version', true) = '1'
64
+ or to_regclass('accounting.payment') is null then
65
+ if tg_op = 'DELETE' then return old; else return new; end if;
66
+ end if;
67
+ for target in
68
+ select distinct (value ->> 'tenant_id')::uuid as tenant_id,
69
+ (case when tg_table_name = 'transaction' then value ->> 'id'
70
+ else value ->> 'transaction_id' end)::uuid as transaction_id
71
+ from jsonb_array_elements(jsonb_build_array(to_jsonb(old), to_jsonb(new)))
72
+ where value is not null and value <> 'null'::jsonb
73
+ order by tenant_id, transaction_id
74
+ loop
75
+ if target.transaction_id is null then continue; end if;
76
+ -- Payment creation locks this same row before inserting its evidence.
77
+ perform id from accounting.transaction
78
+ where id = target.transaction_id and tenant_id = target.tenant_id for update;
79
+ execute 'select exists (select 1 from accounting.payment
80
+ where tenant_id = $1 and transaction_id = $2)'
81
+ into has_payments using target.tenant_id, target.transaction_id;
82
+ if has_payments then
83
+ raise exception using errcode = '23514', constraint = 'payment_writer_compatibility',
84
+ message = 'This transaction requires a deployment with payments support',
85
+ detail = jsonb_build_object('tenantId', target.tenant_id,
86
+ 'transactionId', target.transaction_id)::text;
87
+ end if;
88
+ end loop;
89
+ if tg_op = 'DELETE' then return old; else return new; end if;
90
+ end $$
91
+ `.execute(db);
92
+ }
@@ -0,0 +1,44 @@
1
+ import type { Kysely } from 'kysely';
2
+ import { sql } from 'kysely';
3
+
4
+ export async function up(db: Kysely<unknown>): Promise<void> {
5
+ await sql`set local lock_timeout = '5s'`.execute(db);
6
+ // These indexes scan existing multi-million-row tables.
7
+ await sql`set local statement_timeout = '10min'`.execute(db);
8
+
9
+ // recoverPublicAuditEvents (PRO-19064) looks for events projected with an
10
+ // older version. Without this index it probes every audit action since the
11
+ // cutover on each run.
12
+ await sql`
13
+ create index if not exists public_event_projection_version_idx
14
+ on audit.public_event (projection_version)
15
+ `.execute(db);
16
+ // The payment linker (PRO-18060) reads pending lines newest first, one
17
+ // keyset page at a time. match_status_tenant_id_idx cannot order them, so
18
+ // every page read all pending lines of the tenant.
19
+ await sql`
20
+ create index if not exists payment_line_pending_tenant_created_idx
21
+ on public.payment_line (tenant_id, created_at desc, id desc)
22
+ where match_status = 'pending'
23
+ `.execute(db);
24
+ await sql`
25
+ create index if not exists transaction_line_pending_tenant_created_idx
26
+ on accounting.transaction_line (tenant_id, created_at desc, id desc)
27
+ where match_status = 'pending'
28
+ `.execute(db);
29
+ }
30
+
31
+ export async function down(db: Kysely<unknown>): Promise<void> {
32
+ await sql`set local lock_timeout = '5s'`.execute(db);
33
+ await sql`set local statement_timeout = '60s'`.execute(db);
34
+
35
+ await sql`
36
+ drop index if exists accounting.transaction_line_pending_tenant_created_idx
37
+ `.execute(db);
38
+ await sql`
39
+ drop index if exists public.payment_line_pending_tenant_created_idx
40
+ `.execute(db);
41
+ await sql`
42
+ drop index if exists audit.public_event_projection_version_idx
43
+ `.execute(db);
44
+ }
@@ -0,0 +1,26 @@
1
+ import type { Kysely } from 'kysely';
2
+ import { sql } from 'kysely';
3
+
4
+ export async function up(db: Kysely<unknown>): Promise<void> {
5
+ await sql`set local lock_timeout = '5s'`.execute(db);
6
+ await sql`set local statement_timeout = '10min'`.execute(db);
7
+
8
+ // With 100 most-common values, the planner assumed an emptied tenant still
9
+ // owned about 545000 core.change rows, chose a skip scan over
10
+ // (sync_id, tenant_id) for the foreign-key check, and timed out deleting the
11
+ // tenant row (PRO-18138). A running vacuum holds the lock this needs; apply
12
+ // it when the table is idle.
13
+ await sql`
14
+ alter table core.change alter column tenant_id set statistics 1000
15
+ `.execute(db);
16
+ await sql`analyze core.change (tenant_id)`.execute(db);
17
+ }
18
+
19
+ export async function down(db: Kysely<unknown>): Promise<void> {
20
+ await sql`set local lock_timeout = '5s'`.execute(db);
21
+ await sql`set local statement_timeout = '60s'`.execute(db);
22
+
23
+ await sql`
24
+ alter table core.change alter column tenant_id set statistics -1
25
+ `.execute(db);
26
+ }
@@ -0,0 +1,60 @@
1
+ import type { Kysely } from 'kysely';
2
+ import { sql } from 'kysely';
3
+
4
+ // Product events live in Control Plane public.events. The legacy regional sink
5
+ // received its last write on 2026-08-18 and was reconciled by PRO-16951.
6
+ // Hasura never delivered the tracking_event trigger rows, so they are dropped
7
+ // with the table and are not restored by down.
8
+ export async function up(db: Kysely<unknown>): Promise<void> {
9
+ await sql`set local lock_timeout = '5s'`.execute(db);
10
+ await sql`set local statement_timeout = '240s'`.execute(db);
11
+ await sql`drop table if exists tracking.event`.execute(db);
12
+ await sql`
13
+ drop function if exists hdb_catalog."notify_hasura_tracking_event_INSERT"()
14
+ `.execute(db);
15
+ await sql`
16
+ drop function if exists hdb_catalog."notify_hasura_tracking_event_UPDATE"()
17
+ `.execute(db);
18
+ await sql`
19
+ delete from hdb_catalog.event_invocation_logs
20
+ where trigger_name = 'tracking_event'
21
+ `.execute(db);
22
+ await sql`
23
+ delete from hdb_catalog.event_log
24
+ where trigger_name = 'tracking_event'
25
+ and schema_name = 'tracking'
26
+ and table_name = 'event'
27
+ `.execute(db);
28
+ }
29
+
30
+ export async function down(db: Kysely<unknown>): Promise<void> {
31
+ await sql`
32
+ create table if not exists tracking.event (
33
+ id uuid default gen_random_uuid() not null primary key,
34
+ tenant_id uuid,
35
+ user_id uuid,
36
+ created_at timestamp with time zone default now() not null,
37
+ name text not null,
38
+ props jsonb not null,
39
+ package_name text not null,
40
+ tracked_at timestamp with time zone default now(),
41
+ "timestamp" timestamp without time zone
42
+ generated always as (coalesce(tracked_at, created_at)) stored
43
+ )
44
+ `.execute(db);
45
+ await sql`
46
+ create index if not exists event_name_created_at_idx
47
+ on tracking.event (name, created_at)
48
+ `.execute(db);
49
+ await sql`
50
+ create index if not exists event_name_tracked_at_idx
51
+ on tracking.event (name, tracked_at)
52
+ `.execute(db);
53
+ await sql`
54
+ create index if not exists event_tenant_id_name_idx
55
+ on tracking.event (tenant_id, name)
56
+ `.execute(db);
57
+ await sql`
58
+ create index if not exists event_user_id on tracking.event (user_id)
59
+ `.execute(db);
60
+ }
@@ -0,0 +1,35 @@
1
+ import { type Kysely, sql } from 'kysely';
2
+
3
+ const original = `effect.effect_type = 'REFRESH_RESERVATION_JOURNAL'
4
+ and effect.entity_type = 'reservation'`;
5
+ const corrected = `effect.effect_type in (
6
+ 'REFRESH_RESERVATION_JOURNAL',
7
+ 'REFRESH_RECURRING_FEE_RESERVATIONS'
8
+ )
9
+ and effect.entity_type in ('reservation', 'recurringFee')`;
10
+
11
+ async function replaceProjectedEffects<Database>(
12
+ db: Kysely<Database>,
13
+ before: string,
14
+ after: string
15
+ ) {
16
+ const { rows } = await sql<{ definition: string }>`
17
+ select pg_get_functiondef('core.refresh_audit_action_source(uuid)'::regprocedure)
18
+ as definition
19
+ `.execute(db);
20
+ const definition = rows[0]?.definition;
21
+ if (!definition || definition.split(before).length !== 2) {
22
+ throw new Error(
23
+ 'Journal operation source projection has an unexpected definition'
24
+ );
25
+ }
26
+ await sql.raw(definition.replace(before, after)).execute(db);
27
+ }
28
+
29
+ export async function up<Database>(db: Kysely<Database>): Promise<void> {
30
+ await replaceProjectedEffects(db, original, corrected);
31
+ }
32
+
33
+ export async function down<Database>(db: Kysely<Database>): Promise<void> {
34
+ await replaceProjectedEffects(db, corrected, original);
35
+ }
@@ -0,0 +1,54 @@
1
+ import type { Kysely } from 'kysely';
2
+ import { sql } from 'kysely';
3
+
4
+ // GET /reservations searches these five columns with ILIKE '%term%'. Without
5
+ // trigram indexes the total count reads every reservation of the team. On
6
+ // large databases run scripts/ben-2/pro-19034-create-search-indexes.ts
7
+ // first: it builds them concurrently, and this migration then skips them.
8
+ export async function up(db: Kysely<unknown>): Promise<void> {
9
+ await sql`set local lock_timeout = '5s'`.execute(db);
10
+ await sql`set local statement_timeout = '30min'`.execute(db);
11
+
12
+ await sql`create extension if not exists pg_trgm`.execute(db);
13
+ await sql`
14
+ create index if not exists reservation_guest_name_trgm_idx
15
+ on public.reservation using gin (guest_name gin_trgm_ops)
16
+ `.execute(db);
17
+ await sql`
18
+ create index if not exists reservation_unique_ref_trgm_idx
19
+ on public.reservation using gin (unique_ref gin_trgm_ops)
20
+ `.execute(db);
21
+ await sql`
22
+ create index if not exists reservation_short_ref_trgm_idx
23
+ on public.reservation using gin (short_ref gin_trgm_ops)
24
+ `.execute(db);
25
+ await sql`
26
+ create index if not exists reservation_confirmation_code_trgm_idx
27
+ on public.reservation using gin (confirmation_code gin_trgm_ops)
28
+ `.execute(db);
29
+ await sql`
30
+ create index if not exists reservation_pms_reference_code_trgm_idx
31
+ on public.reservation using gin (pms_reference_code gin_trgm_ops)
32
+ `.execute(db);
33
+ }
34
+
35
+ export async function down(db: Kysely<unknown>): Promise<void> {
36
+ await sql`set local lock_timeout = '5s'`.execute(db);
37
+ await sql`set local statement_timeout = '60s'`.execute(db);
38
+
39
+ await sql`drop index if exists public.reservation_guest_name_trgm_idx`.execute(
40
+ db
41
+ );
42
+ await sql`drop index if exists public.reservation_unique_ref_trgm_idx`.execute(
43
+ db
44
+ );
45
+ await sql`drop index if exists public.reservation_short_ref_trgm_idx`.execute(
46
+ db
47
+ );
48
+ await sql`
49
+ drop index if exists public.reservation_confirmation_code_trgm_idx
50
+ `.execute(db);
51
+ await sql`
52
+ drop index if exists public.reservation_pms_reference_code_trgm_idx
53
+ `.execute(db);
54
+ }
@@ -0,0 +1,31 @@
1
+ import type { Kysely } from 'kysely';
2
+ import { sql } from 'kysely';
3
+
4
+ // The reservation payment correction (GET /reservations paidStatus filter and
5
+ // its total count) looks up each reservation's deposit journal entries. The
6
+ // existing (reservation_id, tenant_id) index returns every journal entry of the
7
+ // reservation and filters the three deposit predicates after the heap fetch.
8
+ // This partial index holds only those rows. On large databases run
9
+ // scripts/ben-2/pro-18866-create-deposit-index.ts first: it builds the index
10
+ // concurrently, and this migration then skips it.
11
+ export async function up(db: Kysely<unknown>): Promise<void> {
12
+ await sql`set local lock_timeout = '5s'`.execute(db);
13
+ await sql`set local statement_timeout = '30min'`.execute(db);
14
+
15
+ await sql`
16
+ create index if not exists journal_entry_reservation_deposit_idx
17
+ on accounting.journal_entry (reservation_id, tenant_id)
18
+ where entity_type = 'transaction'
19
+ and unique_ref like 'deposit%'
20
+ and type <> 'transaction_deposit'
21
+ `.execute(db);
22
+ }
23
+
24
+ export async function down(db: Kysely<unknown>): Promise<void> {
25
+ await sql`set local lock_timeout = '5s'`.execute(db);
26
+ await sql`set local statement_timeout = '60s'`.execute(db);
27
+
28
+ await sql`
29
+ drop index if exists accounting.journal_entry_reservation_deposit_idx
30
+ `.execute(db);
31
+ }
@@ -0,0 +1,57 @@
1
+ import type { Kysely } from 'kysely';
2
+ import { sql } from 'kysely';
3
+
4
+ // PRO-19314: the manager dashboard reads active reservation journal entries by
5
+ // posting date (revenue, take rate, booked revenue) and per reservation (ADR,
6
+ // posted-stay checks). On the largest team that is about 1.9M entries a year,
7
+ // and a heap fetch per entry took 21-39 s. Both partial indexes cover every
8
+ // column those queries read, so they can run as index-only scans. On large
9
+ // databases run scripts/ben-2/pro-19314-create-revenue-indexes.ts first: it
10
+ // builds the indexes concurrently, and this migration then skips them. The
11
+ // migrator runs in a transaction, so this build cannot be concurrent: the short
12
+ // statement timeout fails it before it blocks journal writes for long.
13
+ export async function up(db: Kysely<unknown>): Promise<void> {
14
+ await sql`set local lock_timeout = '5s'`.execute(db);
15
+ await sql`set local statement_timeout = '60s'`.execute(db);
16
+ // A failed concurrent build leaves an invalid index that `if not exists`
17
+ // would keep, so drop it first.
18
+ const invalid = await sql<{ name: string }>`
19
+ select index_class.relname as name
20
+ from pg_index as i
21
+ inner join pg_class as index_class on index_class.oid = i.indexrelid
22
+ where i.indrelid = 'accounting.journal_entry'::regclass
23
+ and index_class.relname in (
24
+ 'journal_entry_reservation_revenue_txn_at_idx',
25
+ 'journal_entry_reservation_revenue_reservation_idx'
26
+ )
27
+ and not (i.indisvalid and i.indisready)
28
+ `.execute(db);
29
+ for (const { name } of invalid.rows) {
30
+ await sql`drop index accounting.${sql.id(name)}`.execute(db);
31
+ }
32
+
33
+ await sql`
34
+ create index if not exists journal_entry_reservation_revenue_txn_at_idx
35
+ on accounting.journal_entry (tenant_id, txn_at)
36
+ include (reservation_id, account_id, type, party, cent_total)
37
+ where entity_type = 'reservation' and status = 'active'
38
+ `.execute(db);
39
+ await sql`
40
+ create index if not exists journal_entry_reservation_revenue_reservation_idx
41
+ on accounting.journal_entry (reservation_id, tenant_id)
42
+ include (account_id, type, party, cent_total, txn_at)
43
+ where entity_type = 'reservation' and status = 'active'
44
+ `.execute(db);
45
+ }
46
+
47
+ export async function down(db: Kysely<unknown>): Promise<void> {
48
+ await sql`set local lock_timeout = '5s'`.execute(db);
49
+ await sql`set local statement_timeout = '60s'`.execute(db);
50
+
51
+ await sql`
52
+ drop index if exists accounting.journal_entry_reservation_revenue_txn_at_idx
53
+ `.execute(db);
54
+ await sql`
55
+ drop index if exists accounting.journal_entry_reservation_revenue_reservation_idx
56
+ `.execute(db);
57
+ }
@@ -0,0 +1,23 @@
1
+ import type { Kysely } from 'kysely';
2
+ import { sql } from 'kysely';
3
+
4
+ // PRO-19365: owners who open statements by emailed link get their own
5
+ // editable owner statement email, separate from the portal user email.
6
+ export async function up(db: Kysely<unknown>): Promise<void> {
7
+ await sql`
8
+ insert into public.email_template_type (name)
9
+ values ('ownerStatementLink_owner')
10
+ on conflict do nothing
11
+ `.execute(db);
12
+ }
13
+
14
+ export async function down(db: Kysely<unknown>): Promise<void> {
15
+ await sql`
16
+ delete from public.email_template
17
+ where type = 'ownerStatementLink_owner'
18
+ `.execute(db);
19
+ await sql`
20
+ delete from public.email_template_type
21
+ where name = 'ownerStatementLink_owner'
22
+ `.execute(db);
23
+ }
@@ -0,0 +1,72 @@
1
+ import type { Kysely } from 'kysely';
2
+ import { sql } from 'kysely';
3
+
4
+ // Expand only: VRT becomes the source of truth for owner and vendor payment
5
+ // setup. Full bank numbers live in their own table so contact reads, copies
6
+ // and exports never select them. address_edited_at marks a mailing address
7
+ // edited in VRT so PMS sync stops overwriting it.
8
+ export async function up(db: Kysely<unknown>): Promise<void> {
9
+ await sql`set local lock_timeout = '5s'`.execute(db);
10
+ await sql`set local statement_timeout = '60s'`.execute(db);
11
+
12
+ await sql`
13
+ create type accounting.contact_payment_method as enum (
14
+ 'rampAch', 'nachaAch', 'check', 'outside'
15
+ )
16
+ `.execute(db);
17
+ await sql`
18
+ create type accounting.bank_account_holder_type as enum ('individual', 'business')
19
+ `.execute(db);
20
+ await sql`
21
+ create type accounting.bank_account_kind as enum ('checking', 'savings')
22
+ `.execute(db);
23
+
24
+ await sql`
25
+ alter table accounting.contact
26
+ add column if not exists default_payment_method accounting.contact_payment_method,
27
+ add column if not exists address_edited_at timestamptz
28
+ `.execute(db);
29
+
30
+ await sql`
31
+ create table accounting.contact_bank_account (
32
+ contact_id uuid primary key references accounting.contact (id) on delete cascade,
33
+ tenant_id uuid not null references public.tenant (id) on delete restrict,
34
+ holder_name text not null check (length(holder_name) between 1 and 200),
35
+ holder_type accounting.bank_account_holder_type not null,
36
+ account_kind accounting.bank_account_kind not null,
37
+ routing_number text not null check (routing_number ~ '^[0-9]{9}$'),
38
+ account_number text not null check (account_number ~ '^[0-9]{4,17}$'),
39
+ updated_by_user_id uuid null references public.user (id) on delete set null,
40
+ created_at timestamptz not null default now(),
41
+ updated_at timestamptz not null default now()
42
+ )
43
+ `.execute(db);
44
+ await sql`
45
+ create index contact_bank_account_tenant_id_idx
46
+ on accounting.contact_bank_account (tenant_id)
47
+ `.execute(db);
48
+ await sql`
49
+ do $$
50
+ begin
51
+ if exists (select 1 from pg_roles where rolname = 'application') then
52
+ grant select, insert, update, delete on accounting.contact_bank_account
53
+ to application;
54
+ end if;
55
+ end;
56
+ $$
57
+ `.execute(db);
58
+ }
59
+
60
+ export async function down(db: Kysely<unknown>): Promise<void> {
61
+ await sql`drop table if exists accounting.contact_bank_account`.execute(db);
62
+ await sql`
63
+ alter table accounting.contact
64
+ drop column if exists address_edited_at,
65
+ drop column if exists default_payment_method
66
+ `.execute(db);
67
+ await sql`drop type if exists accounting.bank_account_kind`.execute(db);
68
+ await sql`drop type if exists accounting.bank_account_holder_type`.execute(
69
+ db
70
+ );
71
+ await sql`drop type if exists accounting.contact_payment_method`.execute(db);
72
+ }
@@ -0,0 +1,30 @@
1
+ import type { Kysely } from 'kysely';
2
+ import { sql } from 'kysely';
3
+
4
+ export async function up(db: Kysely<unknown>): Promise<void> {
5
+ await sql`set local lock_timeout = '5s'`.execute(db);
6
+ await sql`set local statement_timeout = '10min'`.execute(db);
7
+ // Each address delete probes these referencing columns, including global users.
8
+ await sql`
9
+ create index if not exists user_address_id_idx on public."user" (address_id)
10
+ where address_id is not null
11
+ `.execute(db);
12
+ await sql`
13
+ create index if not exists owner_address_id_idx on public.owner (address_id)
14
+ where address_id is not null
15
+ `.execute(db);
16
+ await sql`
17
+ create index if not exists tenant_billing_address_id_idx on public.tenant (billing_address_id)
18
+ where billing_address_id is not null
19
+ `.execute(db);
20
+ }
21
+
22
+ export async function down(db: Kysely<unknown>): Promise<void> {
23
+ await sql`set local lock_timeout = '5s'`.execute(db);
24
+ await sql`set local statement_timeout = '60s'`.execute(db);
25
+ await sql`drop index if exists public.tenant_billing_address_id_idx`.execute(
26
+ db
27
+ );
28
+ await sql`drop index if exists public.owner_address_id_idx`.execute(db);
29
+ await sql`drop index if exists public.user_address_id_idx`.execute(db);
30
+ }