@coursebuilder/adapter-drizzle 0.5.2 → 1.0.1
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.
- package/dist/{chunk-QQA7STVO.js → chunk-3GONHHMY.js} +2 -2
- package/dist/{chunk-2UU2F4DM.js → chunk-6MRFUIH5.js} +6 -2
- package/dist/{chunk-XIGJFVUM.js → chunk-6YPHJWS2.js} +9 -2
- package/dist/{chunk-3NUCFLQJ.js → chunk-BLDW3QUS.js} +7 -3
- package/dist/{chunk-QP6YMUQX.js → chunk-DKJO4Y3K.js} +7 -3
- package/dist/{chunk-P4VXXTVA.js → chunk-EHRARBRS.js} +4 -1
- package/dist/{chunk-YVVXDJHI.js → chunk-ET3QAIY7.js} +9 -2
- package/dist/{chunk-27UC2HEP.js → chunk-FPAQINSA.js} +7 -3
- package/dist/{chunk-XJXCDN7B.js → chunk-HWIQUI7O.js} +8 -4
- package/dist/{chunk-4ZWS76VQ.js → chunk-KPBVZ44W.js} +7 -3
- package/dist/chunk-LPJ2P2KJ.js +2122 -0
- package/dist/{chunk-6ON2O6UD.js → chunk-MGZMGDQ5.js} +7 -3
- package/dist/{chunk-ZYQYJNLK.js → chunk-MOV5TUON.js} +409 -127
- package/dist/{chunk-KDEWFXEP.js → chunk-MP4CUWYC.js} +6 -2
- package/dist/{chunk-YMFPIZMO.js → chunk-OBUGOZKM.js} +2 -2
- package/dist/{chunk-EFVZ7IN4.js → chunk-PBTEHA7F.js} +2 -2
- package/dist/{chunk-GINRTL6J.js → chunk-WJWJ6E5Y.js} +6 -2
- package/dist/{chunk-YGRYHMCG.js → chunk-WPJZAYX7.js} +7 -3
- package/dist/{chunk-6SLQW6OM.js → chunk-YQNIXCD3.js} +5 -2
- package/dist/index.js +19 -20
- package/dist/lib/mysql/index.cjs +1889 -994
- package/dist/lib/mysql/index.cjs.map +1 -1
- package/dist/lib/mysql/index.d.cts +4641 -1889
- package/dist/lib/mysql/index.d.ts +4641 -1889
- package/dist/lib/mysql/index.js +19 -20
- package/dist/lib/mysql/schemas/auth/accounts.cjs +121 -97
- package/dist/lib/mysql/schemas/auth/accounts.cjs.map +1 -1
- package/dist/lib/mysql/schemas/auth/accounts.js +10 -11
- package/dist/lib/mysql/schemas/auth/device-access-token.cjs +116 -89
- package/dist/lib/mysql/schemas/auth/device-access-token.cjs.map +1 -1
- package/dist/lib/mysql/schemas/auth/device-access-token.d.cts +16 -0
- package/dist/lib/mysql/schemas/auth/device-access-token.d.ts +16 -0
- package/dist/lib/mysql/schemas/auth/device-access-token.js +11 -12
- package/dist/lib/mysql/schemas/auth/device-verification.cjs +115 -91
- package/dist/lib/mysql/schemas/auth/device-verification.cjs.map +1 -1
- package/dist/lib/mysql/schemas/auth/device-verification.js +11 -12
- package/dist/lib/mysql/schemas/auth/profiles.cjs +254 -0
- package/dist/lib/mysql/schemas/auth/profiles.cjs.map +1 -0
- package/dist/lib/mysql/schemas/auth/profiles.d.cts +112 -0
- package/dist/lib/mysql/schemas/auth/profiles.d.ts +112 -0
- package/dist/lib/mysql/schemas/auth/profiles.js +20 -0
- package/dist/lib/mysql/schemas/auth/profiles.js.map +1 -0
- package/dist/lib/mysql/schemas/auth/role-permissions.cjs +112 -83
- package/dist/lib/mysql/schemas/auth/role-permissions.cjs.map +1 -1
- package/dist/lib/mysql/schemas/auth/role-permissions.js +11 -12
- package/dist/lib/mysql/schemas/auth/roles.cjs +116 -83
- package/dist/lib/mysql/schemas/auth/roles.cjs.map +1 -1
- package/dist/lib/mysql/schemas/auth/roles.d.cts +16 -0
- package/dist/lib/mysql/schemas/auth/roles.d.ts +16 -0
- package/dist/lib/mysql/schemas/auth/roles.js +10 -11
- package/dist/lib/mysql/schemas/auth/sessions.cjs +111 -87
- package/dist/lib/mysql/schemas/auth/sessions.cjs.map +1 -1
- package/dist/lib/mysql/schemas/auth/sessions.js +11 -12
- package/dist/lib/mysql/schemas/auth/user-permissions.cjs +116 -88
- package/dist/lib/mysql/schemas/auth/user-permissions.cjs.map +1 -1
- package/dist/lib/mysql/schemas/auth/user-permissions.d.cts +16 -0
- package/dist/lib/mysql/schemas/auth/user-permissions.d.ts +16 -0
- package/dist/lib/mysql/schemas/auth/user-permissions.js +10 -11
- package/dist/lib/mysql/schemas/auth/user-prefs.cjs +120 -92
- package/dist/lib/mysql/schemas/auth/user-prefs.cjs.map +1 -1
- package/dist/lib/mysql/schemas/auth/user-prefs.d.cts +16 -0
- package/dist/lib/mysql/schemas/auth/user-prefs.d.ts +16 -0
- package/dist/lib/mysql/schemas/auth/user-prefs.js +10 -11
- package/dist/lib/mysql/schemas/auth/user-roles.cjs +119 -86
- package/dist/lib/mysql/schemas/auth/user-roles.cjs.map +1 -1
- package/dist/lib/mysql/schemas/auth/user-roles.d.cts +16 -0
- package/dist/lib/mysql/schemas/auth/user-roles.d.ts +16 -0
- package/dist/lib/mysql/schemas/auth/user-roles.js +10 -11
- package/dist/lib/mysql/schemas/auth/users.cjs +355 -223
- package/dist/lib/mysql/schemas/auth/users.cjs.map +1 -1
- package/dist/lib/mysql/schemas/auth/users.d.cts +2 -0
- package/dist/lib/mysql/schemas/auth/users.d.ts +2 -0
- package/dist/lib/mysql/schemas/auth/users.js +10 -11
- package/dist/lib/mysql/schemas/commerce/coupon.cjs +155 -111
- package/dist/lib/mysql/schemas/commerce/coupon.cjs.map +1 -1
- package/dist/lib/mysql/schemas/commerce/coupon.d.cts +16 -0
- package/dist/lib/mysql/schemas/commerce/coupon.d.ts +16 -0
- package/dist/lib/mysql/schemas/commerce/coupon.js +10 -11
- package/dist/lib/mysql/schemas/commerce/merchant-account.cjs +5 -1
- package/dist/lib/mysql/schemas/commerce/merchant-account.cjs.map +1 -1
- package/dist/lib/mysql/schemas/commerce/merchant-account.d.cts +16 -0
- package/dist/lib/mysql/schemas/commerce/merchant-account.d.ts +16 -0
- package/dist/lib/mysql/schemas/commerce/merchant-account.js +1 -1
- package/dist/lib/mysql/schemas/commerce/merchant-charge.cjs +218 -17
- package/dist/lib/mysql/schemas/commerce/merchant-charge.cjs.map +1 -1
- package/dist/lib/mysql/schemas/commerce/merchant-charge.d.cts +33 -0
- package/dist/lib/mysql/schemas/commerce/merchant-charge.d.ts +33 -0
- package/dist/lib/mysql/schemas/commerce/merchant-charge.js +11 -4
- package/dist/lib/mysql/schemas/commerce/merchant-coupon.cjs +5 -1
- package/dist/lib/mysql/schemas/commerce/merchant-coupon.cjs.map +1 -1
- package/dist/lib/mysql/schemas/commerce/merchant-coupon.d.cts +16 -0
- package/dist/lib/mysql/schemas/commerce/merchant-coupon.d.ts +16 -0
- package/dist/lib/mysql/schemas/commerce/merchant-coupon.js +1 -1
- package/dist/lib/mysql/schemas/commerce/merchant-customer.cjs +5 -1
- package/dist/lib/mysql/schemas/commerce/merchant-customer.cjs.map +1 -1
- package/dist/lib/mysql/schemas/commerce/merchant-customer.d.cts +16 -0
- package/dist/lib/mysql/schemas/commerce/merchant-customer.d.ts +16 -0
- package/dist/lib/mysql/schemas/commerce/merchant-customer.js +1 -1
- package/dist/lib/mysql/schemas/commerce/merchant-price.cjs +5 -1
- package/dist/lib/mysql/schemas/commerce/merchant-price.cjs.map +1 -1
- package/dist/lib/mysql/schemas/commerce/merchant-price.d.cts +16 -0
- package/dist/lib/mysql/schemas/commerce/merchant-price.d.ts +16 -0
- package/dist/lib/mysql/schemas/commerce/merchant-price.js +1 -1
- package/dist/lib/mysql/schemas/commerce/merchant-product.cjs +5 -1
- package/dist/lib/mysql/schemas/commerce/merchant-product.cjs.map +1 -1
- package/dist/lib/mysql/schemas/commerce/merchant-product.d.cts +16 -0
- package/dist/lib/mysql/schemas/commerce/merchant-product.d.ts +16 -0
- package/dist/lib/mysql/schemas/commerce/merchant-product.js +1 -1
- package/dist/lib/mysql/schemas/commerce/merchant-session.cjs +5 -1
- package/dist/lib/mysql/schemas/commerce/merchant-session.cjs.map +1 -1
- package/dist/lib/mysql/schemas/commerce/merchant-session.d.cts +16 -0
- package/dist/lib/mysql/schemas/commerce/merchant-session.d.ts +16 -0
- package/dist/lib/mysql/schemas/commerce/merchant-session.js +1 -1
- package/dist/lib/mysql/schemas/commerce/merchant-subscription.cjs +323 -0
- package/dist/lib/mysql/schemas/commerce/merchant-subscription.cjs.map +1 -0
- package/dist/lib/mysql/schemas/commerce/merchant-subscription.d.cts +161 -0
- package/dist/lib/mysql/schemas/commerce/merchant-subscription.d.ts +161 -0
- package/dist/lib/mysql/schemas/commerce/merchant-subscription.js +20 -0
- package/dist/lib/mysql/schemas/commerce/merchant-subscription.js.map +1 -0
- package/dist/lib/mysql/schemas/commerce/price.cjs +115 -79
- package/dist/lib/mysql/schemas/commerce/price.cjs.map +1 -1
- package/dist/lib/mysql/schemas/commerce/price.d.cts +16 -0
- package/dist/lib/mysql/schemas/commerce/price.d.ts +16 -0
- package/dist/lib/mysql/schemas/commerce/price.js +10 -11
- package/dist/lib/mysql/schemas/commerce/product.cjs +134 -94
- package/dist/lib/mysql/schemas/commerce/product.cjs.map +1 -1
- package/dist/lib/mysql/schemas/commerce/product.d.cts +16 -0
- package/dist/lib/mysql/schemas/commerce/product.d.ts +16 -0
- package/dist/lib/mysql/schemas/commerce/product.js +10 -11
- package/dist/lib/mysql/schemas/commerce/purchase-user-transfer.cjs +153 -117
- package/dist/lib/mysql/schemas/commerce/purchase-user-transfer.cjs.map +1 -1
- package/dist/lib/mysql/schemas/commerce/purchase-user-transfer.d.cts +16 -0
- package/dist/lib/mysql/schemas/commerce/purchase-user-transfer.d.ts +16 -0
- package/dist/lib/mysql/schemas/commerce/purchase-user-transfer.js +11 -12
- package/dist/lib/mysql/schemas/commerce/purchase.cjs +307 -181
- package/dist/lib/mysql/schemas/commerce/purchase.cjs.map +1 -1
- package/dist/lib/mysql/schemas/commerce/purchase.d.cts +34 -0
- package/dist/lib/mysql/schemas/commerce/purchase.d.ts +34 -0
- package/dist/lib/mysql/schemas/commerce/purchase.js +10 -11
- package/dist/lib/mysql/schemas/commerce/subscription.cjs +351 -0
- package/dist/lib/mysql/schemas/commerce/subscription.cjs.map +1 -0
- package/dist/lib/mysql/schemas/commerce/subscription.d.cts +130 -0
- package/dist/lib/mysql/schemas/commerce/subscription.d.ts +130 -0
- package/dist/lib/mysql/schemas/commerce/subscription.js +20 -0
- package/dist/lib/mysql/schemas/commerce/subscription.js.map +1 -0
- package/dist/lib/mysql/schemas/commerce/upgradable-products.cjs +116 -84
- package/dist/lib/mysql/schemas/commerce/upgradable-products.cjs.map +1 -1
- package/dist/lib/mysql/schemas/commerce/upgradable-products.d.cts +16 -0
- package/dist/lib/mysql/schemas/commerce/upgradable-products.d.ts +16 -0
- package/dist/lib/mysql/schemas/commerce/upgradable-products.js +11 -12
- package/dist/lib/mysql/schemas/communication/comment.cjs +161 -92
- package/dist/lib/mysql/schemas/communication/comment.cjs.map +1 -1
- package/dist/lib/mysql/schemas/communication/comment.d.cts +17 -0
- package/dist/lib/mysql/schemas/communication/comment.d.ts +17 -0
- package/dist/lib/mysql/schemas/communication/comment.js +10 -11
- package/dist/lib/mysql/schemas/communication/communication-channel.cjs +5 -1
- package/dist/lib/mysql/schemas/communication/communication-channel.cjs.map +1 -1
- package/dist/lib/mysql/schemas/communication/communication-channel.d.cts +16 -0
- package/dist/lib/mysql/schemas/communication/communication-channel.d.ts +16 -0
- package/dist/lib/mysql/schemas/communication/communication-channel.js +1 -1
- package/dist/lib/mysql/schemas/communication/communication-preference-types.cjs +3 -0
- package/dist/lib/mysql/schemas/communication/communication-preference-types.cjs.map +1 -1
- package/dist/lib/mysql/schemas/communication/communication-preference-types.d.cts +16 -0
- package/dist/lib/mysql/schemas/communication/communication-preference-types.d.ts +16 -0
- package/dist/lib/mysql/schemas/communication/communication-preference-types.js +1 -1
- package/dist/lib/mysql/schemas/communication/communication-preferences.cjs +189 -110
- package/dist/lib/mysql/schemas/communication/communication-preferences.cjs.map +1 -1
- package/dist/lib/mysql/schemas/communication/communication-preferences.d.cts +33 -0
- package/dist/lib/mysql/schemas/communication/communication-preferences.d.ts +33 -0
- package/dist/lib/mysql/schemas/communication/communication-preferences.js +10 -11
- package/dist/lib/mysql/schemas/content/content-contributions.cjs +199 -116
- package/dist/lib/mysql/schemas/content/content-contributions.cjs.map +1 -1
- package/dist/lib/mysql/schemas/content/content-contributions.d.cts +33 -0
- package/dist/lib/mysql/schemas/content/content-contributions.d.ts +33 -0
- package/dist/lib/mysql/schemas/content/content-contributions.js +10 -11
- package/dist/lib/mysql/schemas/content/content-resource-product.cjs +118 -79
- package/dist/lib/mysql/schemas/content/content-resource-product.cjs.map +1 -1
- package/dist/lib/mysql/schemas/content/content-resource-product.d.cts +16 -0
- package/dist/lib/mysql/schemas/content/content-resource-product.d.ts +16 -0
- package/dist/lib/mysql/schemas/content/content-resource-product.js +10 -11
- package/dist/lib/mysql/schemas/content/content-resource-resource.cjs +128 -93
- package/dist/lib/mysql/schemas/content/content-resource-resource.cjs.map +1 -1
- package/dist/lib/mysql/schemas/content/content-resource-resource.d.cts +16 -0
- package/dist/lib/mysql/schemas/content/content-resource-resource.d.ts +16 -0
- package/dist/lib/mysql/schemas/content/content-resource-resource.js +10 -11
- package/dist/lib/mysql/schemas/content/content-resource-tag.cjs +140 -101
- package/dist/lib/mysql/schemas/content/content-resource-tag.cjs.map +1 -1
- package/dist/lib/mysql/schemas/content/content-resource-tag.d.cts +16 -0
- package/dist/lib/mysql/schemas/content/content-resource-tag.d.ts +16 -0
- package/dist/lib/mysql/schemas/content/content-resource-tag.js +10 -11
- package/dist/lib/mysql/schemas/content/content-resource-version.cjs +142 -107
- package/dist/lib/mysql/schemas/content/content-resource-version.cjs.map +1 -1
- package/dist/lib/mysql/schemas/content/content-resource-version.d.cts +16 -0
- package/dist/lib/mysql/schemas/content/content-resource-version.d.ts +16 -0
- package/dist/lib/mysql/schemas/content/content-resource-version.js +10 -11
- package/dist/lib/mysql/schemas/content/content-resource.cjs +260 -161
- package/dist/lib/mysql/schemas/content/content-resource.cjs.map +1 -1
- package/dist/lib/mysql/schemas/content/content-resource.d.cts +33 -0
- package/dist/lib/mysql/schemas/content/content-resource.d.ts +33 -0
- package/dist/lib/mysql/schemas/content/content-resource.js +10 -11
- package/dist/lib/mysql/schemas/content/contribution-types.cjs +5 -1
- package/dist/lib/mysql/schemas/content/contribution-types.cjs.map +1 -1
- package/dist/lib/mysql/schemas/content/contribution-types.d.cts +16 -0
- package/dist/lib/mysql/schemas/content/contribution-types.d.ts +16 -0
- package/dist/lib/mysql/schemas/content/contribution-types.js +1 -1
- package/dist/lib/mysql/schemas/content/lesson-progress.cjs +8 -1
- package/dist/lib/mysql/schemas/content/lesson-progress.cjs.map +1 -1
- package/dist/lib/mysql/schemas/content/lesson-progress.d.cts +32 -0
- package/dist/lib/mysql/schemas/content/lesson-progress.d.ts +32 -0
- package/dist/lib/mysql/schemas/content/lesson-progress.js +1 -1
- package/dist/lib/mysql/schemas/content/resource-progress.cjs +8 -1
- package/dist/lib/mysql/schemas/content/resource-progress.cjs.map +1 -1
- package/dist/lib/mysql/schemas/content/resource-progress.d.cts +32 -0
- package/dist/lib/mysql/schemas/content/resource-progress.d.ts +32 -0
- package/dist/lib/mysql/schemas/content/resource-progress.js +1 -1
- package/dist/lib/mysql/schemas/content/tag-tag.cjs +121 -89
- package/dist/lib/mysql/schemas/content/tag-tag.cjs.map +1 -1
- package/dist/lib/mysql/schemas/content/tag-tag.d.cts +16 -0
- package/dist/lib/mysql/schemas/content/tag-tag.d.ts +16 -0
- package/dist/lib/mysql/schemas/content/tag-tag.js +10 -11
- package/dist/lib/mysql/schemas/content/tag.cjs +136 -100
- package/dist/lib/mysql/schemas/content/tag.cjs.map +1 -1
- package/dist/lib/mysql/schemas/content/tag.d.cts +16 -0
- package/dist/lib/mysql/schemas/content/tag.d.ts +16 -0
- package/dist/lib/mysql/schemas/content/tag.js +10 -11
- package/dist/lib/mysql/schemas/org/organization-membership-roles.cjs +339 -0
- package/dist/lib/mysql/schemas/org/organization-membership-roles.cjs.map +1 -0
- package/dist/lib/mysql/schemas/org/organization-membership-roles.d.cts +130 -0
- package/dist/lib/mysql/schemas/org/organization-membership-roles.d.ts +130 -0
- package/dist/lib/mysql/schemas/org/organization-membership-roles.js +20 -0
- package/dist/lib/mysql/schemas/org/organization-membership-roles.js.map +1 -0
- package/dist/lib/mysql/schemas/org/organization-memberships.cjs +420 -0
- package/dist/lib/mysql/schemas/org/organization-memberships.cjs.map +1 -0
- package/dist/lib/mysql/schemas/org/organization-memberships.d.cts +132 -0
- package/dist/lib/mysql/schemas/org/organization-memberships.d.ts +132 -0
- package/dist/lib/mysql/schemas/org/organization-memberships.js +20 -0
- package/dist/lib/mysql/schemas/org/organization-memberships.js.map +1 -0
- package/dist/lib/mysql/schemas/org/organizations.cjs +359 -0
- package/dist/lib/mysql/schemas/org/organizations.cjs.map +1 -0
- package/dist/lib/mysql/schemas/org/organizations.d.cts +98 -0
- package/dist/lib/mysql/schemas/org/organizations.d.ts +98 -0
- package/dist/lib/mysql/schemas/org/organizations.js +20 -0
- package/dist/lib/mysql/schemas/org/organizations.js.map +1 -0
- package/package.json +4 -3
- package/src/lib/mysql/index.ts +354 -26
- package/src/lib/mysql/schemas/auth/device-access-token.ts +3 -0
- package/src/lib/mysql/schemas/auth/profiles.ts +50 -0
- package/src/lib/mysql/schemas/auth/roles.ts +9 -1
- package/src/lib/mysql/schemas/auth/user-permissions.ts +2 -0
- package/src/lib/mysql/schemas/auth/user-prefs.ts +2 -0
- package/src/lib/mysql/schemas/auth/user-roles.ts +2 -0
- package/src/lib/mysql/schemas/auth/users.ts +11 -1
- package/src/lib/mysql/schemas/commerce/coupon.ts +2 -0
- package/src/lib/mysql/schemas/commerce/merchant-account.ts +3 -0
- package/src/lib/mysql/schemas/commerce/merchant-charge.ts +16 -0
- package/src/lib/mysql/schemas/commerce/merchant-coupon.ts +3 -0
- package/src/lib/mysql/schemas/commerce/merchant-customer.ts +2 -0
- package/src/lib/mysql/schemas/commerce/merchant-price.ts +3 -0
- package/src/lib/mysql/schemas/commerce/merchant-product.ts +3 -0
- package/src/lib/mysql/schemas/commerce/merchant-session.ts +8 -1
- package/src/lib/mysql/schemas/commerce/merchant-subscription.ts +64 -0
- package/src/lib/mysql/schemas/commerce/price.ts +3 -0
- package/src/lib/mysql/schemas/commerce/product.ts +3 -0
- package/src/lib/mysql/schemas/commerce/purchase-user-transfer.ts +3 -0
- package/src/lib/mysql/schemas/commerce/purchase.ts +22 -0
- package/src/lib/mysql/schemas/commerce/subscription.ts +69 -0
- package/src/lib/mysql/schemas/commerce/upgradable-products.ts +2 -0
- package/src/lib/mysql/schemas/communication/comment.ts +13 -0
- package/src/lib/mysql/schemas/communication/communication-channel.ts +2 -0
- package/src/lib/mysql/schemas/communication/communication-preference-types.ts +1 -0
- package/src/lib/mysql/schemas/communication/communication-preferences.ts +14 -0
- package/src/lib/mysql/schemas/content/content-contributions.ts +14 -0
- package/src/lib/mysql/schemas/content/content-resource-product.ts +2 -0
- package/src/lib/mysql/schemas/content/content-resource-resource.ts +2 -0
- package/src/lib/mysql/schemas/content/content-resource-tag.ts +2 -0
- package/src/lib/mysql/schemas/content/content-resource-version.ts +2 -0
- package/src/lib/mysql/schemas/content/content-resource.ts +17 -0
- package/src/lib/mysql/schemas/content/contribution-types.ts +2 -0
- package/src/lib/mysql/schemas/content/lesson-progress.ts +7 -0
- package/src/lib/mysql/schemas/content/resource-progress.ts +7 -0
- package/src/lib/mysql/schemas/content/tag-tag.ts +2 -0
- package/src/lib/mysql/schemas/content/tag.ts +2 -0
- package/src/lib/mysql/schemas/org/organization-membership-roles.ts +75 -0
- package/src/lib/mysql/schemas/org/organization-memberships.ts +75 -0
- package/src/lib/mysql/schemas/org/organizations.ts +50 -0
- package/dist/chunk-JW2PFVLO.js +0 -1468
- package/dist/chunk-SRTIWWLG.js +0 -96
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { sql } from 'drizzle-orm'
|
|
2
2
|
import {
|
|
3
|
+
index,
|
|
3
4
|
int,
|
|
4
5
|
MySqlTableFn,
|
|
5
6
|
primaryKey,
|
|
@@ -12,6 +13,7 @@ export function getMerchantAccountSchema(mysqlTable: MySqlTableFn) {
|
|
|
12
13
|
'MerchantAccount',
|
|
13
14
|
{
|
|
14
15
|
id: varchar('id', { length: 191 }).notNull(),
|
|
16
|
+
organizationId: varchar('organizationId', { length: 191 }),
|
|
15
17
|
status: int('status').default(0).notNull(),
|
|
16
18
|
createdAt: timestamp('createdAt', { mode: 'date', fsp: 3 })
|
|
17
19
|
.default(sql`CURRENT_TIMESTAMP(3)`)
|
|
@@ -25,6 +27,7 @@ export function getMerchantAccountSchema(mysqlTable: MySqlTableFn) {
|
|
|
25
27
|
columns: [table.id],
|
|
26
28
|
name: 'MerchantAccount_id',
|
|
27
29
|
}),
|
|
30
|
+
organizationIdIdx: index('organizationId_idx').on(table.organizationId),
|
|
28
31
|
}
|
|
29
32
|
},
|
|
30
33
|
)
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { relations, sql } from 'drizzle-orm'
|
|
2
2
|
import {
|
|
3
|
+
index,
|
|
3
4
|
int,
|
|
4
5
|
MySqlTableFn,
|
|
5
6
|
primaryKey,
|
|
@@ -11,12 +12,14 @@ import {
|
|
|
11
12
|
import { getMerchantAccountSchema } from './merchant-account.js'
|
|
12
13
|
import { getMerchantCustomerSchema } from './merchant-customer.js'
|
|
13
14
|
import { getMerchantProductSchema } from './merchant-product.js'
|
|
15
|
+
import { getMerchantSubscriptionSchema } from './merchant-subscription.js'
|
|
14
16
|
|
|
15
17
|
export function getMerchantChargeSchema(mysqlTable: MySqlTableFn) {
|
|
16
18
|
return mysqlTable(
|
|
17
19
|
'MerchantCharge',
|
|
18
20
|
{
|
|
19
21
|
id: varchar('id', { length: 191 }).notNull(),
|
|
22
|
+
organizationId: varchar('organizationId', { length: 191 }),
|
|
20
23
|
status: int('status').default(0).notNull(),
|
|
21
24
|
identifier: varchar('identifier', { length: 191 }).notNull(),
|
|
22
25
|
userId: varchar('userId', { length: 191 }).notNull(),
|
|
@@ -26,6 +29,9 @@ export function getMerchantChargeSchema(mysqlTable: MySqlTableFn) {
|
|
|
26
29
|
merchantProductId: varchar('merchantProductId', {
|
|
27
30
|
length: 191,
|
|
28
31
|
}).notNull(),
|
|
32
|
+
merchantSubscriptionId: varchar('merchantSubscriptionId', {
|
|
33
|
+
length: 191,
|
|
34
|
+
}),
|
|
29
35
|
createdAt: timestamp('createdAt', { mode: 'date', fsp: 3 })
|
|
30
36
|
.default(sql`CURRENT_TIMESTAMP(3)`)
|
|
31
37
|
.notNull(),
|
|
@@ -42,6 +48,10 @@ export function getMerchantChargeSchema(mysqlTable: MySqlTableFn) {
|
|
|
42
48
|
merchantChargeIdentifierKey: unique('MerchantCharge_identifier_key').on(
|
|
43
49
|
table.identifier,
|
|
44
50
|
),
|
|
51
|
+
merchantSubscriptionIdIdx: index('merchantSubscriptionId_idx').on(
|
|
52
|
+
table.merchantSubscriptionId,
|
|
53
|
+
),
|
|
54
|
+
organizationIdIdx: index('organizationId_idx').on(table.organizationId),
|
|
45
55
|
}
|
|
46
56
|
},
|
|
47
57
|
)
|
|
@@ -52,6 +62,7 @@ export function getMerchantChargeRelationsSchema(mysqlTable: MySqlTableFn) {
|
|
|
52
62
|
const merchantAccount = getMerchantAccountSchema(mysqlTable)
|
|
53
63
|
const merchantProduct = getMerchantProductSchema(mysqlTable)
|
|
54
64
|
const merchantCustomer = getMerchantCustomerSchema(mysqlTable)
|
|
65
|
+
const merchantSubscription = getMerchantSubscriptionSchema(mysqlTable)
|
|
55
66
|
return relations(merchantCharge, ({ one }) => ({
|
|
56
67
|
merchantAccount: one(merchantAccount, {
|
|
57
68
|
fields: [merchantCharge.merchantAccountId],
|
|
@@ -68,5 +79,10 @@ export function getMerchantChargeRelationsSchema(mysqlTable: MySqlTableFn) {
|
|
|
68
79
|
references: [merchantCustomer.id],
|
|
69
80
|
relationName: 'merchantCustomer',
|
|
70
81
|
}),
|
|
82
|
+
merchantSubscription: one(merchantSubscription, {
|
|
83
|
+
fields: [merchantCharge.merchantSubscriptionId],
|
|
84
|
+
references: [merchantSubscription.id],
|
|
85
|
+
relationName: 'merchantSubscription',
|
|
86
|
+
}),
|
|
71
87
|
}))
|
|
72
88
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
decimal,
|
|
3
|
+
index,
|
|
3
4
|
int,
|
|
4
5
|
MySqlTableFn,
|
|
5
6
|
primaryKey,
|
|
@@ -13,6 +14,7 @@ export function getMerchantCouponSchema(mysqlTable: MySqlTableFn) {
|
|
|
13
14
|
{
|
|
14
15
|
id: varchar('id', { length: 191 }).notNull(),
|
|
15
16
|
identifier: varchar('identifier', { length: 191 }),
|
|
17
|
+
organizationId: varchar('organizationId', { length: 191 }),
|
|
16
18
|
status: int('status').default(0).notNull(),
|
|
17
19
|
merchantAccountId: varchar('merchantAccountId', {
|
|
18
20
|
length: 191,
|
|
@@ -32,6 +34,7 @@ export function getMerchantCouponSchema(mysqlTable: MySqlTableFn) {
|
|
|
32
34
|
merchantCouponIdentifierKey: unique('MerchantCoupon_identifier_key').on(
|
|
33
35
|
table.identifier,
|
|
34
36
|
),
|
|
37
|
+
organizationIdIdx: index('organizationId_idx').on(table.organizationId),
|
|
35
38
|
}
|
|
36
39
|
},
|
|
37
40
|
)
|
|
@@ -14,6 +14,7 @@ export function getMerchantCustomerSchema(mysqlTable: MySqlTableFn) {
|
|
|
14
14
|
'MerchantCustomer',
|
|
15
15
|
{
|
|
16
16
|
id: varchar('id', { length: 191 }).notNull(),
|
|
17
|
+
organizationId: varchar('organizationId', { length: 191 }),
|
|
17
18
|
userId: varchar('userId', { length: 191 }).notNull(),
|
|
18
19
|
merchantAccountId: varchar('merchantAccountId', {
|
|
19
20
|
length: 191,
|
|
@@ -34,6 +35,7 @@ export function getMerchantCustomerSchema(mysqlTable: MySqlTableFn) {
|
|
|
34
35
|
'MerchantCustomer_identifier_key',
|
|
35
36
|
).on(table.identifier),
|
|
36
37
|
userIdIdx: index('idx_MerchantCustomer_on_userId').on(table.userId),
|
|
38
|
+
organizationIdIdx: index('organizationId_idx').on(table.organizationId),
|
|
37
39
|
}
|
|
38
40
|
},
|
|
39
41
|
)
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { sql } from 'drizzle-orm'
|
|
2
2
|
import {
|
|
3
|
+
index,
|
|
3
4
|
int,
|
|
4
5
|
MySqlTableFn,
|
|
5
6
|
primaryKey,
|
|
@@ -13,6 +14,7 @@ export function getMerchantPriceSchema(mysqlTable: MySqlTableFn) {
|
|
|
13
14
|
'MerchantPrice',
|
|
14
15
|
{
|
|
15
16
|
id: varchar('id', { length: 191 }).notNull(),
|
|
17
|
+
organizationId: varchar('organizationId', { length: 191 }),
|
|
16
18
|
merchantAccountId: varchar('merchantAccountId', {
|
|
17
19
|
length: 191,
|
|
18
20
|
}).notNull(),
|
|
@@ -35,6 +37,7 @@ export function getMerchantPriceSchema(mysqlTable: MySqlTableFn) {
|
|
|
35
37
|
merchantPriceIdentifierKey: unique('MerchantPrice_identifier_key').on(
|
|
36
38
|
table.identifier,
|
|
37
39
|
),
|
|
40
|
+
organizationIdIdx: index('organizationId_idx').on(table.organizationId),
|
|
38
41
|
}
|
|
39
42
|
},
|
|
40
43
|
)
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { sql } from 'drizzle-orm'
|
|
2
2
|
import {
|
|
3
|
+
index,
|
|
3
4
|
int,
|
|
4
5
|
MySqlTableFn,
|
|
5
6
|
primaryKey,
|
|
@@ -13,6 +14,7 @@ export function getMerchantProductSchema(mysqlTable: MySqlTableFn) {
|
|
|
13
14
|
'MerchantProduct',
|
|
14
15
|
{
|
|
15
16
|
id: varchar('id', { length: 191 }).notNull(),
|
|
17
|
+
organizationId: varchar('organizationId', { length: 191 }),
|
|
16
18
|
merchantAccountId: varchar('merchantAccountId', {
|
|
17
19
|
length: 191,
|
|
18
20
|
}).notNull(),
|
|
@@ -32,6 +34,7 @@ export function getMerchantProductSchema(mysqlTable: MySqlTableFn) {
|
|
|
32
34
|
merchantProductIdentifierKey: unique(
|
|
33
35
|
'MerchantProduct_identifier_key',
|
|
34
36
|
).on(table.identifier),
|
|
37
|
+
organizationIdIdx: index('organizationId_idx').on(table.organizationId),
|
|
35
38
|
}
|
|
36
39
|
},
|
|
37
40
|
)
|
|
@@ -1,10 +1,16 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
index,
|
|
3
|
+
MySqlTableFn,
|
|
4
|
+
primaryKey,
|
|
5
|
+
varchar,
|
|
6
|
+
} from 'drizzle-orm/mysql-core'
|
|
2
7
|
|
|
3
8
|
export function getMerchantSessionSchema(mysqlTable: MySqlTableFn) {
|
|
4
9
|
return mysqlTable(
|
|
5
10
|
'MerchantSession',
|
|
6
11
|
{
|
|
7
12
|
id: varchar('id', { length: 191 }).notNull(),
|
|
13
|
+
organizationId: varchar('organizationId', { length: 191 }),
|
|
8
14
|
identifier: varchar('identifier', { length: 191 }).notNull(),
|
|
9
15
|
merchantAccountId: varchar('merchantAccountId', {
|
|
10
16
|
length: 191,
|
|
@@ -16,6 +22,7 @@ export function getMerchantSessionSchema(mysqlTable: MySqlTableFn) {
|
|
|
16
22
|
columns: [table.id],
|
|
17
23
|
name: 'MerchantSession_id',
|
|
18
24
|
}),
|
|
25
|
+
organizationIdIdx: index('organizationId_idx').on(table.organizationId),
|
|
19
26
|
}
|
|
20
27
|
},
|
|
21
28
|
)
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { relations, sql } from 'drizzle-orm'
|
|
2
|
+
import {
|
|
3
|
+
index,
|
|
4
|
+
int,
|
|
5
|
+
MySqlTableFn,
|
|
6
|
+
primaryKey,
|
|
7
|
+
timestamp,
|
|
8
|
+
varchar,
|
|
9
|
+
} from 'drizzle-orm/mysql-core'
|
|
10
|
+
|
|
11
|
+
import { getMerchantChargeSchema } from './merchant-charge.js'
|
|
12
|
+
import { getSubscriptionSchema } from './subscription.js'
|
|
13
|
+
|
|
14
|
+
export function getMerchantSubscriptionSchema(mysqlTable: MySqlTableFn) {
|
|
15
|
+
return mysqlTable(
|
|
16
|
+
'MerchantSubscription',
|
|
17
|
+
{
|
|
18
|
+
id: varchar('id', { length: 191 }).notNull(),
|
|
19
|
+
organizationId: varchar('organizationId', { length: 191 }),
|
|
20
|
+
merchantAccountId: varchar('merchantAccountId', {
|
|
21
|
+
length: 191,
|
|
22
|
+
}).notNull(),
|
|
23
|
+
status: int('status').default(0).notNull(),
|
|
24
|
+
createdAt: timestamp('createdAt', { mode: 'date', fsp: 3 })
|
|
25
|
+
.default(sql`CURRENT_TIMESTAMP(3)`)
|
|
26
|
+
.notNull(),
|
|
27
|
+
label: varchar('label', { length: 191 }),
|
|
28
|
+
identifier: varchar('identifier', { length: 191 }),
|
|
29
|
+
merchantCustomerId: varchar('merchantCustomerId', {
|
|
30
|
+
length: 191,
|
|
31
|
+
}).notNull(),
|
|
32
|
+
merchantProductId: varchar('merchantProductId', {
|
|
33
|
+
length: 191,
|
|
34
|
+
}).notNull(),
|
|
35
|
+
},
|
|
36
|
+
(table) => {
|
|
37
|
+
return {
|
|
38
|
+
merchantSubscriptionId: primaryKey({
|
|
39
|
+
columns: [table.id],
|
|
40
|
+
name: 'MerchantSubscription_id',
|
|
41
|
+
}),
|
|
42
|
+
organizationIdIdx: index('organizationId_idx').on(table.organizationId),
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
)
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export function getMerchantSubscriptionRelationsSchema(
|
|
49
|
+
mysqlTable: MySqlTableFn,
|
|
50
|
+
) {
|
|
51
|
+
const merchantSubscription = getMerchantSubscriptionSchema(mysqlTable)
|
|
52
|
+
const merchantCharge = getMerchantChargeSchema(mysqlTable)
|
|
53
|
+
const subscription = getSubscriptionSchema(mysqlTable)
|
|
54
|
+
return relations(merchantSubscription, ({ many, one }) => ({
|
|
55
|
+
merchantCharges: many(merchantCharge, {
|
|
56
|
+
relationName: 'merchantSubscription',
|
|
57
|
+
}),
|
|
58
|
+
subscription: one(subscription, {
|
|
59
|
+
fields: [merchantSubscription.id],
|
|
60
|
+
references: [subscription.merchantSubscriptionId],
|
|
61
|
+
relationName: 'subscription',
|
|
62
|
+
}),
|
|
63
|
+
}))
|
|
64
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { relations, sql } from 'drizzle-orm'
|
|
2
2
|
import {
|
|
3
3
|
decimal,
|
|
4
|
+
index,
|
|
4
5
|
int,
|
|
5
6
|
json,
|
|
6
7
|
MySqlTableFn,
|
|
@@ -18,6 +19,7 @@ export function getPriceSchema(mysqlTable: MySqlTableFn) {
|
|
|
18
19
|
{
|
|
19
20
|
id: varchar('id', { length: 191 }).notNull(),
|
|
20
21
|
productId: varchar('productId', { length: 191 }),
|
|
22
|
+
organizationId: varchar('organizationId', { length: 191 }),
|
|
21
23
|
nickname: varchar('nickname', { length: 191 }),
|
|
22
24
|
status: int('status').default(0).notNull(),
|
|
23
25
|
unitAmount: decimal('unitAmount', { precision: 10, scale: 2 }).notNull(),
|
|
@@ -29,6 +31,7 @@ export function getPriceSchema(mysqlTable: MySqlTableFn) {
|
|
|
29
31
|
(table) => {
|
|
30
32
|
return {
|
|
31
33
|
priceId: primaryKey({ columns: [table.id], name: 'Price_id' }),
|
|
34
|
+
organizationIdIdx: index('organizationId_idx').on(table.organizationId),
|
|
32
35
|
}
|
|
33
36
|
},
|
|
34
37
|
)
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { relations, sql } from 'drizzle-orm'
|
|
2
2
|
import {
|
|
3
|
+
index,
|
|
3
4
|
int,
|
|
4
5
|
json,
|
|
5
6
|
MySqlTableFn,
|
|
@@ -17,6 +18,7 @@ export function getProductSchema(mysqlTable: MySqlTableFn) {
|
|
|
17
18
|
'Product',
|
|
18
19
|
{
|
|
19
20
|
id: varchar('id', { length: 191 }).notNull(),
|
|
21
|
+
organizationId: varchar('organizationId', { length: 191 }),
|
|
20
22
|
name: varchar('name', { length: 191 }).notNull(),
|
|
21
23
|
key: varchar('key', { length: 191 }),
|
|
22
24
|
type: varchar('type', { length: 191 }),
|
|
@@ -30,6 +32,7 @@ export function getProductSchema(mysqlTable: MySqlTableFn) {
|
|
|
30
32
|
(table) => {
|
|
31
33
|
return {
|
|
32
34
|
productId: primaryKey({ columns: [table.id], name: 'Product_id' }),
|
|
35
|
+
organizationIdIdx: index('organizationId_idx').on(table.organizationId),
|
|
33
36
|
}
|
|
34
37
|
},
|
|
35
38
|
)
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { relations, sql } from 'drizzle-orm'
|
|
2
2
|
import {
|
|
3
|
+
index,
|
|
3
4
|
mysqlEnum,
|
|
4
5
|
MySqlTableFn,
|
|
5
6
|
primaryKey,
|
|
@@ -27,6 +28,7 @@ export function getPurchaseUserTransferSchema(mysqlTable: MySqlTableFn) {
|
|
|
27
28
|
.default('AVAILABLE')
|
|
28
29
|
.notNull(),
|
|
29
30
|
purchaseId: varchar('purchaseId', { length: 191 }).notNull(),
|
|
31
|
+
organizationId: varchar('organizationId', { length: 191 }),
|
|
30
32
|
sourceUserId: varchar('sourceUserId', { length: 191 }).notNull(),
|
|
31
33
|
targetUserId: varchar('targetUserId', { length: 191 }),
|
|
32
34
|
createdAt: timestamp('createdAt', { mode: 'date', fsp: 3 })
|
|
@@ -43,6 +45,7 @@ export function getPurchaseUserTransferSchema(mysqlTable: MySqlTableFn) {
|
|
|
43
45
|
columns: [table.id],
|
|
44
46
|
name: 'PurchaseUserTransfer_id',
|
|
45
47
|
}),
|
|
48
|
+
organizationIdIdx: index('organizationId_idx').on(table.organizationId),
|
|
46
49
|
}
|
|
47
50
|
},
|
|
48
51
|
)
|
|
@@ -11,6 +11,8 @@ import {
|
|
|
11
11
|
} from 'drizzle-orm/mysql-core'
|
|
12
12
|
|
|
13
13
|
import { getUsersSchema } from '../auth/users.js'
|
|
14
|
+
import { getOrganizationMembershipsSchema } from '../org/organization-memberships.js'
|
|
15
|
+
import { getOrganizationsSchema } from '../org/organizations.js'
|
|
14
16
|
import { getCouponSchema } from './coupon.js'
|
|
15
17
|
import { getMerchantChargeSchema } from './merchant-charge.js'
|
|
16
18
|
import { getMerchantSessionSchema } from './merchant-session.js'
|
|
@@ -22,6 +24,10 @@ export function getPurchaseSchema(mysqlTable: MySqlTableFn) {
|
|
|
22
24
|
{
|
|
23
25
|
id: varchar('id', { length: 191 }).notNull(),
|
|
24
26
|
userId: varchar('userId', { length: 191 }),
|
|
27
|
+
purchasedByorganizationMembershipId: varchar('organizationMembershipId', {
|
|
28
|
+
length: 191,
|
|
29
|
+
}),
|
|
30
|
+
organizationId: varchar('organizationId', { length: 191 }),
|
|
25
31
|
createdAt: timestamp('createdAt', { mode: 'date', fsp: 3 })
|
|
26
32
|
.default(sql`CURRENT_TIMESTAMP(3)`)
|
|
27
33
|
.notNull(),
|
|
@@ -52,6 +58,10 @@ export function getPurchaseSchema(mysqlTable: MySqlTableFn) {
|
|
|
52
58
|
purchaseUpgradedFromIdKey: unique('Purchase_upgradedFromId_key').on(
|
|
53
59
|
table.upgradedFromId,
|
|
54
60
|
),
|
|
61
|
+
organizationIdIdx: index('organizationId_idx').on(table.organizationId),
|
|
62
|
+
organizationMembershipIdIdx: index('organizationMembershipId_idx').on(
|
|
63
|
+
table.purchasedByorganizationMembershipId,
|
|
64
|
+
),
|
|
55
65
|
}
|
|
56
66
|
},
|
|
57
67
|
)
|
|
@@ -64,6 +74,8 @@ export function getPurchaseRelationsSchema(mysqlTable: MySqlTableFn) {
|
|
|
64
74
|
const merchantCharges = getMerchantChargeSchema(mysqlTable)
|
|
65
75
|
const merchantSessions = getMerchantSessionSchema(mysqlTable)
|
|
66
76
|
const coupons = getCouponSchema(mysqlTable)
|
|
77
|
+
const organizations = getOrganizationsSchema(mysqlTable)
|
|
78
|
+
const organizationMemberships = getOrganizationMembershipsSchema(mysqlTable)
|
|
67
79
|
|
|
68
80
|
return relations(purchases, ({ many, one }) => ({
|
|
69
81
|
redeemedBulkCoupon: one(coupons, {
|
|
@@ -76,6 +88,16 @@ export function getPurchaseRelationsSchema(mysqlTable: MySqlTableFn) {
|
|
|
76
88
|
references: [users.id],
|
|
77
89
|
relationName: 'user',
|
|
78
90
|
}),
|
|
91
|
+
organization: one(organizations, {
|
|
92
|
+
fields: [purchases.organizationId],
|
|
93
|
+
references: [organizations.id],
|
|
94
|
+
relationName: 'organization',
|
|
95
|
+
}),
|
|
96
|
+
purchasedBy: one(organizationMemberships, {
|
|
97
|
+
fields: [purchases.purchasedByorganizationMembershipId],
|
|
98
|
+
references: [organizationMemberships.id],
|
|
99
|
+
relationName: 'organizationMembership',
|
|
100
|
+
}),
|
|
79
101
|
product: one(products, {
|
|
80
102
|
fields: [purchases.productId],
|
|
81
103
|
references: [products.id],
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { relations, sql } from 'drizzle-orm'
|
|
2
|
+
import {
|
|
3
|
+
index,
|
|
4
|
+
json,
|
|
5
|
+
MySqlTableFn,
|
|
6
|
+
primaryKey,
|
|
7
|
+
timestamp,
|
|
8
|
+
varchar,
|
|
9
|
+
} from 'drizzle-orm/mysql-core'
|
|
10
|
+
|
|
11
|
+
import { getOrganizationsSchema } from '../org/organizations.js'
|
|
12
|
+
import { getMerchantSubscriptionSchema } from './merchant-subscription.js'
|
|
13
|
+
import { getProductSchema } from './product.js'
|
|
14
|
+
|
|
15
|
+
// TODO: do we add a renewal date here? probably just add that stuff to fields
|
|
16
|
+
// even status feels out of place at the top level maybe
|
|
17
|
+
export function getSubscriptionSchema(mysqlTable: MySqlTableFn) {
|
|
18
|
+
return mysqlTable(
|
|
19
|
+
'Subscription',
|
|
20
|
+
{
|
|
21
|
+
id: varchar('id', { length: 191 }).notNull(),
|
|
22
|
+
organizationId: varchar('organizationId', { length: 191 }),
|
|
23
|
+
productId: varchar('productId', { length: 191 }).notNull(),
|
|
24
|
+
createdAt: timestamp('createdAt', { mode: 'date', fsp: 3 })
|
|
25
|
+
.default(sql`CURRENT_TIMESTAMP(3)`)
|
|
26
|
+
.notNull(),
|
|
27
|
+
merchantSubscriptionId: varchar('merchantSubscriptionId', {
|
|
28
|
+
length: 191,
|
|
29
|
+
}).notNull(),
|
|
30
|
+
status: varchar('status', { length: 191 }).default('active').notNull(),
|
|
31
|
+
fields: json('fields').$type<Record<string, any>>().default({}),
|
|
32
|
+
},
|
|
33
|
+
(table) => {
|
|
34
|
+
return {
|
|
35
|
+
subscriptionId: primaryKey({
|
|
36
|
+
columns: [table.id],
|
|
37
|
+
name: 'Subscription_id',
|
|
38
|
+
}),
|
|
39
|
+
organizationIdIdx: index('organizationId_idx').on(table.organizationId),
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
)
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export function getSubscriptionRelationsSchema(mysqlTable: MySqlTableFn) {
|
|
46
|
+
const subscriptions = getSubscriptionSchema(mysqlTable)
|
|
47
|
+
const products = getProductSchema(mysqlTable)
|
|
48
|
+
|
|
49
|
+
const organizations = getOrganizationsSchema(mysqlTable)
|
|
50
|
+
const merchantSubscriptions = getMerchantSubscriptionSchema(mysqlTable)
|
|
51
|
+
|
|
52
|
+
return relations(subscriptions, ({ many, one }) => ({
|
|
53
|
+
organization: one(organizations, {
|
|
54
|
+
fields: [subscriptions.organizationId],
|
|
55
|
+
references: [organizations.id],
|
|
56
|
+
relationName: 'organization',
|
|
57
|
+
}),
|
|
58
|
+
product: one(products, {
|
|
59
|
+
fields: [subscriptions.productId],
|
|
60
|
+
references: [products.id],
|
|
61
|
+
relationName: 'product',
|
|
62
|
+
}),
|
|
63
|
+
merchantSubscription: one(merchantSubscriptions, {
|
|
64
|
+
fields: [subscriptions.merchantSubscriptionId],
|
|
65
|
+
references: [merchantSubscriptions.id],
|
|
66
|
+
relationName: 'merchantSubscription',
|
|
67
|
+
}),
|
|
68
|
+
}))
|
|
69
|
+
}
|
|
@@ -17,6 +17,7 @@ export function getUpgradableProductsSchema(mysqlTable: MySqlTableFn) {
|
|
|
17
17
|
{
|
|
18
18
|
upgradableToId: varchar('upgradableToId', { length: 255 }).notNull(),
|
|
19
19
|
upgradableFromId: varchar('upgradableFrom', { length: 255 }).notNull(),
|
|
20
|
+
organizationId: varchar('organizationId', { length: 191 }),
|
|
20
21
|
position: double('position').notNull().default(0),
|
|
21
22
|
metadata: json('metadata').$type<Record<string, any>>().default({}),
|
|
22
23
|
createdAt: timestamp('createdAt', {
|
|
@@ -36,6 +37,7 @@ export function getUpgradableProductsSchema(mysqlTable: MySqlTableFn) {
|
|
|
36
37
|
pk: primaryKey({ columns: [crr.upgradableToId, crr.upgradableFromId] }),
|
|
37
38
|
upgradableToIdIdx: index('upgradableFromId_idx').on(crr.upgradableToId),
|
|
38
39
|
upgradableFromIdIdx: index('upgradableToId_idx').on(crr.upgradableFromId),
|
|
40
|
+
organizationIdIdx: index('organizationId_idx').on(crr.organizationId),
|
|
39
41
|
}),
|
|
40
42
|
)
|
|
41
43
|
}
|
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
} from 'drizzle-orm/mysql-core'
|
|
11
11
|
|
|
12
12
|
import { getUsersSchema } from '../auth/users.js'
|
|
13
|
+
import { getOrganizationMembershipsSchema } from '../org/organization-memberships.js'
|
|
13
14
|
|
|
14
15
|
export function getCommentsSchema(mysqlTable: MySqlTableFn) {
|
|
15
16
|
return mysqlTable(
|
|
@@ -17,6 +18,9 @@ export function getCommentsSchema(mysqlTable: MySqlTableFn) {
|
|
|
17
18
|
{
|
|
18
19
|
id: varchar('id', { length: 191 }).notNull(),
|
|
19
20
|
userId: varchar('userId', { length: 255 }).notNull(),
|
|
21
|
+
organizationMembershipId: varchar('organizationMembershipId', {
|
|
22
|
+
length: 255,
|
|
23
|
+
}),
|
|
20
24
|
context: json('context').$type<Record<string, any>>().default({}),
|
|
21
25
|
text: text('text').notNull(),
|
|
22
26
|
createdAt: timestamp('createdAt', {
|
|
@@ -35,6 +39,9 @@ export function getCommentsSchema(mysqlTable: MySqlTableFn) {
|
|
|
35
39
|
(crr) => ({
|
|
36
40
|
pk: primaryKey({ columns: [crr.id] }),
|
|
37
41
|
crrUserIdIdKey: index('crr_userIdId_idx').on(crr.userId),
|
|
42
|
+
organizationMembershipIdIdx: index('organizationMembershipId_idx').on(
|
|
43
|
+
crr.organizationMembershipId,
|
|
44
|
+
),
|
|
38
45
|
}),
|
|
39
46
|
)
|
|
40
47
|
}
|
|
@@ -42,11 +49,17 @@ export function getCommentsSchema(mysqlTable: MySqlTableFn) {
|
|
|
42
49
|
export function getCommentRelationsSchema(mysqlTable: MySqlTableFn) {
|
|
43
50
|
const comment = getCommentsSchema(mysqlTable)
|
|
44
51
|
const user = getUsersSchema(mysqlTable)
|
|
52
|
+
const organizationMemberships = getOrganizationMembershipsSchema(mysqlTable)
|
|
45
53
|
return relations(comment, ({ one }) => ({
|
|
46
54
|
user: one(user, {
|
|
47
55
|
fields: [comment.userId],
|
|
48
56
|
references: [user.id],
|
|
49
57
|
relationName: 'user',
|
|
50
58
|
}),
|
|
59
|
+
organizationMembership: one(organizationMemberships, {
|
|
60
|
+
fields: [comment.organizationMembershipId],
|
|
61
|
+
references: [organizationMemberships.id],
|
|
62
|
+
relationName: 'organizationMembership',
|
|
63
|
+
}),
|
|
51
64
|
}))
|
|
52
65
|
}
|
|
@@ -12,6 +12,7 @@ export function getCommunicationChannelSchema(mysqlTable: MySqlTableFn) {
|
|
|
12
12
|
'CommunicationChannel',
|
|
13
13
|
{
|
|
14
14
|
id: varchar('id', { length: 255 }).notNull().primaryKey(),
|
|
15
|
+
organizationId: varchar('organizationId', { length: 191 }),
|
|
15
16
|
name: varchar('name', { length: 255 }).notNull(),
|
|
16
17
|
description: text('description'),
|
|
17
18
|
active: boolean('active').notNull().default(true),
|
|
@@ -30,6 +31,7 @@ export function getCommunicationChannelSchema(mysqlTable: MySqlTableFn) {
|
|
|
30
31
|
},
|
|
31
32
|
(cc) => ({
|
|
32
33
|
nameIdx: index('name_idx').on(cc.name),
|
|
34
|
+
organizationIdIdx: index('organizationId_idx').on(cc.organizationId),
|
|
33
35
|
}),
|
|
34
36
|
)
|
|
35
37
|
}
|
|
@@ -11,6 +11,7 @@ export function getCommunicationPreferenceTypesSchema(
|
|
|
11
11
|
) {
|
|
12
12
|
return mysqlTable('CommunicationPreferenceType', {
|
|
13
13
|
id: varchar('id', { length: 255 }).notNull().primaryKey(),
|
|
14
|
+
organizationId: varchar('organizationId', { length: 191 }),
|
|
14
15
|
name: varchar('name', { length: 255 }).notNull(),
|
|
15
16
|
description: text('description'),
|
|
16
17
|
active: boolean('active').notNull().default(true),
|
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
} from 'drizzle-orm/mysql-core'
|
|
10
10
|
|
|
11
11
|
import { getUsersSchema } from '../auth/users.js'
|
|
12
|
+
import { getOrganizationMembershipsSchema } from '../org/organization-memberships.js'
|
|
12
13
|
import { getCommunicationChannelSchema } from './communication-channel.js'
|
|
13
14
|
import { getCommunicationPreferenceTypesSchema } from './communication-preference-types.js'
|
|
14
15
|
|
|
@@ -17,7 +18,11 @@ export function getCommunicationPreferencesSchema(mysqlTable: MySqlTableFn) {
|
|
|
17
18
|
'CommunicationPreference',
|
|
18
19
|
{
|
|
19
20
|
id: varchar('id', { length: 255 }).notNull().primaryKey(),
|
|
21
|
+
organizationId: varchar('organizationId', { length: 191 }),
|
|
20
22
|
userId: varchar('userId', { length: 255 }).notNull(),
|
|
23
|
+
organizationMembershipId: varchar('organizationMembershipId', {
|
|
24
|
+
length: 255,
|
|
25
|
+
}),
|
|
21
26
|
channelId: varchar('channelId', { length: 255 }).notNull(),
|
|
22
27
|
preferenceLevel: mysqlEnum('preferenceLevel', ['low', 'medium', 'high'])
|
|
23
28
|
.notNull()
|
|
@@ -49,6 +54,9 @@ export function getCommunicationPreferencesSchema(mysqlTable: MySqlTableFn) {
|
|
|
49
54
|
userIdIdx: index('userId_idx').on(cp.userId),
|
|
50
55
|
preferenceTypeIdx: index('preferenceTypeId_idx').on(cp.preferenceTypeId),
|
|
51
56
|
channelIdIdx: index('channelId_idx').on(cp.channelId),
|
|
57
|
+
organizationMembershipIdIdx: index('organizationMembershipId_idx').on(
|
|
58
|
+
cp.organizationMembershipId,
|
|
59
|
+
),
|
|
52
60
|
}),
|
|
53
61
|
)
|
|
54
62
|
}
|
|
@@ -61,12 +69,18 @@ export function getCommunicationPreferencesRelationsSchema(
|
|
|
61
69
|
const communicationChannel = getCommunicationChannelSchema(mysqlTable)
|
|
62
70
|
const communicationPreferenceTypes =
|
|
63
71
|
getCommunicationPreferenceTypesSchema(mysqlTable)
|
|
72
|
+
const organizationMemberships = getOrganizationMembershipsSchema(mysqlTable)
|
|
64
73
|
return relations(communicationPreferences, ({ one }) => ({
|
|
65
74
|
user: one(users, {
|
|
66
75
|
fields: [communicationPreferences.userId],
|
|
67
76
|
references: [users.id],
|
|
68
77
|
relationName: 'user',
|
|
69
78
|
}),
|
|
79
|
+
organizationMembership: one(organizationMemberships, {
|
|
80
|
+
fields: [communicationPreferences.organizationMembershipId],
|
|
81
|
+
references: [organizationMemberships.id],
|
|
82
|
+
relationName: 'organizationMembership',
|
|
83
|
+
}),
|
|
70
84
|
channel: one(communicationChannel, {
|
|
71
85
|
fields: [communicationPreferences.channelId],
|
|
72
86
|
references: [communicationChannel.id],
|
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
} from 'drizzle-orm/mysql-core'
|
|
9
9
|
|
|
10
10
|
import { getUsersSchema } from '../auth/users.js'
|
|
11
|
+
import { getOrganizationMembershipsSchema } from '../org/organization-memberships.js'
|
|
11
12
|
import { getContentResourceSchema } from './content-resource.js'
|
|
12
13
|
import { getContributionTypesSchema } from './contribution-types.js'
|
|
13
14
|
|
|
@@ -17,6 +18,10 @@ export function getContentContributionsSchema(mysqlTable: MySqlTableFn) {
|
|
|
17
18
|
{
|
|
18
19
|
id: varchar('id', { length: 255 }).notNull().primaryKey(),
|
|
19
20
|
userId: varchar('userId', { length: 255 }).notNull(),
|
|
21
|
+
organizationId: varchar('organizationId', { length: 191 }),
|
|
22
|
+
organizationMembershipId: varchar('organizationMembershipId', {
|
|
23
|
+
length: 255,
|
|
24
|
+
}),
|
|
20
25
|
contentId: varchar('contentId', { length: 255 }).notNull(),
|
|
21
26
|
contributionTypeId: varchar('contributionTypeId', {
|
|
22
27
|
length: 255,
|
|
@@ -41,6 +46,9 @@ export function getContentContributionsSchema(mysqlTable: MySqlTableFn) {
|
|
|
41
46
|
contributionTypeIdIdx: index('contributionTypeId_idx').on(
|
|
42
47
|
cc.contributionTypeId,
|
|
43
48
|
),
|
|
49
|
+
organizationMembershipIdIdx: index('organizationMembershipId_idx').on(
|
|
50
|
+
cc.organizationMembershipId,
|
|
51
|
+
),
|
|
44
52
|
}),
|
|
45
53
|
)
|
|
46
54
|
}
|
|
@@ -52,6 +60,7 @@ export function getContentContributionRelationsSchema(
|
|
|
52
60
|
const users = getUsersSchema(mysqlTable)
|
|
53
61
|
const contentResource = getContentResourceSchema(mysqlTable)
|
|
54
62
|
const contributionTypes = getContributionTypesSchema(mysqlTable)
|
|
63
|
+
const organizationMemberships = getOrganizationMembershipsSchema(mysqlTable)
|
|
55
64
|
|
|
56
65
|
return relations(contentContributions, ({ one }) => ({
|
|
57
66
|
user: one(users, {
|
|
@@ -69,5 +78,10 @@ export function getContentContributionRelationsSchema(
|
|
|
69
78
|
references: [contributionTypes.id],
|
|
70
79
|
relationName: 'contributionType',
|
|
71
80
|
}),
|
|
81
|
+
organizationMembership: one(organizationMemberships, {
|
|
82
|
+
fields: [contentContributions.organizationMembershipId],
|
|
83
|
+
references: [organizationMemberships.id],
|
|
84
|
+
relationName: 'organizationMembership',
|
|
85
|
+
}),
|
|
72
86
|
}))
|
|
73
87
|
}
|
|
@@ -18,6 +18,7 @@ export function getContentResourceProductSchema(mysqlTable: MySqlTableFn) {
|
|
|
18
18
|
{
|
|
19
19
|
productId: varchar('productId', { length: 255 }).notNull(),
|
|
20
20
|
resourceId: varchar('resourceId', { length: 255 }).notNull(),
|
|
21
|
+
organizationId: varchar('organizationId', { length: 191 }),
|
|
21
22
|
position: double('position').notNull().default(0),
|
|
22
23
|
metadata: json('metadata').$type<Record<string, any>>().default({}),
|
|
23
24
|
createdAt: timestamp('createdAt', {
|
|
@@ -37,6 +38,7 @@ export function getContentResourceProductSchema(mysqlTable: MySqlTableFn) {
|
|
|
37
38
|
pk: primaryKey({ columns: [crr.productId, crr.resourceId] }),
|
|
38
39
|
contentResourceIdIdx: index('contentResourceId_idx').on(crr.productId),
|
|
39
40
|
resourceIdIdx: index('resourceId_idx').on(crr.resourceId),
|
|
41
|
+
organizationIdIdx: index('organizationId_idx').on(crr.organizationId),
|
|
40
42
|
}),
|
|
41
43
|
)
|
|
42
44
|
}
|
|
@@ -19,6 +19,7 @@ export function getContentResourceResourceSchema(mysqlTable: MySqlTableFn) {
|
|
|
19
19
|
resourceId: varchar('resourceId', { length: 255 }).notNull(),
|
|
20
20
|
position: double('position').notNull().default(0),
|
|
21
21
|
metadata: json('metadata').$type<Record<string, any>>().default({}),
|
|
22
|
+
organizationId: varchar('organizationId', { length: 191 }),
|
|
22
23
|
createdAt: timestamp('createdAt', {
|
|
23
24
|
mode: 'date',
|
|
24
25
|
fsp: 3,
|
|
@@ -36,6 +37,7 @@ export function getContentResourceResourceSchema(mysqlTable: MySqlTableFn) {
|
|
|
36
37
|
pk: primaryKey({ columns: [crr.resourceOfId, crr.resourceId] }),
|
|
37
38
|
contentResourceIdIdx: index('contentResourceId_idx').on(crr.resourceOfId),
|
|
38
39
|
resourceIdIdx: index('resourceId_idx').on(crr.resourceId),
|
|
40
|
+
organizationIdIdx: index('organizationId_idx').on(crr.organizationId),
|
|
39
41
|
}),
|
|
40
42
|
)
|
|
41
43
|
}
|