@wopr-network/platform-core 0.1.0

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 (694) hide show
  1. package/biome.json +61 -0
  2. package/dist/admin/admin-audit-log-repository.d.ts +33 -0
  3. package/dist/admin/admin-audit-log-repository.js +102 -0
  4. package/dist/admin/audit-log.d.ts +49 -0
  5. package/dist/admin/audit-log.js +63 -0
  6. package/dist/admin/index.d.ts +6 -0
  7. package/dist/admin/index.js +3 -0
  8. package/dist/admin/role-store.d.ts +37 -0
  9. package/dist/admin/role-store.js +106 -0
  10. package/dist/auth/api-key-repository.d.ts +11 -0
  11. package/dist/auth/api-key-repository.js +33 -0
  12. package/dist/auth/api-key-repository.test.d.ts +1 -0
  13. package/dist/auth/api-key-repository.test.js +46 -0
  14. package/dist/auth/auth.test.d.ts +1 -0
  15. package/dist/auth/auth.test.js +140 -0
  16. package/dist/auth/better-auth.d.ts +42 -0
  17. package/dist/auth/better-auth.js +196 -0
  18. package/dist/auth/index.d.ts +186 -0
  19. package/dist/auth/index.js +422 -0
  20. package/dist/auth/login-history-repository.d.ts +14 -0
  21. package/dist/auth/login-history-repository.js +15 -0
  22. package/dist/auth/login-history-repository.test.d.ts +1 -0
  23. package/dist/auth/login-history-repository.test.js +47 -0
  24. package/dist/auth/middleware.d.ts +55 -0
  25. package/dist/auth/middleware.js +101 -0
  26. package/dist/auth/middleware.test.d.ts +1 -0
  27. package/dist/auth/middleware.test.js +213 -0
  28. package/dist/auth/scoped-tokens.test.d.ts +1 -0
  29. package/dist/auth/scoped-tokens.test.js +306 -0
  30. package/dist/auth/tenant-access.test.d.ts +1 -0
  31. package/dist/auth/tenant-access.test.js +62 -0
  32. package/dist/auth/user-creator.d.ts +9 -0
  33. package/dist/auth/user-creator.js +47 -0
  34. package/dist/auth/user-creator.test.d.ts +1 -0
  35. package/dist/auth/user-creator.test.js +78 -0
  36. package/dist/auth/user-role-repository.d.ts +31 -0
  37. package/dist/auth/user-role-repository.js +53 -0
  38. package/dist/auth/user-role-repository.test.d.ts +1 -0
  39. package/dist/auth/user-role-repository.test.js +122 -0
  40. package/dist/billing/drizzle-webhook-seen-repository.d.ts +10 -0
  41. package/dist/billing/drizzle-webhook-seen-repository.js +28 -0
  42. package/dist/billing/index.d.ts +7 -0
  43. package/dist/billing/index.js +7 -0
  44. package/dist/billing/payment-processor.d.ts +127 -0
  45. package/dist/billing/payment-processor.js +8 -0
  46. package/dist/billing/payment-processor.test.d.ts +1 -0
  47. package/dist/billing/payment-processor.test.js +71 -0
  48. package/dist/billing/payram/cents-credits-boundary.test.d.ts +1 -0
  49. package/dist/billing/payram/cents-credits-boundary.test.js +75 -0
  50. package/dist/billing/payram/charge-store.d.ts +41 -0
  51. package/dist/billing/payram/charge-store.js +72 -0
  52. package/dist/billing/payram/charge-store.test.d.ts +1 -0
  53. package/dist/billing/payram/charge-store.test.js +64 -0
  54. package/dist/billing/payram/checkout.d.ts +15 -0
  55. package/dist/billing/payram/checkout.js +24 -0
  56. package/dist/billing/payram/checkout.test.d.ts +1 -0
  57. package/dist/billing/payram/checkout.test.js +74 -0
  58. package/dist/billing/payram/client.d.ts +7 -0
  59. package/dist/billing/payram/client.js +15 -0
  60. package/dist/billing/payram/client.test.d.ts +1 -0
  61. package/dist/billing/payram/client.test.js +52 -0
  62. package/dist/billing/payram/index.d.ts +8 -0
  63. package/dist/billing/payram/index.js +4 -0
  64. package/dist/billing/payram/types.d.ts +40 -0
  65. package/dist/billing/payram/types.js +1 -0
  66. package/dist/billing/payram/webhook.d.ts +19 -0
  67. package/dist/billing/payram/webhook.js +67 -0
  68. package/dist/billing/payram/webhook.test.d.ts +7 -0
  69. package/dist/billing/payram/webhook.test.js +248 -0
  70. package/dist/billing/stripe/cents-credits-boundary.test.d.ts +1 -0
  71. package/dist/billing/stripe/cents-credits-boundary.test.js +62 -0
  72. package/dist/billing/stripe/checkout.d.ts +20 -0
  73. package/dist/billing/stripe/checkout.js +63 -0
  74. package/dist/billing/stripe/checkout.test.d.ts +1 -0
  75. package/dist/billing/stripe/checkout.test.js +148 -0
  76. package/dist/billing/stripe/client.d.ts +14 -0
  77. package/dist/billing/stripe/client.js +33 -0
  78. package/dist/billing/stripe/client.test.d.ts +1 -0
  79. package/dist/billing/stripe/client.test.js +58 -0
  80. package/dist/billing/stripe/credit-prices.d.ts +63 -0
  81. package/dist/billing/stripe/credit-prices.js +81 -0
  82. package/dist/billing/stripe/credit-prices.test.d.ts +1 -0
  83. package/dist/billing/stripe/credit-prices.test.js +87 -0
  84. package/dist/billing/stripe/index.d.ts +14 -0
  85. package/dist/billing/stripe/index.js +8 -0
  86. package/dist/billing/stripe/payment-methods-detach-all.test.d.ts +1 -0
  87. package/dist/billing/stripe/payment-methods-detach-all.test.js +40 -0
  88. package/dist/billing/stripe/payment-methods.d.ts +25 -0
  89. package/dist/billing/stripe/payment-methods.js +53 -0
  90. package/dist/billing/stripe/payment-methods.test.d.ts +1 -0
  91. package/dist/billing/stripe/payment-methods.test.js +122 -0
  92. package/dist/billing/stripe/portal.d.ts +10 -0
  93. package/dist/billing/stripe/portal.js +16 -0
  94. package/dist/billing/stripe/portal.test.d.ts +1 -0
  95. package/dist/billing/stripe/portal.test.js +48 -0
  96. package/dist/billing/stripe/setup-intent.d.ts +16 -0
  97. package/dist/billing/stripe/setup-intent.js +22 -0
  98. package/dist/billing/stripe/setup-intent.test.d.ts +1 -0
  99. package/dist/billing/stripe/setup-intent.test.js +58 -0
  100. package/dist/billing/stripe/stripe-payment-processor.d.ts +49 -0
  101. package/dist/billing/stripe/stripe-payment-processor.js +166 -0
  102. package/dist/billing/stripe/stripe-payment-processor.test.d.ts +1 -0
  103. package/dist/billing/stripe/stripe-payment-processor.test.js +413 -0
  104. package/dist/billing/stripe/tenant-store.d.ts +56 -0
  105. package/dist/billing/stripe/tenant-store.js +119 -0
  106. package/dist/billing/stripe/tenant-store.test.d.ts +1 -0
  107. package/dist/billing/stripe/tenant-store.test.js +97 -0
  108. package/dist/billing/stripe/types.d.ts +49 -0
  109. package/dist/billing/stripe/types.js +1 -0
  110. package/dist/billing/webhook-seen-repository.d.ts +14 -0
  111. package/dist/billing/webhook-seen-repository.js +13 -0
  112. package/dist/config/billing-env.test.d.ts +1 -0
  113. package/dist/config/billing-env.test.js +48 -0
  114. package/dist/config/index.d.ts +46 -0
  115. package/dist/config/index.js +38 -0
  116. package/dist/config/logger.d.ts +2 -0
  117. package/dist/config/logger.js +11 -0
  118. package/dist/config/provider-endpoints.d.ts +6 -0
  119. package/dist/config/provider-endpoints.js +12 -0
  120. package/dist/credits/auto-topup-charge.d.ts +27 -0
  121. package/dist/credits/auto-topup-charge.js +139 -0
  122. package/dist/credits/auto-topup-charge.test.d.ts +1 -0
  123. package/dist/credits/auto-topup-charge.test.js +242 -0
  124. package/dist/credits/auto-topup-event-log-repository.d.ts +16 -0
  125. package/dist/credits/auto-topup-event-log-repository.js +18 -0
  126. package/dist/credits/auto-topup-event-log-repository.test.d.ts +1 -0
  127. package/dist/credits/auto-topup-event-log-repository.test.js +83 -0
  128. package/dist/credits/auto-topup-schedule.d.ts +27 -0
  129. package/dist/credits/auto-topup-schedule.js +66 -0
  130. package/dist/credits/auto-topup-schedule.test.d.ts +1 -0
  131. package/dist/credits/auto-topup-schedule.test.js +145 -0
  132. package/dist/credits/auto-topup-settings-repository.d.ts +54 -0
  133. package/dist/credits/auto-topup-settings-repository.js +184 -0
  134. package/dist/credits/auto-topup-settings-repository.test.d.ts +1 -0
  135. package/dist/credits/auto-topup-settings-repository.test.js +104 -0
  136. package/dist/credits/auto-topup-usage.d.ts +22 -0
  137. package/dist/credits/auto-topup-usage.js +56 -0
  138. package/dist/credits/auto-topup-usage.test.d.ts +1 -0
  139. package/dist/credits/auto-topup-usage.test.js +181 -0
  140. package/dist/credits/credit-expiry-cron.d.ts +19 -0
  141. package/dist/credits/credit-expiry-cron.js +50 -0
  142. package/dist/credits/credit-expiry-cron.test.d.ts +1 -0
  143. package/dist/credits/credit-expiry-cron.test.js +67 -0
  144. package/dist/credits/credit-ledger-extra.test.d.ts +1 -0
  145. package/dist/credits/credit-ledger-extra.test.js +40 -0
  146. package/dist/credits/credit-ledger.bench.d.ts +1 -0
  147. package/dist/credits/credit-ledger.bench.js +33 -0
  148. package/dist/credits/credit-ledger.d.ts +130 -0
  149. package/dist/credits/credit-ledger.js +293 -0
  150. package/dist/credits/credit-ledger.test.d.ts +4 -0
  151. package/dist/credits/credit-ledger.test.js +203 -0
  152. package/dist/credits/credit-transaction-repository.d.ts +17 -0
  153. package/dist/credits/credit-transaction-repository.js +35 -0
  154. package/dist/credits/credit-transaction-repository.test.d.ts +1 -0
  155. package/dist/credits/credit-transaction-repository.test.js +232 -0
  156. package/dist/credits/credit.d.ts +75 -0
  157. package/dist/credits/credit.js +139 -0
  158. package/dist/credits/credit.test.d.ts +1 -0
  159. package/dist/credits/credit.test.js +196 -0
  160. package/dist/credits/dividend-cron.d.ts +29 -0
  161. package/dist/credits/dividend-cron.js +88 -0
  162. package/dist/credits/dividend-cron.test.d.ts +1 -0
  163. package/dist/credits/dividend-cron.test.js +128 -0
  164. package/dist/credits/dividend-repository.d.ts +29 -0
  165. package/dist/credits/dividend-repository.js +126 -0
  166. package/dist/credits/dividend-repository.test.d.ts +1 -0
  167. package/dist/credits/dividend-repository.test.js +176 -0
  168. package/dist/credits/index.d.ts +9 -0
  169. package/dist/credits/index.js +5 -0
  170. package/dist/credits/repository-types.d.ts +29 -0
  171. package/dist/credits/repository-types.js +1 -0
  172. package/dist/credits/signup-grant.d.ts +12 -0
  173. package/dist/credits/signup-grant.js +35 -0
  174. package/dist/credits/signup-grant.test.d.ts +1 -0
  175. package/dist/credits/signup-grant.test.js +51 -0
  176. package/dist/credits/tenant-customer-repository.d.ts +30 -0
  177. package/dist/credits/tenant-customer-repository.js +5 -0
  178. package/dist/db/auth-user-repository.d.ts +46 -0
  179. package/dist/db/auth-user-repository.js +90 -0
  180. package/dist/db/credit-column.d.ts +27 -0
  181. package/dist/db/credit-column.js +13 -0
  182. package/dist/db/index.d.ts +14 -0
  183. package/dist/db/index.js +8 -0
  184. package/dist/db/schema/account-deletion-requests.d.ts +203 -0
  185. package/dist/db/schema/account-deletion-requests.js +36 -0
  186. package/dist/db/schema/account-export-requests.d.ts +148 -0
  187. package/dist/db/schema/account-export-requests.js +19 -0
  188. package/dist/db/schema/admin-audit.d.ts +194 -0
  189. package/dist/db/schema/admin-audit.js +21 -0
  190. package/dist/db/schema/admin-users.d.ts +177 -0
  191. package/dist/db/schema/admin-users.js +23 -0
  192. package/dist/db/schema/affiliate-fraud.d.ts +160 -0
  193. package/dist/db/schema/affiliate-fraud.js +18 -0
  194. package/dist/db/schema/affiliate.d.ts +277 -0
  195. package/dist/db/schema/affiliate.js +32 -0
  196. package/dist/db/schema/coupon-codes.d.ts +143 -0
  197. package/dist/db/schema/coupon-codes.js +17 -0
  198. package/dist/db/schema/credit-auto-topup-settings.d.ts +232 -0
  199. package/dist/db/schema/credit-auto-topup-settings.js +27 -0
  200. package/dist/db/schema/credit-auto-topup.d.ts +130 -0
  201. package/dist/db/schema/credit-auto-topup.js +21 -0
  202. package/dist/db/schema/credits.d.ts +283 -0
  203. package/dist/db/schema/credits.js +38 -0
  204. package/dist/db/schema/dividend-distributions.d.ts +130 -0
  205. package/dist/db/schema/dividend-distributions.js +19 -0
  206. package/dist/db/schema/email-notifications.d.ts +99 -0
  207. package/dist/db/schema/email-notifications.js +21 -0
  208. package/dist/db/schema/index.d.ts +33 -0
  209. package/dist/db/schema/index.js +33 -0
  210. package/dist/db/schema/meter-events.d.ts +599 -0
  211. package/dist/db/schema/meter-events.js +55 -0
  212. package/dist/db/schema/notification-preferences.d.ts +165 -0
  213. package/dist/db/schema/notification-preferences.js +18 -0
  214. package/dist/db/schema/notification-queue.d.ts +236 -0
  215. package/dist/db/schema/notification-queue.js +40 -0
  216. package/dist/db/schema/org-memberships.d.ts +63 -0
  217. package/dist/db/schema/org-memberships.js +15 -0
  218. package/dist/db/schema/organization-members.d.ts +235 -0
  219. package/dist/db/schema/organization-members.js +27 -0
  220. package/dist/db/schema/payram.d.ts +164 -0
  221. package/dist/db/schema/payram.js +21 -0
  222. package/dist/db/schema/platform-api-keys.d.ts +143 -0
  223. package/dist/db/schema/platform-api-keys.js +20 -0
  224. package/dist/db/schema/promotion-redemptions.d.ts +143 -0
  225. package/dist/db/schema/promotion-redemptions.js +18 -0
  226. package/dist/db/schema/promotions.d.ts +445 -0
  227. package/dist/db/schema/promotions.js +48 -0
  228. package/dist/db/schema/provider-credentials.d.ts +201 -0
  229. package/dist/db/schema/provider-credentials.js +36 -0
  230. package/dist/db/schema/rate-limit-entries.d.ts +75 -0
  231. package/dist/db/schema/rate-limit-entries.js +7 -0
  232. package/dist/db/schema/secret-audit-log.d.ts +109 -0
  233. package/dist/db/schema/secret-audit-log.js +15 -0
  234. package/dist/db/schema/session-usage.d.ts +194 -0
  235. package/dist/db/schema/session-usage.js +19 -0
  236. package/dist/db/schema/spending-limits.d.ts +92 -0
  237. package/dist/db/schema/spending-limits.js +8 -0
  238. package/dist/db/schema/tenant-addons.d.ts +58 -0
  239. package/dist/db/schema/tenant-addons.js +9 -0
  240. package/dist/db/schema/tenant-api-keys.d.ts +131 -0
  241. package/dist/db/schema/tenant-api-keys.js +21 -0
  242. package/dist/db/schema/tenant-capability-settings.d.ts +79 -0
  243. package/dist/db/schema/tenant-capability-settings.js +12 -0
  244. package/dist/db/schema/tenant-customers.d.ts +303 -0
  245. package/dist/db/schema/tenant-customers.js +25 -0
  246. package/dist/db/schema/tenants.d.ts +126 -0
  247. package/dist/db/schema/tenants.js +18 -0
  248. package/dist/db/schema/user-roles.d.ts +98 -0
  249. package/dist/db/schema/user-roles.js +18 -0
  250. package/dist/db/schema/webhook-seen-events.d.ts +58 -0
  251. package/dist/db/schema/webhook-seen-events.js +9 -0
  252. package/dist/email/billing-emails.d.ts +51 -0
  253. package/dist/email/billing-emails.js +163 -0
  254. package/dist/email/billing-emails.test.d.ts +1 -0
  255. package/dist/email/billing-emails.test.js +162 -0
  256. package/dist/email/client.d.ts +51 -0
  257. package/dist/email/client.js +102 -0
  258. package/dist/email/client.test.d.ts +1 -0
  259. package/dist/email/client.test.js +120 -0
  260. package/dist/email/drizzle-billing-email-repository.d.ts +21 -0
  261. package/dist/email/drizzle-billing-email-repository.js +36 -0
  262. package/dist/email/drizzle-billing-email-repository.test.d.ts +1 -0
  263. package/dist/email/drizzle-billing-email-repository.test.js +42 -0
  264. package/dist/email/index.d.ts +33 -0
  265. package/dist/email/index.js +22 -0
  266. package/dist/email/notification-preferences-store.d.ts +12 -0
  267. package/dist/email/notification-preferences-store.js +82 -0
  268. package/dist/email/notification-preferences-store.test.d.ts +1 -0
  269. package/dist/email/notification-preferences-store.test.js +86 -0
  270. package/dist/email/notification-queue-store.d.ts +25 -0
  271. package/dist/email/notification-queue-store.js +97 -0
  272. package/dist/email/notification-queue-store.test.d.ts +1 -0
  273. package/dist/email/notification-queue-store.test.js +177 -0
  274. package/dist/email/notification-repository-types.d.ts +70 -0
  275. package/dist/email/notification-repository-types.js +6 -0
  276. package/dist/email/notification-service.d.ts +41 -0
  277. package/dist/email/notification-service.js +196 -0
  278. package/dist/email/notification-service.test.d.ts +1 -0
  279. package/dist/email/notification-service.test.js +160 -0
  280. package/dist/email/notification-templates.d.ts +18 -0
  281. package/dist/email/notification-templates.js +574 -0
  282. package/dist/email/notification-templates.test.d.ts +1 -0
  283. package/dist/email/notification-templates.test.js +238 -0
  284. package/dist/email/notification-worker.d.ts +24 -0
  285. package/dist/email/notification-worker.js +109 -0
  286. package/dist/email/notification-worker.test.d.ts +1 -0
  287. package/dist/email/notification-worker.test.js +153 -0
  288. package/dist/email/require-verified.d.ts +25 -0
  289. package/dist/email/require-verified.js +52 -0
  290. package/dist/email/require-verified.test.d.ts +1 -0
  291. package/dist/email/require-verified.test.js +62 -0
  292. package/dist/email/resend-adapter.d.ts +47 -0
  293. package/dist/email/resend-adapter.js +137 -0
  294. package/dist/email/resend-adapter.test.d.ts +1 -0
  295. package/dist/email/resend-adapter.test.js +190 -0
  296. package/dist/email/templates.d.ts +22 -0
  297. package/dist/email/templates.js +359 -0
  298. package/dist/email/templates.test.d.ts +1 -0
  299. package/dist/email/templates.test.js +170 -0
  300. package/dist/email/verification.d.ts +42 -0
  301. package/dist/email/verification.js +83 -0
  302. package/dist/email/verification.test.d.ts +1 -0
  303. package/dist/email/verification.test.js +141 -0
  304. package/dist/index.d.ts +13 -0
  305. package/dist/index.js +23 -0
  306. package/dist/metering/aggregator.d.ts +54 -0
  307. package/dist/metering/aggregator.js +123 -0
  308. package/dist/metering/aggregator.test.d.ts +1 -0
  309. package/dist/metering/aggregator.test.js +179 -0
  310. package/dist/metering/dlq.d.ts +31 -0
  311. package/dist/metering/dlq.js +82 -0
  312. package/dist/metering/dlq.test.d.ts +1 -0
  313. package/dist/metering/dlq.test.js +117 -0
  314. package/dist/metering/drizzle-usage-summary-repository.d.ts +67 -0
  315. package/dist/metering/drizzle-usage-summary-repository.js +98 -0
  316. package/dist/metering/emitter.d.ts +66 -0
  317. package/dist/metering/emitter.js +185 -0
  318. package/dist/metering/emitter.test.d.ts +1 -0
  319. package/dist/metering/emitter.test.js +171 -0
  320. package/dist/metering/index.d.ts +11 -0
  321. package/dist/metering/index.js +5 -0
  322. package/dist/metering/load-test.bench.d.ts +1 -0
  323. package/dist/metering/load-test.bench.js +103 -0
  324. package/dist/metering/meter-event-repository.d.ts +33 -0
  325. package/dist/metering/meter-event-repository.js +58 -0
  326. package/dist/metering/meter-repositories.test.d.ts +1 -0
  327. package/dist/metering/meter-repositories.test.js +419 -0
  328. package/dist/metering/metering.test.d.ts +1 -0
  329. package/dist/metering/metering.test.js +1046 -0
  330. package/dist/metering/reconciliation-cron.d.ts +37 -0
  331. package/dist/metering/reconciliation-cron.js +85 -0
  332. package/dist/metering/reconciliation-cron.test.d.ts +1 -0
  333. package/dist/metering/reconciliation-cron.test.js +162 -0
  334. package/dist/metering/reconciliation-repository.d.ts +27 -0
  335. package/dist/metering/reconciliation-repository.js +43 -0
  336. package/dist/metering/reconciliation-repository.test.d.ts +1 -0
  337. package/dist/metering/reconciliation-repository.test.js +160 -0
  338. package/dist/metering/types.d.ts +88 -0
  339. package/dist/metering/types.js +1 -0
  340. package/dist/metering/wal.d.ts +49 -0
  341. package/dist/metering/wal.js +124 -0
  342. package/dist/metering/wal.test.d.ts +1 -0
  343. package/dist/metering/wal.test.js +175 -0
  344. package/dist/middleware/csrf.d.ts +24 -0
  345. package/dist/middleware/csrf.js +80 -0
  346. package/dist/middleware/csrf.test.d.ts +1 -0
  347. package/dist/middleware/csrf.test.js +152 -0
  348. package/dist/middleware/drizzle-rate-limit-repository.d.ts +9 -0
  349. package/dist/middleware/drizzle-rate-limit-repository.js +52 -0
  350. package/dist/middleware/drizzle-rate-limit-repository.test.d.ts +1 -0
  351. package/dist/middleware/drizzle-rate-limit-repository.test.js +74 -0
  352. package/dist/middleware/get-client-ip.d.ts +22 -0
  353. package/dist/middleware/get-client-ip.js +51 -0
  354. package/dist/middleware/get-client-ip.test.d.ts +1 -0
  355. package/dist/middleware/get-client-ip.test.js +40 -0
  356. package/dist/middleware/index.d.ts +5 -0
  357. package/dist/middleware/index.js +4 -0
  358. package/dist/middleware/rate-limit-repository.d.ts +19 -0
  359. package/dist/middleware/rate-limit-repository.js +1 -0
  360. package/dist/middleware/rate-limit.d.ts +57 -0
  361. package/dist/middleware/rate-limit.js +109 -0
  362. package/dist/middleware/rate-limit.test.d.ts +1 -0
  363. package/dist/middleware/rate-limit.test.js +247 -0
  364. package/dist/security/credential-vault/audit-repository.d.ts +27 -0
  365. package/dist/security/credential-vault/audit-repository.js +42 -0
  366. package/dist/security/credential-vault/audit-repository.test.d.ts +1 -0
  367. package/dist/security/credential-vault/audit-repository.test.js +78 -0
  368. package/dist/security/credential-vault/credential-repository.d.ts +94 -0
  369. package/dist/security/credential-vault/credential-repository.js +145 -0
  370. package/dist/security/credential-vault/credential-repository.test.d.ts +1 -0
  371. package/dist/security/credential-vault/credential-repository.test.js +206 -0
  372. package/dist/security/credential-vault/index.d.ts +12 -0
  373. package/dist/security/credential-vault/index.js +6 -0
  374. package/dist/security/credential-vault/key-rotation.d.ts +18 -0
  375. package/dist/security/credential-vault/key-rotation.js +52 -0
  376. package/dist/security/credential-vault/key-rotation.test.d.ts +1 -0
  377. package/dist/security/credential-vault/key-rotation.test.js +95 -0
  378. package/dist/security/credential-vault/migrate-plaintext.d.ts +15 -0
  379. package/dist/security/credential-vault/migrate-plaintext.js +80 -0
  380. package/dist/security/credential-vault/migrate-plaintext.test.d.ts +1 -0
  381. package/dist/security/credential-vault/migrate-plaintext.test.js +111 -0
  382. package/dist/security/credential-vault/migration-check.d.ts +15 -0
  383. package/dist/security/credential-vault/migration-check.js +71 -0
  384. package/dist/security/credential-vault/migration-check.test.d.ts +1 -0
  385. package/dist/security/credential-vault/migration-check.test.js +457 -0
  386. package/dist/security/credential-vault/store.d.ts +106 -0
  387. package/dist/security/credential-vault/store.js +181 -0
  388. package/dist/security/credential-vault/store.test.d.ts +1 -0
  389. package/dist/security/credential-vault/store.test.js +482 -0
  390. package/dist/security/encryption.d.ts +22 -0
  391. package/dist/security/encryption.js +53 -0
  392. package/dist/security/encryption.test.d.ts +1 -0
  393. package/dist/security/encryption.test.js +95 -0
  394. package/dist/security/host-validation.d.ts +11 -0
  395. package/dist/security/host-validation.js +108 -0
  396. package/dist/security/host-validation.test.d.ts +1 -0
  397. package/dist/security/host-validation.test.js +106 -0
  398. package/dist/security/index.d.ts +11 -0
  399. package/dist/security/index.js +11 -0
  400. package/dist/security/key-audit.d.ts +16 -0
  401. package/dist/security/key-audit.js +35 -0
  402. package/dist/security/key-audit.test.d.ts +1 -0
  403. package/dist/security/key-audit.test.js +50 -0
  404. package/dist/security/key-injection.d.ts +28 -0
  405. package/dist/security/key-injection.js +57 -0
  406. package/dist/security/key-injection.test.d.ts +1 -0
  407. package/dist/security/key-injection.test.js +97 -0
  408. package/dist/security/key-validation.d.ts +16 -0
  409. package/dist/security/key-validation.js +78 -0
  410. package/dist/security/key-validation.test.d.ts +1 -0
  411. package/dist/security/key-validation.test.js +87 -0
  412. package/dist/security/redirect-allowlist.d.ts +6 -0
  413. package/dist/security/redirect-allowlist.js +36 -0
  414. package/dist/security/redirect-allowlist.test.d.ts +1 -0
  415. package/dist/security/redirect-allowlist.test.js +55 -0
  416. package/dist/security/tenant-keys/capability-settings-store.d.ts +22 -0
  417. package/dist/security/tenant-keys/capability-settings-store.js +33 -0
  418. package/dist/security/tenant-keys/capability-settings-store.test.d.ts +1 -0
  419. package/dist/security/tenant-keys/capability-settings-store.test.js +77 -0
  420. package/dist/security/tenant-keys/index.d.ts +10 -0
  421. package/dist/security/tenant-keys/index.js +5 -0
  422. package/dist/security/tenant-keys/key-resolution-repository.d.ts +15 -0
  423. package/dist/security/tenant-keys/key-resolution-repository.js +18 -0
  424. package/dist/security/tenant-keys/key-resolution-repository.test.d.ts +1 -0
  425. package/dist/security/tenant-keys/key-resolution-repository.test.js +72 -0
  426. package/dist/security/tenant-keys/key-resolution.d.ts +39 -0
  427. package/dist/security/tenant-keys/key-resolution.js +59 -0
  428. package/dist/security/tenant-keys/key-resolution.test.d.ts +1 -0
  429. package/dist/security/tenant-keys/key-resolution.test.js +97 -0
  430. package/dist/security/tenant-keys/org-key-resolution.d.ts +30 -0
  431. package/dist/security/tenant-keys/org-key-resolution.js +50 -0
  432. package/dist/security/tenant-keys/org-key-resolution.test.d.ts +1 -0
  433. package/dist/security/tenant-keys/org-key-resolution.test.js +103 -0
  434. package/dist/security/tenant-keys/tenant-key-repository.d.ts +36 -0
  435. package/dist/security/tenant-keys/tenant-key-repository.js +96 -0
  436. package/dist/security/tenant-keys/tenant-key-repository.test.d.ts +1 -0
  437. package/dist/security/tenant-keys/tenant-key-repository.test.js +114 -0
  438. package/dist/security/types.d.ts +35 -0
  439. package/dist/security/types.js +15 -0
  440. package/dist/tenancy/drizzle-org-repository.d.ts +40 -0
  441. package/dist/tenancy/drizzle-org-repository.js +126 -0
  442. package/dist/tenancy/index.d.ts +6 -0
  443. package/dist/tenancy/index.js +3 -0
  444. package/dist/tenancy/org-member-repository.d.ts +57 -0
  445. package/dist/tenancy/org-member-repository.js +99 -0
  446. package/dist/tenancy/org-repository.test.d.ts +1 -0
  447. package/dist/tenancy/org-repository.test.js +143 -0
  448. package/dist/tenancy/org-service.d.ts +70 -0
  449. package/dist/tenancy/org-service.js +223 -0
  450. package/dist/tenancy/org-service.test.d.ts +1 -0
  451. package/dist/tenancy/org-service.test.js +550 -0
  452. package/dist/test/db.d.ts +33 -0
  453. package/dist/test/db.js +65 -0
  454. package/dist/trpc/index.d.ts +1 -0
  455. package/dist/trpc/index.js +1 -0
  456. package/dist/trpc/init.d.ts +49 -0
  457. package/dist/trpc/init.js +108 -0
  458. package/dist/trpc/init.test.d.ts +1 -0
  459. package/dist/trpc/init.test.js +154 -0
  460. package/drizzle/migrations/0000_slippery_mandrill.sql +559 -0
  461. package/drizzle/migrations/meta/0000_snapshot.json +4374 -0
  462. package/drizzle/migrations/meta/_journal.json +13 -0
  463. package/drizzle.config.ts +41 -0
  464. package/package.json +64 -0
  465. package/src/admin/admin-audit-log-repository.ts +135 -0
  466. package/src/admin/audit-log.ts +111 -0
  467. package/src/admin/index.ts +6 -0
  468. package/src/admin/role-store.ts +134 -0
  469. package/src/auth/api-key-repository.test.ts +63 -0
  470. package/src/auth/api-key-repository.ts +46 -0
  471. package/src/auth/auth.test.ts +166 -0
  472. package/src/auth/better-auth.ts +216 -0
  473. package/src/auth/index.ts +520 -0
  474. package/src/auth/login-history-repository.test.ts +54 -0
  475. package/src/auth/login-history-repository.ts +28 -0
  476. package/src/auth/middleware.test.ts +264 -0
  477. package/src/auth/middleware.ts +117 -0
  478. package/src/auth/scoped-tokens.test.ts +362 -0
  479. package/src/auth/tenant-access.test.ts +69 -0
  480. package/src/auth/user-creator.test.ts +98 -0
  481. package/src/auth/user-creator.ts +54 -0
  482. package/src/auth/user-role-repository.test.ts +149 -0
  483. package/src/auth/user-role-repository.ts +67 -0
  484. package/src/billing/drizzle-webhook-seen-repository.ts +34 -0
  485. package/src/billing/index.ts +22 -0
  486. package/src/billing/payment-processor.test.ts +93 -0
  487. package/src/billing/payment-processor.ts +150 -0
  488. package/src/billing/payram/cents-credits-boundary.test.ts +84 -0
  489. package/src/billing/payram/charge-store.test.ts +84 -0
  490. package/src/billing/payram/charge-store.ts +109 -0
  491. package/src/billing/payram/checkout.test.ts +99 -0
  492. package/src/billing/payram/checkout.ts +40 -0
  493. package/src/billing/payram/client.test.ts +62 -0
  494. package/src/billing/payram/client.ts +21 -0
  495. package/src/billing/payram/index.ts +14 -0
  496. package/src/billing/payram/types.ts +44 -0
  497. package/src/billing/payram/webhook.test.ts +318 -0
  498. package/src/billing/payram/webhook.ts +97 -0
  499. package/src/billing/stripe/cents-credits-boundary.test.ts +70 -0
  500. package/src/billing/stripe/checkout.test.ts +186 -0
  501. package/src/billing/stripe/checkout.ts +82 -0
  502. package/src/billing/stripe/client.test.ts +64 -0
  503. package/src/billing/stripe/client.ts +39 -0
  504. package/src/billing/stripe/credit-prices.test.ts +114 -0
  505. package/src/billing/stripe/credit-prices.ts +113 -0
  506. package/src/billing/stripe/index.ts +14 -0
  507. package/src/billing/stripe/payment-methods-detach-all.test.ts +53 -0
  508. package/src/billing/stripe/payment-methods.test.ts +157 -0
  509. package/src/billing/stripe/payment-methods.ts +76 -0
  510. package/src/billing/stripe/portal.test.ts +63 -0
  511. package/src/billing/stripe/portal.ts +25 -0
  512. package/src/billing/stripe/setup-intent.test.ts +78 -0
  513. package/src/billing/stripe/setup-intent.ts +34 -0
  514. package/src/billing/stripe/stripe-payment-processor.test.ts +517 -0
  515. package/src/billing/stripe/stripe-payment-processor.ts +255 -0
  516. package/src/billing/stripe/tenant-store.test.ts +124 -0
  517. package/src/billing/stripe/tenant-store.ts +151 -0
  518. package/src/billing/stripe/types.ts +53 -0
  519. package/src/billing/webhook-seen-repository.ts +24 -0
  520. package/src/config/billing-env.test.ts +54 -0
  521. package/src/config/index.ts +44 -0
  522. package/src/config/logger.ts +12 -0
  523. package/src/config/provider-endpoints.ts +14 -0
  524. package/src/credits/auto-topup-charge.test.ts +292 -0
  525. package/src/credits/auto-topup-charge.ts +171 -0
  526. package/src/credits/auto-topup-event-log-repository.test.ts +99 -0
  527. package/src/credits/auto-topup-event-log-repository.ts +30 -0
  528. package/src/credits/auto-topup-schedule.test.ts +179 -0
  529. package/src/credits/auto-topup-schedule.ts +93 -0
  530. package/src/credits/auto-topup-settings-repository.test.ts +123 -0
  531. package/src/credits/auto-topup-settings-repository.ts +245 -0
  532. package/src/credits/auto-topup-usage.test.ts +220 -0
  533. package/src/credits/auto-topup-usage.ts +68 -0
  534. package/src/credits/credit-expiry-cron.test.ts +125 -0
  535. package/src/credits/credit-expiry-cron.ts +76 -0
  536. package/src/credits/credit-ledger-extra.test.ts +57 -0
  537. package/src/credits/credit-ledger.bench.ts +56 -0
  538. package/src/credits/credit-ledger.test.ts +276 -0
  539. package/src/credits/credit-ledger.ts +450 -0
  540. package/src/credits/credit-transaction-repository.test.ts +274 -0
  541. package/src/credits/credit-transaction-repository.ts +62 -0
  542. package/src/credits/credit.test.ts +234 -0
  543. package/src/credits/credit.ts +160 -0
  544. package/src/credits/dividend-cron.test.ts +158 -0
  545. package/src/credits/dividend-cron.ts +127 -0
  546. package/src/credits/dividend-repository.test.ts +223 -0
  547. package/src/credits/dividend-repository.ts +182 -0
  548. package/src/credits/index.ts +25 -0
  549. package/src/credits/repository-types.ts +33 -0
  550. package/src/credits/signup-grant.test.ts +63 -0
  551. package/src/credits/signup-grant.ts +44 -0
  552. package/src/credits/tenant-customer-repository.ts +28 -0
  553. package/src/db/auth-user-repository.ts +124 -0
  554. package/src/db/credit-column.ts +17 -0
  555. package/src/db/index.ts +21 -0
  556. package/src/db/schema/account-deletion-requests.ts +41 -0
  557. package/src/db/schema/account-export-requests.ts +24 -0
  558. package/src/db/schema/admin-audit.ts +26 -0
  559. package/src/db/schema/admin-users.ts +31 -0
  560. package/src/db/schema/affiliate-fraud.ts +23 -0
  561. package/src/db/schema/affiliate.ts +38 -0
  562. package/src/db/schema/coupon-codes.ts +22 -0
  563. package/src/db/schema/credit-auto-topup-settings.ts +32 -0
  564. package/src/db/schema/credit-auto-topup.ts +26 -0
  565. package/src/db/schema/credits.ts +44 -0
  566. package/src/db/schema/dividend-distributions.ts +24 -0
  567. package/src/db/schema/email-notifications.ts +26 -0
  568. package/src/db/schema/index.ts +33 -0
  569. package/src/db/schema/meter-events.ts +70 -0
  570. package/src/db/schema/notification-preferences.ts +19 -0
  571. package/src/db/schema/notification-queue.ts +45 -0
  572. package/src/db/schema/org-memberships.ts +20 -0
  573. package/src/db/schema/organization-members.ts +37 -0
  574. package/src/db/schema/payram.ts +26 -0
  575. package/src/db/schema/platform-api-keys.ts +25 -0
  576. package/src/db/schema/promotion-redemptions.ts +23 -0
  577. package/src/db/schema/promotions.ts +57 -0
  578. package/src/db/schema/provider-credentials.ts +41 -0
  579. package/src/db/schema/rate-limit-entries.ts +12 -0
  580. package/src/db/schema/secret-audit-log.ts +20 -0
  581. package/src/db/schema/session-usage.ts +24 -0
  582. package/src/db/schema/spending-limits.ts +9 -0
  583. package/src/db/schema/tenant-addons.ts +14 -0
  584. package/src/db/schema/tenant-api-keys.ts +26 -0
  585. package/src/db/schema/tenant-capability-settings.ts +17 -0
  586. package/src/db/schema/tenant-customers.ts +35 -0
  587. package/src/db/schema/tenants.ts +23 -0
  588. package/src/db/schema/user-roles.ts +23 -0
  589. package/src/db/schema/webhook-seen-events.ts +14 -0
  590. package/src/email/billing-emails.test.ts +198 -0
  591. package/src/email/billing-emails.ts +211 -0
  592. package/src/email/client.test.ts +149 -0
  593. package/src/email/client.ts +137 -0
  594. package/src/email/drizzle-billing-email-repository.test.ts +52 -0
  595. package/src/email/drizzle-billing-email-repository.ts +59 -0
  596. package/src/email/index.ts +57 -0
  597. package/src/email/notification-preferences-store.test.ts +102 -0
  598. package/src/email/notification-preferences-store.ts +90 -0
  599. package/src/email/notification-queue-store.test.ts +215 -0
  600. package/src/email/notification-queue-store.ts +127 -0
  601. package/src/email/notification-repository-types.ts +101 -0
  602. package/src/email/notification-service.test.ts +178 -0
  603. package/src/email/notification-service.ts +265 -0
  604. package/src/email/notification-templates.test.ts +261 -0
  605. package/src/email/notification-templates.ts +727 -0
  606. package/src/email/notification-worker.test.ts +189 -0
  607. package/src/email/notification-worker.ts +133 -0
  608. package/src/email/require-verified.ts +65 -0
  609. package/src/email/resend-adapter.test.ts +253 -0
  610. package/src/email/resend-adapter.ts +157 -0
  611. package/src/email/templates.test.ts +217 -0
  612. package/src/email/templates.ts +469 -0
  613. package/src/email/verification.test.ts +185 -0
  614. package/src/email/verification.ts +110 -0
  615. package/src/index.ts +51 -0
  616. package/src/metering/aggregator.test.ts +239 -0
  617. package/src/metering/aggregator.ts +160 -0
  618. package/src/metering/dlq.test.ts +134 -0
  619. package/src/metering/dlq.ts +102 -0
  620. package/src/metering/drizzle-usage-summary-repository.ts +167 -0
  621. package/src/metering/emitter.test.ts +202 -0
  622. package/src/metering/emitter.ts +227 -0
  623. package/src/metering/index.ts +21 -0
  624. package/src/metering/load-test.bench.ts +130 -0
  625. package/src/metering/meter-event-repository.ts +87 -0
  626. package/src/metering/meter-repositories.test.ts +491 -0
  627. package/src/metering/metering.test.ts +1317 -0
  628. package/src/metering/reconciliation-cron.test.ts +202 -0
  629. package/src/metering/reconciliation-cron.ts +134 -0
  630. package/src/metering/reconciliation-repository.test.ts +196 -0
  631. package/src/metering/reconciliation-repository.ts +83 -0
  632. package/src/metering/types.ts +93 -0
  633. package/src/metering/wal.test.ts +222 -0
  634. package/src/metering/wal.ts +139 -0
  635. package/src/middleware/csrf.test.ts +178 -0
  636. package/src/middleware/csrf.ts +101 -0
  637. package/src/middleware/drizzle-rate-limit-repository.test.ts +97 -0
  638. package/src/middleware/drizzle-rate-limit-repository.ts +57 -0
  639. package/src/middleware/get-client-ip.test.ts +49 -0
  640. package/src/middleware/get-client-ip.ts +62 -0
  641. package/src/middleware/index.ts +12 -0
  642. package/src/middleware/rate-limit-repository.ts +22 -0
  643. package/src/middleware/rate-limit.test.ts +338 -0
  644. package/src/middleware/rate-limit.ts +169 -0
  645. package/src/security/credential-vault/audit-repository.test.ts +91 -0
  646. package/src/security/credential-vault/audit-repository.ts +64 -0
  647. package/src/security/credential-vault/credential-repository.test.ts +264 -0
  648. package/src/security/credential-vault/credential-repository.ts +233 -0
  649. package/src/security/credential-vault/index.ts +26 -0
  650. package/src/security/credential-vault/key-rotation.test.ts +139 -0
  651. package/src/security/credential-vault/key-rotation.ts +70 -0
  652. package/src/security/credential-vault/migrate-plaintext.test.ts +138 -0
  653. package/src/security/credential-vault/migrate-plaintext.ts +101 -0
  654. package/src/security/credential-vault/migration-check.test.ts +533 -0
  655. package/src/security/credential-vault/migration-check.ts +88 -0
  656. package/src/security/credential-vault/store.test.ts +569 -0
  657. package/src/security/credential-vault/store.ts +284 -0
  658. package/src/security/encryption.test.ts +114 -0
  659. package/src/security/encryption.ts +65 -0
  660. package/src/security/host-validation.test.ts +136 -0
  661. package/src/security/host-validation.ts +116 -0
  662. package/src/security/index.ts +59 -0
  663. package/src/security/key-audit.test.ts +57 -0
  664. package/src/security/key-audit.ts +45 -0
  665. package/src/security/key-injection.test.ts +131 -0
  666. package/src/security/key-injection.ts +71 -0
  667. package/src/security/key-validation.test.ts +111 -0
  668. package/src/security/key-validation.ts +84 -0
  669. package/src/security/redirect-allowlist.test.ts +70 -0
  670. package/src/security/redirect-allowlist.ts +35 -0
  671. package/src/security/tenant-keys/capability-settings-store.test.ts +98 -0
  672. package/src/security/tenant-keys/capability-settings-store.ts +53 -0
  673. package/src/security/tenant-keys/index.ts +10 -0
  674. package/src/security/tenant-keys/key-resolution-repository.test.ts +95 -0
  675. package/src/security/tenant-keys/key-resolution-repository.ts +31 -0
  676. package/src/security/tenant-keys/key-resolution.test.ts +173 -0
  677. package/src/security/tenant-keys/key-resolution.ts +87 -0
  678. package/src/security/tenant-keys/org-key-resolution.test.ts +217 -0
  679. package/src/security/tenant-keys/org-key-resolution.ts +76 -0
  680. package/src/security/tenant-keys/tenant-key-repository.test.ts +143 -0
  681. package/src/security/tenant-keys/tenant-key-repository.ts +130 -0
  682. package/src/security/types.ts +43 -0
  683. package/src/tenancy/drizzle-org-repository.ts +169 -0
  684. package/src/tenancy/index.ts +6 -0
  685. package/src/tenancy/org-member-repository.ts +159 -0
  686. package/src/tenancy/org-repository.test.ts +172 -0
  687. package/src/tenancy/org-service.test.ts +634 -0
  688. package/src/tenancy/org-service.ts +290 -0
  689. package/src/test/db.ts +97 -0
  690. package/src/trpc/index.ts +11 -0
  691. package/src/trpc/init.test.ts +196 -0
  692. package/src/trpc/init.ts +138 -0
  693. package/tsconfig.json +20 -0
  694. package/vitest.config.ts +8 -0
@@ -0,0 +1,4374 @@
1
+ {
2
+ "id": "bd3f587d-d29b-4a1c-aa60-d3174e11cbc3",
3
+ "prevId": "00000000-0000-0000-0000-000000000000",
4
+ "version": "7",
5
+ "dialect": "postgresql",
6
+ "tables": {
7
+ "public.account_deletion_requests": {
8
+ "name": "account_deletion_requests",
9
+ "schema": "",
10
+ "columns": {
11
+ "id": {
12
+ "name": "id",
13
+ "type": "text",
14
+ "primaryKey": true,
15
+ "notNull": true
16
+ },
17
+ "tenant_id": {
18
+ "name": "tenant_id",
19
+ "type": "text",
20
+ "primaryKey": false,
21
+ "notNull": true
22
+ },
23
+ "requested_by": {
24
+ "name": "requested_by",
25
+ "type": "text",
26
+ "primaryKey": false,
27
+ "notNull": true
28
+ },
29
+ "status": {
30
+ "name": "status",
31
+ "type": "text",
32
+ "primaryKey": false,
33
+ "notNull": true,
34
+ "default": "'pending'"
35
+ },
36
+ "delete_after": {
37
+ "name": "delete_after",
38
+ "type": "text",
39
+ "primaryKey": false,
40
+ "notNull": true
41
+ },
42
+ "reason": {
43
+ "name": "reason",
44
+ "type": "text",
45
+ "primaryKey": false,
46
+ "notNull": false
47
+ },
48
+ "cancel_reason": {
49
+ "name": "cancel_reason",
50
+ "type": "text",
51
+ "primaryKey": false,
52
+ "notNull": false
53
+ },
54
+ "completed_at": {
55
+ "name": "completed_at",
56
+ "type": "text",
57
+ "primaryKey": false,
58
+ "notNull": false
59
+ },
60
+ "deletion_summary": {
61
+ "name": "deletion_summary",
62
+ "type": "text",
63
+ "primaryKey": false,
64
+ "notNull": false
65
+ },
66
+ "created_at": {
67
+ "name": "created_at",
68
+ "type": "text",
69
+ "primaryKey": false,
70
+ "notNull": true,
71
+ "default": "(now())"
72
+ },
73
+ "updated_at": {
74
+ "name": "updated_at",
75
+ "type": "text",
76
+ "primaryKey": false,
77
+ "notNull": true,
78
+ "default": "(now())"
79
+ }
80
+ },
81
+ "indexes": {
82
+ "idx_acct_del_tenant": {
83
+ "name": "idx_acct_del_tenant",
84
+ "columns": [
85
+ {
86
+ "expression": "tenant_id",
87
+ "isExpression": false,
88
+ "asc": true,
89
+ "nulls": "last"
90
+ }
91
+ ],
92
+ "isUnique": false,
93
+ "concurrently": false,
94
+ "method": "btree",
95
+ "with": {}
96
+ },
97
+ "idx_acct_del_status": {
98
+ "name": "idx_acct_del_status",
99
+ "columns": [
100
+ {
101
+ "expression": "status",
102
+ "isExpression": false,
103
+ "asc": true,
104
+ "nulls": "last"
105
+ }
106
+ ],
107
+ "isUnique": false,
108
+ "concurrently": false,
109
+ "method": "btree",
110
+ "with": {}
111
+ },
112
+ "idx_acct_del_delete_after": {
113
+ "name": "idx_acct_del_delete_after",
114
+ "columns": [
115
+ {
116
+ "expression": "status",
117
+ "isExpression": false,
118
+ "asc": true,
119
+ "nulls": "last"
120
+ },
121
+ {
122
+ "expression": "delete_after",
123
+ "isExpression": false,
124
+ "asc": true,
125
+ "nulls": "last"
126
+ }
127
+ ],
128
+ "isUnique": false,
129
+ "concurrently": false,
130
+ "method": "btree",
131
+ "with": {}
132
+ }
133
+ },
134
+ "foreignKeys": {},
135
+ "compositePrimaryKeys": {},
136
+ "uniqueConstraints": {},
137
+ "policies": {},
138
+ "checkConstraints": {},
139
+ "isRLSEnabled": false
140
+ },
141
+ "public.account_export_requests": {
142
+ "name": "account_export_requests",
143
+ "schema": "",
144
+ "columns": {
145
+ "id": {
146
+ "name": "id",
147
+ "type": "text",
148
+ "primaryKey": true,
149
+ "notNull": true
150
+ },
151
+ "tenant_id": {
152
+ "name": "tenant_id",
153
+ "type": "text",
154
+ "primaryKey": false,
155
+ "notNull": true
156
+ },
157
+ "requested_by": {
158
+ "name": "requested_by",
159
+ "type": "text",
160
+ "primaryKey": false,
161
+ "notNull": true
162
+ },
163
+ "status": {
164
+ "name": "status",
165
+ "type": "text",
166
+ "primaryKey": false,
167
+ "notNull": true,
168
+ "default": "'pending'"
169
+ },
170
+ "format": {
171
+ "name": "format",
172
+ "type": "text",
173
+ "primaryKey": false,
174
+ "notNull": true,
175
+ "default": "'json'"
176
+ },
177
+ "download_url": {
178
+ "name": "download_url",
179
+ "type": "text",
180
+ "primaryKey": false,
181
+ "notNull": false
182
+ },
183
+ "created_at": {
184
+ "name": "created_at",
185
+ "type": "timestamp with time zone",
186
+ "primaryKey": false,
187
+ "notNull": true,
188
+ "default": "now()"
189
+ },
190
+ "updated_at": {
191
+ "name": "updated_at",
192
+ "type": "timestamp with time zone",
193
+ "primaryKey": false,
194
+ "notNull": true,
195
+ "default": "now()"
196
+ }
197
+ },
198
+ "indexes": {
199
+ "idx_acct_export_tenant": {
200
+ "name": "idx_acct_export_tenant",
201
+ "columns": [
202
+ {
203
+ "expression": "tenant_id",
204
+ "isExpression": false,
205
+ "asc": true,
206
+ "nulls": "last"
207
+ }
208
+ ],
209
+ "isUnique": false,
210
+ "concurrently": false,
211
+ "method": "btree",
212
+ "with": {}
213
+ },
214
+ "idx_acct_export_status": {
215
+ "name": "idx_acct_export_status",
216
+ "columns": [
217
+ {
218
+ "expression": "status",
219
+ "isExpression": false,
220
+ "asc": true,
221
+ "nulls": "last"
222
+ }
223
+ ],
224
+ "isUnique": false,
225
+ "concurrently": false,
226
+ "method": "btree",
227
+ "with": {}
228
+ }
229
+ },
230
+ "foreignKeys": {},
231
+ "compositePrimaryKeys": {},
232
+ "uniqueConstraints": {},
233
+ "policies": {},
234
+ "checkConstraints": {},
235
+ "isRLSEnabled": false
236
+ },
237
+ "public.admin_audit_log": {
238
+ "name": "admin_audit_log",
239
+ "schema": "",
240
+ "columns": {
241
+ "id": {
242
+ "name": "id",
243
+ "type": "text",
244
+ "primaryKey": true,
245
+ "notNull": true
246
+ },
247
+ "admin_user": {
248
+ "name": "admin_user",
249
+ "type": "text",
250
+ "primaryKey": false,
251
+ "notNull": true
252
+ },
253
+ "action": {
254
+ "name": "action",
255
+ "type": "text",
256
+ "primaryKey": false,
257
+ "notNull": true
258
+ },
259
+ "category": {
260
+ "name": "category",
261
+ "type": "text",
262
+ "primaryKey": false,
263
+ "notNull": true
264
+ },
265
+ "target_tenant": {
266
+ "name": "target_tenant",
267
+ "type": "text",
268
+ "primaryKey": false,
269
+ "notNull": false
270
+ },
271
+ "target_user": {
272
+ "name": "target_user",
273
+ "type": "text",
274
+ "primaryKey": false,
275
+ "notNull": false
276
+ },
277
+ "details": {
278
+ "name": "details",
279
+ "type": "text",
280
+ "primaryKey": false,
281
+ "notNull": true,
282
+ "default": "'{}'"
283
+ },
284
+ "ip_address": {
285
+ "name": "ip_address",
286
+ "type": "text",
287
+ "primaryKey": false,
288
+ "notNull": false
289
+ },
290
+ "user_agent": {
291
+ "name": "user_agent",
292
+ "type": "text",
293
+ "primaryKey": false,
294
+ "notNull": false
295
+ },
296
+ "created_at": {
297
+ "name": "created_at",
298
+ "type": "bigint",
299
+ "primaryKey": false,
300
+ "notNull": true,
301
+ "default": "(extract(epoch from now()) * 1000)::bigint"
302
+ },
303
+ "outcome": {
304
+ "name": "outcome",
305
+ "type": "text",
306
+ "primaryKey": false,
307
+ "notNull": false
308
+ }
309
+ },
310
+ "indexes": {
311
+ "idx_admin_audit_admin": {
312
+ "name": "idx_admin_audit_admin",
313
+ "columns": [
314
+ {
315
+ "expression": "admin_user",
316
+ "isExpression": false,
317
+ "asc": true,
318
+ "nulls": "last"
319
+ },
320
+ {
321
+ "expression": "created_at",
322
+ "isExpression": false,
323
+ "asc": true,
324
+ "nulls": "last"
325
+ }
326
+ ],
327
+ "isUnique": false,
328
+ "concurrently": false,
329
+ "method": "btree",
330
+ "with": {}
331
+ },
332
+ "idx_admin_audit_tenant": {
333
+ "name": "idx_admin_audit_tenant",
334
+ "columns": [
335
+ {
336
+ "expression": "target_tenant",
337
+ "isExpression": false,
338
+ "asc": true,
339
+ "nulls": "last"
340
+ },
341
+ {
342
+ "expression": "created_at",
343
+ "isExpression": false,
344
+ "asc": true,
345
+ "nulls": "last"
346
+ }
347
+ ],
348
+ "isUnique": false,
349
+ "concurrently": false,
350
+ "method": "btree",
351
+ "with": {}
352
+ },
353
+ "idx_admin_audit_action": {
354
+ "name": "idx_admin_audit_action",
355
+ "columns": [
356
+ {
357
+ "expression": "action",
358
+ "isExpression": false,
359
+ "asc": true,
360
+ "nulls": "last"
361
+ },
362
+ {
363
+ "expression": "created_at",
364
+ "isExpression": false,
365
+ "asc": true,
366
+ "nulls": "last"
367
+ }
368
+ ],
369
+ "isUnique": false,
370
+ "concurrently": false,
371
+ "method": "btree",
372
+ "with": {}
373
+ }
374
+ },
375
+ "foreignKeys": {},
376
+ "compositePrimaryKeys": {},
377
+ "uniqueConstraints": {},
378
+ "policies": {},
379
+ "checkConstraints": {},
380
+ "isRLSEnabled": false
381
+ },
382
+ "public.admin_users": {
383
+ "name": "admin_users",
384
+ "schema": "",
385
+ "columns": {
386
+ "id": {
387
+ "name": "id",
388
+ "type": "text",
389
+ "primaryKey": true,
390
+ "notNull": true
391
+ },
392
+ "email": {
393
+ "name": "email",
394
+ "type": "text",
395
+ "primaryKey": false,
396
+ "notNull": true
397
+ },
398
+ "name": {
399
+ "name": "name",
400
+ "type": "text",
401
+ "primaryKey": false,
402
+ "notNull": false
403
+ },
404
+ "tenant_id": {
405
+ "name": "tenant_id",
406
+ "type": "text",
407
+ "primaryKey": false,
408
+ "notNull": true
409
+ },
410
+ "status": {
411
+ "name": "status",
412
+ "type": "text",
413
+ "primaryKey": false,
414
+ "notNull": true,
415
+ "default": "'active'"
416
+ },
417
+ "role": {
418
+ "name": "role",
419
+ "type": "text",
420
+ "primaryKey": false,
421
+ "notNull": true,
422
+ "default": "'user'"
423
+ },
424
+ "credit_balance_cents": {
425
+ "name": "credit_balance_cents",
426
+ "type": "integer",
427
+ "primaryKey": false,
428
+ "notNull": true,
429
+ "default": 0
430
+ },
431
+ "agent_count": {
432
+ "name": "agent_count",
433
+ "type": "integer",
434
+ "primaryKey": false,
435
+ "notNull": true,
436
+ "default": 0
437
+ },
438
+ "last_seen": {
439
+ "name": "last_seen",
440
+ "type": "bigint",
441
+ "primaryKey": false,
442
+ "notNull": false
443
+ },
444
+ "created_at": {
445
+ "name": "created_at",
446
+ "type": "bigint",
447
+ "primaryKey": false,
448
+ "notNull": true
449
+ }
450
+ },
451
+ "indexes": {
452
+ "idx_admin_users_email": {
453
+ "name": "idx_admin_users_email",
454
+ "columns": [
455
+ {
456
+ "expression": "email",
457
+ "isExpression": false,
458
+ "asc": true,
459
+ "nulls": "last"
460
+ }
461
+ ],
462
+ "isUnique": false,
463
+ "concurrently": false,
464
+ "method": "btree",
465
+ "with": {}
466
+ },
467
+ "idx_admin_users_tenant": {
468
+ "name": "idx_admin_users_tenant",
469
+ "columns": [
470
+ {
471
+ "expression": "tenant_id",
472
+ "isExpression": false,
473
+ "asc": true,
474
+ "nulls": "last"
475
+ }
476
+ ],
477
+ "isUnique": false,
478
+ "concurrently": false,
479
+ "method": "btree",
480
+ "with": {}
481
+ },
482
+ "idx_admin_users_status": {
483
+ "name": "idx_admin_users_status",
484
+ "columns": [
485
+ {
486
+ "expression": "status",
487
+ "isExpression": false,
488
+ "asc": true,
489
+ "nulls": "last"
490
+ }
491
+ ],
492
+ "isUnique": false,
493
+ "concurrently": false,
494
+ "method": "btree",
495
+ "with": {}
496
+ },
497
+ "idx_admin_users_role": {
498
+ "name": "idx_admin_users_role",
499
+ "columns": [
500
+ {
501
+ "expression": "role",
502
+ "isExpression": false,
503
+ "asc": true,
504
+ "nulls": "last"
505
+ }
506
+ ],
507
+ "isUnique": false,
508
+ "concurrently": false,
509
+ "method": "btree",
510
+ "with": {}
511
+ },
512
+ "idx_admin_users_created": {
513
+ "name": "idx_admin_users_created",
514
+ "columns": [
515
+ {
516
+ "expression": "created_at",
517
+ "isExpression": false,
518
+ "asc": true,
519
+ "nulls": "last"
520
+ }
521
+ ],
522
+ "isUnique": false,
523
+ "concurrently": false,
524
+ "method": "btree",
525
+ "with": {}
526
+ },
527
+ "idx_admin_users_last_seen": {
528
+ "name": "idx_admin_users_last_seen",
529
+ "columns": [
530
+ {
531
+ "expression": "last_seen",
532
+ "isExpression": false,
533
+ "asc": true,
534
+ "nulls": "last"
535
+ }
536
+ ],
537
+ "isUnique": false,
538
+ "concurrently": false,
539
+ "method": "btree",
540
+ "with": {}
541
+ }
542
+ },
543
+ "foreignKeys": {},
544
+ "compositePrimaryKeys": {},
545
+ "uniqueConstraints": {},
546
+ "policies": {},
547
+ "checkConstraints": {
548
+ "chk_admin_users_status": {
549
+ "name": "chk_admin_users_status",
550
+ "value": "\"admin_users\".\"status\" IN ('active', 'suspended', 'grace_period', 'dormant', 'banned')"
551
+ },
552
+ "chk_admin_users_role": {
553
+ "name": "chk_admin_users_role",
554
+ "value": "\"admin_users\".\"role\" IN ('platform_admin', 'tenant_admin', 'user')"
555
+ }
556
+ },
557
+ "isRLSEnabled": false
558
+ },
559
+ "public.affiliate_codes": {
560
+ "name": "affiliate_codes",
561
+ "schema": "",
562
+ "columns": {
563
+ "tenant_id": {
564
+ "name": "tenant_id",
565
+ "type": "text",
566
+ "primaryKey": true,
567
+ "notNull": true
568
+ },
569
+ "code": {
570
+ "name": "code",
571
+ "type": "text",
572
+ "primaryKey": false,
573
+ "notNull": true
574
+ },
575
+ "created_at": {
576
+ "name": "created_at",
577
+ "type": "text",
578
+ "primaryKey": false,
579
+ "notNull": true,
580
+ "default": "(now())"
581
+ }
582
+ },
583
+ "indexes": {},
584
+ "foreignKeys": {},
585
+ "compositePrimaryKeys": {},
586
+ "uniqueConstraints": {
587
+ "affiliate_codes_code_unique": {
588
+ "name": "affiliate_codes_code_unique",
589
+ "nullsNotDistinct": false,
590
+ "columns": [
591
+ "code"
592
+ ]
593
+ }
594
+ },
595
+ "policies": {},
596
+ "checkConstraints": {},
597
+ "isRLSEnabled": false
598
+ },
599
+ "public.affiliate_referrals": {
600
+ "name": "affiliate_referrals",
601
+ "schema": "",
602
+ "columns": {
603
+ "id": {
604
+ "name": "id",
605
+ "type": "text",
606
+ "primaryKey": true,
607
+ "notNull": true
608
+ },
609
+ "referrer_tenant_id": {
610
+ "name": "referrer_tenant_id",
611
+ "type": "text",
612
+ "primaryKey": false,
613
+ "notNull": true
614
+ },
615
+ "referred_tenant_id": {
616
+ "name": "referred_tenant_id",
617
+ "type": "text",
618
+ "primaryKey": false,
619
+ "notNull": true
620
+ },
621
+ "code": {
622
+ "name": "code",
623
+ "type": "text",
624
+ "primaryKey": false,
625
+ "notNull": true
626
+ },
627
+ "signed_up_at": {
628
+ "name": "signed_up_at",
629
+ "type": "text",
630
+ "primaryKey": false,
631
+ "notNull": true,
632
+ "default": "(now())"
633
+ },
634
+ "first_purchase_at": {
635
+ "name": "first_purchase_at",
636
+ "type": "text",
637
+ "primaryKey": false,
638
+ "notNull": false
639
+ },
640
+ "match_amount_cents": {
641
+ "name": "match_amount_cents",
642
+ "type": "integer",
643
+ "primaryKey": false,
644
+ "notNull": false
645
+ },
646
+ "matched_at": {
647
+ "name": "matched_at",
648
+ "type": "text",
649
+ "primaryKey": false,
650
+ "notNull": false
651
+ },
652
+ "payout_suppressed": {
653
+ "name": "payout_suppressed",
654
+ "type": "boolean",
655
+ "primaryKey": false,
656
+ "notNull": true,
657
+ "default": false
658
+ },
659
+ "suppression_reason": {
660
+ "name": "suppression_reason",
661
+ "type": "text",
662
+ "primaryKey": false,
663
+ "notNull": false
664
+ },
665
+ "signup_ip": {
666
+ "name": "signup_ip",
667
+ "type": "text",
668
+ "primaryKey": false,
669
+ "notNull": false
670
+ },
671
+ "signup_email": {
672
+ "name": "signup_email",
673
+ "type": "text",
674
+ "primaryKey": false,
675
+ "notNull": false
676
+ }
677
+ },
678
+ "indexes": {
679
+ "idx_affiliate_ref_referrer": {
680
+ "name": "idx_affiliate_ref_referrer",
681
+ "columns": [
682
+ {
683
+ "expression": "referrer_tenant_id",
684
+ "isExpression": false,
685
+ "asc": true,
686
+ "nulls": "last"
687
+ }
688
+ ],
689
+ "isUnique": false,
690
+ "concurrently": false,
691
+ "method": "btree",
692
+ "with": {}
693
+ },
694
+ "idx_affiliate_ref_code": {
695
+ "name": "idx_affiliate_ref_code",
696
+ "columns": [
697
+ {
698
+ "expression": "code",
699
+ "isExpression": false,
700
+ "asc": true,
701
+ "nulls": "last"
702
+ }
703
+ ],
704
+ "isUnique": false,
705
+ "concurrently": false,
706
+ "method": "btree",
707
+ "with": {}
708
+ }
709
+ },
710
+ "foreignKeys": {},
711
+ "compositePrimaryKeys": {},
712
+ "uniqueConstraints": {
713
+ "affiliate_referrals_referred_tenant_id_unique": {
714
+ "name": "affiliate_referrals_referred_tenant_id_unique",
715
+ "nullsNotDistinct": false,
716
+ "columns": [
717
+ "referred_tenant_id"
718
+ ]
719
+ }
720
+ },
721
+ "policies": {},
722
+ "checkConstraints": {},
723
+ "isRLSEnabled": false
724
+ },
725
+ "public.affiliate_fraud_events": {
726
+ "name": "affiliate_fraud_events",
727
+ "schema": "",
728
+ "columns": {
729
+ "id": {
730
+ "name": "id",
731
+ "type": "text",
732
+ "primaryKey": true,
733
+ "notNull": true
734
+ },
735
+ "referral_id": {
736
+ "name": "referral_id",
737
+ "type": "text",
738
+ "primaryKey": false,
739
+ "notNull": true
740
+ },
741
+ "referrer_tenant_id": {
742
+ "name": "referrer_tenant_id",
743
+ "type": "text",
744
+ "primaryKey": false,
745
+ "notNull": true
746
+ },
747
+ "referred_tenant_id": {
748
+ "name": "referred_tenant_id",
749
+ "type": "text",
750
+ "primaryKey": false,
751
+ "notNull": true
752
+ },
753
+ "verdict": {
754
+ "name": "verdict",
755
+ "type": "text",
756
+ "primaryKey": false,
757
+ "notNull": true
758
+ },
759
+ "signals": {
760
+ "name": "signals",
761
+ "type": "text",
762
+ "primaryKey": false,
763
+ "notNull": true
764
+ },
765
+ "signal_details": {
766
+ "name": "signal_details",
767
+ "type": "text",
768
+ "primaryKey": false,
769
+ "notNull": true
770
+ },
771
+ "phase": {
772
+ "name": "phase",
773
+ "type": "text",
774
+ "primaryKey": false,
775
+ "notNull": true
776
+ },
777
+ "created_at": {
778
+ "name": "created_at",
779
+ "type": "text",
780
+ "primaryKey": false,
781
+ "notNull": true,
782
+ "default": "(now())"
783
+ }
784
+ },
785
+ "indexes": {
786
+ "idx_fraud_referrer": {
787
+ "name": "idx_fraud_referrer",
788
+ "columns": [
789
+ {
790
+ "expression": "referrer_tenant_id",
791
+ "isExpression": false,
792
+ "asc": true,
793
+ "nulls": "last"
794
+ }
795
+ ],
796
+ "isUnique": false,
797
+ "concurrently": false,
798
+ "method": "btree",
799
+ "with": {}
800
+ },
801
+ "idx_fraud_referred": {
802
+ "name": "idx_fraud_referred",
803
+ "columns": [
804
+ {
805
+ "expression": "referred_tenant_id",
806
+ "isExpression": false,
807
+ "asc": true,
808
+ "nulls": "last"
809
+ }
810
+ ],
811
+ "isUnique": false,
812
+ "concurrently": false,
813
+ "method": "btree",
814
+ "with": {}
815
+ },
816
+ "idx_fraud_verdict": {
817
+ "name": "idx_fraud_verdict",
818
+ "columns": [
819
+ {
820
+ "expression": "verdict",
821
+ "isExpression": false,
822
+ "asc": true,
823
+ "nulls": "last"
824
+ }
825
+ ],
826
+ "isUnique": false,
827
+ "concurrently": false,
828
+ "method": "btree",
829
+ "with": {}
830
+ },
831
+ "uq_fraud_referral_phase": {
832
+ "name": "uq_fraud_referral_phase",
833
+ "columns": [
834
+ {
835
+ "expression": "referral_id",
836
+ "isExpression": false,
837
+ "asc": true,
838
+ "nulls": "last"
839
+ },
840
+ {
841
+ "expression": "phase",
842
+ "isExpression": false,
843
+ "asc": true,
844
+ "nulls": "last"
845
+ }
846
+ ],
847
+ "isUnique": true,
848
+ "concurrently": false,
849
+ "method": "btree",
850
+ "with": {}
851
+ }
852
+ },
853
+ "foreignKeys": {},
854
+ "compositePrimaryKeys": {},
855
+ "uniqueConstraints": {},
856
+ "policies": {},
857
+ "checkConstraints": {},
858
+ "isRLSEnabled": false
859
+ },
860
+ "public.coupon_codes": {
861
+ "name": "coupon_codes",
862
+ "schema": "",
863
+ "columns": {
864
+ "id": {
865
+ "name": "id",
866
+ "type": "uuid",
867
+ "primaryKey": true,
868
+ "notNull": true,
869
+ "default": "gen_random_uuid()"
870
+ },
871
+ "promotion_id": {
872
+ "name": "promotion_id",
873
+ "type": "uuid",
874
+ "primaryKey": false,
875
+ "notNull": true
876
+ },
877
+ "code": {
878
+ "name": "code",
879
+ "type": "text",
880
+ "primaryKey": false,
881
+ "notNull": true
882
+ },
883
+ "assigned_tenant_id": {
884
+ "name": "assigned_tenant_id",
885
+ "type": "text",
886
+ "primaryKey": false,
887
+ "notNull": false
888
+ },
889
+ "assigned_email": {
890
+ "name": "assigned_email",
891
+ "type": "text",
892
+ "primaryKey": false,
893
+ "notNull": false
894
+ },
895
+ "redeemed_at": {
896
+ "name": "redeemed_at",
897
+ "type": "timestamp with time zone",
898
+ "primaryKey": false,
899
+ "notNull": false
900
+ },
901
+ "redeemed_by_tenant_id": {
902
+ "name": "redeemed_by_tenant_id",
903
+ "type": "text",
904
+ "primaryKey": false,
905
+ "notNull": false
906
+ },
907
+ "created_at": {
908
+ "name": "created_at",
909
+ "type": "timestamp with time zone",
910
+ "primaryKey": false,
911
+ "notNull": true,
912
+ "default": "now()"
913
+ }
914
+ },
915
+ "indexes": {
916
+ "coupon_codes_promotion_idx": {
917
+ "name": "coupon_codes_promotion_idx",
918
+ "columns": [
919
+ {
920
+ "expression": "promotion_id",
921
+ "isExpression": false,
922
+ "asc": true,
923
+ "nulls": "last"
924
+ }
925
+ ],
926
+ "isUnique": false,
927
+ "concurrently": false,
928
+ "method": "btree",
929
+ "with": {}
930
+ },
931
+ "coupon_codes_assigned_tenant_idx": {
932
+ "name": "coupon_codes_assigned_tenant_idx",
933
+ "columns": [
934
+ {
935
+ "expression": "assigned_tenant_id",
936
+ "isExpression": false,
937
+ "asc": true,
938
+ "nulls": "last"
939
+ }
940
+ ],
941
+ "isUnique": false,
942
+ "concurrently": false,
943
+ "method": "btree",
944
+ "with": {}
945
+ }
946
+ },
947
+ "foreignKeys": {
948
+ "coupon_codes_promotion_id_promotions_id_fk": {
949
+ "name": "coupon_codes_promotion_id_promotions_id_fk",
950
+ "tableFrom": "coupon_codes",
951
+ "tableTo": "promotions",
952
+ "columnsFrom": [
953
+ "promotion_id"
954
+ ],
955
+ "columnsTo": [
956
+ "id"
957
+ ],
958
+ "onDelete": "no action",
959
+ "onUpdate": "no action"
960
+ }
961
+ },
962
+ "compositePrimaryKeys": {},
963
+ "uniqueConstraints": {
964
+ "coupon_codes_code_unique": {
965
+ "name": "coupon_codes_code_unique",
966
+ "nullsNotDistinct": false,
967
+ "columns": [
968
+ "code"
969
+ ]
970
+ }
971
+ },
972
+ "policies": {},
973
+ "checkConstraints": {},
974
+ "isRLSEnabled": false
975
+ },
976
+ "public.credit_auto_topup": {
977
+ "name": "credit_auto_topup",
978
+ "schema": "",
979
+ "columns": {
980
+ "id": {
981
+ "name": "id",
982
+ "type": "text",
983
+ "primaryKey": true,
984
+ "notNull": true
985
+ },
986
+ "tenant_id": {
987
+ "name": "tenant_id",
988
+ "type": "text",
989
+ "primaryKey": false,
990
+ "notNull": true
991
+ },
992
+ "amount_cents": {
993
+ "name": "amount_cents",
994
+ "type": "integer",
995
+ "primaryKey": false,
996
+ "notNull": true
997
+ },
998
+ "status": {
999
+ "name": "status",
1000
+ "type": "text",
1001
+ "primaryKey": false,
1002
+ "notNull": true
1003
+ },
1004
+ "failure_reason": {
1005
+ "name": "failure_reason",
1006
+ "type": "text",
1007
+ "primaryKey": false,
1008
+ "notNull": false
1009
+ },
1010
+ "payment_reference": {
1011
+ "name": "payment_reference",
1012
+ "type": "text",
1013
+ "primaryKey": false,
1014
+ "notNull": false
1015
+ },
1016
+ "created_at": {
1017
+ "name": "created_at",
1018
+ "type": "text",
1019
+ "primaryKey": false,
1020
+ "notNull": true,
1021
+ "default": "(now())"
1022
+ }
1023
+ },
1024
+ "indexes": {
1025
+ "idx_auto_topup_tenant": {
1026
+ "name": "idx_auto_topup_tenant",
1027
+ "columns": [
1028
+ {
1029
+ "expression": "tenant_id",
1030
+ "isExpression": false,
1031
+ "asc": true,
1032
+ "nulls": "last"
1033
+ }
1034
+ ],
1035
+ "isUnique": false,
1036
+ "concurrently": false,
1037
+ "method": "btree",
1038
+ "with": {}
1039
+ },
1040
+ "idx_auto_topup_status": {
1041
+ "name": "idx_auto_topup_status",
1042
+ "columns": [
1043
+ {
1044
+ "expression": "status",
1045
+ "isExpression": false,
1046
+ "asc": true,
1047
+ "nulls": "last"
1048
+ }
1049
+ ],
1050
+ "isUnique": false,
1051
+ "concurrently": false,
1052
+ "method": "btree",
1053
+ "with": {}
1054
+ },
1055
+ "idx_auto_topup_created": {
1056
+ "name": "idx_auto_topup_created",
1057
+ "columns": [
1058
+ {
1059
+ "expression": "created_at",
1060
+ "isExpression": false,
1061
+ "asc": true,
1062
+ "nulls": "last"
1063
+ }
1064
+ ],
1065
+ "isUnique": false,
1066
+ "concurrently": false,
1067
+ "method": "btree",
1068
+ "with": {}
1069
+ },
1070
+ "idx_auto_topup_tenant_created": {
1071
+ "name": "idx_auto_topup_tenant_created",
1072
+ "columns": [
1073
+ {
1074
+ "expression": "tenant_id",
1075
+ "isExpression": false,
1076
+ "asc": true,
1077
+ "nulls": "last"
1078
+ },
1079
+ {
1080
+ "expression": "created_at",
1081
+ "isExpression": false,
1082
+ "asc": true,
1083
+ "nulls": "last"
1084
+ }
1085
+ ],
1086
+ "isUnique": false,
1087
+ "concurrently": false,
1088
+ "method": "btree",
1089
+ "with": {}
1090
+ }
1091
+ },
1092
+ "foreignKeys": {},
1093
+ "compositePrimaryKeys": {},
1094
+ "uniqueConstraints": {},
1095
+ "policies": {},
1096
+ "checkConstraints": {},
1097
+ "isRLSEnabled": false
1098
+ },
1099
+ "public.credit_auto_topup_settings": {
1100
+ "name": "credit_auto_topup_settings",
1101
+ "schema": "",
1102
+ "columns": {
1103
+ "tenant_id": {
1104
+ "name": "tenant_id",
1105
+ "type": "text",
1106
+ "primaryKey": true,
1107
+ "notNull": true
1108
+ },
1109
+ "usage_enabled": {
1110
+ "name": "usage_enabled",
1111
+ "type": "boolean",
1112
+ "primaryKey": false,
1113
+ "notNull": true,
1114
+ "default": false
1115
+ },
1116
+ "usage_threshold_cents": {
1117
+ "name": "usage_threshold_cents",
1118
+ "type": "integer",
1119
+ "primaryKey": false,
1120
+ "notNull": true,
1121
+ "default": 100
1122
+ },
1123
+ "usage_topup_cents": {
1124
+ "name": "usage_topup_cents",
1125
+ "type": "integer",
1126
+ "primaryKey": false,
1127
+ "notNull": true,
1128
+ "default": 500
1129
+ },
1130
+ "usage_consecutive_failures": {
1131
+ "name": "usage_consecutive_failures",
1132
+ "type": "integer",
1133
+ "primaryKey": false,
1134
+ "notNull": true,
1135
+ "default": 0
1136
+ },
1137
+ "usage_charge_in_flight": {
1138
+ "name": "usage_charge_in_flight",
1139
+ "type": "boolean",
1140
+ "primaryKey": false,
1141
+ "notNull": true,
1142
+ "default": false
1143
+ },
1144
+ "schedule_enabled": {
1145
+ "name": "schedule_enabled",
1146
+ "type": "boolean",
1147
+ "primaryKey": false,
1148
+ "notNull": true,
1149
+ "default": false
1150
+ },
1151
+ "schedule_amount_cents": {
1152
+ "name": "schedule_amount_cents",
1153
+ "type": "integer",
1154
+ "primaryKey": false,
1155
+ "notNull": true,
1156
+ "default": 500
1157
+ },
1158
+ "schedule_interval_hours": {
1159
+ "name": "schedule_interval_hours",
1160
+ "type": "integer",
1161
+ "primaryKey": false,
1162
+ "notNull": true,
1163
+ "default": 168
1164
+ },
1165
+ "schedule_next_at": {
1166
+ "name": "schedule_next_at",
1167
+ "type": "text",
1168
+ "primaryKey": false,
1169
+ "notNull": false
1170
+ },
1171
+ "schedule_consecutive_failures": {
1172
+ "name": "schedule_consecutive_failures",
1173
+ "type": "integer",
1174
+ "primaryKey": false,
1175
+ "notNull": true,
1176
+ "default": 0
1177
+ },
1178
+ "created_at": {
1179
+ "name": "created_at",
1180
+ "type": "text",
1181
+ "primaryKey": false,
1182
+ "notNull": true,
1183
+ "default": "(now())"
1184
+ },
1185
+ "updated_at": {
1186
+ "name": "updated_at",
1187
+ "type": "text",
1188
+ "primaryKey": false,
1189
+ "notNull": true,
1190
+ "default": "(now())"
1191
+ }
1192
+ },
1193
+ "indexes": {
1194
+ "idx_auto_topup_settings_usage": {
1195
+ "name": "idx_auto_topup_settings_usage",
1196
+ "columns": [
1197
+ {
1198
+ "expression": "usage_enabled",
1199
+ "isExpression": false,
1200
+ "asc": true,
1201
+ "nulls": "last"
1202
+ }
1203
+ ],
1204
+ "isUnique": false,
1205
+ "concurrently": false,
1206
+ "method": "btree",
1207
+ "with": {}
1208
+ },
1209
+ "idx_auto_topup_settings_schedule": {
1210
+ "name": "idx_auto_topup_settings_schedule",
1211
+ "columns": [
1212
+ {
1213
+ "expression": "schedule_enabled",
1214
+ "isExpression": false,
1215
+ "asc": true,
1216
+ "nulls": "last"
1217
+ },
1218
+ {
1219
+ "expression": "schedule_next_at",
1220
+ "isExpression": false,
1221
+ "asc": true,
1222
+ "nulls": "last"
1223
+ }
1224
+ ],
1225
+ "isUnique": false,
1226
+ "concurrently": false,
1227
+ "method": "btree",
1228
+ "with": {}
1229
+ }
1230
+ },
1231
+ "foreignKeys": {},
1232
+ "compositePrimaryKeys": {},
1233
+ "uniqueConstraints": {},
1234
+ "policies": {},
1235
+ "checkConstraints": {},
1236
+ "isRLSEnabled": false
1237
+ },
1238
+ "public.credit_balances": {
1239
+ "name": "credit_balances",
1240
+ "schema": "",
1241
+ "columns": {
1242
+ "tenant_id": {
1243
+ "name": "tenant_id",
1244
+ "type": "text",
1245
+ "primaryKey": true,
1246
+ "notNull": true
1247
+ },
1248
+ "balance_credits": {
1249
+ "name": "balance_credits",
1250
+ "type": "bigint",
1251
+ "primaryKey": false,
1252
+ "notNull": true,
1253
+ "default": "0"
1254
+ },
1255
+ "last_updated": {
1256
+ "name": "last_updated",
1257
+ "type": "text",
1258
+ "primaryKey": false,
1259
+ "notNull": true,
1260
+ "default": "(now())"
1261
+ }
1262
+ },
1263
+ "indexes": {},
1264
+ "foreignKeys": {},
1265
+ "compositePrimaryKeys": {},
1266
+ "uniqueConstraints": {},
1267
+ "policies": {},
1268
+ "checkConstraints": {},
1269
+ "isRLSEnabled": false
1270
+ },
1271
+ "public.credit_transactions": {
1272
+ "name": "credit_transactions",
1273
+ "schema": "",
1274
+ "columns": {
1275
+ "id": {
1276
+ "name": "id",
1277
+ "type": "text",
1278
+ "primaryKey": true,
1279
+ "notNull": true
1280
+ },
1281
+ "tenant_id": {
1282
+ "name": "tenant_id",
1283
+ "type": "text",
1284
+ "primaryKey": false,
1285
+ "notNull": true
1286
+ },
1287
+ "amount_credits": {
1288
+ "name": "amount_credits",
1289
+ "type": "bigint",
1290
+ "primaryKey": false,
1291
+ "notNull": true
1292
+ },
1293
+ "balance_after_credits": {
1294
+ "name": "balance_after_credits",
1295
+ "type": "bigint",
1296
+ "primaryKey": false,
1297
+ "notNull": true
1298
+ },
1299
+ "type": {
1300
+ "name": "type",
1301
+ "type": "text",
1302
+ "primaryKey": false,
1303
+ "notNull": true
1304
+ },
1305
+ "description": {
1306
+ "name": "description",
1307
+ "type": "text",
1308
+ "primaryKey": false,
1309
+ "notNull": false
1310
+ },
1311
+ "reference_id": {
1312
+ "name": "reference_id",
1313
+ "type": "text",
1314
+ "primaryKey": false,
1315
+ "notNull": false
1316
+ },
1317
+ "funding_source": {
1318
+ "name": "funding_source",
1319
+ "type": "text",
1320
+ "primaryKey": false,
1321
+ "notNull": false
1322
+ },
1323
+ "attributed_user_id": {
1324
+ "name": "attributed_user_id",
1325
+ "type": "text",
1326
+ "primaryKey": false,
1327
+ "notNull": false
1328
+ },
1329
+ "created_at": {
1330
+ "name": "created_at",
1331
+ "type": "text",
1332
+ "primaryKey": false,
1333
+ "notNull": true,
1334
+ "default": "(now())"
1335
+ },
1336
+ "expires_at": {
1337
+ "name": "expires_at",
1338
+ "type": "text",
1339
+ "primaryKey": false,
1340
+ "notNull": false
1341
+ },
1342
+ "stripe_fingerprint": {
1343
+ "name": "stripe_fingerprint",
1344
+ "type": "text",
1345
+ "primaryKey": false,
1346
+ "notNull": false
1347
+ }
1348
+ },
1349
+ "indexes": {
1350
+ "idx_credit_tx_tenant": {
1351
+ "name": "idx_credit_tx_tenant",
1352
+ "columns": [
1353
+ {
1354
+ "expression": "tenant_id",
1355
+ "isExpression": false,
1356
+ "asc": true,
1357
+ "nulls": "last"
1358
+ }
1359
+ ],
1360
+ "isUnique": false,
1361
+ "concurrently": false,
1362
+ "method": "btree",
1363
+ "with": {}
1364
+ },
1365
+ "idx_credit_tx_type": {
1366
+ "name": "idx_credit_tx_type",
1367
+ "columns": [
1368
+ {
1369
+ "expression": "type",
1370
+ "isExpression": false,
1371
+ "asc": true,
1372
+ "nulls": "last"
1373
+ }
1374
+ ],
1375
+ "isUnique": false,
1376
+ "concurrently": false,
1377
+ "method": "btree",
1378
+ "with": {}
1379
+ },
1380
+ "idx_credit_tx_ref": {
1381
+ "name": "idx_credit_tx_ref",
1382
+ "columns": [
1383
+ {
1384
+ "expression": "reference_id",
1385
+ "isExpression": false,
1386
+ "asc": true,
1387
+ "nulls": "last"
1388
+ }
1389
+ ],
1390
+ "isUnique": false,
1391
+ "concurrently": false,
1392
+ "method": "btree",
1393
+ "with": {}
1394
+ },
1395
+ "idx_credit_tx_created": {
1396
+ "name": "idx_credit_tx_created",
1397
+ "columns": [
1398
+ {
1399
+ "expression": "created_at",
1400
+ "isExpression": false,
1401
+ "asc": true,
1402
+ "nulls": "last"
1403
+ }
1404
+ ],
1405
+ "isUnique": false,
1406
+ "concurrently": false,
1407
+ "method": "btree",
1408
+ "with": {}
1409
+ },
1410
+ "idx_credit_tx_tenant_created": {
1411
+ "name": "idx_credit_tx_tenant_created",
1412
+ "columns": [
1413
+ {
1414
+ "expression": "tenant_id",
1415
+ "isExpression": false,
1416
+ "asc": true,
1417
+ "nulls": "last"
1418
+ },
1419
+ {
1420
+ "expression": "created_at",
1421
+ "isExpression": false,
1422
+ "asc": true,
1423
+ "nulls": "last"
1424
+ }
1425
+ ],
1426
+ "isUnique": false,
1427
+ "concurrently": false,
1428
+ "method": "btree",
1429
+ "with": {}
1430
+ },
1431
+ "idx_credit_tx_expires": {
1432
+ "name": "idx_credit_tx_expires",
1433
+ "columns": [
1434
+ {
1435
+ "expression": "expires_at",
1436
+ "isExpression": false,
1437
+ "asc": true,
1438
+ "nulls": "last"
1439
+ }
1440
+ ],
1441
+ "isUnique": false,
1442
+ "concurrently": false,
1443
+ "method": "btree",
1444
+ "with": {}
1445
+ },
1446
+ "idx_credit_tx_fingerprint": {
1447
+ "name": "idx_credit_tx_fingerprint",
1448
+ "columns": [
1449
+ {
1450
+ "expression": "stripe_fingerprint",
1451
+ "isExpression": false,
1452
+ "asc": true,
1453
+ "nulls": "last"
1454
+ }
1455
+ ],
1456
+ "isUnique": false,
1457
+ "where": "\"credit_transactions\".\"stripe_fingerprint\" IS NOT NULL",
1458
+ "concurrently": false,
1459
+ "method": "btree",
1460
+ "with": {}
1461
+ }
1462
+ },
1463
+ "foreignKeys": {},
1464
+ "compositePrimaryKeys": {},
1465
+ "uniqueConstraints": {
1466
+ "credit_transactions_reference_id_unique": {
1467
+ "name": "credit_transactions_reference_id_unique",
1468
+ "nullsNotDistinct": false,
1469
+ "columns": [
1470
+ "reference_id"
1471
+ ]
1472
+ }
1473
+ },
1474
+ "policies": {},
1475
+ "checkConstraints": {},
1476
+ "isRLSEnabled": false
1477
+ },
1478
+ "public.dividend_distributions": {
1479
+ "name": "dividend_distributions",
1480
+ "schema": "",
1481
+ "columns": {
1482
+ "id": {
1483
+ "name": "id",
1484
+ "type": "text",
1485
+ "primaryKey": true,
1486
+ "notNull": true
1487
+ },
1488
+ "tenant_id": {
1489
+ "name": "tenant_id",
1490
+ "type": "text",
1491
+ "primaryKey": false,
1492
+ "notNull": true
1493
+ },
1494
+ "date": {
1495
+ "name": "date",
1496
+ "type": "text",
1497
+ "primaryKey": false,
1498
+ "notNull": true
1499
+ },
1500
+ "amount_cents": {
1501
+ "name": "amount_cents",
1502
+ "type": "integer",
1503
+ "primaryKey": false,
1504
+ "notNull": true
1505
+ },
1506
+ "pool_cents": {
1507
+ "name": "pool_cents",
1508
+ "type": "integer",
1509
+ "primaryKey": false,
1510
+ "notNull": true
1511
+ },
1512
+ "active_users": {
1513
+ "name": "active_users",
1514
+ "type": "integer",
1515
+ "primaryKey": false,
1516
+ "notNull": true
1517
+ },
1518
+ "created_at": {
1519
+ "name": "created_at",
1520
+ "type": "text",
1521
+ "primaryKey": false,
1522
+ "notNull": true,
1523
+ "default": "(now())"
1524
+ }
1525
+ },
1526
+ "indexes": {
1527
+ "idx_dividend_dist_tenant": {
1528
+ "name": "idx_dividend_dist_tenant",
1529
+ "columns": [
1530
+ {
1531
+ "expression": "tenant_id",
1532
+ "isExpression": false,
1533
+ "asc": true,
1534
+ "nulls": "last"
1535
+ }
1536
+ ],
1537
+ "isUnique": false,
1538
+ "concurrently": false,
1539
+ "method": "btree",
1540
+ "with": {}
1541
+ },
1542
+ "idx_dividend_dist_date": {
1543
+ "name": "idx_dividend_dist_date",
1544
+ "columns": [
1545
+ {
1546
+ "expression": "date",
1547
+ "isExpression": false,
1548
+ "asc": true,
1549
+ "nulls": "last"
1550
+ }
1551
+ ],
1552
+ "isUnique": false,
1553
+ "concurrently": false,
1554
+ "method": "btree",
1555
+ "with": {}
1556
+ },
1557
+ "idx_dividend_dist_tenant_date": {
1558
+ "name": "idx_dividend_dist_tenant_date",
1559
+ "columns": [
1560
+ {
1561
+ "expression": "tenant_id",
1562
+ "isExpression": false,
1563
+ "asc": true,
1564
+ "nulls": "last"
1565
+ },
1566
+ {
1567
+ "expression": "date",
1568
+ "isExpression": false,
1569
+ "asc": true,
1570
+ "nulls": "last"
1571
+ }
1572
+ ],
1573
+ "isUnique": false,
1574
+ "concurrently": false,
1575
+ "method": "btree",
1576
+ "with": {}
1577
+ }
1578
+ },
1579
+ "foreignKeys": {},
1580
+ "compositePrimaryKeys": {},
1581
+ "uniqueConstraints": {},
1582
+ "policies": {},
1583
+ "checkConstraints": {},
1584
+ "isRLSEnabled": false
1585
+ },
1586
+ "public.email_notifications": {
1587
+ "name": "email_notifications",
1588
+ "schema": "",
1589
+ "columns": {
1590
+ "id": {
1591
+ "name": "id",
1592
+ "type": "text",
1593
+ "primaryKey": true,
1594
+ "notNull": true
1595
+ },
1596
+ "tenant_id": {
1597
+ "name": "tenant_id",
1598
+ "type": "text",
1599
+ "primaryKey": false,
1600
+ "notNull": true
1601
+ },
1602
+ "email_type": {
1603
+ "name": "email_type",
1604
+ "type": "text",
1605
+ "primaryKey": false,
1606
+ "notNull": true
1607
+ },
1608
+ "sent_at": {
1609
+ "name": "sent_at",
1610
+ "type": "text",
1611
+ "primaryKey": false,
1612
+ "notNull": true,
1613
+ "default": "(now())"
1614
+ },
1615
+ "sent_date": {
1616
+ "name": "sent_date",
1617
+ "type": "text",
1618
+ "primaryKey": false,
1619
+ "notNull": true
1620
+ }
1621
+ },
1622
+ "indexes": {
1623
+ "idx_email_notif_tenant": {
1624
+ "name": "idx_email_notif_tenant",
1625
+ "columns": [
1626
+ {
1627
+ "expression": "tenant_id",
1628
+ "isExpression": false,
1629
+ "asc": true,
1630
+ "nulls": "last"
1631
+ }
1632
+ ],
1633
+ "isUnique": false,
1634
+ "concurrently": false,
1635
+ "method": "btree",
1636
+ "with": {}
1637
+ },
1638
+ "idx_email_notif_type": {
1639
+ "name": "idx_email_notif_type",
1640
+ "columns": [
1641
+ {
1642
+ "expression": "email_type",
1643
+ "isExpression": false,
1644
+ "asc": true,
1645
+ "nulls": "last"
1646
+ }
1647
+ ],
1648
+ "isUnique": false,
1649
+ "concurrently": false,
1650
+ "method": "btree",
1651
+ "with": {}
1652
+ }
1653
+ },
1654
+ "foreignKeys": {},
1655
+ "compositePrimaryKeys": {},
1656
+ "uniqueConstraints": {
1657
+ "uniq_email_per_day": {
1658
+ "name": "uniq_email_per_day",
1659
+ "nullsNotDistinct": false,
1660
+ "columns": [
1661
+ "tenant_id",
1662
+ "email_type",
1663
+ "sent_date"
1664
+ ]
1665
+ }
1666
+ },
1667
+ "policies": {},
1668
+ "checkConstraints": {},
1669
+ "isRLSEnabled": false
1670
+ },
1671
+ "public.billing_period_summaries": {
1672
+ "name": "billing_period_summaries",
1673
+ "schema": "",
1674
+ "columns": {
1675
+ "id": {
1676
+ "name": "id",
1677
+ "type": "text",
1678
+ "primaryKey": true,
1679
+ "notNull": true
1680
+ },
1681
+ "tenant": {
1682
+ "name": "tenant",
1683
+ "type": "text",
1684
+ "primaryKey": false,
1685
+ "notNull": true
1686
+ },
1687
+ "capability": {
1688
+ "name": "capability",
1689
+ "type": "text",
1690
+ "primaryKey": false,
1691
+ "notNull": true
1692
+ },
1693
+ "provider": {
1694
+ "name": "provider",
1695
+ "type": "text",
1696
+ "primaryKey": false,
1697
+ "notNull": true
1698
+ },
1699
+ "event_count": {
1700
+ "name": "event_count",
1701
+ "type": "integer",
1702
+ "primaryKey": false,
1703
+ "notNull": true
1704
+ },
1705
+ "total_cost": {
1706
+ "name": "total_cost",
1707
+ "type": "bigint",
1708
+ "primaryKey": false,
1709
+ "notNull": true
1710
+ },
1711
+ "total_charge": {
1712
+ "name": "total_charge",
1713
+ "type": "bigint",
1714
+ "primaryKey": false,
1715
+ "notNull": true
1716
+ },
1717
+ "total_duration": {
1718
+ "name": "total_duration",
1719
+ "type": "integer",
1720
+ "primaryKey": false,
1721
+ "notNull": true,
1722
+ "default": 0
1723
+ },
1724
+ "period_start": {
1725
+ "name": "period_start",
1726
+ "type": "bigint",
1727
+ "primaryKey": false,
1728
+ "notNull": true
1729
+ },
1730
+ "period_end": {
1731
+ "name": "period_end",
1732
+ "type": "bigint",
1733
+ "primaryKey": false,
1734
+ "notNull": true
1735
+ },
1736
+ "updated_at": {
1737
+ "name": "updated_at",
1738
+ "type": "bigint",
1739
+ "primaryKey": false,
1740
+ "notNull": true
1741
+ }
1742
+ },
1743
+ "indexes": {
1744
+ "idx_billing_period_unique": {
1745
+ "name": "idx_billing_period_unique",
1746
+ "columns": [
1747
+ {
1748
+ "expression": "tenant",
1749
+ "isExpression": false,
1750
+ "asc": true,
1751
+ "nulls": "last"
1752
+ },
1753
+ {
1754
+ "expression": "capability",
1755
+ "isExpression": false,
1756
+ "asc": true,
1757
+ "nulls": "last"
1758
+ },
1759
+ {
1760
+ "expression": "provider",
1761
+ "isExpression": false,
1762
+ "asc": true,
1763
+ "nulls": "last"
1764
+ },
1765
+ {
1766
+ "expression": "period_start",
1767
+ "isExpression": false,
1768
+ "asc": true,
1769
+ "nulls": "last"
1770
+ }
1771
+ ],
1772
+ "isUnique": true,
1773
+ "concurrently": false,
1774
+ "method": "btree",
1775
+ "with": {}
1776
+ },
1777
+ "idx_billing_period_tenant": {
1778
+ "name": "idx_billing_period_tenant",
1779
+ "columns": [
1780
+ {
1781
+ "expression": "tenant",
1782
+ "isExpression": false,
1783
+ "asc": true,
1784
+ "nulls": "last"
1785
+ },
1786
+ {
1787
+ "expression": "period_start",
1788
+ "isExpression": false,
1789
+ "asc": true,
1790
+ "nulls": "last"
1791
+ }
1792
+ ],
1793
+ "isUnique": false,
1794
+ "concurrently": false,
1795
+ "method": "btree",
1796
+ "with": {}
1797
+ },
1798
+ "idx_billing_period_window": {
1799
+ "name": "idx_billing_period_window",
1800
+ "columns": [
1801
+ {
1802
+ "expression": "period_start",
1803
+ "isExpression": false,
1804
+ "asc": true,
1805
+ "nulls": "last"
1806
+ },
1807
+ {
1808
+ "expression": "period_end",
1809
+ "isExpression": false,
1810
+ "asc": true,
1811
+ "nulls": "last"
1812
+ }
1813
+ ],
1814
+ "isUnique": false,
1815
+ "concurrently": false,
1816
+ "method": "btree",
1817
+ "with": {}
1818
+ }
1819
+ },
1820
+ "foreignKeys": {},
1821
+ "compositePrimaryKeys": {},
1822
+ "uniqueConstraints": {},
1823
+ "policies": {},
1824
+ "checkConstraints": {},
1825
+ "isRLSEnabled": false
1826
+ },
1827
+ "public.meter_events": {
1828
+ "name": "meter_events",
1829
+ "schema": "",
1830
+ "columns": {
1831
+ "id": {
1832
+ "name": "id",
1833
+ "type": "text",
1834
+ "primaryKey": true,
1835
+ "notNull": true
1836
+ },
1837
+ "tenant": {
1838
+ "name": "tenant",
1839
+ "type": "text",
1840
+ "primaryKey": false,
1841
+ "notNull": true
1842
+ },
1843
+ "cost": {
1844
+ "name": "cost",
1845
+ "type": "bigint",
1846
+ "primaryKey": false,
1847
+ "notNull": true
1848
+ },
1849
+ "charge": {
1850
+ "name": "charge",
1851
+ "type": "bigint",
1852
+ "primaryKey": false,
1853
+ "notNull": true
1854
+ },
1855
+ "capability": {
1856
+ "name": "capability",
1857
+ "type": "text",
1858
+ "primaryKey": false,
1859
+ "notNull": true
1860
+ },
1861
+ "provider": {
1862
+ "name": "provider",
1863
+ "type": "text",
1864
+ "primaryKey": false,
1865
+ "notNull": true
1866
+ },
1867
+ "timestamp": {
1868
+ "name": "timestamp",
1869
+ "type": "bigint",
1870
+ "primaryKey": false,
1871
+ "notNull": true
1872
+ },
1873
+ "session_id": {
1874
+ "name": "session_id",
1875
+ "type": "text",
1876
+ "primaryKey": false,
1877
+ "notNull": false
1878
+ },
1879
+ "duration": {
1880
+ "name": "duration",
1881
+ "type": "integer",
1882
+ "primaryKey": false,
1883
+ "notNull": false
1884
+ },
1885
+ "usage_units": {
1886
+ "name": "usage_units",
1887
+ "type": "real",
1888
+ "primaryKey": false,
1889
+ "notNull": false
1890
+ },
1891
+ "usage_unit_type": {
1892
+ "name": "usage_unit_type",
1893
+ "type": "text",
1894
+ "primaryKey": false,
1895
+ "notNull": false
1896
+ },
1897
+ "tier": {
1898
+ "name": "tier",
1899
+ "type": "text",
1900
+ "primaryKey": false,
1901
+ "notNull": false
1902
+ },
1903
+ "metadata": {
1904
+ "name": "metadata",
1905
+ "type": "text",
1906
+ "primaryKey": false,
1907
+ "notNull": false
1908
+ }
1909
+ },
1910
+ "indexes": {
1911
+ "idx_meter_tenant": {
1912
+ "name": "idx_meter_tenant",
1913
+ "columns": [
1914
+ {
1915
+ "expression": "tenant",
1916
+ "isExpression": false,
1917
+ "asc": true,
1918
+ "nulls": "last"
1919
+ }
1920
+ ],
1921
+ "isUnique": false,
1922
+ "concurrently": false,
1923
+ "method": "btree",
1924
+ "with": {}
1925
+ },
1926
+ "idx_meter_timestamp": {
1927
+ "name": "idx_meter_timestamp",
1928
+ "columns": [
1929
+ {
1930
+ "expression": "timestamp",
1931
+ "isExpression": false,
1932
+ "asc": true,
1933
+ "nulls": "last"
1934
+ }
1935
+ ],
1936
+ "isUnique": false,
1937
+ "concurrently": false,
1938
+ "method": "btree",
1939
+ "with": {}
1940
+ },
1941
+ "idx_meter_capability": {
1942
+ "name": "idx_meter_capability",
1943
+ "columns": [
1944
+ {
1945
+ "expression": "capability",
1946
+ "isExpression": false,
1947
+ "asc": true,
1948
+ "nulls": "last"
1949
+ }
1950
+ ],
1951
+ "isUnique": false,
1952
+ "concurrently": false,
1953
+ "method": "btree",
1954
+ "with": {}
1955
+ },
1956
+ "idx_meter_session": {
1957
+ "name": "idx_meter_session",
1958
+ "columns": [
1959
+ {
1960
+ "expression": "session_id",
1961
+ "isExpression": false,
1962
+ "asc": true,
1963
+ "nulls": "last"
1964
+ }
1965
+ ],
1966
+ "isUnique": false,
1967
+ "concurrently": false,
1968
+ "method": "btree",
1969
+ "with": {}
1970
+ },
1971
+ "idx_meter_tenant_timestamp": {
1972
+ "name": "idx_meter_tenant_timestamp",
1973
+ "columns": [
1974
+ {
1975
+ "expression": "tenant",
1976
+ "isExpression": false,
1977
+ "asc": true,
1978
+ "nulls": "last"
1979
+ },
1980
+ {
1981
+ "expression": "timestamp",
1982
+ "isExpression": false,
1983
+ "asc": true,
1984
+ "nulls": "last"
1985
+ }
1986
+ ],
1987
+ "isUnique": false,
1988
+ "concurrently": false,
1989
+ "method": "btree",
1990
+ "with": {}
1991
+ },
1992
+ "idx_meter_tier": {
1993
+ "name": "idx_meter_tier",
1994
+ "columns": [
1995
+ {
1996
+ "expression": "tier",
1997
+ "isExpression": false,
1998
+ "asc": true,
1999
+ "nulls": "last"
2000
+ }
2001
+ ],
2002
+ "isUnique": false,
2003
+ "concurrently": false,
2004
+ "method": "btree",
2005
+ "with": {}
2006
+ }
2007
+ },
2008
+ "foreignKeys": {},
2009
+ "compositePrimaryKeys": {},
2010
+ "uniqueConstraints": {},
2011
+ "policies": {},
2012
+ "checkConstraints": {},
2013
+ "isRLSEnabled": false
2014
+ },
2015
+ "public.usage_summaries": {
2016
+ "name": "usage_summaries",
2017
+ "schema": "",
2018
+ "columns": {
2019
+ "id": {
2020
+ "name": "id",
2021
+ "type": "text",
2022
+ "primaryKey": true,
2023
+ "notNull": true
2024
+ },
2025
+ "tenant": {
2026
+ "name": "tenant",
2027
+ "type": "text",
2028
+ "primaryKey": false,
2029
+ "notNull": true
2030
+ },
2031
+ "capability": {
2032
+ "name": "capability",
2033
+ "type": "text",
2034
+ "primaryKey": false,
2035
+ "notNull": true
2036
+ },
2037
+ "provider": {
2038
+ "name": "provider",
2039
+ "type": "text",
2040
+ "primaryKey": false,
2041
+ "notNull": true
2042
+ },
2043
+ "event_count": {
2044
+ "name": "event_count",
2045
+ "type": "integer",
2046
+ "primaryKey": false,
2047
+ "notNull": true
2048
+ },
2049
+ "total_cost": {
2050
+ "name": "total_cost",
2051
+ "type": "bigint",
2052
+ "primaryKey": false,
2053
+ "notNull": true
2054
+ },
2055
+ "total_charge": {
2056
+ "name": "total_charge",
2057
+ "type": "bigint",
2058
+ "primaryKey": false,
2059
+ "notNull": true
2060
+ },
2061
+ "total_duration": {
2062
+ "name": "total_duration",
2063
+ "type": "integer",
2064
+ "primaryKey": false,
2065
+ "notNull": true,
2066
+ "default": 0
2067
+ },
2068
+ "window_start": {
2069
+ "name": "window_start",
2070
+ "type": "bigint",
2071
+ "primaryKey": false,
2072
+ "notNull": true
2073
+ },
2074
+ "window_end": {
2075
+ "name": "window_end",
2076
+ "type": "bigint",
2077
+ "primaryKey": false,
2078
+ "notNull": true
2079
+ }
2080
+ },
2081
+ "indexes": {
2082
+ "idx_summary_tenant": {
2083
+ "name": "idx_summary_tenant",
2084
+ "columns": [
2085
+ {
2086
+ "expression": "tenant",
2087
+ "isExpression": false,
2088
+ "asc": true,
2089
+ "nulls": "last"
2090
+ },
2091
+ {
2092
+ "expression": "window_start",
2093
+ "isExpression": false,
2094
+ "asc": true,
2095
+ "nulls": "last"
2096
+ }
2097
+ ],
2098
+ "isUnique": false,
2099
+ "concurrently": false,
2100
+ "method": "btree",
2101
+ "with": {}
2102
+ },
2103
+ "idx_summary_window": {
2104
+ "name": "idx_summary_window",
2105
+ "columns": [
2106
+ {
2107
+ "expression": "window_start",
2108
+ "isExpression": false,
2109
+ "asc": true,
2110
+ "nulls": "last"
2111
+ },
2112
+ {
2113
+ "expression": "window_end",
2114
+ "isExpression": false,
2115
+ "asc": true,
2116
+ "nulls": "last"
2117
+ }
2118
+ ],
2119
+ "isUnique": false,
2120
+ "concurrently": false,
2121
+ "method": "btree",
2122
+ "with": {}
2123
+ }
2124
+ },
2125
+ "foreignKeys": {},
2126
+ "compositePrimaryKeys": {},
2127
+ "uniqueConstraints": {},
2128
+ "policies": {},
2129
+ "checkConstraints": {},
2130
+ "isRLSEnabled": false
2131
+ },
2132
+ "public.notification_preferences": {
2133
+ "name": "notification_preferences",
2134
+ "schema": "",
2135
+ "columns": {
2136
+ "tenant_id": {
2137
+ "name": "tenant_id",
2138
+ "type": "text",
2139
+ "primaryKey": true,
2140
+ "notNull": true
2141
+ },
2142
+ "billing_low_balance": {
2143
+ "name": "billing_low_balance",
2144
+ "type": "boolean",
2145
+ "primaryKey": false,
2146
+ "notNull": true,
2147
+ "default": true
2148
+ },
2149
+ "billing_receipts": {
2150
+ "name": "billing_receipts",
2151
+ "type": "boolean",
2152
+ "primaryKey": false,
2153
+ "notNull": true,
2154
+ "default": true
2155
+ },
2156
+ "billing_auto_topup": {
2157
+ "name": "billing_auto_topup",
2158
+ "type": "boolean",
2159
+ "primaryKey": false,
2160
+ "notNull": true,
2161
+ "default": true
2162
+ },
2163
+ "agent_channel_disconnect": {
2164
+ "name": "agent_channel_disconnect",
2165
+ "type": "boolean",
2166
+ "primaryKey": false,
2167
+ "notNull": true,
2168
+ "default": true
2169
+ },
2170
+ "agent_status_changes": {
2171
+ "name": "agent_status_changes",
2172
+ "type": "boolean",
2173
+ "primaryKey": false,
2174
+ "notNull": true,
2175
+ "default": false
2176
+ },
2177
+ "account_role_changes": {
2178
+ "name": "account_role_changes",
2179
+ "type": "boolean",
2180
+ "primaryKey": false,
2181
+ "notNull": true,
2182
+ "default": true
2183
+ },
2184
+ "account_team_invites": {
2185
+ "name": "account_team_invites",
2186
+ "type": "boolean",
2187
+ "primaryKey": false,
2188
+ "notNull": true,
2189
+ "default": true
2190
+ },
2191
+ "updated_at": {
2192
+ "name": "updated_at",
2193
+ "type": "bigint",
2194
+ "primaryKey": false,
2195
+ "notNull": true,
2196
+ "default": "(extract(epoch from now()))::bigint"
2197
+ }
2198
+ },
2199
+ "indexes": {},
2200
+ "foreignKeys": {},
2201
+ "compositePrimaryKeys": {},
2202
+ "uniqueConstraints": {},
2203
+ "policies": {},
2204
+ "checkConstraints": {},
2205
+ "isRLSEnabled": false
2206
+ },
2207
+ "public.notification_queue": {
2208
+ "name": "notification_queue",
2209
+ "schema": "",
2210
+ "columns": {
2211
+ "id": {
2212
+ "name": "id",
2213
+ "type": "text",
2214
+ "primaryKey": true,
2215
+ "notNull": true
2216
+ },
2217
+ "tenant_id": {
2218
+ "name": "tenant_id",
2219
+ "type": "text",
2220
+ "primaryKey": false,
2221
+ "notNull": true
2222
+ },
2223
+ "email_type": {
2224
+ "name": "email_type",
2225
+ "type": "text",
2226
+ "primaryKey": false,
2227
+ "notNull": true
2228
+ },
2229
+ "recipient_email": {
2230
+ "name": "recipient_email",
2231
+ "type": "text",
2232
+ "primaryKey": false,
2233
+ "notNull": true
2234
+ },
2235
+ "payload": {
2236
+ "name": "payload",
2237
+ "type": "text",
2238
+ "primaryKey": false,
2239
+ "notNull": true,
2240
+ "default": "'{}'"
2241
+ },
2242
+ "status": {
2243
+ "name": "status",
2244
+ "type": "text",
2245
+ "primaryKey": false,
2246
+ "notNull": true,
2247
+ "default": "'pending'"
2248
+ },
2249
+ "attempts": {
2250
+ "name": "attempts",
2251
+ "type": "integer",
2252
+ "primaryKey": false,
2253
+ "notNull": true,
2254
+ "default": 0
2255
+ },
2256
+ "max_attempts": {
2257
+ "name": "max_attempts",
2258
+ "type": "integer",
2259
+ "primaryKey": false,
2260
+ "notNull": true,
2261
+ "default": 3
2262
+ },
2263
+ "last_attempt_at": {
2264
+ "name": "last_attempt_at",
2265
+ "type": "bigint",
2266
+ "primaryKey": false,
2267
+ "notNull": false
2268
+ },
2269
+ "last_error": {
2270
+ "name": "last_error",
2271
+ "type": "text",
2272
+ "primaryKey": false,
2273
+ "notNull": false
2274
+ },
2275
+ "retry_after": {
2276
+ "name": "retry_after",
2277
+ "type": "bigint",
2278
+ "primaryKey": false,
2279
+ "notNull": false
2280
+ },
2281
+ "created_at": {
2282
+ "name": "created_at",
2283
+ "type": "bigint",
2284
+ "primaryKey": false,
2285
+ "notNull": true,
2286
+ "default": "(extract(epoch from now()) * 1000)::bigint"
2287
+ },
2288
+ "sent_at": {
2289
+ "name": "sent_at",
2290
+ "type": "bigint",
2291
+ "primaryKey": false,
2292
+ "notNull": false
2293
+ }
2294
+ },
2295
+ "indexes": {
2296
+ "idx_notif_queue_tenant": {
2297
+ "name": "idx_notif_queue_tenant",
2298
+ "columns": [
2299
+ {
2300
+ "expression": "tenant_id",
2301
+ "isExpression": false,
2302
+ "asc": true,
2303
+ "nulls": "last"
2304
+ }
2305
+ ],
2306
+ "isUnique": false,
2307
+ "concurrently": false,
2308
+ "method": "btree",
2309
+ "with": {}
2310
+ },
2311
+ "idx_notif_queue_status": {
2312
+ "name": "idx_notif_queue_status",
2313
+ "columns": [
2314
+ {
2315
+ "expression": "status",
2316
+ "isExpression": false,
2317
+ "asc": true,
2318
+ "nulls": "last"
2319
+ }
2320
+ ],
2321
+ "isUnique": false,
2322
+ "concurrently": false,
2323
+ "method": "btree",
2324
+ "with": {}
2325
+ },
2326
+ "idx_notif_queue_type": {
2327
+ "name": "idx_notif_queue_type",
2328
+ "columns": [
2329
+ {
2330
+ "expression": "email_type",
2331
+ "isExpression": false,
2332
+ "asc": true,
2333
+ "nulls": "last"
2334
+ }
2335
+ ],
2336
+ "isUnique": false,
2337
+ "concurrently": false,
2338
+ "method": "btree",
2339
+ "with": {}
2340
+ },
2341
+ "idx_notif_queue_retry": {
2342
+ "name": "idx_notif_queue_retry",
2343
+ "columns": [
2344
+ {
2345
+ "expression": "status",
2346
+ "isExpression": false,
2347
+ "asc": true,
2348
+ "nulls": "last"
2349
+ },
2350
+ {
2351
+ "expression": "retry_after",
2352
+ "isExpression": false,
2353
+ "asc": true,
2354
+ "nulls": "last"
2355
+ }
2356
+ ],
2357
+ "isUnique": false,
2358
+ "concurrently": false,
2359
+ "method": "btree",
2360
+ "with": {}
2361
+ }
2362
+ },
2363
+ "foreignKeys": {},
2364
+ "compositePrimaryKeys": {},
2365
+ "uniqueConstraints": {},
2366
+ "policies": {},
2367
+ "checkConstraints": {},
2368
+ "isRLSEnabled": false
2369
+ },
2370
+ "public.org_memberships": {
2371
+ "name": "org_memberships",
2372
+ "schema": "",
2373
+ "columns": {
2374
+ "org_tenant_id": {
2375
+ "name": "org_tenant_id",
2376
+ "type": "text",
2377
+ "primaryKey": false,
2378
+ "notNull": true
2379
+ },
2380
+ "member_tenant_id": {
2381
+ "name": "member_tenant_id",
2382
+ "type": "text",
2383
+ "primaryKey": false,
2384
+ "notNull": true
2385
+ },
2386
+ "created_at": {
2387
+ "name": "created_at",
2388
+ "type": "bigint",
2389
+ "primaryKey": false,
2390
+ "notNull": true
2391
+ }
2392
+ },
2393
+ "indexes": {
2394
+ "idx_org_memberships_member_unique": {
2395
+ "name": "idx_org_memberships_member_unique",
2396
+ "columns": [
2397
+ {
2398
+ "expression": "member_tenant_id",
2399
+ "isExpression": false,
2400
+ "asc": true,
2401
+ "nulls": "last"
2402
+ }
2403
+ ],
2404
+ "isUnique": true,
2405
+ "concurrently": false,
2406
+ "method": "btree",
2407
+ "with": {}
2408
+ },
2409
+ "idx_org_memberships_org": {
2410
+ "name": "idx_org_memberships_org",
2411
+ "columns": [
2412
+ {
2413
+ "expression": "org_tenant_id",
2414
+ "isExpression": false,
2415
+ "asc": true,
2416
+ "nulls": "last"
2417
+ }
2418
+ ],
2419
+ "isUnique": false,
2420
+ "concurrently": false,
2421
+ "method": "btree",
2422
+ "with": {}
2423
+ }
2424
+ },
2425
+ "foreignKeys": {},
2426
+ "compositePrimaryKeys": {
2427
+ "org_memberships_org_tenant_id_member_tenant_id_pk": {
2428
+ "name": "org_memberships_org_tenant_id_member_tenant_id_pk",
2429
+ "columns": [
2430
+ "org_tenant_id",
2431
+ "member_tenant_id"
2432
+ ]
2433
+ }
2434
+ },
2435
+ "uniqueConstraints": {},
2436
+ "policies": {},
2437
+ "checkConstraints": {},
2438
+ "isRLSEnabled": false
2439
+ },
2440
+ "public.organization_invites": {
2441
+ "name": "organization_invites",
2442
+ "schema": "",
2443
+ "columns": {
2444
+ "id": {
2445
+ "name": "id",
2446
+ "type": "text",
2447
+ "primaryKey": true,
2448
+ "notNull": true
2449
+ },
2450
+ "org_id": {
2451
+ "name": "org_id",
2452
+ "type": "text",
2453
+ "primaryKey": false,
2454
+ "notNull": true
2455
+ },
2456
+ "email": {
2457
+ "name": "email",
2458
+ "type": "text",
2459
+ "primaryKey": false,
2460
+ "notNull": true
2461
+ },
2462
+ "role": {
2463
+ "name": "role",
2464
+ "type": "text",
2465
+ "primaryKey": false,
2466
+ "notNull": true,
2467
+ "default": "'member'"
2468
+ },
2469
+ "invited_by": {
2470
+ "name": "invited_by",
2471
+ "type": "text",
2472
+ "primaryKey": false,
2473
+ "notNull": true
2474
+ },
2475
+ "token": {
2476
+ "name": "token",
2477
+ "type": "text",
2478
+ "primaryKey": false,
2479
+ "notNull": true
2480
+ },
2481
+ "expires_at": {
2482
+ "name": "expires_at",
2483
+ "type": "bigint",
2484
+ "primaryKey": false,
2485
+ "notNull": true
2486
+ },
2487
+ "created_at": {
2488
+ "name": "created_at",
2489
+ "type": "bigint",
2490
+ "primaryKey": false,
2491
+ "notNull": true,
2492
+ "default": "(extract(epoch from now()) * 1000)::bigint"
2493
+ }
2494
+ },
2495
+ "indexes": {
2496
+ "idx_org_invites_org_id": {
2497
+ "name": "idx_org_invites_org_id",
2498
+ "columns": [
2499
+ {
2500
+ "expression": "org_id",
2501
+ "isExpression": false,
2502
+ "asc": true,
2503
+ "nulls": "last"
2504
+ }
2505
+ ],
2506
+ "isUnique": false,
2507
+ "concurrently": false,
2508
+ "method": "btree",
2509
+ "with": {}
2510
+ },
2511
+ "idx_org_invites_token": {
2512
+ "name": "idx_org_invites_token",
2513
+ "columns": [
2514
+ {
2515
+ "expression": "token",
2516
+ "isExpression": false,
2517
+ "asc": true,
2518
+ "nulls": "last"
2519
+ }
2520
+ ],
2521
+ "isUnique": false,
2522
+ "concurrently": false,
2523
+ "method": "btree",
2524
+ "with": {}
2525
+ }
2526
+ },
2527
+ "foreignKeys": {},
2528
+ "compositePrimaryKeys": {},
2529
+ "uniqueConstraints": {
2530
+ "organization_invites_token_unique": {
2531
+ "name": "organization_invites_token_unique",
2532
+ "nullsNotDistinct": false,
2533
+ "columns": [
2534
+ "token"
2535
+ ]
2536
+ }
2537
+ },
2538
+ "policies": {},
2539
+ "checkConstraints": {},
2540
+ "isRLSEnabled": false
2541
+ },
2542
+ "public.organization_members": {
2543
+ "name": "organization_members",
2544
+ "schema": "",
2545
+ "columns": {
2546
+ "id": {
2547
+ "name": "id",
2548
+ "type": "text",
2549
+ "primaryKey": true,
2550
+ "notNull": true
2551
+ },
2552
+ "org_id": {
2553
+ "name": "org_id",
2554
+ "type": "text",
2555
+ "primaryKey": false,
2556
+ "notNull": true
2557
+ },
2558
+ "user_id": {
2559
+ "name": "user_id",
2560
+ "type": "text",
2561
+ "primaryKey": false,
2562
+ "notNull": true
2563
+ },
2564
+ "role": {
2565
+ "name": "role",
2566
+ "type": "text",
2567
+ "primaryKey": false,
2568
+ "notNull": true,
2569
+ "default": "'member'"
2570
+ },
2571
+ "joined_at": {
2572
+ "name": "joined_at",
2573
+ "type": "bigint",
2574
+ "primaryKey": false,
2575
+ "notNull": true,
2576
+ "default": "(extract(epoch from now()) * 1000)::bigint"
2577
+ }
2578
+ },
2579
+ "indexes": {
2580
+ "idx_org_members_org_id": {
2581
+ "name": "idx_org_members_org_id",
2582
+ "columns": [
2583
+ {
2584
+ "expression": "org_id",
2585
+ "isExpression": false,
2586
+ "asc": true,
2587
+ "nulls": "last"
2588
+ }
2589
+ ],
2590
+ "isUnique": false,
2591
+ "concurrently": false,
2592
+ "method": "btree",
2593
+ "with": {}
2594
+ },
2595
+ "idx_org_members_user_id": {
2596
+ "name": "idx_org_members_user_id",
2597
+ "columns": [
2598
+ {
2599
+ "expression": "user_id",
2600
+ "isExpression": false,
2601
+ "asc": true,
2602
+ "nulls": "last"
2603
+ }
2604
+ ],
2605
+ "isUnique": false,
2606
+ "concurrently": false,
2607
+ "method": "btree",
2608
+ "with": {}
2609
+ },
2610
+ "org_members_org_user_unique": {
2611
+ "name": "org_members_org_user_unique",
2612
+ "columns": [
2613
+ {
2614
+ "expression": "org_id",
2615
+ "isExpression": false,
2616
+ "asc": true,
2617
+ "nulls": "last"
2618
+ },
2619
+ {
2620
+ "expression": "user_id",
2621
+ "isExpression": false,
2622
+ "asc": true,
2623
+ "nulls": "last"
2624
+ }
2625
+ ],
2626
+ "isUnique": true,
2627
+ "concurrently": false,
2628
+ "method": "btree",
2629
+ "with": {}
2630
+ }
2631
+ },
2632
+ "foreignKeys": {},
2633
+ "compositePrimaryKeys": {},
2634
+ "uniqueConstraints": {},
2635
+ "policies": {},
2636
+ "checkConstraints": {},
2637
+ "isRLSEnabled": false
2638
+ },
2639
+ "public.payram_charges": {
2640
+ "name": "payram_charges",
2641
+ "schema": "",
2642
+ "columns": {
2643
+ "reference_id": {
2644
+ "name": "reference_id",
2645
+ "type": "text",
2646
+ "primaryKey": true,
2647
+ "notNull": true
2648
+ },
2649
+ "tenant_id": {
2650
+ "name": "tenant_id",
2651
+ "type": "text",
2652
+ "primaryKey": false,
2653
+ "notNull": true
2654
+ },
2655
+ "amount_usd_cents": {
2656
+ "name": "amount_usd_cents",
2657
+ "type": "integer",
2658
+ "primaryKey": false,
2659
+ "notNull": true
2660
+ },
2661
+ "status": {
2662
+ "name": "status",
2663
+ "type": "text",
2664
+ "primaryKey": false,
2665
+ "notNull": true,
2666
+ "default": "'OPEN'"
2667
+ },
2668
+ "currency": {
2669
+ "name": "currency",
2670
+ "type": "text",
2671
+ "primaryKey": false,
2672
+ "notNull": false
2673
+ },
2674
+ "filled_amount": {
2675
+ "name": "filled_amount",
2676
+ "type": "text",
2677
+ "primaryKey": false,
2678
+ "notNull": false
2679
+ },
2680
+ "created_at": {
2681
+ "name": "created_at",
2682
+ "type": "text",
2683
+ "primaryKey": false,
2684
+ "notNull": true,
2685
+ "default": "(now())"
2686
+ },
2687
+ "updated_at": {
2688
+ "name": "updated_at",
2689
+ "type": "text",
2690
+ "primaryKey": false,
2691
+ "notNull": true,
2692
+ "default": "(now())"
2693
+ },
2694
+ "credited_at": {
2695
+ "name": "credited_at",
2696
+ "type": "text",
2697
+ "primaryKey": false,
2698
+ "notNull": false
2699
+ }
2700
+ },
2701
+ "indexes": {
2702
+ "idx_payram_charges_tenant": {
2703
+ "name": "idx_payram_charges_tenant",
2704
+ "columns": [
2705
+ {
2706
+ "expression": "tenant_id",
2707
+ "isExpression": false,
2708
+ "asc": true,
2709
+ "nulls": "last"
2710
+ }
2711
+ ],
2712
+ "isUnique": false,
2713
+ "concurrently": false,
2714
+ "method": "btree",
2715
+ "with": {}
2716
+ },
2717
+ "idx_payram_charges_status": {
2718
+ "name": "idx_payram_charges_status",
2719
+ "columns": [
2720
+ {
2721
+ "expression": "status",
2722
+ "isExpression": false,
2723
+ "asc": true,
2724
+ "nulls": "last"
2725
+ }
2726
+ ],
2727
+ "isUnique": false,
2728
+ "concurrently": false,
2729
+ "method": "btree",
2730
+ "with": {}
2731
+ },
2732
+ "idx_payram_charges_created": {
2733
+ "name": "idx_payram_charges_created",
2734
+ "columns": [
2735
+ {
2736
+ "expression": "created_at",
2737
+ "isExpression": false,
2738
+ "asc": true,
2739
+ "nulls": "last"
2740
+ }
2741
+ ],
2742
+ "isUnique": false,
2743
+ "concurrently": false,
2744
+ "method": "btree",
2745
+ "with": {}
2746
+ }
2747
+ },
2748
+ "foreignKeys": {},
2749
+ "compositePrimaryKeys": {},
2750
+ "uniqueConstraints": {},
2751
+ "policies": {},
2752
+ "checkConstraints": {},
2753
+ "isRLSEnabled": false
2754
+ },
2755
+ "public.platform_api_keys": {
2756
+ "name": "platform_api_keys",
2757
+ "schema": "",
2758
+ "columns": {
2759
+ "id": {
2760
+ "name": "id",
2761
+ "type": "text",
2762
+ "primaryKey": true,
2763
+ "notNull": true
2764
+ },
2765
+ "key_hash": {
2766
+ "name": "key_hash",
2767
+ "type": "text",
2768
+ "primaryKey": false,
2769
+ "notNull": true
2770
+ },
2771
+ "user_id": {
2772
+ "name": "user_id",
2773
+ "type": "text",
2774
+ "primaryKey": false,
2775
+ "notNull": true
2776
+ },
2777
+ "roles": {
2778
+ "name": "roles",
2779
+ "type": "text",
2780
+ "primaryKey": false,
2781
+ "notNull": true
2782
+ },
2783
+ "label": {
2784
+ "name": "label",
2785
+ "type": "text",
2786
+ "primaryKey": false,
2787
+ "notNull": true,
2788
+ "default": "''"
2789
+ },
2790
+ "expires_at": {
2791
+ "name": "expires_at",
2792
+ "type": "bigint",
2793
+ "primaryKey": false,
2794
+ "notNull": false
2795
+ },
2796
+ "revoked_at": {
2797
+ "name": "revoked_at",
2798
+ "type": "bigint",
2799
+ "primaryKey": false,
2800
+ "notNull": false
2801
+ },
2802
+ "created_at": {
2803
+ "name": "created_at",
2804
+ "type": "bigint",
2805
+ "primaryKey": false,
2806
+ "notNull": true
2807
+ }
2808
+ },
2809
+ "indexes": {
2810
+ "idx_platform_api_keys_hash": {
2811
+ "name": "idx_platform_api_keys_hash",
2812
+ "columns": [
2813
+ {
2814
+ "expression": "key_hash",
2815
+ "isExpression": false,
2816
+ "asc": true,
2817
+ "nulls": "last"
2818
+ }
2819
+ ],
2820
+ "isUnique": true,
2821
+ "concurrently": false,
2822
+ "method": "btree",
2823
+ "with": {}
2824
+ },
2825
+ "idx_platform_api_keys_user": {
2826
+ "name": "idx_platform_api_keys_user",
2827
+ "columns": [
2828
+ {
2829
+ "expression": "user_id",
2830
+ "isExpression": false,
2831
+ "asc": true,
2832
+ "nulls": "last"
2833
+ }
2834
+ ],
2835
+ "isUnique": false,
2836
+ "concurrently": false,
2837
+ "method": "btree",
2838
+ "with": {}
2839
+ }
2840
+ },
2841
+ "foreignKeys": {},
2842
+ "compositePrimaryKeys": {},
2843
+ "uniqueConstraints": {},
2844
+ "policies": {},
2845
+ "checkConstraints": {},
2846
+ "isRLSEnabled": false
2847
+ },
2848
+ "public.promotion_redemptions": {
2849
+ "name": "promotion_redemptions",
2850
+ "schema": "",
2851
+ "columns": {
2852
+ "id": {
2853
+ "name": "id",
2854
+ "type": "uuid",
2855
+ "primaryKey": true,
2856
+ "notNull": true,
2857
+ "default": "gen_random_uuid()"
2858
+ },
2859
+ "promotion_id": {
2860
+ "name": "promotion_id",
2861
+ "type": "uuid",
2862
+ "primaryKey": false,
2863
+ "notNull": true
2864
+ },
2865
+ "tenant_id": {
2866
+ "name": "tenant_id",
2867
+ "type": "text",
2868
+ "primaryKey": false,
2869
+ "notNull": true
2870
+ },
2871
+ "coupon_code_id": {
2872
+ "name": "coupon_code_id",
2873
+ "type": "uuid",
2874
+ "primaryKey": false,
2875
+ "notNull": false
2876
+ },
2877
+ "credits_granted": {
2878
+ "name": "credits_granted",
2879
+ "type": "integer",
2880
+ "primaryKey": false,
2881
+ "notNull": true
2882
+ },
2883
+ "credit_transaction_id": {
2884
+ "name": "credit_transaction_id",
2885
+ "type": "text",
2886
+ "primaryKey": false,
2887
+ "notNull": true
2888
+ },
2889
+ "purchase_amount_credits": {
2890
+ "name": "purchase_amount_credits",
2891
+ "type": "integer",
2892
+ "primaryKey": false,
2893
+ "notNull": false
2894
+ },
2895
+ "redeemed_at": {
2896
+ "name": "redeemed_at",
2897
+ "type": "timestamp with time zone",
2898
+ "primaryKey": false,
2899
+ "notNull": true,
2900
+ "default": "now()"
2901
+ }
2902
+ },
2903
+ "indexes": {
2904
+ "promotion_redemptions_promotion_idx": {
2905
+ "name": "promotion_redemptions_promotion_idx",
2906
+ "columns": [
2907
+ {
2908
+ "expression": "promotion_id",
2909
+ "isExpression": false,
2910
+ "asc": true,
2911
+ "nulls": "last"
2912
+ }
2913
+ ],
2914
+ "isUnique": false,
2915
+ "concurrently": false,
2916
+ "method": "btree",
2917
+ "with": {}
2918
+ },
2919
+ "promotion_redemptions_tenant_idx": {
2920
+ "name": "promotion_redemptions_tenant_idx",
2921
+ "columns": [
2922
+ {
2923
+ "expression": "tenant_id",
2924
+ "isExpression": false,
2925
+ "asc": true,
2926
+ "nulls": "last"
2927
+ }
2928
+ ],
2929
+ "isUnique": false,
2930
+ "concurrently": false,
2931
+ "method": "btree",
2932
+ "with": {}
2933
+ }
2934
+ },
2935
+ "foreignKeys": {
2936
+ "promotion_redemptions_promotion_id_promotions_id_fk": {
2937
+ "name": "promotion_redemptions_promotion_id_promotions_id_fk",
2938
+ "tableFrom": "promotion_redemptions",
2939
+ "tableTo": "promotions",
2940
+ "columnsFrom": [
2941
+ "promotion_id"
2942
+ ],
2943
+ "columnsTo": [
2944
+ "id"
2945
+ ],
2946
+ "onDelete": "no action",
2947
+ "onUpdate": "no action"
2948
+ },
2949
+ "promotion_redemptions_coupon_code_id_coupon_codes_id_fk": {
2950
+ "name": "promotion_redemptions_coupon_code_id_coupon_codes_id_fk",
2951
+ "tableFrom": "promotion_redemptions",
2952
+ "tableTo": "coupon_codes",
2953
+ "columnsFrom": [
2954
+ "coupon_code_id"
2955
+ ],
2956
+ "columnsTo": [
2957
+ "id"
2958
+ ],
2959
+ "onDelete": "no action",
2960
+ "onUpdate": "no action"
2961
+ }
2962
+ },
2963
+ "compositePrimaryKeys": {},
2964
+ "uniqueConstraints": {},
2965
+ "policies": {},
2966
+ "checkConstraints": {},
2967
+ "isRLSEnabled": false
2968
+ },
2969
+ "public.promotions": {
2970
+ "name": "promotions",
2971
+ "schema": "",
2972
+ "columns": {
2973
+ "id": {
2974
+ "name": "id",
2975
+ "type": "uuid",
2976
+ "primaryKey": true,
2977
+ "notNull": true,
2978
+ "default": "gen_random_uuid()"
2979
+ },
2980
+ "name": {
2981
+ "name": "name",
2982
+ "type": "text",
2983
+ "primaryKey": false,
2984
+ "notNull": true
2985
+ },
2986
+ "type": {
2987
+ "name": "type",
2988
+ "type": "promotion_type",
2989
+ "typeSchema": "public",
2990
+ "primaryKey": false,
2991
+ "notNull": true
2992
+ },
2993
+ "status": {
2994
+ "name": "status",
2995
+ "type": "promotion_status",
2996
+ "typeSchema": "public",
2997
+ "primaryKey": false,
2998
+ "notNull": true,
2999
+ "default": "'draft'"
3000
+ },
3001
+ "starts_at": {
3002
+ "name": "starts_at",
3003
+ "type": "timestamp with time zone",
3004
+ "primaryKey": false,
3005
+ "notNull": false
3006
+ },
3007
+ "ends_at": {
3008
+ "name": "ends_at",
3009
+ "type": "timestamp with time zone",
3010
+ "primaryKey": false,
3011
+ "notNull": false
3012
+ },
3013
+ "value_type": {
3014
+ "name": "value_type",
3015
+ "type": "promotion_value_type",
3016
+ "typeSchema": "public",
3017
+ "primaryKey": false,
3018
+ "notNull": true
3019
+ },
3020
+ "value_amount": {
3021
+ "name": "value_amount",
3022
+ "type": "integer",
3023
+ "primaryKey": false,
3024
+ "notNull": true
3025
+ },
3026
+ "max_value_credits": {
3027
+ "name": "max_value_credits",
3028
+ "type": "integer",
3029
+ "primaryKey": false,
3030
+ "notNull": false
3031
+ },
3032
+ "first_purchase_only": {
3033
+ "name": "first_purchase_only",
3034
+ "type": "boolean",
3035
+ "primaryKey": false,
3036
+ "notNull": true,
3037
+ "default": false
3038
+ },
3039
+ "min_purchase_credits": {
3040
+ "name": "min_purchase_credits",
3041
+ "type": "integer",
3042
+ "primaryKey": false,
3043
+ "notNull": false
3044
+ },
3045
+ "user_segment": {
3046
+ "name": "user_segment",
3047
+ "type": "promotion_user_segment",
3048
+ "typeSchema": "public",
3049
+ "primaryKey": false,
3050
+ "notNull": true,
3051
+ "default": "'all'"
3052
+ },
3053
+ "eligible_tenant_ids": {
3054
+ "name": "eligible_tenant_ids",
3055
+ "type": "text[]",
3056
+ "primaryKey": false,
3057
+ "notNull": false
3058
+ },
3059
+ "total_use_limit": {
3060
+ "name": "total_use_limit",
3061
+ "type": "integer",
3062
+ "primaryKey": false,
3063
+ "notNull": false
3064
+ },
3065
+ "per_user_limit": {
3066
+ "name": "per_user_limit",
3067
+ "type": "integer",
3068
+ "primaryKey": false,
3069
+ "notNull": true,
3070
+ "default": 1
3071
+ },
3072
+ "budget_credits": {
3073
+ "name": "budget_credits",
3074
+ "type": "integer",
3075
+ "primaryKey": false,
3076
+ "notNull": false
3077
+ },
3078
+ "total_uses": {
3079
+ "name": "total_uses",
3080
+ "type": "integer",
3081
+ "primaryKey": false,
3082
+ "notNull": true,
3083
+ "default": 0
3084
+ },
3085
+ "total_credits_granted": {
3086
+ "name": "total_credits_granted",
3087
+ "type": "integer",
3088
+ "primaryKey": false,
3089
+ "notNull": true,
3090
+ "default": 0
3091
+ },
3092
+ "coupon_code": {
3093
+ "name": "coupon_code",
3094
+ "type": "text",
3095
+ "primaryKey": false,
3096
+ "notNull": false
3097
+ },
3098
+ "coupon_batch_id": {
3099
+ "name": "coupon_batch_id",
3100
+ "type": "uuid",
3101
+ "primaryKey": false,
3102
+ "notNull": false
3103
+ },
3104
+ "created_by": {
3105
+ "name": "created_by",
3106
+ "type": "text",
3107
+ "primaryKey": false,
3108
+ "notNull": true
3109
+ },
3110
+ "created_at": {
3111
+ "name": "created_at",
3112
+ "type": "timestamp with time zone",
3113
+ "primaryKey": false,
3114
+ "notNull": true,
3115
+ "default": "now()"
3116
+ },
3117
+ "updated_at": {
3118
+ "name": "updated_at",
3119
+ "type": "timestamp with time zone",
3120
+ "primaryKey": false,
3121
+ "notNull": true,
3122
+ "default": "now()"
3123
+ },
3124
+ "notes": {
3125
+ "name": "notes",
3126
+ "type": "text",
3127
+ "primaryKey": false,
3128
+ "notNull": false
3129
+ }
3130
+ },
3131
+ "indexes": {
3132
+ "promotions_status_idx": {
3133
+ "name": "promotions_status_idx",
3134
+ "columns": [
3135
+ {
3136
+ "expression": "status",
3137
+ "isExpression": false,
3138
+ "asc": true,
3139
+ "nulls": "last"
3140
+ }
3141
+ ],
3142
+ "isUnique": false,
3143
+ "concurrently": false,
3144
+ "method": "btree",
3145
+ "with": {}
3146
+ },
3147
+ "promotions_coupon_code_idx": {
3148
+ "name": "promotions_coupon_code_idx",
3149
+ "columns": [
3150
+ {
3151
+ "expression": "coupon_code",
3152
+ "isExpression": false,
3153
+ "asc": true,
3154
+ "nulls": "last"
3155
+ }
3156
+ ],
3157
+ "isUnique": false,
3158
+ "concurrently": false,
3159
+ "method": "btree",
3160
+ "with": {}
3161
+ }
3162
+ },
3163
+ "foreignKeys": {},
3164
+ "compositePrimaryKeys": {},
3165
+ "uniqueConstraints": {
3166
+ "promotions_coupon_code_unique": {
3167
+ "name": "promotions_coupon_code_unique",
3168
+ "nullsNotDistinct": false,
3169
+ "columns": [
3170
+ "coupon_code"
3171
+ ]
3172
+ }
3173
+ },
3174
+ "policies": {},
3175
+ "checkConstraints": {},
3176
+ "isRLSEnabled": false
3177
+ },
3178
+ "public.provider_credentials": {
3179
+ "name": "provider_credentials",
3180
+ "schema": "",
3181
+ "columns": {
3182
+ "id": {
3183
+ "name": "id",
3184
+ "type": "text",
3185
+ "primaryKey": true,
3186
+ "notNull": true
3187
+ },
3188
+ "provider": {
3189
+ "name": "provider",
3190
+ "type": "text",
3191
+ "primaryKey": false,
3192
+ "notNull": true
3193
+ },
3194
+ "key_name": {
3195
+ "name": "key_name",
3196
+ "type": "text",
3197
+ "primaryKey": false,
3198
+ "notNull": true
3199
+ },
3200
+ "encrypted_value": {
3201
+ "name": "encrypted_value",
3202
+ "type": "text",
3203
+ "primaryKey": false,
3204
+ "notNull": true
3205
+ },
3206
+ "auth_type": {
3207
+ "name": "auth_type",
3208
+ "type": "text",
3209
+ "primaryKey": false,
3210
+ "notNull": true
3211
+ },
3212
+ "auth_header": {
3213
+ "name": "auth_header",
3214
+ "type": "text",
3215
+ "primaryKey": false,
3216
+ "notNull": false
3217
+ },
3218
+ "is_active": {
3219
+ "name": "is_active",
3220
+ "type": "boolean",
3221
+ "primaryKey": false,
3222
+ "notNull": true,
3223
+ "default": true
3224
+ },
3225
+ "last_validated": {
3226
+ "name": "last_validated",
3227
+ "type": "text",
3228
+ "primaryKey": false,
3229
+ "notNull": false
3230
+ },
3231
+ "created_at": {
3232
+ "name": "created_at",
3233
+ "type": "text",
3234
+ "primaryKey": false,
3235
+ "notNull": true,
3236
+ "default": "(now())"
3237
+ },
3238
+ "rotated_at": {
3239
+ "name": "rotated_at",
3240
+ "type": "text",
3241
+ "primaryKey": false,
3242
+ "notNull": false
3243
+ },
3244
+ "created_by": {
3245
+ "name": "created_by",
3246
+ "type": "text",
3247
+ "primaryKey": false,
3248
+ "notNull": true
3249
+ }
3250
+ },
3251
+ "indexes": {
3252
+ "idx_provider_creds_provider": {
3253
+ "name": "idx_provider_creds_provider",
3254
+ "columns": [
3255
+ {
3256
+ "expression": "provider",
3257
+ "isExpression": false,
3258
+ "asc": true,
3259
+ "nulls": "last"
3260
+ }
3261
+ ],
3262
+ "isUnique": false,
3263
+ "concurrently": false,
3264
+ "method": "btree",
3265
+ "with": {}
3266
+ },
3267
+ "idx_provider_creds_active": {
3268
+ "name": "idx_provider_creds_active",
3269
+ "columns": [
3270
+ {
3271
+ "expression": "provider",
3272
+ "isExpression": false,
3273
+ "asc": true,
3274
+ "nulls": "last"
3275
+ },
3276
+ {
3277
+ "expression": "is_active",
3278
+ "isExpression": false,
3279
+ "asc": true,
3280
+ "nulls": "last"
3281
+ }
3282
+ ],
3283
+ "isUnique": false,
3284
+ "concurrently": false,
3285
+ "method": "btree",
3286
+ "with": {}
3287
+ },
3288
+ "idx_provider_creds_created_by": {
3289
+ "name": "idx_provider_creds_created_by",
3290
+ "columns": [
3291
+ {
3292
+ "expression": "created_by",
3293
+ "isExpression": false,
3294
+ "asc": true,
3295
+ "nulls": "last"
3296
+ }
3297
+ ],
3298
+ "isUnique": false,
3299
+ "concurrently": false,
3300
+ "method": "btree",
3301
+ "with": {}
3302
+ }
3303
+ },
3304
+ "foreignKeys": {},
3305
+ "compositePrimaryKeys": {},
3306
+ "uniqueConstraints": {},
3307
+ "policies": {},
3308
+ "checkConstraints": {},
3309
+ "isRLSEnabled": false
3310
+ },
3311
+ "public.rate_limit_entries": {
3312
+ "name": "rate_limit_entries",
3313
+ "schema": "",
3314
+ "columns": {
3315
+ "key": {
3316
+ "name": "key",
3317
+ "type": "text",
3318
+ "primaryKey": false,
3319
+ "notNull": true
3320
+ },
3321
+ "scope": {
3322
+ "name": "scope",
3323
+ "type": "text",
3324
+ "primaryKey": false,
3325
+ "notNull": true
3326
+ },
3327
+ "count": {
3328
+ "name": "count",
3329
+ "type": "integer",
3330
+ "primaryKey": false,
3331
+ "notNull": true,
3332
+ "default": 0
3333
+ },
3334
+ "window_start": {
3335
+ "name": "window_start",
3336
+ "type": "bigint",
3337
+ "primaryKey": false,
3338
+ "notNull": true
3339
+ }
3340
+ },
3341
+ "indexes": {
3342
+ "idx_rate_limit_window": {
3343
+ "name": "idx_rate_limit_window",
3344
+ "columns": [
3345
+ {
3346
+ "expression": "window_start",
3347
+ "isExpression": false,
3348
+ "asc": true,
3349
+ "nulls": "last"
3350
+ }
3351
+ ],
3352
+ "isUnique": false,
3353
+ "concurrently": false,
3354
+ "method": "btree",
3355
+ "with": {}
3356
+ }
3357
+ },
3358
+ "foreignKeys": {},
3359
+ "compositePrimaryKeys": {
3360
+ "rate_limit_entries_key_scope_pk": {
3361
+ "name": "rate_limit_entries_key_scope_pk",
3362
+ "columns": [
3363
+ "key",
3364
+ "scope"
3365
+ ]
3366
+ }
3367
+ },
3368
+ "uniqueConstraints": {},
3369
+ "policies": {},
3370
+ "checkConstraints": {},
3371
+ "isRLSEnabled": false
3372
+ },
3373
+ "public.secret_audit_log": {
3374
+ "name": "secret_audit_log",
3375
+ "schema": "",
3376
+ "columns": {
3377
+ "id": {
3378
+ "name": "id",
3379
+ "type": "text",
3380
+ "primaryKey": true,
3381
+ "notNull": true
3382
+ },
3383
+ "credential_id": {
3384
+ "name": "credential_id",
3385
+ "type": "text",
3386
+ "primaryKey": false,
3387
+ "notNull": true
3388
+ },
3389
+ "accessed_at": {
3390
+ "name": "accessed_at",
3391
+ "type": "bigint",
3392
+ "primaryKey": false,
3393
+ "notNull": true,
3394
+ "default": "(extract(epoch from now()) * 1000)::bigint"
3395
+ },
3396
+ "accessed_by": {
3397
+ "name": "accessed_by",
3398
+ "type": "text",
3399
+ "primaryKey": false,
3400
+ "notNull": true
3401
+ },
3402
+ "action": {
3403
+ "name": "action",
3404
+ "type": "text",
3405
+ "primaryKey": false,
3406
+ "notNull": true
3407
+ },
3408
+ "ip": {
3409
+ "name": "ip",
3410
+ "type": "text",
3411
+ "primaryKey": false,
3412
+ "notNull": false
3413
+ }
3414
+ },
3415
+ "indexes": {
3416
+ "idx_secret_audit_credential": {
3417
+ "name": "idx_secret_audit_credential",
3418
+ "columns": [
3419
+ {
3420
+ "expression": "credential_id",
3421
+ "isExpression": false,
3422
+ "asc": true,
3423
+ "nulls": "last"
3424
+ },
3425
+ {
3426
+ "expression": "accessed_at",
3427
+ "isExpression": false,
3428
+ "asc": true,
3429
+ "nulls": "last"
3430
+ }
3431
+ ],
3432
+ "isUnique": false,
3433
+ "concurrently": false,
3434
+ "method": "btree",
3435
+ "with": {}
3436
+ },
3437
+ "idx_secret_audit_accessed_by": {
3438
+ "name": "idx_secret_audit_accessed_by",
3439
+ "columns": [
3440
+ {
3441
+ "expression": "accessed_by",
3442
+ "isExpression": false,
3443
+ "asc": true,
3444
+ "nulls": "last"
3445
+ }
3446
+ ],
3447
+ "isUnique": false,
3448
+ "concurrently": false,
3449
+ "method": "btree",
3450
+ "with": {}
3451
+ }
3452
+ },
3453
+ "foreignKeys": {},
3454
+ "compositePrimaryKeys": {},
3455
+ "uniqueConstraints": {},
3456
+ "policies": {},
3457
+ "checkConstraints": {},
3458
+ "isRLSEnabled": false
3459
+ },
3460
+ "public.session_usage": {
3461
+ "name": "session_usage",
3462
+ "schema": "",
3463
+ "columns": {
3464
+ "id": {
3465
+ "name": "id",
3466
+ "type": "text",
3467
+ "primaryKey": true,
3468
+ "notNull": true
3469
+ },
3470
+ "session_id": {
3471
+ "name": "session_id",
3472
+ "type": "text",
3473
+ "primaryKey": false,
3474
+ "notNull": true
3475
+ },
3476
+ "user_id": {
3477
+ "name": "user_id",
3478
+ "type": "text",
3479
+ "primaryKey": false,
3480
+ "notNull": false
3481
+ },
3482
+ "page": {
3483
+ "name": "page",
3484
+ "type": "text",
3485
+ "primaryKey": false,
3486
+ "notNull": false
3487
+ },
3488
+ "input_tokens": {
3489
+ "name": "input_tokens",
3490
+ "type": "integer",
3491
+ "primaryKey": false,
3492
+ "notNull": true,
3493
+ "default": 0
3494
+ },
3495
+ "output_tokens": {
3496
+ "name": "output_tokens",
3497
+ "type": "integer",
3498
+ "primaryKey": false,
3499
+ "notNull": true,
3500
+ "default": 0
3501
+ },
3502
+ "cached_tokens": {
3503
+ "name": "cached_tokens",
3504
+ "type": "integer",
3505
+ "primaryKey": false,
3506
+ "notNull": true,
3507
+ "default": 0
3508
+ },
3509
+ "cache_write_tokens": {
3510
+ "name": "cache_write_tokens",
3511
+ "type": "integer",
3512
+ "primaryKey": false,
3513
+ "notNull": true,
3514
+ "default": 0
3515
+ },
3516
+ "model": {
3517
+ "name": "model",
3518
+ "type": "text",
3519
+ "primaryKey": false,
3520
+ "notNull": true
3521
+ },
3522
+ "cost_usd": {
3523
+ "name": "cost_usd",
3524
+ "type": "double precision",
3525
+ "primaryKey": false,
3526
+ "notNull": true,
3527
+ "default": 0
3528
+ },
3529
+ "created_at": {
3530
+ "name": "created_at",
3531
+ "type": "bigint",
3532
+ "primaryKey": false,
3533
+ "notNull": true
3534
+ }
3535
+ },
3536
+ "indexes": {
3537
+ "idx_session_usage_session": {
3538
+ "name": "idx_session_usage_session",
3539
+ "columns": [
3540
+ {
3541
+ "expression": "session_id",
3542
+ "isExpression": false,
3543
+ "asc": true,
3544
+ "nulls": "last"
3545
+ }
3546
+ ],
3547
+ "isUnique": false,
3548
+ "concurrently": false,
3549
+ "method": "btree",
3550
+ "with": {}
3551
+ },
3552
+ "idx_session_usage_user": {
3553
+ "name": "idx_session_usage_user",
3554
+ "columns": [
3555
+ {
3556
+ "expression": "user_id",
3557
+ "isExpression": false,
3558
+ "asc": true,
3559
+ "nulls": "last"
3560
+ }
3561
+ ],
3562
+ "isUnique": false,
3563
+ "concurrently": false,
3564
+ "method": "btree",
3565
+ "with": {}
3566
+ },
3567
+ "idx_session_usage_created": {
3568
+ "name": "idx_session_usage_created",
3569
+ "columns": [
3570
+ {
3571
+ "expression": "created_at",
3572
+ "isExpression": false,
3573
+ "asc": true,
3574
+ "nulls": "last"
3575
+ }
3576
+ ],
3577
+ "isUnique": false,
3578
+ "concurrently": false,
3579
+ "method": "btree",
3580
+ "with": {}
3581
+ },
3582
+ "idx_session_usage_page": {
3583
+ "name": "idx_session_usage_page",
3584
+ "columns": [
3585
+ {
3586
+ "expression": "page",
3587
+ "isExpression": false,
3588
+ "asc": true,
3589
+ "nulls": "last"
3590
+ }
3591
+ ],
3592
+ "isUnique": false,
3593
+ "concurrently": false,
3594
+ "method": "btree",
3595
+ "with": {}
3596
+ }
3597
+ },
3598
+ "foreignKeys": {},
3599
+ "compositePrimaryKeys": {},
3600
+ "uniqueConstraints": {},
3601
+ "policies": {},
3602
+ "checkConstraints": {},
3603
+ "isRLSEnabled": false
3604
+ },
3605
+ "public.tenant_spending_limits": {
3606
+ "name": "tenant_spending_limits",
3607
+ "schema": "",
3608
+ "columns": {
3609
+ "tenant_id": {
3610
+ "name": "tenant_id",
3611
+ "type": "text",
3612
+ "primaryKey": true,
3613
+ "notNull": true
3614
+ },
3615
+ "global_alert_at": {
3616
+ "name": "global_alert_at",
3617
+ "type": "real",
3618
+ "primaryKey": false,
3619
+ "notNull": false
3620
+ },
3621
+ "global_hard_cap": {
3622
+ "name": "global_hard_cap",
3623
+ "type": "real",
3624
+ "primaryKey": false,
3625
+ "notNull": false
3626
+ },
3627
+ "per_capability_json": {
3628
+ "name": "per_capability_json",
3629
+ "type": "text",
3630
+ "primaryKey": false,
3631
+ "notNull": false
3632
+ },
3633
+ "updated_at": {
3634
+ "name": "updated_at",
3635
+ "type": "bigint",
3636
+ "primaryKey": false,
3637
+ "notNull": true
3638
+ }
3639
+ },
3640
+ "indexes": {},
3641
+ "foreignKeys": {},
3642
+ "compositePrimaryKeys": {},
3643
+ "uniqueConstraints": {},
3644
+ "policies": {},
3645
+ "checkConstraints": {},
3646
+ "isRLSEnabled": false
3647
+ },
3648
+ "public.tenant_addons": {
3649
+ "name": "tenant_addons",
3650
+ "schema": "",
3651
+ "columns": {
3652
+ "tenant_id": {
3653
+ "name": "tenant_id",
3654
+ "type": "text",
3655
+ "primaryKey": false,
3656
+ "notNull": true
3657
+ },
3658
+ "addon_key": {
3659
+ "name": "addon_key",
3660
+ "type": "text",
3661
+ "primaryKey": false,
3662
+ "notNull": true
3663
+ },
3664
+ "enabled_at": {
3665
+ "name": "enabled_at",
3666
+ "type": "timestamp with time zone",
3667
+ "primaryKey": false,
3668
+ "notNull": true,
3669
+ "default": "now()"
3670
+ }
3671
+ },
3672
+ "indexes": {
3673
+ "idx_tenant_addons_tenant": {
3674
+ "name": "idx_tenant_addons_tenant",
3675
+ "columns": [
3676
+ {
3677
+ "expression": "tenant_id",
3678
+ "isExpression": false,
3679
+ "asc": true,
3680
+ "nulls": "last"
3681
+ }
3682
+ ],
3683
+ "isUnique": false,
3684
+ "concurrently": false,
3685
+ "method": "btree",
3686
+ "with": {}
3687
+ }
3688
+ },
3689
+ "foreignKeys": {},
3690
+ "compositePrimaryKeys": {
3691
+ "tenant_addons_tenant_id_addon_key_pk": {
3692
+ "name": "tenant_addons_tenant_id_addon_key_pk",
3693
+ "columns": [
3694
+ "tenant_id",
3695
+ "addon_key"
3696
+ ]
3697
+ }
3698
+ },
3699
+ "uniqueConstraints": {},
3700
+ "policies": {},
3701
+ "checkConstraints": {},
3702
+ "isRLSEnabled": false
3703
+ },
3704
+ "public.tenant_api_keys": {
3705
+ "name": "tenant_api_keys",
3706
+ "schema": "",
3707
+ "columns": {
3708
+ "id": {
3709
+ "name": "id",
3710
+ "type": "text",
3711
+ "primaryKey": true,
3712
+ "notNull": true
3713
+ },
3714
+ "tenant_id": {
3715
+ "name": "tenant_id",
3716
+ "type": "text",
3717
+ "primaryKey": false,
3718
+ "notNull": true
3719
+ },
3720
+ "provider": {
3721
+ "name": "provider",
3722
+ "type": "text",
3723
+ "primaryKey": false,
3724
+ "notNull": true
3725
+ },
3726
+ "label": {
3727
+ "name": "label",
3728
+ "type": "text",
3729
+ "primaryKey": false,
3730
+ "notNull": true,
3731
+ "default": "''"
3732
+ },
3733
+ "encrypted_key": {
3734
+ "name": "encrypted_key",
3735
+ "type": "text",
3736
+ "primaryKey": false,
3737
+ "notNull": true
3738
+ },
3739
+ "created_at": {
3740
+ "name": "created_at",
3741
+ "type": "bigint",
3742
+ "primaryKey": false,
3743
+ "notNull": true
3744
+ },
3745
+ "updated_at": {
3746
+ "name": "updated_at",
3747
+ "type": "bigint",
3748
+ "primaryKey": false,
3749
+ "notNull": true
3750
+ }
3751
+ },
3752
+ "indexes": {
3753
+ "idx_tenant_keys_tenant_provider": {
3754
+ "name": "idx_tenant_keys_tenant_provider",
3755
+ "columns": [
3756
+ {
3757
+ "expression": "tenant_id",
3758
+ "isExpression": false,
3759
+ "asc": true,
3760
+ "nulls": "last"
3761
+ },
3762
+ {
3763
+ "expression": "provider",
3764
+ "isExpression": false,
3765
+ "asc": true,
3766
+ "nulls": "last"
3767
+ }
3768
+ ],
3769
+ "isUnique": true,
3770
+ "concurrently": false,
3771
+ "method": "btree",
3772
+ "with": {}
3773
+ },
3774
+ "idx_tenant_keys_tenant": {
3775
+ "name": "idx_tenant_keys_tenant",
3776
+ "columns": [
3777
+ {
3778
+ "expression": "tenant_id",
3779
+ "isExpression": false,
3780
+ "asc": true,
3781
+ "nulls": "last"
3782
+ }
3783
+ ],
3784
+ "isUnique": false,
3785
+ "concurrently": false,
3786
+ "method": "btree",
3787
+ "with": {}
3788
+ },
3789
+ "idx_tenant_keys_provider": {
3790
+ "name": "idx_tenant_keys_provider",
3791
+ "columns": [
3792
+ {
3793
+ "expression": "provider",
3794
+ "isExpression": false,
3795
+ "asc": true,
3796
+ "nulls": "last"
3797
+ }
3798
+ ],
3799
+ "isUnique": false,
3800
+ "concurrently": false,
3801
+ "method": "btree",
3802
+ "with": {}
3803
+ }
3804
+ },
3805
+ "foreignKeys": {},
3806
+ "compositePrimaryKeys": {},
3807
+ "uniqueConstraints": {},
3808
+ "policies": {},
3809
+ "checkConstraints": {},
3810
+ "isRLSEnabled": false
3811
+ },
3812
+ "public.tenant_capability_settings": {
3813
+ "name": "tenant_capability_settings",
3814
+ "schema": "",
3815
+ "columns": {
3816
+ "tenant_id": {
3817
+ "name": "tenant_id",
3818
+ "type": "text",
3819
+ "primaryKey": false,
3820
+ "notNull": true
3821
+ },
3822
+ "capability": {
3823
+ "name": "capability",
3824
+ "type": "text",
3825
+ "primaryKey": false,
3826
+ "notNull": true
3827
+ },
3828
+ "mode": {
3829
+ "name": "mode",
3830
+ "type": "text",
3831
+ "primaryKey": false,
3832
+ "notNull": true,
3833
+ "default": "'hosted'"
3834
+ },
3835
+ "updated_at": {
3836
+ "name": "updated_at",
3837
+ "type": "bigint",
3838
+ "primaryKey": false,
3839
+ "notNull": true
3840
+ }
3841
+ },
3842
+ "indexes": {},
3843
+ "foreignKeys": {},
3844
+ "compositePrimaryKeys": {
3845
+ "tenant_capability_settings_tenant_id_capability_pk": {
3846
+ "name": "tenant_capability_settings_tenant_id_capability_pk",
3847
+ "columns": [
3848
+ "tenant_id",
3849
+ "capability"
3850
+ ]
3851
+ }
3852
+ },
3853
+ "uniqueConstraints": {},
3854
+ "policies": {},
3855
+ "checkConstraints": {},
3856
+ "isRLSEnabled": false
3857
+ },
3858
+ "public.stripe_usage_reports": {
3859
+ "name": "stripe_usage_reports",
3860
+ "schema": "",
3861
+ "columns": {
3862
+ "id": {
3863
+ "name": "id",
3864
+ "type": "text",
3865
+ "primaryKey": true,
3866
+ "notNull": true
3867
+ },
3868
+ "tenant": {
3869
+ "name": "tenant",
3870
+ "type": "text",
3871
+ "primaryKey": false,
3872
+ "notNull": true
3873
+ },
3874
+ "capability": {
3875
+ "name": "capability",
3876
+ "type": "text",
3877
+ "primaryKey": false,
3878
+ "notNull": true
3879
+ },
3880
+ "provider": {
3881
+ "name": "provider",
3882
+ "type": "text",
3883
+ "primaryKey": false,
3884
+ "notNull": true
3885
+ },
3886
+ "period_start": {
3887
+ "name": "period_start",
3888
+ "type": "bigint",
3889
+ "primaryKey": false,
3890
+ "notNull": true
3891
+ },
3892
+ "period_end": {
3893
+ "name": "period_end",
3894
+ "type": "bigint",
3895
+ "primaryKey": false,
3896
+ "notNull": true
3897
+ },
3898
+ "event_name": {
3899
+ "name": "event_name",
3900
+ "type": "text",
3901
+ "primaryKey": false,
3902
+ "notNull": true
3903
+ },
3904
+ "value_cents": {
3905
+ "name": "value_cents",
3906
+ "type": "integer",
3907
+ "primaryKey": false,
3908
+ "notNull": true
3909
+ },
3910
+ "reported_at": {
3911
+ "name": "reported_at",
3912
+ "type": "bigint",
3913
+ "primaryKey": false,
3914
+ "notNull": true
3915
+ }
3916
+ },
3917
+ "indexes": {
3918
+ "idx_stripe_usage_unique": {
3919
+ "name": "idx_stripe_usage_unique",
3920
+ "columns": [
3921
+ {
3922
+ "expression": "tenant",
3923
+ "isExpression": false,
3924
+ "asc": true,
3925
+ "nulls": "last"
3926
+ },
3927
+ {
3928
+ "expression": "capability",
3929
+ "isExpression": false,
3930
+ "asc": true,
3931
+ "nulls": "last"
3932
+ },
3933
+ {
3934
+ "expression": "provider",
3935
+ "isExpression": false,
3936
+ "asc": true,
3937
+ "nulls": "last"
3938
+ },
3939
+ {
3940
+ "expression": "period_start",
3941
+ "isExpression": false,
3942
+ "asc": true,
3943
+ "nulls": "last"
3944
+ }
3945
+ ],
3946
+ "isUnique": true,
3947
+ "concurrently": false,
3948
+ "method": "btree",
3949
+ "with": {}
3950
+ },
3951
+ "idx_stripe_usage_tenant": {
3952
+ "name": "idx_stripe_usage_tenant",
3953
+ "columns": [
3954
+ {
3955
+ "expression": "tenant",
3956
+ "isExpression": false,
3957
+ "asc": true,
3958
+ "nulls": "last"
3959
+ },
3960
+ {
3961
+ "expression": "reported_at",
3962
+ "isExpression": false,
3963
+ "asc": true,
3964
+ "nulls": "last"
3965
+ }
3966
+ ],
3967
+ "isUnique": false,
3968
+ "concurrently": false,
3969
+ "method": "btree",
3970
+ "with": {}
3971
+ }
3972
+ },
3973
+ "foreignKeys": {},
3974
+ "compositePrimaryKeys": {},
3975
+ "uniqueConstraints": {},
3976
+ "policies": {},
3977
+ "checkConstraints": {},
3978
+ "isRLSEnabled": false
3979
+ },
3980
+ "public.tenant_customers": {
3981
+ "name": "tenant_customers",
3982
+ "schema": "",
3983
+ "columns": {
3984
+ "tenant": {
3985
+ "name": "tenant",
3986
+ "type": "text",
3987
+ "primaryKey": true,
3988
+ "notNull": true
3989
+ },
3990
+ "processor_customer_id": {
3991
+ "name": "processor_customer_id",
3992
+ "type": "text",
3993
+ "primaryKey": false,
3994
+ "notNull": true
3995
+ },
3996
+ "processor": {
3997
+ "name": "processor",
3998
+ "type": "text",
3999
+ "primaryKey": false,
4000
+ "notNull": true,
4001
+ "default": "'stripe'"
4002
+ },
4003
+ "tier": {
4004
+ "name": "tier",
4005
+ "type": "text",
4006
+ "primaryKey": false,
4007
+ "notNull": true,
4008
+ "default": "'free'"
4009
+ },
4010
+ "billing_hold": {
4011
+ "name": "billing_hold",
4012
+ "type": "integer",
4013
+ "primaryKey": false,
4014
+ "notNull": true,
4015
+ "default": 0
4016
+ },
4017
+ "inference_mode": {
4018
+ "name": "inference_mode",
4019
+ "type": "text",
4020
+ "primaryKey": false,
4021
+ "notNull": true,
4022
+ "default": "'byok'"
4023
+ },
4024
+ "created_at": {
4025
+ "name": "created_at",
4026
+ "type": "bigint",
4027
+ "primaryKey": false,
4028
+ "notNull": true
4029
+ },
4030
+ "updated_at": {
4031
+ "name": "updated_at",
4032
+ "type": "bigint",
4033
+ "primaryKey": false,
4034
+ "notNull": true
4035
+ }
4036
+ },
4037
+ "indexes": {
4038
+ "idx_tenant_customers_processor": {
4039
+ "name": "idx_tenant_customers_processor",
4040
+ "columns": [
4041
+ {
4042
+ "expression": "processor_customer_id",
4043
+ "isExpression": false,
4044
+ "asc": true,
4045
+ "nulls": "last"
4046
+ }
4047
+ ],
4048
+ "isUnique": false,
4049
+ "concurrently": false,
4050
+ "method": "btree",
4051
+ "with": {}
4052
+ }
4053
+ },
4054
+ "foreignKeys": {},
4055
+ "compositePrimaryKeys": {},
4056
+ "uniqueConstraints": {
4057
+ "tenant_customers_processor_customer_id_unique": {
4058
+ "name": "tenant_customers_processor_customer_id_unique",
4059
+ "nullsNotDistinct": false,
4060
+ "columns": [
4061
+ "processor_customer_id"
4062
+ ]
4063
+ }
4064
+ },
4065
+ "policies": {},
4066
+ "checkConstraints": {},
4067
+ "isRLSEnabled": false
4068
+ },
4069
+ "public.tenants": {
4070
+ "name": "tenants",
4071
+ "schema": "",
4072
+ "columns": {
4073
+ "id": {
4074
+ "name": "id",
4075
+ "type": "text",
4076
+ "primaryKey": true,
4077
+ "notNull": true
4078
+ },
4079
+ "name": {
4080
+ "name": "name",
4081
+ "type": "text",
4082
+ "primaryKey": false,
4083
+ "notNull": true
4084
+ },
4085
+ "slug": {
4086
+ "name": "slug",
4087
+ "type": "text",
4088
+ "primaryKey": false,
4089
+ "notNull": false
4090
+ },
4091
+ "type": {
4092
+ "name": "type",
4093
+ "type": "text",
4094
+ "primaryKey": false,
4095
+ "notNull": true
4096
+ },
4097
+ "owner_id": {
4098
+ "name": "owner_id",
4099
+ "type": "text",
4100
+ "primaryKey": false,
4101
+ "notNull": true
4102
+ },
4103
+ "billing_email": {
4104
+ "name": "billing_email",
4105
+ "type": "text",
4106
+ "primaryKey": false,
4107
+ "notNull": false
4108
+ },
4109
+ "created_at": {
4110
+ "name": "created_at",
4111
+ "type": "bigint",
4112
+ "primaryKey": false,
4113
+ "notNull": true,
4114
+ "default": "(extract(epoch from now()) * 1000)::bigint"
4115
+ }
4116
+ },
4117
+ "indexes": {
4118
+ "idx_tenants_slug": {
4119
+ "name": "idx_tenants_slug",
4120
+ "columns": [
4121
+ {
4122
+ "expression": "slug",
4123
+ "isExpression": false,
4124
+ "asc": true,
4125
+ "nulls": "last"
4126
+ }
4127
+ ],
4128
+ "isUnique": false,
4129
+ "concurrently": false,
4130
+ "method": "btree",
4131
+ "with": {}
4132
+ },
4133
+ "idx_tenants_owner": {
4134
+ "name": "idx_tenants_owner",
4135
+ "columns": [
4136
+ {
4137
+ "expression": "owner_id",
4138
+ "isExpression": false,
4139
+ "asc": true,
4140
+ "nulls": "last"
4141
+ }
4142
+ ],
4143
+ "isUnique": false,
4144
+ "concurrently": false,
4145
+ "method": "btree",
4146
+ "with": {}
4147
+ },
4148
+ "idx_tenants_type": {
4149
+ "name": "idx_tenants_type",
4150
+ "columns": [
4151
+ {
4152
+ "expression": "type",
4153
+ "isExpression": false,
4154
+ "asc": true,
4155
+ "nulls": "last"
4156
+ }
4157
+ ],
4158
+ "isUnique": false,
4159
+ "concurrently": false,
4160
+ "method": "btree",
4161
+ "with": {}
4162
+ }
4163
+ },
4164
+ "foreignKeys": {},
4165
+ "compositePrimaryKeys": {},
4166
+ "uniqueConstraints": {
4167
+ "tenants_slug_unique": {
4168
+ "name": "tenants_slug_unique",
4169
+ "nullsNotDistinct": false,
4170
+ "columns": [
4171
+ "slug"
4172
+ ]
4173
+ }
4174
+ },
4175
+ "policies": {},
4176
+ "checkConstraints": {
4177
+ "chk_tenants_type": {
4178
+ "name": "chk_tenants_type",
4179
+ "value": "\"tenants\".\"type\" IN ('personal', 'org')"
4180
+ }
4181
+ },
4182
+ "isRLSEnabled": false
4183
+ },
4184
+ "public.user_roles": {
4185
+ "name": "user_roles",
4186
+ "schema": "",
4187
+ "columns": {
4188
+ "user_id": {
4189
+ "name": "user_id",
4190
+ "type": "text",
4191
+ "primaryKey": false,
4192
+ "notNull": true
4193
+ },
4194
+ "tenant_id": {
4195
+ "name": "tenant_id",
4196
+ "type": "text",
4197
+ "primaryKey": false,
4198
+ "notNull": true
4199
+ },
4200
+ "role": {
4201
+ "name": "role",
4202
+ "type": "text",
4203
+ "primaryKey": false,
4204
+ "notNull": true
4205
+ },
4206
+ "granted_by": {
4207
+ "name": "granted_by",
4208
+ "type": "text",
4209
+ "primaryKey": false,
4210
+ "notNull": false
4211
+ },
4212
+ "granted_at": {
4213
+ "name": "granted_at",
4214
+ "type": "bigint",
4215
+ "primaryKey": false,
4216
+ "notNull": true
4217
+ }
4218
+ },
4219
+ "indexes": {
4220
+ "idx_user_roles_tenant": {
4221
+ "name": "idx_user_roles_tenant",
4222
+ "columns": [
4223
+ {
4224
+ "expression": "tenant_id",
4225
+ "isExpression": false,
4226
+ "asc": true,
4227
+ "nulls": "last"
4228
+ }
4229
+ ],
4230
+ "isUnique": false,
4231
+ "concurrently": false,
4232
+ "method": "btree",
4233
+ "with": {}
4234
+ },
4235
+ "idx_user_roles_role": {
4236
+ "name": "idx_user_roles_role",
4237
+ "columns": [
4238
+ {
4239
+ "expression": "role",
4240
+ "isExpression": false,
4241
+ "asc": true,
4242
+ "nulls": "last"
4243
+ }
4244
+ ],
4245
+ "isUnique": false,
4246
+ "concurrently": false,
4247
+ "method": "btree",
4248
+ "with": {}
4249
+ }
4250
+ },
4251
+ "foreignKeys": {},
4252
+ "compositePrimaryKeys": {
4253
+ "user_roles_user_id_tenant_id_pk": {
4254
+ "name": "user_roles_user_id_tenant_id_pk",
4255
+ "columns": [
4256
+ "user_id",
4257
+ "tenant_id"
4258
+ ]
4259
+ }
4260
+ },
4261
+ "uniqueConstraints": {},
4262
+ "policies": {},
4263
+ "checkConstraints": {},
4264
+ "isRLSEnabled": false
4265
+ },
4266
+ "public.webhook_seen_events": {
4267
+ "name": "webhook_seen_events",
4268
+ "schema": "",
4269
+ "columns": {
4270
+ "event_id": {
4271
+ "name": "event_id",
4272
+ "type": "text",
4273
+ "primaryKey": false,
4274
+ "notNull": true
4275
+ },
4276
+ "source": {
4277
+ "name": "source",
4278
+ "type": "text",
4279
+ "primaryKey": false,
4280
+ "notNull": true
4281
+ },
4282
+ "seen_at": {
4283
+ "name": "seen_at",
4284
+ "type": "bigint",
4285
+ "primaryKey": false,
4286
+ "notNull": true
4287
+ }
4288
+ },
4289
+ "indexes": {
4290
+ "idx_webhook_seen_expires": {
4291
+ "name": "idx_webhook_seen_expires",
4292
+ "columns": [
4293
+ {
4294
+ "expression": "seen_at",
4295
+ "isExpression": false,
4296
+ "asc": true,
4297
+ "nulls": "last"
4298
+ }
4299
+ ],
4300
+ "isUnique": false,
4301
+ "concurrently": false,
4302
+ "method": "btree",
4303
+ "with": {}
4304
+ }
4305
+ },
4306
+ "foreignKeys": {},
4307
+ "compositePrimaryKeys": {
4308
+ "webhook_seen_events_event_id_source_pk": {
4309
+ "name": "webhook_seen_events_event_id_source_pk",
4310
+ "columns": [
4311
+ "event_id",
4312
+ "source"
4313
+ ]
4314
+ }
4315
+ },
4316
+ "uniqueConstraints": {},
4317
+ "policies": {},
4318
+ "checkConstraints": {},
4319
+ "isRLSEnabled": false
4320
+ }
4321
+ },
4322
+ "enums": {
4323
+ "public.promotion_status": {
4324
+ "name": "promotion_status",
4325
+ "schema": "public",
4326
+ "values": [
4327
+ "draft",
4328
+ "scheduled",
4329
+ "active",
4330
+ "paused",
4331
+ "expired",
4332
+ "cancelled"
4333
+ ]
4334
+ },
4335
+ "public.promotion_type": {
4336
+ "name": "promotion_type",
4337
+ "schema": "public",
4338
+ "values": [
4339
+ "bonus_on_purchase",
4340
+ "coupon_fixed",
4341
+ "coupon_unique",
4342
+ "batch_grant"
4343
+ ]
4344
+ },
4345
+ "public.promotion_user_segment": {
4346
+ "name": "promotion_user_segment",
4347
+ "schema": "public",
4348
+ "values": [
4349
+ "all",
4350
+ "new_users",
4351
+ "existing_users",
4352
+ "tenant_list"
4353
+ ]
4354
+ },
4355
+ "public.promotion_value_type": {
4356
+ "name": "promotion_value_type",
4357
+ "schema": "public",
4358
+ "values": [
4359
+ "flat_credits",
4360
+ "percent_of_purchase"
4361
+ ]
4362
+ }
4363
+ },
4364
+ "schemas": {},
4365
+ "sequences": {},
4366
+ "roles": {},
4367
+ "policies": {},
4368
+ "views": {},
4369
+ "_meta": {
4370
+ "columns": {},
4371
+ "schemas": {},
4372
+ "tables": {}
4373
+ }
4374
+ }