@vrplatform/kysely 1.3.45-4447 → 1.3.45-44494530923

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 (350) 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 +421 -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 +1407 -177
  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/migrations-v2/0000000000138-contact-tax-details-requested-at.ts +24 -0
  223. package/build/migrations-v2/0000000000139-tax-statement-1099.ts +140 -0
  224. package/build/migrations-v2/0000000000140-owner-payment-settings.ts +53 -0
  225. package/build/migrations-v2/0000000000141-owner-payment-requests.ts +100 -0
  226. package/build/migrations-v2/0000000000148-statement-level-operation-triggers.ts +229 -0
  227. package/build/migrations-v2/0000000000151-core-change-unused-indexes.ts +85 -0
  228. package/build/migrations-v2/0000000000154-accounting-integrity-backlog-performance.ts +68 -0
  229. package/build/migrations-v2/0000000000155-source-last-successful-hash.ts +23 -0
  230. package/build/module/camel-case/index.d.ts +4 -4
  231. package/build/module/camel-case/index.js +4 -3
  232. package/build/module/camel-case/index.js.map +1 -1
  233. package/build/module/connect-handoff.d.ts +12 -0
  234. package/build/module/connect-handoff.js +70 -0
  235. package/build/module/connect-handoff.js.map +1 -0
  236. package/build/module/control-plane/index.d.ts +421 -14
  237. package/build/module/control-plane/index.js +58 -1
  238. package/build/module/control-plane/index.js.map +1 -1
  239. package/build/module/domain.d.ts +4 -0
  240. package/build/module/domain.js +2 -0
  241. package/build/module/domain.js.map +1 -0
  242. package/build/module/error.d.ts +2 -1
  243. package/build/module/error.js +3 -1
  244. package/build/module/error.js.map +1 -1
  245. package/build/module/index.d.ts +57 -15
  246. package/build/module/index.js +496 -64
  247. package/build/module/index.js.map +1 -1
  248. package/build/module/isomorphic.d.ts +6 -6
  249. package/build/module/isomorphic.js +2 -7
  250. package/build/module/isomorphic.js.map +1 -1
  251. package/build/module/local/digest.d.ts +3 -3
  252. package/build/module/local/digest.js.map +1 -1
  253. package/build/module/local/generate.js +15 -13
  254. package/build/module/local/generate.js.map +1 -1
  255. package/build/module/local/index.d.ts +5 -1
  256. package/build/module/local/index.js +347 -13
  257. package/build/module/local/index.js.map +1 -1
  258. package/build/module/local/prune-pulled-schema.js +4 -1
  259. package/build/module/local/prune-pulled-schema.js.map +1 -1
  260. package/build/module/migration-source.d.ts +4 -0
  261. package/build/module/migration-source.js +42 -0
  262. package/build/module/migration-source.js.map +1 -0
  263. package/build/module/migration.d.ts +7 -0
  264. package/build/module/migration.js +8 -0
  265. package/build/module/migration.js.map +1 -0
  266. package/build/module/pganalyze-comment-plugin/comment-transformer.js +3 -1
  267. package/build/module/pganalyze-comment-plugin/comment-transformer.js.map +1 -1
  268. package/build/module/plugins.d.ts +2 -2
  269. package/build/module/plugins.js.map +1 -1
  270. package/build/module/postgres-error.d.ts +9 -0
  271. package/build/module/postgres-error.js +24 -0
  272. package/build/module/postgres-error.js.map +1 -0
  273. package/build/module/query/index.d.ts +1 -0
  274. package/build/module/query/index.js +1 -0
  275. package/build/module/query/index.js.map +1 -1
  276. package/build/module/query/listing/status.d.ts +2 -12
  277. package/build/module/query/listing/status.js +35 -18
  278. package/build/module/query/listing/status.js.map +1 -1
  279. package/build/module/query/tenant/billing-partner.d.ts +4 -0
  280. package/build/module/query/tenant/billing-partner.js +5 -0
  281. package/build/module/query/tenant/billing-partner.js.map +1 -0
  282. package/build/module/query/tenant/feature-enabled.d.ts +6 -0
  283. package/build/module/query/tenant/feature-enabled.js +27 -0
  284. package/build/module/query/tenant/feature-enabled.js.map +1 -0
  285. package/build/module/query/tenant/index.d.ts +4 -0
  286. package/build/module/query/tenant/index.js +5 -0
  287. package/build/module/query/tenant/index.js.map +1 -0
  288. package/build/module/query/tenant/status.d.ts +9 -0
  289. package/build/module/query/tenant/status.js +28 -0
  290. package/build/module/query/tenant/status.js.map +1 -0
  291. package/build/module/query/tenant/where-uuid-in.d.ts +2 -0
  292. package/build/module/query/tenant/where-uuid-in.js +11 -0
  293. package/build/module/query/tenant/where-uuid-in.js.map +1 -0
  294. package/build/module/regional.d.ts +31 -4
  295. package/build/module/regional.js +68 -8
  296. package/build/module/regional.js.map +1 -1
  297. package/build/module/test/index.d.ts +21 -11
  298. package/build/module/test/index.js +31 -26
  299. package/build/module/test/index.js.map +1 -1
  300. package/build/module/transaction.d.ts +3 -3
  301. package/build/module/transaction.js.map +1 -1
  302. package/build/module/v1.generated.d.ts +1407 -177
  303. package/build/module/v1.generated.js.map +1 -1
  304. package/package.json +19 -16
  305. package/build/migrations/0000000000001-init.ts +0 -5
  306. package/build/migrations/0000000000009-drop-store-schema.ts +0 -14
  307. package/build/migrations/0000000000010-bank-rules.ts +0 -190
  308. package/build/migrations/0000000000011-bank-rule-line-adjustments.ts +0 -65
  309. package/build/migrations/0000000000012-bank-rule-conditions.ts +0 -45
  310. package/build/migrations/0000000000013-bank-rule-name-unique.ts +0 -15
  311. package/build/migrations/0000000000014-bank-rule-drop-legacy-conditions.ts +0 -41
  312. package/build/migrations/0000000000015-booking-channel-logo-dev-provider.ts +0 -70
  313. package/build/migrations/0000000000016-owner-statement-draft-status.ts +0 -22
  314. package/build/migrations/0000000000017-tenant-migration-markers.ts +0 -18
  315. package/build/migrations/0000000000018-security-deposits-payable-category.ts +0 -63
  316. package/build/migrations/0000000000019-tenant-app-settings.ts +0 -76
  317. package/build/migrations/0000000000020-operating-opening-trial-balance.ts +0 -36
  318. package/build/migrations/0000000000021-audit-foreign-key-indexes.ts +0 -77
  319. package/build/migrations/0000000000022-opening-trial-balance-combined-columns.ts +0 -30
  320. package/build/migrations/0000000000024-listing-parent.ts +0 -37
  321. package/build/migrations/0000000000025-journal-entry-parent-listing.ts +0 -26
  322. package/build/migrations/0000000000026-booking-channel-logo-slots.ts +0 -89
  323. package/build/migrations/0000000000027-list-browse-performance-indexes.ts +0 -52
  324. package/build/migrations/0000000000028-flow-setting-status-jsonb.ts +0 -20
  325. package/build/migrations/0000000000029-tenant-slug.ts +0 -328
  326. package/build/migrations/0000000000030-pms-accounting-windows.ts +0 -50
  327. package/build/migrations/0000000000031-owner-statement-projection-listing-revision.ts +0 -20
  328. package/build/migrations/0000000000032-flow-event-listening.ts +0 -28
  329. package/build/migrations/0000000000033-opening-trial-balance-transaction.ts +0 -272
  330. package/build/migrations/0000000000034-historic-general-ledger.ts +0 -24
  331. package/build/migrations/0000000000035-tenant-regional-placement.ts +0 -37
  332. package/build/migrations/0000000000036-control-plane-projection-events.ts +0 -43
  333. package/build/migrations/0000000000037-tenant-guide-onboarding.ts +0 -21
  334. package/build/migrations/0000000000038-tracking-event-analytics-sink.ts +0 -31
  335. package/build/migrations/0000000000039-crunchy-region.ts +0 -86
  336. package/build/migrations/0000000000040-hostaway-region.ts +0 -72
  337. package/build/migrations/0000000000041-audit-tenant-fk.ts +0 -66
  338. package/build/migrations/0000000000042-ramp-staging-connect-params.ts +0 -35
  339. package/build/migrations/0000000000043-gl-pms-accounting-window-guard.ts +0 -125
  340. package/build/migrations/0000000000044-tenant-cross-region-fks.ts +0 -45
  341. package/build/migrations/0000000000045-cloudflare-region-env.ts +0 -100
  342. package/build/migrations/0000000000046-control-plane-outbox-alias.ts +0 -46
  343. package/build/migrations/0000000000047-ramp-contact-last-4-digits.ts +0 -16
  344. package/build/migrations/0000000000047-tenant-status-backfill.ts +0 -40
  345. package/build/migrations/0000000000048-tenant-status-constraint.ts +0 -24
  346. package/build/migrations/0000000000049-health-tenant-issues.ts +0 -69
  347. package/build/migrations/0000000000050-partner-webhooks.ts +0 -135
  348. package/build/migrations/0000000000051-health-webhook-runtime-grants.ts +0 -42
  349. package/build/migrations/0000000000052-feature-approval-team-enablement.ts +0 -13
  350. package/build/migrations/0000000000053-health-webhook-enums.ts +0 -296
@@ -0,0 +1,25 @@
1
+ import type { Kysely } from 'kysely';
2
+ import { sql } from 'kysely';
3
+
4
+ // PRO-20068: the account that holds a booking's merchant fee as a positive
5
+ // amount, for Fees v2 merchant fee formulas.
6
+ export async function up(db: Kysely<unknown>): Promise<void> {
7
+ await sql`set local lock_timeout = '5s'`.execute(db);
8
+ await sql`
9
+ insert into accounting.account_assignment_type (name)
10
+ values ('merchantFeeReference')
11
+ on conflict (name) do nothing
12
+ `.execute(db);
13
+ }
14
+
15
+ export async function down(db: Kysely<unknown>): Promise<void> {
16
+ await sql`set local lock_timeout = '5s'`.execute(db);
17
+ await sql`
18
+ delete from accounting.account_assignment
19
+ where type = 'merchantFeeReference'
20
+ `.execute(db);
21
+ await sql`
22
+ delete from accounting.account_assignment_type
23
+ where name = 'merchantFeeReference'
24
+ `.execute(db);
25
+ }
@@ -0,0 +1,32 @@
1
+ import type { Kysely } from 'kysely';
2
+ import { sql } from 'kysely';
3
+
4
+ // PRO-19679: a fee applies only to reservations whose nights fall inside
5
+ // [nights_filter_min, nights_filter_max]. A null bound is open.
6
+ export async function up(db: Kysely<unknown>): Promise<void> {
7
+ await sql`set local lock_timeout = '5s'`.execute(db);
8
+ await sql`
9
+ alter table public.recurring_fee
10
+ add column nights_filter_min integer,
11
+ add column nights_filter_max integer,
12
+ add constraint recurring_fee_nights_filter_check check (
13
+ (nights_filter_min is null or nights_filter_min >= 1)
14
+ and (nights_filter_max is null or nights_filter_max >= 1)
15
+ and (
16
+ nights_filter_min is null
17
+ or nights_filter_max is null
18
+ or nights_filter_max >= nights_filter_min
19
+ )
20
+ )
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`
27
+ alter table public.recurring_fee
28
+ drop constraint recurring_fee_nights_filter_check,
29
+ drop column nights_filter_max,
30
+ drop column nights_filter_min
31
+ `.execute(db);
32
+ }
@@ -0,0 +1,13 @@
1
+ import type { Kysely } from 'kysely';
2
+ import { sql } from 'kysely';
3
+
4
+ export async function up(db: Kysely<unknown>): Promise<void> {
5
+ // Expand storage only. The code must be writable on every channel before
6
+ // API producers mark it dirty in shared regional databases.
7
+ await sql`alter type health.tenant_issue_code add value if not exists 'bankRecordsWithSuggestedRule'`.execute(
8
+ db
9
+ );
10
+ }
11
+
12
+ // PostgreSQL enum additions are retained so historical issues remain readable.
13
+ export async function down(_db: Kysely<unknown>): Promise<void> {}
@@ -0,0 +1,45 @@
1
+ import type { Kysely } from 'kysely';
2
+ import { sql } from 'kysely';
3
+
4
+ // PRO-19775: public guest reviews synced from the PMS for the owner portal.
5
+ // Ratings are stored on a five-star scale; private feedback is never stored.
6
+ export async function up(db: Kysely<unknown>): Promise<void> {
7
+ await sql`set local lock_timeout = '5s'`.execute(db);
8
+ await sql`set local statement_timeout = '60s'`.execute(db);
9
+
10
+ await sql`
11
+ create type public.guest_review_channel as enum ('airbnb', 'vrbo', 'bookingCom')
12
+ `.execute(db);
13
+ await sql`
14
+ create table public.guest_review (
15
+ id uuid primary key default gen_random_uuid(),
16
+ tenant_id uuid not null references public.tenant (id) on delete cascade,
17
+ connection_id uuid not null references public.connection (id) on delete cascade,
18
+ reservation_id uuid not null references public.reservation (id) on delete cascade,
19
+ unique_ref text not null,
20
+ channel public.guest_review_channel not null,
21
+ rating numeric(3, 2) not null,
22
+ title text,
23
+ text text,
24
+ negative_text text,
25
+ host_reply text,
26
+ is_hidden boolean not null default false,
27
+ reviewed_at timestamptz not null,
28
+ created_at timestamptz not null default now(),
29
+ updated_at timestamptz not null default now(),
30
+ constraint guest_review_rating_range check (rating >= 0 and rating <= 5),
31
+ constraint guest_review_unique_ref unique (tenant_id, connection_id, unique_ref)
32
+ )
33
+ `.execute(db);
34
+ await sql`
35
+ create index guest_review_reservation_idx on public.guest_review (tenant_id, reservation_id)
36
+ `.execute(db);
37
+ await sql`
38
+ create index guest_review_reviewed_at_idx on public.guest_review (tenant_id, reviewed_at desc)
39
+ `.execute(db);
40
+ }
41
+
42
+ export async function down(db: Kysely<unknown>): Promise<void> {
43
+ await sql`drop table if exists public.guest_review`.execute(db);
44
+ await sql`drop type if exists public.guest_review_channel`.execute(db);
45
+ }
@@ -0,0 +1,91 @@
1
+ import type { Kysely } from 'kysely';
2
+ import { sql } from 'kysely';
3
+
4
+ // PRO-20223: a Ramp external linked bank account is stored as an account
5
+ // connection with role `funding` on the Ramp connection. Funding rows never
6
+ // carry bank records; every bank feed reader filters on `role = 'feed'`.
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
+
11
+ // Attach already keeps one active connection per account; fail loudly if a
12
+ // database holds data the new unique index would reject.
13
+ await sql`
14
+ do $$
15
+ begin
16
+ if exists (
17
+ select 1
18
+ from accounting.account_connection
19
+ where status = 'active' and account_id is not null
20
+ group by tenant_id, connection_id, account_id
21
+ having count(*) > 1
22
+ ) then
23
+ raise exception 'account_connection has two active rows of one connection on one account';
24
+ end if;
25
+ end
26
+ $$
27
+ `.execute(db);
28
+
29
+ await sql`
30
+ create type accounting.account_connection_role as enum ('feed', 'funding')
31
+ `.execute(db);
32
+ await sql`
33
+ create type accounting.account_connection_match_source as enum ('auto', 'manual')
34
+ `.execute(db);
35
+ await sql`
36
+ create type accounting.account_connection_match_status as enum (
37
+ 'matched', 'noMatch', 'ambiguous', 'entityMismatch', 'unmapped'
38
+ )
39
+ `.execute(db);
40
+
41
+ await sql`
42
+ alter table accounting.account_connection
43
+ add column role accounting.account_connection_role not null default 'feed',
44
+ add column funding_entity_ref text null
45
+ check (funding_entity_ref is null or length(funding_entity_ref) between 1 and 500),
46
+ add column match_source accounting.account_connection_match_source null,
47
+ add column match_status accounting.account_connection_match_status null,
48
+ add column match_candidate_account_ids uuid[] not null default '{}',
49
+ add column matched_at timestamptz null,
50
+ add constraint account_connection_funding_fields check (
51
+ role = 'funding' or (
52
+ funding_entity_ref is null and match_source is null and match_status is null
53
+ and cardinality(match_candidate_account_ids) = 0 and matched_at is null)),
54
+ add constraint account_connection_funding_status check (
55
+ role <> 'funding' or ((account_id is not null) = (match_status = 'matched')))
56
+ `.execute(db);
57
+
58
+ await sql`
59
+ create unique index account_connection_connection_account_idx
60
+ on accounting.account_connection (tenant_id, connection_id, account_id)
61
+ where status = 'active' and account_id is not null
62
+ `.execute(db);
63
+ }
64
+
65
+ export async function down(db: Kysely<unknown>): Promise<void> {
66
+ await sql`set local lock_timeout = '5s'`.execute(db);
67
+ await sql`drop index if exists accounting.account_connection_connection_account_idx`.execute(
68
+ db
69
+ );
70
+ await sql`delete from accounting.account_connection where role = 'funding'`.execute(
71
+ db
72
+ );
73
+ await sql`
74
+ alter table accounting.account_connection
75
+ drop constraint if exists account_connection_funding_status,
76
+ drop constraint if exists account_connection_funding_fields,
77
+ drop column if exists matched_at,
78
+ drop column if exists match_candidate_account_ids,
79
+ drop column if exists match_status,
80
+ drop column if exists match_source,
81
+ drop column if exists funding_entity_ref,
82
+ drop column if exists role
83
+ `.execute(db);
84
+ await sql`drop type if exists accounting.account_connection_match_status`.execute(
85
+ db
86
+ );
87
+ await sql`drop type if exists accounting.account_connection_match_source`.execute(
88
+ db
89
+ );
90
+ await sql`drop type if exists accounting.account_connection_role`.execute(db);
91
+ }
@@ -0,0 +1,25 @@
1
+ import type { Kysely } from 'kysely';
2
+ import { sql } from 'kysely';
3
+
4
+ // PRO-19748: the account a payout from a PM statement posts to, next to the
5
+ // Owner Payout (`payout_distribution`) account of owner statement payouts.
6
+ export async function up(db: Kysely<unknown>): Promise<void> {
7
+ await sql`set local lock_timeout = '5s'`.execute(db);
8
+ await sql`
9
+ insert into accounting.account_assignment_type (name)
10
+ values ('payout_manager')
11
+ on conflict (name) do nothing
12
+ `.execute(db);
13
+ }
14
+
15
+ export async function down(db: Kysely<unknown>): Promise<void> {
16
+ await sql`set local lock_timeout = '5s'`.execute(db);
17
+ await sql`
18
+ delete from accounting.account_assignment
19
+ where type = 'payout_manager'
20
+ `.execute(db);
21
+ await sql`
22
+ delete from accounting.account_assignment_type
23
+ where name = 'payout_manager'
24
+ `.execute(db);
25
+ }
@@ -0,0 +1,46 @@
1
+ import type { Kysely } from 'kysely';
2
+ import { sql } from 'kysely';
3
+
4
+ // VRT-805: adds the equity and costOfRevenue classifications and the new
5
+ // categories whose names are free before the renames. The rows use a
6
+ // classification the old code parses; `scripts/fix/vrt-805-chart-of-accounts.ts`
7
+ // renames, re-classifies and creates the new Cost of Revenue - Rents once the
8
+ // new code runs.
9
+ export async function up(db: Kysely<unknown>): Promise<void> {
10
+ await sql`
11
+ insert into accounting.account_classification (name)
12
+ values ('equity'), ('costOfRevenue')
13
+ on conflict (name) do nothing
14
+ `.execute(db);
15
+
16
+ await sql`
17
+ insert into accounting.account_category (id, name, classification, "index")
18
+ values
19
+ ('7ee6de3d-271d-431b-bac8-80cdfd64f342'::uuid, 'Revenue - Guests: Taxes Collected', 'revenue', 53),
20
+ ('fc0679d1-84f6-40a1-94f7-e9f4e0fd6aa5'::uuid, 'Revenue - Management: VAT', 'revenue', 57),
21
+ ('dce650ed-a3d7-4ba5-9c2c-fa99d4badfc7'::uuid, 'Cost of Revenue - Owner Deductions', 'expense', 67),
22
+ ('b182f0f2-82b7-41db-8681-f94b2d4a5b8a'::uuid, 'Cost of Revenue - VAT', 'expense', 68),
23
+ ('a3aeab43-9347-4734-bad3-96e4305dd27d'::uuid, 'Transfers', 'expense', 101),
24
+ ('e1534965-2e01-4bc5-bdf8-a6342980f0ca'::uuid, 'Adjustments', 'expense', 102)
25
+ on conflict (id) do nothing
26
+ `.execute(db);
27
+ }
28
+
29
+ export async function down(db: Kysely<unknown>): Promise<void> {
30
+ await sql`
31
+ delete from accounting.account_category
32
+ where id in (
33
+ '7ee6de3d-271d-431b-bac8-80cdfd64f342'::uuid,
34
+ 'fc0679d1-84f6-40a1-94f7-e9f4e0fd6aa5'::uuid,
35
+ 'dce650ed-a3d7-4ba5-9c2c-fa99d4badfc7'::uuid,
36
+ 'b182f0f2-82b7-41db-8681-f94b2d4a5b8a'::uuid,
37
+ 'a3aeab43-9347-4734-bad3-96e4305dd27d'::uuid,
38
+ 'e1534965-2e01-4bc5-bdf8-a6342980f0ca'::uuid
39
+ )
40
+ `.execute(db);
41
+
42
+ await sql`
43
+ delete from accounting.account_classification
44
+ where name in ('equity', 'costOfRevenue')
45
+ `.execute(db);
46
+ }
@@ -0,0 +1,41 @@
1
+ import type { Kysely } from 'kysely';
2
+ import { sql } from 'kysely';
3
+
4
+ // PRO-20316: bug reports, feedback and questions that API and MCP clients send
5
+ // through POST /feedback. The reporter and the linked Linear issue are stored
6
+ // so a later status read and a "fixed" notification need no schema change.
7
+ // The Intercom contact of the reporter has external_id = reporter_user_id.
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 public.feedback_kind as enum ('bug', 'feedback', 'question')
14
+ `.execute(db);
15
+ await sql`
16
+ create table public.feedback (
17
+ id uuid primary key default gen_random_uuid(),
18
+ tenant_id uuid not null references public.tenant (id) on delete cascade,
19
+ kind public.feedback_kind not null,
20
+ title text not null,
21
+ description text not null,
22
+ related_request text,
23
+ route text,
24
+ operation_id text,
25
+ error_reason text,
26
+ context text,
27
+ reporter_user_id uuid references public."user" (id) on delete set null,
28
+ reporter_email text,
29
+ linear_issue_id text,
30
+ created_at timestamptz not null default now()
31
+ )
32
+ `.execute(db);
33
+ await sql`
34
+ create index feedback_tenant_created_at_idx on public.feedback (tenant_id, created_at desc)
35
+ `.execute(db);
36
+ }
37
+
38
+ export async function down(db: Kysely<unknown>): Promise<void> {
39
+ await sql`drop table if exists public.feedback`.execute(db);
40
+ await sql`drop type if exists public.feedback_kind`.execute(db);
41
+ }
@@ -0,0 +1,43 @@
1
+ import type { Kysely } from 'kysely';
2
+ import { sql } from 'kysely';
3
+
4
+ // The owner block days query behind owner-performance, owner-financials and the
5
+ // occupancy metrics read every calendar source of a team, or the global
6
+ // `(description, type)` index of all teams: up to 2.4 s on a team with 674k
7
+ // calendar rows (PRO-20492). This partial index holds only owner block rows.
8
+ // The query must keep the three predicates as constants so the index serves it.
9
+ // On large databases run scripts/ben-2/pro-20492-create-owner-block-index.ts
10
+ // first: it builds the index 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
+ const existing = await sql<{ valid: boolean }>`
15
+ select (i.indisvalid and i.indisready) as valid
16
+ from pg_index as i
17
+ inner join pg_class as index_class on index_class.oid = i.indexrelid
18
+ where index_class.relname = 'source_owner_block_calendar_idx'
19
+ `.execute(db);
20
+ // `create index if not exists` locks the table before it finds the index, which
21
+ // times out on a busy database, so skip a valid pre-built index here.
22
+ if (existing.rows[0]?.valid) return;
23
+ // A failed concurrent build leaves an invalid index that `if not exists`
24
+ // would keep, so drop it first.
25
+ if (existing.rows[0]) {
26
+ await sql`drop index public.source_owner_block_calendar_idx`.execute(db);
27
+ }
28
+ await sql`
29
+ create index source_owner_block_calendar_idx
30
+ on public.source (tenant_id, date)
31
+ where type = 'calendar'
32
+ and description = 'unavailable'
33
+ and (json ->> 'blockReason') = 'ownerBlock'
34
+ `.execute(db);
35
+ }
36
+
37
+ export async function down(db: Kysely<unknown>): Promise<void> {
38
+ await sql`set local lock_timeout = '5s'`.execute(db);
39
+ await sql`set local statement_timeout = '60s'`.execute(db);
40
+ await sql`
41
+ drop index if exists public.source_owner_block_calendar_idx
42
+ `.execute(db);
43
+ }
@@ -0,0 +1,20 @@
1
+ import type { Kysely } from 'kysely';
2
+ import { sql } from 'kysely';
3
+
4
+ // PRO-20444: a fee applies only to reservations whose stay type is in
5
+ // stay_types_filter. Null means every stay type, so existing fees keep posting
6
+ // on every stay and older writers that omit the column are unaffected.
7
+ export async function up(db: Kysely<unknown>): Promise<void> {
8
+ await sql`set local lock_timeout = '5s'`.execute(db);
9
+ await sql`
10
+ alter table public.recurring_fee
11
+ add column stay_types_filter public.reservation_stay_type[]
12
+ `.execute(db);
13
+ }
14
+
15
+ export async function down(db: Kysely<unknown>): Promise<void> {
16
+ await sql`set local lock_timeout = '5s'`.execute(db);
17
+ await sql`
18
+ alter table public.recurring_fee drop column if exists stay_types_filter
19
+ `.execute(db);
20
+ }
@@ -0,0 +1,40 @@
1
+ import type { Kysely } from 'kysely';
2
+ import { sql } from 'kysely';
3
+
4
+ // The fee editor lists the stay types a team has (PRO-20444). Without an index,
5
+ // finding no owner stays reads every reservation of the team: 10 s on a team
6
+ // with 715k reservations. This partial index holds only owner and friends &
7
+ // family stays, so the lookup must keep `stay_type <> 'guest'` as a constant.
8
+ // On large databases run scripts/ben-2/pro-20444-create-owner-stay-type-index.ts
9
+ // first: it builds the index concurrently, and this migration then skips it.
10
+ export async function up(db: Kysely<unknown>): Promise<void> {
11
+ await sql`set local lock_timeout = '5s'`.execute(db);
12
+ await sql`set local statement_timeout = '30min'`.execute(db);
13
+ const existing = await sql<{ valid: boolean }>`
14
+ select (i.indisvalid and i.indisready) as valid
15
+ from pg_index as i
16
+ inner join pg_class as index_class on index_class.oid = i.indexrelid
17
+ where index_class.relname = 'reservation_owner_stay_type_idx'
18
+ `.execute(db);
19
+ // `create index if not exists` locks the table before it finds the index, which
20
+ // times out on a busy database, so skip a valid pre-built index here.
21
+ if (existing.rows[0]?.valid) return;
22
+ // A failed concurrent build leaves an invalid index that `if not exists`
23
+ // would keep, so drop it first.
24
+ if (existing.rows[0]) {
25
+ await sql`drop index public.reservation_owner_stay_type_idx`.execute(db);
26
+ }
27
+ await sql`
28
+ create index reservation_owner_stay_type_idx
29
+ on public.reservation (tenant_id, stay_type)
30
+ where stay_type <> 'guest'
31
+ `.execute(db);
32
+ }
33
+
34
+ export async function down(db: Kysely<unknown>): Promise<void> {
35
+ await sql`set local lock_timeout = '5s'`.execute(db);
36
+ await sql`set local statement_timeout = '60s'`.execute(db);
37
+ await sql`
38
+ drop index if exists public.reservation_owner_stay_type_idx
39
+ `.execute(db);
40
+ }
@@ -0,0 +1,63 @@
1
+ import type { Kysely } from 'kysely';
2
+ import { sql } from 'kysely';
3
+
4
+ // BIL-613: drop the stored tenant test flag and the generated legacy billing
5
+ // flag. Test classification comes from partner assignments, payment ownership
6
+ // from the effective Billing Partner. Hasura's tenant event-trigger functions
7
+ // list every column, so they are rewritten first. A function that still names
8
+ // either column, or a view that depends on one, aborts the migration.
9
+ export async function up(db: Kysely<unknown>): Promise<void> {
10
+ await sql`set local lock_timeout = '5s'`.execute(db);
11
+ await sql`set local statement_timeout = '60s'`.execute(db);
12
+ await sql`
13
+ do $$
14
+ declare
15
+ definition text;
16
+ begin
17
+ for definition in
18
+ select pg_get_functiondef(p.oid)
19
+ from pg_proc p
20
+ join pg_namespace n on n.oid = p.pronamespace
21
+ where n.nspname = 'hdb_catalog'
22
+ and p.prorettype = 'pg_catalog.trigger'::regtype
23
+ and p.prosrc ~ '\\m(is_test|calculated_is_billable)\\M'
24
+ loop
25
+ definition := regexp_replace(
26
+ definition,
27
+ '(OLD|NEW)\\."(is_test|calculated_is_billable)"[[:space:]]*,[[:space:]]*',
28
+ '',
29
+ 'gi'
30
+ );
31
+ definition := regexp_replace(
32
+ definition,
33
+ '[[:space:]]*,[[:space:]]*(OLD|NEW)\\."(is_test|calculated_is_billable)"',
34
+ '',
35
+ 'gi'
36
+ );
37
+ if definition ~ '\\m(is_test|calculated_is_billable)\\M' then
38
+ raise exception 'Hasura trigger still references a retired tenant column';
39
+ end if;
40
+ execute definition;
41
+ end loop;
42
+ end;
43
+ $$
44
+ `.execute(db);
45
+ await sql`
46
+ alter table public.tenant
47
+ drop column if exists is_test,
48
+ drop column if exists calculated_is_billable
49
+ `.execute(db);
50
+ }
51
+
52
+ // Restores both columns for older code. Stored test flags come back as false.
53
+ export async function down(db: Kysely<unknown>): Promise<void> {
54
+ await sql`
55
+ alter table public.tenant
56
+ add column if not exists is_test boolean default false,
57
+ add column if not exists calculated_is_billable boolean
58
+ generated always as (
59
+ coalesce(billing_partner_id, partner_id) = '7bfec41f-aa3f-4602-95d2-f7996e4f0e59'::uuid
60
+ or coalesce(billing_partner_id, partner_id) = 'd6ab2bbe-e0fc-48d9-89a3-c3c05f4e79b5'::uuid
61
+ ) stored
62
+ `.execute(db);
63
+ }
@@ -0,0 +1,56 @@
1
+ import type { Kysely } from 'kysely';
2
+ import { sql } from 'kysely';
3
+
4
+ // PRO-18843: one Ramp application per team, started from the VRPilot Connect
5
+ // Ramp step. The row holds who Ramp invited, the application status, and the
6
+ // application-only OAuth grant and webhook subscription of the new Ramp
7
+ // business. A team gets its Ramp connection later through the connect flow.
8
+ // `state_nonce` ties Ramp's consent redirect to this application, and
9
+ // `webhook_token` is the header Ramp sends back with every webhook request.
10
+ export async function up(db: Kysely<unknown>): Promise<void> {
11
+ await sql`set local lock_timeout = '5s'`.execute(db);
12
+ await sql`set local statement_timeout = '60s'`.execute(db);
13
+
14
+ await sql`
15
+ create type public.ramp_application_status as enum (
16
+ 'invited',
17
+ 'started',
18
+ 'inReview',
19
+ 'followUpsRequired',
20
+ 'approved',
21
+ 'rejected',
22
+ 'withdrawn'
23
+ )
24
+ `.execute(db);
25
+ await sql`
26
+ create type public.ramp_application_environment as enum ('demo', 'production')
27
+ `.execute(db);
28
+ await sql`
29
+ create table public.ramp_application (
30
+ id uuid primary key default gen_random_uuid(),
31
+ tenant_id uuid not null unique references public.tenant (id) on delete cascade,
32
+ applicant_user_id uuid references public."user" (id) on delete set null,
33
+ applicant_email text not null,
34
+ environment public.ramp_application_environment not null,
35
+ status public.ramp_application_status not null default 'invited',
36
+ ramp_application_id text,
37
+ credentials jsonb,
38
+ state_nonce text not null,
39
+ webhook_token text,
40
+ webhook_id text,
41
+ webhook_secret text,
42
+ invited_at timestamptz not null default now(),
43
+ status_updated_at timestamptz not null default now(),
44
+ created_at timestamptz not null default now(),
45
+ updated_at timestamptz not null default now()
46
+ )
47
+ `.execute(db);
48
+ }
49
+
50
+ export async function down(db: Kysely<unknown>): Promise<void> {
51
+ await sql`drop table if exists public.ramp_application`.execute(db);
52
+ await sql`drop type if exists public.ramp_application_environment`.execute(
53
+ db
54
+ );
55
+ await sql`drop type if exists public.ramp_application_status`.execute(db);
56
+ }
@@ -0,0 +1,10 @@
1
+ import { type Kysely, sql } from 'kysely';
2
+
3
+ export async function up(db: Kysely<unknown>): Promise<void> {
4
+ await sql`alter type core.operation_type add value if not exists 'advanced-deposits-update'`.execute(
5
+ db
6
+ );
7
+ }
8
+
9
+ // PostgreSQL enum additions are retained so historical operations remain readable.
10
+ export async function down(_db: Kysely<unknown>): Promise<void> {}
@@ -0,0 +1,46 @@
1
+ import type { Kysely } from 'kysely';
2
+ import { sql } from 'kysely';
3
+
4
+ // 1099s: the tax ID type (SSN or EIN) and whether the contact gets no 1099.
5
+ // Expand only: code that predates it ignores both columns. The type comes from
6
+ // the stored format, otherwise from the owner type; C and S corporations start
7
+ // exempt.
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 = '120s'`.execute(db);
11
+
12
+ await sql`
13
+ create type accounting.contact_tax_id_type as enum ('ssn', 'ein')
14
+ `.execute(db);
15
+ await sql`
16
+ alter table accounting.contact
17
+ add column tax_id_type accounting.contact_tax_id_type,
18
+ add column is1099_exempt boolean not null default false
19
+ `.execute(db);
20
+ await sql`
21
+ update accounting.contact
22
+ set tax_id_type = case
23
+ when tax_id ~ '^\\s*\\d{3}-\\d{2}-\\d{4}\\s*$' then 'ssn'
24
+ when tax_id ~ '^\\s*\\d{2}-\\d{7}\\s*$' then 'ein'
25
+ when company_type is null then 'ssn'
26
+ else 'ein'
27
+ end::accounting.contact_tax_id_type
28
+ where tax_id_type is null
29
+ and nullif(btrim(tax_id), '') is not null
30
+ `.execute(db);
31
+ await sql`
32
+ update accounting.contact
33
+ set is1099_exempt = true
34
+ where company_type in ('c_corporation', 's_corporation')
35
+ and not is1099_exempt
36
+ `.execute(db);
37
+ }
38
+
39
+ export async function down(db: Kysely<unknown>): Promise<void> {
40
+ await sql`
41
+ alter table accounting.contact
42
+ drop column if exists tax_id_type,
43
+ drop column if exists is1099_exempt
44
+ `.execute(db);
45
+ await sql`drop type if exists accounting.contact_tax_id_type`.execute(db);
46
+ }
@@ -0,0 +1,36 @@
1
+ import type { Kysely } from 'kysely';
2
+ import { sql } from 'kysely';
3
+
4
+ // PRO-20621: teams edit four 1099 owner emails in Settings > Emails.
5
+ export async function up(db: Kysely<unknown>): Promise<void> {
6
+ await sql`
7
+ insert into public.email_template_type (name)
8
+ values
9
+ ('taxInfoRequest_owner'),
10
+ ('emailDeliveryRequest_owner'),
11
+ ('tax1099Ready_owner'),
12
+ ('tax1099Corrected_owner')
13
+ on conflict do nothing
14
+ `.execute(db);
15
+ }
16
+
17
+ export async function down(db: Kysely<unknown>): Promise<void> {
18
+ await sql`
19
+ delete from public.email_template
20
+ where type in (
21
+ 'taxInfoRequest_owner',
22
+ 'emailDeliveryRequest_owner',
23
+ 'tax1099Ready_owner',
24
+ 'tax1099Corrected_owner'
25
+ )
26
+ `.execute(db);
27
+ await sql`
28
+ delete from public.email_template_type
29
+ where name in (
30
+ 'taxInfoRequest_owner',
31
+ 'emailDeliveryRequest_owner',
32
+ 'tax1099Ready_owner',
33
+ 'tax1099Corrected_owner'
34
+ )
35
+ `.execute(db);
36
+ }
@@ -0,0 +1,18 @@
1
+ import type { Kysely } from 'kysely';
2
+ import { sql } from 'kysely';
3
+
4
+ // PRO-20659: regional copy of the control-plane team lock. Payout paths read
5
+ // it from the team's own database. Null while the team is unlocked.
6
+ export async function up(db: Kysely<unknown>): Promise<void> {
7
+ await sql`set local lock_timeout = '5s'`.execute(db);
8
+ await sql`
9
+ alter table public.tenant
10
+ add column if not exists locked_at timestamptz
11
+ `.execute(db);
12
+ }
13
+
14
+ export async function down(db: Kysely<unknown>): Promise<void> {
15
+ await sql`alter table public.tenant drop column if exists locked_at`.execute(
16
+ db
17
+ );
18
+ }