@vrplatform/kysely 1.3.45-4459 → 1.3.45-44603116832

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 (352) 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/0000000000150-recurring-fee-listing-subscription-listing-index.ts +37 -0
  228. package/build/migrations-v2/0000000000151-core-change-unused-indexes.ts +85 -0
  229. package/build/migrations-v2/0000000000152-core-change-pms-sync-failures-index.ts +38 -0
  230. package/build/migrations-v2/0000000000154-accounting-integrity-backlog-performance.ts +68 -0
  231. package/build/migrations-v2/0000000000155-source-last-successful-hash.ts +23 -0
  232. package/build/module/camel-case/index.d.ts +4 -4
  233. package/build/module/camel-case/index.js +4 -3
  234. package/build/module/camel-case/index.js.map +1 -1
  235. package/build/module/connect-handoff.d.ts +12 -0
  236. package/build/module/connect-handoff.js +70 -0
  237. package/build/module/connect-handoff.js.map +1 -0
  238. package/build/module/control-plane/index.d.ts +421 -14
  239. package/build/module/control-plane/index.js +58 -1
  240. package/build/module/control-plane/index.js.map +1 -1
  241. package/build/module/domain.d.ts +4 -0
  242. package/build/module/domain.js +2 -0
  243. package/build/module/domain.js.map +1 -0
  244. package/build/module/error.d.ts +2 -1
  245. package/build/module/error.js +3 -1
  246. package/build/module/error.js.map +1 -1
  247. package/build/module/index.d.ts +57 -15
  248. package/build/module/index.js +496 -64
  249. package/build/module/index.js.map +1 -1
  250. package/build/module/isomorphic.d.ts +6 -6
  251. package/build/module/isomorphic.js +2 -7
  252. package/build/module/isomorphic.js.map +1 -1
  253. package/build/module/local/digest.d.ts +3 -3
  254. package/build/module/local/digest.js.map +1 -1
  255. package/build/module/local/generate.js +15 -13
  256. package/build/module/local/generate.js.map +1 -1
  257. package/build/module/local/index.d.ts +5 -1
  258. package/build/module/local/index.js +347 -13
  259. package/build/module/local/index.js.map +1 -1
  260. package/build/module/local/prune-pulled-schema.js +4 -1
  261. package/build/module/local/prune-pulled-schema.js.map +1 -1
  262. package/build/module/migration-source.d.ts +4 -0
  263. package/build/module/migration-source.js +42 -0
  264. package/build/module/migration-source.js.map +1 -0
  265. package/build/module/migration.d.ts +7 -0
  266. package/build/module/migration.js +8 -0
  267. package/build/module/migration.js.map +1 -0
  268. package/build/module/pganalyze-comment-plugin/comment-transformer.js +3 -1
  269. package/build/module/pganalyze-comment-plugin/comment-transformer.js.map +1 -1
  270. package/build/module/plugins.d.ts +2 -2
  271. package/build/module/plugins.js.map +1 -1
  272. package/build/module/postgres-error.d.ts +9 -0
  273. package/build/module/postgres-error.js +24 -0
  274. package/build/module/postgres-error.js.map +1 -0
  275. package/build/module/query/index.d.ts +1 -0
  276. package/build/module/query/index.js +1 -0
  277. package/build/module/query/index.js.map +1 -1
  278. package/build/module/query/listing/status.d.ts +2 -12
  279. package/build/module/query/listing/status.js +35 -18
  280. package/build/module/query/listing/status.js.map +1 -1
  281. package/build/module/query/tenant/billing-partner.d.ts +4 -0
  282. package/build/module/query/tenant/billing-partner.js +5 -0
  283. package/build/module/query/tenant/billing-partner.js.map +1 -0
  284. package/build/module/query/tenant/feature-enabled.d.ts +6 -0
  285. package/build/module/query/tenant/feature-enabled.js +27 -0
  286. package/build/module/query/tenant/feature-enabled.js.map +1 -0
  287. package/build/module/query/tenant/index.d.ts +4 -0
  288. package/build/module/query/tenant/index.js +5 -0
  289. package/build/module/query/tenant/index.js.map +1 -0
  290. package/build/module/query/tenant/status.d.ts +9 -0
  291. package/build/module/query/tenant/status.js +28 -0
  292. package/build/module/query/tenant/status.js.map +1 -0
  293. package/build/module/query/tenant/where-uuid-in.d.ts +2 -0
  294. package/build/module/query/tenant/where-uuid-in.js +11 -0
  295. package/build/module/query/tenant/where-uuid-in.js.map +1 -0
  296. package/build/module/regional.d.ts +31 -4
  297. package/build/module/regional.js +68 -8
  298. package/build/module/regional.js.map +1 -1
  299. package/build/module/test/index.d.ts +21 -11
  300. package/build/module/test/index.js +31 -26
  301. package/build/module/test/index.js.map +1 -1
  302. package/build/module/transaction.d.ts +3 -3
  303. package/build/module/transaction.js.map +1 -1
  304. package/build/module/v1.generated.d.ts +1407 -177
  305. package/build/module/v1.generated.js.map +1 -1
  306. package/package.json +19 -16
  307. package/build/migrations/0000000000001-init.ts +0 -5
  308. package/build/migrations/0000000000009-drop-store-schema.ts +0 -14
  309. package/build/migrations/0000000000010-bank-rules.ts +0 -190
  310. package/build/migrations/0000000000011-bank-rule-line-adjustments.ts +0 -65
  311. package/build/migrations/0000000000012-bank-rule-conditions.ts +0 -45
  312. package/build/migrations/0000000000013-bank-rule-name-unique.ts +0 -15
  313. package/build/migrations/0000000000014-bank-rule-drop-legacy-conditions.ts +0 -41
  314. package/build/migrations/0000000000015-booking-channel-logo-dev-provider.ts +0 -70
  315. package/build/migrations/0000000000016-owner-statement-draft-status.ts +0 -22
  316. package/build/migrations/0000000000017-tenant-migration-markers.ts +0 -18
  317. package/build/migrations/0000000000018-security-deposits-payable-category.ts +0 -63
  318. package/build/migrations/0000000000019-tenant-app-settings.ts +0 -76
  319. package/build/migrations/0000000000020-operating-opening-trial-balance.ts +0 -36
  320. package/build/migrations/0000000000021-audit-foreign-key-indexes.ts +0 -77
  321. package/build/migrations/0000000000022-opening-trial-balance-combined-columns.ts +0 -30
  322. package/build/migrations/0000000000024-listing-parent.ts +0 -37
  323. package/build/migrations/0000000000025-journal-entry-parent-listing.ts +0 -26
  324. package/build/migrations/0000000000026-booking-channel-logo-slots.ts +0 -89
  325. package/build/migrations/0000000000027-list-browse-performance-indexes.ts +0 -52
  326. package/build/migrations/0000000000028-flow-setting-status-jsonb.ts +0 -20
  327. package/build/migrations/0000000000029-tenant-slug.ts +0 -328
  328. package/build/migrations/0000000000030-pms-accounting-windows.ts +0 -50
  329. package/build/migrations/0000000000031-owner-statement-projection-listing-revision.ts +0 -20
  330. package/build/migrations/0000000000032-flow-event-listening.ts +0 -28
  331. package/build/migrations/0000000000033-opening-trial-balance-transaction.ts +0 -272
  332. package/build/migrations/0000000000034-historic-general-ledger.ts +0 -24
  333. package/build/migrations/0000000000035-tenant-regional-placement.ts +0 -37
  334. package/build/migrations/0000000000036-control-plane-projection-events.ts +0 -43
  335. package/build/migrations/0000000000037-tenant-guide-onboarding.ts +0 -21
  336. package/build/migrations/0000000000038-tracking-event-analytics-sink.ts +0 -31
  337. package/build/migrations/0000000000039-crunchy-region.ts +0 -86
  338. package/build/migrations/0000000000040-hostaway-region.ts +0 -72
  339. package/build/migrations/0000000000041-audit-tenant-fk.ts +0 -66
  340. package/build/migrations/0000000000042-ramp-staging-connect-params.ts +0 -35
  341. package/build/migrations/0000000000043-gl-pms-accounting-window-guard.ts +0 -125
  342. package/build/migrations/0000000000044-tenant-cross-region-fks.ts +0 -45
  343. package/build/migrations/0000000000045-cloudflare-region-env.ts +0 -100
  344. package/build/migrations/0000000000046-control-plane-outbox-alias.ts +0 -46
  345. package/build/migrations/0000000000047-ramp-contact-last-4-digits.ts +0 -16
  346. package/build/migrations/0000000000047-tenant-status-backfill.ts +0 -40
  347. package/build/migrations/0000000000048-tenant-status-constraint.ts +0 -24
  348. package/build/migrations/0000000000049-health-tenant-issues.ts +0 -69
  349. package/build/migrations/0000000000050-partner-webhooks.ts +0 -135
  350. package/build/migrations/0000000000051-health-webhook-runtime-grants.ts +0 -42
  351. package/build/migrations/0000000000052-feature-approval-team-enablement.ts +0 -13
  352. package/build/migrations/0000000000053-health-webhook-enums.ts +0 -296
@@ -0,0 +1,65 @@
1
+ import type { Kysely } from 'kysely';
2
+ import { sql } from 'kysely';
3
+
4
+ // PRO-20653: one row per two-step verification reset of a team's user. A reset
5
+ // a Team Admin starts is approved on creation. A support start waits as
6
+ // `pending` until a Team Admin decides, unless support checked the identity of
7
+ // a team's only admin. One pending request per user and team. Expand only.
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.second_factor_reset_initiator as enum ('teamAdmin', 'support')
14
+ `.execute(db);
15
+ await sql`
16
+ create type public.second_factor_reset_status as enum ('pending', 'approved', 'denied', 'expired')
17
+ `.execute(db);
18
+ await sql`
19
+ create table public.second_factor_reset (
20
+ id uuid primary key default gen_random_uuid(),
21
+ tenant_id uuid not null references public.tenant (id) on delete cascade,
22
+ user_id uuid not null references public."user" (id) on delete cascade,
23
+ initiator public.second_factor_reset_initiator not null,
24
+ status public.second_factor_reset_status not null,
25
+ requested_by_user_id uuid null references public."user" (id) on delete set null,
26
+ decided_by_user_id uuid null references public."user" (id) on delete set null,
27
+ decided_at timestamptz null,
28
+ identity_check text null check (length(identity_check) between 1 and 500),
29
+ expires_at timestamptz not null,
30
+ created_at timestamptz not null default now(),
31
+ updated_at timestamptz not null default now()
32
+ )
33
+ `.execute(db);
34
+ await sql`
35
+ create index second_factor_reset_tenant_status_idx
36
+ on public.second_factor_reset (tenant_id, status)
37
+ `.execute(db);
38
+ await sql`
39
+ create unique index second_factor_reset_pending_idx
40
+ on public.second_factor_reset (tenant_id, user_id)
41
+ where status = 'pending'
42
+ `.execute(db);
43
+ await sql`
44
+ create index second_factor_reset_user_idx
45
+ on public.second_factor_reset (user_id)
46
+ `.execute(db);
47
+ await sql`
48
+ do $$
49
+ begin
50
+ if exists (select 1 from pg_roles where rolname = 'application') then
51
+ grant select, insert, update, delete on public.second_factor_reset
52
+ to application;
53
+ end if;
54
+ end;
55
+ $$
56
+ `.execute(db);
57
+ }
58
+
59
+ export async function down(db: Kysely<unknown>): Promise<void> {
60
+ await sql`drop table if exists public.second_factor_reset`.execute(db);
61
+ await sql`drop type if exists public.second_factor_reset_status`.execute(db);
62
+ await sql`drop type if exists public.second_factor_reset_initiator`.execute(
63
+ db
64
+ );
65
+ }
@@ -0,0 +1,49 @@
1
+ import type { Kysely } from 'kysely';
2
+ import { sql } from 'kysely';
3
+
4
+ // PRO-20657: one row per hold on payouts to a contact whose bank details just
5
+ // changed. A hold is active until `held_until` passes or it is released.
6
+ // Expand only; code that predates the table ignores it.
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
+ await sql`
12
+ create type accounting.payout_hold_reason as enum (
13
+ 'newBankDetails', 'takeoverPattern'
14
+ )
15
+ `.execute(db);
16
+ await sql`
17
+ create table accounting.payout_hold (
18
+ id uuid primary key default gen_random_uuid(),
19
+ tenant_id uuid not null references public.tenant (id) on delete restrict,
20
+ contact_id uuid not null references accounting.contact (id) on delete cascade,
21
+ reason accounting.payout_hold_reason not null,
22
+ held_until timestamptz not null,
23
+ created_by_user_id uuid null references public.user (id) on delete set null,
24
+ created_by_api_token_id uuid null,
25
+ released_at timestamptz null,
26
+ released_by_user_id uuid null references public.user (id) on delete set null,
27
+ created_at timestamptz not null default now()
28
+ )
29
+ `.execute(db);
30
+ await sql`
31
+ create index payout_hold_contact_idx
32
+ on accounting.payout_hold (tenant_id, contact_id, held_until desc)
33
+ `.execute(db);
34
+ await sql`
35
+ do $$
36
+ begin
37
+ if exists (select 1 from pg_roles where rolname = 'application') then
38
+ grant select, insert, update, delete
39
+ on accounting.payout_hold to application;
40
+ end if;
41
+ end;
42
+ $$
43
+ `.execute(db);
44
+ }
45
+
46
+ export async function down(db: Kysely<unknown>): Promise<void> {
47
+ await sql`drop table if exists accounting.payout_hold`.execute(db);
48
+ await sql`drop type if exists accounting.payout_hold_reason`.execute(db);
49
+ }
@@ -0,0 +1,62 @@
1
+ import type { Kysely } from 'kysely';
2
+ import { sql } from 'kysely';
3
+
4
+ // PRO-20658: an invite to an email outside the team's and its partner's email
5
+ // domains waits here until another Team Admin, or VRPlatform support on a team
6
+ // with one admin, approves it. The invite runs on approval, so nothing exists
7
+ // for the invited user until then. One pending request per team and email.
8
+ // Expand only.
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
+
13
+ await sql`
14
+ create type public.member_invite_approval_status as enum ('pending', 'approved', 'rejected')
15
+ `.execute(db);
16
+ await sql`
17
+ create type public.member_invite_approval_role as enum ('admin', 'user')
18
+ `.execute(db);
19
+ await sql`
20
+ create table public.member_invite_approval (
21
+ id uuid primary key default gen_random_uuid(),
22
+ tenant_id uuid not null references public.tenant (id) on delete cascade,
23
+ email text not null,
24
+ role public.member_invite_approval_role null,
25
+ permission_bundles text[] null,
26
+ send_email boolean not null default true,
27
+ status public.member_invite_approval_status not null default 'pending',
28
+ requested_by_user_id uuid null references public."user" (id) on delete set null,
29
+ decided_by_user_id uuid null references public."user" (id) on delete set null,
30
+ decided_at timestamptz null,
31
+ created_at timestamptz not null default now(),
32
+ updated_at timestamptz not null default now()
33
+ )
34
+ `.execute(db);
35
+ await sql`
36
+ create index member_invite_approval_tenant_status_idx
37
+ on public.member_invite_approval (tenant_id, status)
38
+ `.execute(db);
39
+ await sql`
40
+ create unique index member_invite_approval_pending_idx
41
+ on public.member_invite_approval (tenant_id, email)
42
+ where status = 'pending'
43
+ `.execute(db);
44
+ await sql`
45
+ do $$
46
+ begin
47
+ if exists (select 1 from pg_roles where rolname = 'application') then
48
+ grant select, insert, update, delete on public.member_invite_approval
49
+ to application;
50
+ end if;
51
+ end;
52
+ $$
53
+ `.execute(db);
54
+ }
55
+
56
+ export async function down(db: Kysely<unknown>): Promise<void> {
57
+ await sql`drop table if exists public.member_invite_approval`.execute(db);
58
+ await sql`drop type if exists public.member_invite_approval_role`.execute(db);
59
+ await sql`drop type if exists public.member_invite_approval_status`.execute(
60
+ db
61
+ );
62
+ }
@@ -0,0 +1,38 @@
1
+ import type { Kysely } from 'kysely';
2
+ import { sql } from 'kysely';
3
+
4
+ // PRO-20660: the IP address of the user session that made a request, shown in
5
+ // the security log. It lives in its own table so the busy audit.action table is
6
+ // not altered or indexed: the `retention/audit-client-ips` task deletes rows
7
+ // after 90 days with the created_at index. Expand only; code that predates the
8
+ // table ignores it.
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
+
13
+ await sql`
14
+ create table audit.action_client_ip (
15
+ action_id uuid primary key references audit.action (id) on delete cascade,
16
+ client_ip inet not null,
17
+ created_at timestamptz not null default now()
18
+ )
19
+ `.execute(db);
20
+ await sql`
21
+ create index action_client_ip_created_idx
22
+ on audit.action_client_ip (created_at)
23
+ `.execute(db);
24
+ await sql`
25
+ do $$
26
+ begin
27
+ if exists (select 1 from pg_roles where rolname = 'application') then
28
+ grant select, insert, update, delete
29
+ on audit.action_client_ip to application;
30
+ end if;
31
+ end;
32
+ $$
33
+ `.execute(db);
34
+ }
35
+
36
+ export async function down(db: Kysely<unknown>): Promise<void> {
37
+ await sql`drop table if exists audit.action_client_ip`.execute(db);
38
+ }
@@ -0,0 +1,39 @@
1
+ import type { Kysely } from 'kysely';
2
+ import { sql } from 'kysely';
3
+
4
+ // PRO-20708: Hasura metadata no longer defines the event triggers
5
+ // tracking_user, tracking_tenant_user, tracking_tenant and user-name
6
+ // (PRO-16860), but their generated Postgres triggers kept writing
7
+ // hdb_catalog.event_log rows that nothing delivers. On Crunchy, 145k of them
8
+ // made every Hasura event poll take about 105 ms. Their rows are dropped with
9
+ // the triggers and are not restored by down.
10
+ const triggers = [
11
+ ['user', 'tracking_user', ['INSERT', 'UPDATE', 'DELETE']],
12
+ ['user', 'user-name', ['UPDATE']],
13
+ ['tenant_user', 'tracking_tenant_user', ['INSERT', 'UPDATE', 'DELETE']],
14
+ ['tenant', 'tracking_tenant', ['INSERT', 'UPDATE', 'DELETE']],
15
+ ] as const;
16
+
17
+ export async function up(db: Kysely<unknown>): Promise<void> {
18
+ await sql`set local lock_timeout = '5s'`.execute(db);
19
+ await sql`set local statement_timeout = '240s'`.execute(db);
20
+ for (const [table, name, operations] of triggers) {
21
+ for (const operation of operations) {
22
+ const fn = `notify_hasura_${name}_${operation}`;
23
+ await sql`
24
+ drop trigger if exists ${sql.id(fn)} on ${sql.id('public', table)}
25
+ `.execute(db);
26
+ await sql`drop function if exists ${sql.id('hdb_catalog', fn)}()`.execute(
27
+ db
28
+ );
29
+ }
30
+ }
31
+ await sql`
32
+ delete from hdb_catalog.event_log
33
+ where trigger_name in (${sql.join(triggers.map(([, name]) => name))})
34
+ `.execute(db);
35
+ }
36
+
37
+ // Hasura generates these functions from metadata, which no longer defines the
38
+ // triggers, so there is nothing to restore.
39
+ export async function down(): Promise<void> {}
@@ -0,0 +1,42 @@
1
+ import type { Kysely } from 'kysely';
2
+ import { sql } from 'kysely';
3
+
4
+ // PRO-20708: 0000000000134 passed the trigger names through sql.id, and the
5
+ // migrator's CamelCasePlugin rewrote them (notify_hasura_tracking_user_INSERT
6
+ // became a name that does not exist), so its `drop ... if exists` statements
7
+ // matched nothing. The names are written literally here.
8
+ const statements = [
9
+ ['user', 'notify_hasura_tracking_user_INSERT'],
10
+ ['user', 'notify_hasura_tracking_user_UPDATE'],
11
+ ['user', 'notify_hasura_tracking_user_DELETE'],
12
+ ['user', 'notify_hasura_user-name_UPDATE'],
13
+ ['tenant_user', 'notify_hasura_tracking_tenant_user_INSERT'],
14
+ ['tenant_user', 'notify_hasura_tracking_tenant_user_UPDATE'],
15
+ ['tenant_user', 'notify_hasura_tracking_tenant_user_DELETE'],
16
+ ['tenant', 'notify_hasura_tracking_tenant_INSERT'],
17
+ ['tenant', 'notify_hasura_tracking_tenant_UPDATE'],
18
+ ['tenant', 'notify_hasura_tracking_tenant_DELETE'],
19
+ ] as const;
20
+
21
+ export async function up(db: Kysely<unknown>): Promise<void> {
22
+ await sql`set local lock_timeout = '5s'`.execute(db);
23
+ await sql`set local statement_timeout = '240s'`.execute(db);
24
+ for (const [table, name] of statements) {
25
+ await sql
26
+ .raw(`drop trigger if exists "${name}" on public."${table}"`)
27
+ .execute(db);
28
+ await sql
29
+ .raw(`drop function if exists hdb_catalog."${name}"()`)
30
+ .execute(db);
31
+ }
32
+ await sql`
33
+ delete from hdb_catalog.event_log
34
+ where trigger_name in (
35
+ 'tracking_user', 'user-name', 'tracking_tenant_user', 'tracking_tenant'
36
+ )
37
+ `.execute(db);
38
+ }
39
+
40
+ // Hasura generates these functions from metadata, which no longer defines the
41
+ // triggers, so there is nothing to restore.
42
+ export async function down(): Promise<void> {}
@@ -0,0 +1,43 @@
1
+ import type { Kysely } from 'kysely';
2
+ import { sql } from 'kysely';
3
+
4
+ // PRO-20708: Hasura metadata defines no event trigger since 2026-11-14
5
+ // (PRO-20709, PRO-20753), and only Crunchy ever ran Hasura. The generated
6
+ // notify_hasura_* triggers left in the other databases wrote hdb_catalog.event_log
7
+ // rows nothing delivers. Drops every one of them and their functions, found in
8
+ // the catalog so the migrator's CamelCasePlugin never touches the names
9
+ // (0000000000134), and their undelivered rows. Not restored by down.
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 = '240s'`.execute(db);
13
+ await sql`
14
+ do $$
15
+ declare
16
+ item record;
17
+ begin
18
+ for item in
19
+ select trigger.tgname as name, trigger.tgrelid::regclass as relation
20
+ from pg_trigger as trigger
21
+ where trigger.tgname like 'notify\\_hasura\\_%' and not trigger.tgisinternal
22
+ loop
23
+ execute format('drop trigger if exists %I on %s', item.name, item.relation);
24
+ end loop;
25
+ for item in
26
+ select fn.oid::regprocedure as signature
27
+ from pg_proc as fn
28
+ inner join pg_namespace as namespace on namespace.oid = fn.pronamespace
29
+ where namespace.nspname = 'hdb_catalog' and fn.proname like 'notify\\_hasura\\_%'
30
+ loop
31
+ execute format('drop function if exists %s', item.signature);
32
+ end loop;
33
+ end
34
+ $$
35
+ `.execute(db);
36
+ await sql`
37
+ delete from hdb_catalog.event_log where not delivered and not archived
38
+ `.execute(db);
39
+ }
40
+
41
+ // Hasura generates these functions from metadata, which defines no event
42
+ // trigger, so there is nothing to restore.
43
+ export async function down(): Promise<void> {}
@@ -0,0 +1,57 @@
1
+ import type { Kysely } from 'kysely';
2
+ import { sql } from 'kysely';
3
+
4
+ // Business transactions record webhook events here; a queue processor matches them to the
5
+ // subscriptions that now live in the control plane
6
+ // (docs/rfcs/2026-11-webhook-subscriptions-control-plane.md). Deliveries and attempts keep
7
+ // their subscription ids, whose rows move to the control plane, so the foreign keys go.
8
+ export async function up(db: Kysely<unknown>): Promise<void> {
9
+ await sql`
10
+ create table webhook.event (
11
+ id uuid primary key default gen_random_uuid(),
12
+ tenant_id uuid not null references public.tenant (id) on delete cascade,
13
+ event_type webhook.event_type not null,
14
+ resource_type webhook.resource_type not null,
15
+ resource_id text not null,
16
+ source_event_key text not null,
17
+ data jsonb not null,
18
+ created_at timestamptz not null default now(),
19
+ matched_at timestamptz,
20
+ constraint webhook_event_source_event_key_unique unique (tenant_id, source_event_key)
21
+ )
22
+ `.execute(db);
23
+ await sql`
24
+ create index webhook_event_unmatched_idx
25
+ on webhook.event (created_at, id)
26
+ where matched_at is null
27
+ `.execute(db);
28
+ await sql`
29
+ create index webhook_event_matched_idx
30
+ on webhook.event (matched_at)
31
+ where matched_at is not null
32
+ `.execute(db);
33
+ await sql`
34
+ alter table webhook.delivery
35
+ drop constraint delivery_subscription_id_fkey
36
+ `.execute(db);
37
+ await sql`
38
+ alter table webhook.delivery_attempt_secret
39
+ drop constraint delivery_attempt_secret_subscription_secret_id_fkey
40
+ `.execute(db);
41
+ }
42
+
43
+ export async function down(db: Kysely<unknown>): Promise<void> {
44
+ await sql`
45
+ alter table webhook.delivery_attempt_secret
46
+ add constraint delivery_attempt_secret_subscription_secret_id_fkey
47
+ foreign key (subscription_secret_id)
48
+ references webhook.subscription_secret (id) on delete restrict
49
+ `.execute(db);
50
+ await sql`
51
+ alter table webhook.delivery
52
+ add constraint delivery_subscription_id_fkey
53
+ foreign key (subscription_id)
54
+ references webhook.subscription (id) on delete cascade
55
+ `.execute(db);
56
+ await sql`drop table webhook.event`.execute(db);
57
+ }
@@ -0,0 +1,24 @@
1
+ import type { Kysely } from 'kysely';
2
+ import { sql } from 'kysely';
3
+
4
+ // PRO-20639: when the team last asked an owner for tax info or for 1099
5
+ // delivery by email only. Set while the request is open; the owner's save on
6
+ // Tax info clears both. Expand only; code that predates it ignores them.
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
+ await sql`
12
+ alter table accounting.contact
13
+ add column if not exists tax_info_requested_at timestamptz,
14
+ add column if not exists email_delivery_requested_at timestamptz
15
+ `.execute(db);
16
+ }
17
+
18
+ export async function down(db: Kysely<unknown>): Promise<void> {
19
+ await sql`
20
+ alter table accounting.contact
21
+ drop column if exists tax_info_requested_at,
22
+ drop column if exists email_delivery_requested_at
23
+ `.execute(db);
24
+ }
@@ -0,0 +1,140 @@
1
+ import type { Kysely } from 'kysely';
2
+ import { sql } from 'kysely';
3
+
4
+ // PRO-20627: the 1099 storage of the 1099s API scope, apart from the legacy
5
+ // public.tax_statement, which holds the VRIntegrations archive. Expand only:
6
+ // code that predates it ignores the new table and the three new tenant columns.
7
+ //
8
+ // - accounting.tax_statement: one row per version of an owner's 1099 for a
9
+ // year. Version 0 is the original; every correction, and the new 1099 filed
10
+ // after a void, adds one. Checkout freezes the filing period, amount,
11
+ // recipient, filer, 1099 columns and postal delivery, gives the versions it
12
+ // files one filing_id and records who authorized them; a year is locked once
13
+ // one of its rows is authorized. transmitted_at is when the owner sees it.
14
+ // TaxBandits statuses stay as TaxBandits returns them; status changes are
15
+ // public audit events. errors holds our translated transmission and IRS
16
+ // errors, never the TaxBandits payload. cent_price is the list price, set
17
+ // once the IRS accepts the version; billing applies the partner discount.
18
+ // - public.tenant.tax_statement_filing_period: the filing period of the team's
19
+ // open tax years; null until the team picks one, which files Jan-Dec.
20
+ // - public.tenant.is_tax_bandits_sandbox: the TaxBandits environment a VRP admin
21
+ // set; null files in the default (sandbox for test teams).
22
+ // - public.tenant.tax_bandits_business_id: the team's TaxBandits business,
23
+ // created before its first IRS check.
24
+ export async function up(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
+ create type accounting.tax_statement_filing_period as enum ('janDec', 'decNov')
30
+ `.execute(db);
31
+ await sql`
32
+ create type accounting.tax_statement_correction as enum ('amount', 'recipient', 'void')
33
+ `.execute(db);
34
+ await sql`
35
+ create type accounting.tax_statement_status as enum (
36
+ 'draft', 'queued', 'transmitted', 'failed', 'superseded'
37
+ )
38
+ `.execute(db);
39
+
40
+ await sql`
41
+ alter table public.tenant
42
+ add column tax_statement_filing_period accounting.tax_statement_filing_period,
43
+ add column is_tax_bandits_sandbox boolean,
44
+ add column tax_bandits_business_id text
45
+ `.execute(db);
46
+
47
+ // TaxBandits federal, state and postal statuses are provider-native values
48
+ // that TaxBandits extends; they are stored as TaxBandits returns them and
49
+ // mapped to our status in code.
50
+ await sql`
51
+ create table accounting.tax_statement (
52
+ id uuid primary key default gen_random_uuid(),
53
+ tenant_id uuid not null references public.tenant (id) on delete restrict,
54
+ contact_id uuid not null references accounting.contact (id) on delete restrict,
55
+ year integer not null check (year between 2000 and 2100),
56
+ version integer not null check (version >= 0),
57
+ correction accounting.tax_statement_correction null,
58
+ status accounting.tax_statement_status not null default 'draft',
59
+ cent_starting_balance bigint null check (cent_starting_balance >= 0),
60
+ starting_balance_note text null,
61
+ cent_manual_adjustment bigint null,
62
+ manual_adjustment_note text null,
63
+ filing_period accounting.tax_statement_filing_period null,
64
+ cent_total bigint null,
65
+ recipient jsonb null,
66
+ filer jsonb null,
67
+ tax1099_columns jsonb null,
68
+ is_postal_delivery boolean null,
69
+ filing_id uuid null,
70
+ authorized_by_user_id uuid null references public.user (id) on delete set null,
71
+ authorized_at timestamptz null,
72
+ tax_bandits_submission_id text null,
73
+ tax_bandits_record_id text null,
74
+ tax_bandits_federal_status text null,
75
+ tax_bandits_state_status text null,
76
+ tax_bandits_postal_status text null,
77
+ errors jsonb null,
78
+ cent_price integer null check (cent_price >= 0),
79
+ transmitted_at timestamptz null,
80
+ created_at timestamptz not null default now(),
81
+ updated_at timestamptz not null default now(),
82
+ constraint tax_statement_tenant_id_contact_id_year_version_key
83
+ unique (tenant_id, contact_id, year, version),
84
+ constraint tax_statement_correction_version_check
85
+ check (version > 0 or correction is null),
86
+ constraint tax_statement_starting_balance_note_check
87
+ check ((cent_starting_balance is null) = (starting_balance_note is null)),
88
+ constraint tax_statement_manual_adjustment_note_check
89
+ check ((cent_manual_adjustment is null) = (manual_adjustment_note is null)),
90
+ constraint tax_statement_authorized_check
91
+ check (
92
+ authorized_at is null
93
+ or (
94
+ filing_id is not null
95
+ and filing_period is not null
96
+ and cent_total is not null
97
+ and recipient is not null
98
+ and filer is not null
99
+ and tax1099_columns is not null
100
+ and is_postal_delivery is not null
101
+ )
102
+ )
103
+ )
104
+ `.execute(db);
105
+ await sql`
106
+ create index tax_statement_contact_id_idx
107
+ on accounting.tax_statement (contact_id)
108
+ `.execute(db);
109
+ await sql`
110
+ create index tax_statement_tenant_year_status_idx
111
+ on accounting.tax_statement (tenant_id, year, status)
112
+ `.execute(db);
113
+
114
+ await sql`
115
+ do $$
116
+ begin
117
+ if exists (select 1 from pg_roles where rolname = 'application') then
118
+ grant select, insert, update, delete on accounting.tax_statement
119
+ to application;
120
+ end if;
121
+ end;
122
+ $$
123
+ `.execute(db);
124
+ }
125
+
126
+ export async function down(db: Kysely<unknown>): Promise<void> {
127
+ await sql`drop table if exists accounting.tax_statement`.execute(db);
128
+ await sql`
129
+ alter table public.tenant
130
+ drop column if exists tax_bandits_business_id,
131
+ drop column if exists is_tax_bandits_sandbox,
132
+ drop column if exists tax_statement_filing_period
133
+ `.execute(db);
134
+ for (const type of [
135
+ 'tax_statement_status',
136
+ 'tax_statement_correction',
137
+ 'tax_statement_filing_period',
138
+ ])
139
+ await sql`drop type if exists ${sql.raw(`accounting.${type}`)}`.execute(db);
140
+ }
@@ -0,0 +1,53 @@
1
+ import type { Kysely } from 'kysely';
2
+ import { sql } from 'kysely';
3
+
4
+ // PRO-20790: one row per team with its owner payment settings: whether owners
5
+ // can pay what they owe through the team's Stripe account, the Stripe
6
+ // connection and the bank account the Stripe payout lands in, the statement
7
+ // descriptor, the accepted methods and the publishing defaults.
8
+ // Expand only; code that predates the table ignores it.
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
+
13
+ await sql`
14
+ create type accounting.owner_payment_method as enum ('ach')
15
+ `.execute(db);
16
+ await sql`
17
+ create table accounting.owner_payment_settings (
18
+ tenant_id uuid primary key references public.tenant (id) on delete cascade,
19
+ enabled boolean not null default false,
20
+ connection_id uuid null references public.connection (id) on delete set null,
21
+ account_id uuid null references accounting.account (id) on delete set null,
22
+ statement_descriptor text null,
23
+ payment_methods accounting.owner_payment_method[] not null default '{ach}',
24
+ request_payment_on_publish boolean not null default true,
25
+ send_reminders boolean not null default true,
26
+ created_at timestamptz not null default now(),
27
+ updated_at timestamptz not null default now()
28
+ )
29
+ `.execute(db);
30
+ await sql`
31
+ create index owner_payment_settings_connection_idx
32
+ on accounting.owner_payment_settings (connection_id)
33
+ `.execute(db);
34
+ await sql`
35
+ create index owner_payment_settings_account_idx
36
+ on accounting.owner_payment_settings (account_id)
37
+ `.execute(db);
38
+ await sql`
39
+ do $$
40
+ begin
41
+ if exists (select 1 from pg_roles where rolname = 'application') then
42
+ grant select, insert, update, delete
43
+ on accounting.owner_payment_settings to application;
44
+ end if;
45
+ end;
46
+ $$
47
+ `.execute(db);
48
+ }
49
+
50
+ export async function down(db: Kysely<unknown>): Promise<void> {
51
+ await sql`drop table if exists accounting.owner_payment_settings`.execute(db);
52
+ await sql`drop type if exists accounting.owner_payment_method`.execute(db);
53
+ }