@coursebuilder/adapter-drizzle 0.5.1 → 1.0.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.
- package/dist/{chunk-QPXUGIXO.js → chunk-3WYG5OE7.js} +2 -2
- package/dist/{chunk-UK6EHYS5.js → chunk-5XTOCFDB.js} +5 -2
- package/dist/{chunk-2UU2F4DM.js → chunk-6MRFUIH5.js} +6 -2
- package/dist/{chunk-XIGJFVUM.js → chunk-6YPHJWS2.js} +9 -2
- package/dist/{chunk-7X7TMG4A.js → chunk-A6XPL665.js} +2 -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-KDOSK7KN.js → chunk-GAKWXOAY.js} +2 -2
- package/dist/{chunk-4ZWS76VQ.js → chunk-KPBVZ44W.js} +7 -3
- package/dist/{chunk-VUS77FG3.js → chunk-L5ZAWSTN.js} +127 -29
- package/dist/{chunk-6ON2O6UD.js → chunk-MGZMGDQ5.js} +7 -3
- package/dist/{chunk-KDEWFXEP.js → chunk-MP4CUWYC.js} +6 -2
- package/dist/chunk-QGZ2F5SW.js +1987 -0
- package/dist/{chunk-DAP5KOAO.js → chunk-RCL6HPBL.js} +8 -4
- package/dist/chunk-RP66NZN3.js +81 -0
- package/dist/{chunk-7ISZNMPU.js → chunk-WFC55BSF.js} +7 -3
- package/dist/{chunk-GINRTL6J.js → chunk-WJWJ6E5Y.js} +6 -2
- package/dist/{chunk-YGRYHMCG.js → chunk-WPJZAYX7.js} +7 -3
- package/dist/index.d.ts +1 -0
- package/dist/index.js +20 -20
- package/dist/lib/mysql/index.cjs +1621 -721
- package/dist/lib/mysql/index.cjs.map +1 -1
- package/dist/lib/mysql/index.d.cts +7183 -1606
- package/dist/lib/mysql/index.d.ts +7183 -1606
- package/dist/lib/mysql/index.js +20 -20
- package/dist/lib/mysql/schemas/auth/accounts.cjs +117 -85
- package/dist/lib/mysql/schemas/auth/accounts.cjs.map +1 -1
- package/dist/lib/mysql/schemas/auth/accounts.d.cts +58 -1
- package/dist/lib/mysql/schemas/auth/accounts.d.ts +58 -1
- package/dist/lib/mysql/schemas/auth/accounts.js +10 -11
- package/dist/lib/mysql/schemas/auth/device-access-token.cjs +112 -77
- package/dist/lib/mysql/schemas/auth/device-access-token.cjs.map +1 -1
- package/dist/lib/mysql/schemas/auth/device-access-token.d.cts +28 -0
- package/dist/lib/mysql/schemas/auth/device-access-token.d.ts +28 -0
- package/dist/lib/mysql/schemas/auth/device-access-token.js +11 -12
- package/dist/lib/mysql/schemas/auth/device-verification.cjs +111 -79
- package/dist/lib/mysql/schemas/auth/device-verification.cjs.map +1 -1
- package/dist/lib/mysql/schemas/auth/device-verification.d.cts +24 -0
- package/dist/lib/mysql/schemas/auth/device-verification.d.ts +24 -0
- package/dist/lib/mysql/schemas/auth/device-verification.js +11 -12
- package/dist/lib/mysql/schemas/auth/permissions.d.cts +28 -0
- package/dist/lib/mysql/schemas/auth/permissions.d.ts +28 -0
- package/dist/lib/mysql/schemas/auth/role-permissions.cjs +110 -74
- package/dist/lib/mysql/schemas/auth/role-permissions.cjs.map +1 -1
- package/dist/lib/mysql/schemas/auth/role-permissions.d.cts +24 -0
- package/dist/lib/mysql/schemas/auth/role-permissions.d.ts +24 -0
- package/dist/lib/mysql/schemas/auth/role-permissions.js +11 -12
- package/dist/lib/mysql/schemas/auth/roles.cjs +114 -74
- package/dist/lib/mysql/schemas/auth/roles.cjs.map +1 -1
- package/dist/lib/mysql/schemas/auth/roles.d.cts +44 -0
- package/dist/lib/mysql/schemas/auth/roles.d.ts +44 -0
- package/dist/lib/mysql/schemas/auth/roles.js +10 -11
- package/dist/lib/mysql/schemas/auth/sessions.cjs +107 -75
- package/dist/lib/mysql/schemas/auth/sessions.cjs.map +1 -1
- package/dist/lib/mysql/schemas/auth/sessions.d.cts +12 -0
- package/dist/lib/mysql/schemas/auth/sessions.d.ts +12 -0
- package/dist/lib/mysql/schemas/auth/sessions.js +11 -12
- package/dist/lib/mysql/schemas/auth/user-permissions.cjs +112 -76
- package/dist/lib/mysql/schemas/auth/user-permissions.cjs.map +1 -1
- package/dist/lib/mysql/schemas/auth/user-permissions.d.cts +40 -0
- package/dist/lib/mysql/schemas/auth/user-permissions.d.ts +40 -0
- package/dist/lib/mysql/schemas/auth/user-permissions.js +10 -11
- package/dist/lib/mysql/schemas/auth/user-prefs.cjs +116 -80
- package/dist/lib/mysql/schemas/auth/user-prefs.cjs.map +1 -1
- package/dist/lib/mysql/schemas/auth/user-prefs.d.cts +44 -0
- package/dist/lib/mysql/schemas/auth/user-prefs.d.ts +44 -0
- package/dist/lib/mysql/schemas/auth/user-prefs.js +10 -11
- package/dist/lib/mysql/schemas/auth/user-roles.cjs +117 -77
- package/dist/lib/mysql/schemas/auth/user-roles.cjs.map +1 -1
- package/dist/lib/mysql/schemas/auth/user-roles.d.cts +40 -0
- package/dist/lib/mysql/schemas/auth/user-roles.d.ts +40 -0
- package/dist/lib/mysql/schemas/auth/user-roles.js +10 -11
- package/dist/lib/mysql/schemas/auth/users.cjs +299 -183
- package/dist/lib/mysql/schemas/auth/users.cjs.map +1 -1
- package/dist/lib/mysql/schemas/auth/users.d.cts +33 -0
- package/dist/lib/mysql/schemas/auth/users.d.ts +33 -0
- package/dist/lib/mysql/schemas/auth/users.js +10 -11
- package/dist/lib/mysql/schemas/auth/verification-tokens.d.cts +16 -0
- package/dist/lib/mysql/schemas/auth/verification-tokens.d.ts +16 -0
- package/dist/lib/mysql/schemas/commerce/coupon.cjs +142 -90
- package/dist/lib/mysql/schemas/commerce/coupon.cjs.map +1 -1
- package/dist/lib/mysql/schemas/commerce/coupon.d.cts +64 -0
- package/dist/lib/mysql/schemas/commerce/coupon.d.ts +64 -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 +36 -0
- package/dist/lib/mysql/schemas/commerce/merchant-account.d.ts +36 -0
- package/dist/lib/mysql/schemas/commerce/merchant-account.js +1 -1
- package/dist/lib/mysql/schemas/commerce/merchant-charge.cjs +210 -17
- package/dist/lib/mysql/schemas/commerce/merchant-charge.cjs.map +1 -1
- package/dist/lib/mysql/schemas/commerce/merchant-charge.d.cts +65 -0
- package/dist/lib/mysql/schemas/commerce/merchant-charge.d.ts +65 -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 +40 -0
- package/dist/lib/mysql/schemas/commerce/merchant-coupon.d.ts +40 -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 +40 -0
- package/dist/lib/mysql/schemas/commerce/merchant-customer.d.ts +40 -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 +44 -0
- package/dist/lib/mysql/schemas/commerce/merchant-price.d.ts +44 -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 +40 -0
- package/dist/lib/mysql/schemas/commerce/merchant-product.d.ts +40 -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 +28 -0
- package/dist/lib/mysql/schemas/commerce/merchant-session.d.ts +28 -0
- package/dist/lib/mysql/schemas/commerce/merchant-session.js +1 -1
- package/dist/lib/mysql/schemas/commerce/merchant-subscription.cjs +315 -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 +116 -72
- package/dist/lib/mysql/schemas/commerce/price.cjs.map +1 -1
- package/dist/lib/mysql/schemas/commerce/price.d.cts +44 -0
- package/dist/lib/mysql/schemas/commerce/price.d.ts +44 -0
- package/dist/lib/mysql/schemas/commerce/price.js +10 -11
- package/dist/lib/mysql/schemas/commerce/product.cjs +142 -94
- package/dist/lib/mysql/schemas/commerce/product.cjs.map +1 -1
- package/dist/lib/mysql/schemas/commerce/product.d.cts +48 -0
- package/dist/lib/mysql/schemas/commerce/product.d.ts +48 -0
- package/dist/lib/mysql/schemas/commerce/product.js +10 -11
- package/dist/lib/mysql/schemas/commerce/purchase-user-transfer.cjs +149 -105
- package/dist/lib/mysql/schemas/commerce/purchase-user-transfer.cjs.map +1 -1
- package/dist/lib/mysql/schemas/commerce/purchase-user-transfer.d.cts +56 -0
- package/dist/lib/mysql/schemas/commerce/purchase-user-transfer.d.ts +56 -0
- package/dist/lib/mysql/schemas/commerce/purchase-user-transfer.js +11 -12
- package/dist/lib/mysql/schemas/commerce/purchase.cjs +298 -164
- package/dist/lib/mysql/schemas/commerce/purchase.cjs.map +1 -1
- package/dist/lib/mysql/schemas/commerce/purchase.d.cts +102 -0
- package/dist/lib/mysql/schemas/commerce/purchase.d.ts +102 -0
- package/dist/lib/mysql/schemas/commerce/purchase.js +10 -11
- package/dist/lib/mysql/schemas/commerce/subscription.cjs +343 -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 +117 -77
- package/dist/lib/mysql/schemas/commerce/upgradable-products.cjs.map +1 -1
- package/dist/lib/mysql/schemas/commerce/upgradable-products.d.cts +44 -0
- package/dist/lib/mysql/schemas/commerce/upgradable-products.d.ts +44 -0
- package/dist/lib/mysql/schemas/commerce/upgradable-products.js +11 -12
- package/dist/lib/mysql/schemas/communication/comment.cjs +156 -79
- package/dist/lib/mysql/schemas/communication/comment.cjs.map +1 -1
- package/dist/lib/mysql/schemas/communication/comment.d.cts +45 -0
- package/dist/lib/mysql/schemas/communication/comment.d.ts +45 -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 +44 -0
- package/dist/lib/mysql/schemas/communication/communication-channel.d.ts +44 -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 +44 -0
- package/dist/lib/mysql/schemas/communication/communication-preference-types.d.ts +44 -0
- package/dist/lib/mysql/schemas/communication/communication-preference-types.js +1 -1
- package/dist/lib/mysql/schemas/communication/communication-preferences.cjs +183 -96
- package/dist/lib/mysql/schemas/communication/communication-preferences.cjs.map +1 -1
- package/dist/lib/mysql/schemas/communication/communication-preferences.d.cts +77 -0
- package/dist/lib/mysql/schemas/communication/communication-preferences.d.ts +77 -0
- package/dist/lib/mysql/schemas/communication/communication-preferences.js +10 -11
- package/dist/lib/mysql/schemas/content/content-contributions.cjs +197 -102
- package/dist/lib/mysql/schemas/content/content-contributions.cjs.map +1 -1
- package/dist/lib/mysql/schemas/content/content-contributions.d.cts +65 -0
- package/dist/lib/mysql/schemas/content/content-contributions.d.ts +65 -0
- package/dist/lib/mysql/schemas/content/content-contributions.js +10 -11
- package/dist/lib/mysql/schemas/content/content-resource-product.cjs +120 -69
- package/dist/lib/mysql/schemas/content/content-resource-product.cjs.map +1 -1
- package/dist/lib/mysql/schemas/content/content-resource-product.d.cts +44 -0
- package/dist/lib/mysql/schemas/content/content-resource-product.d.ts +44 -0
- package/dist/lib/mysql/schemas/content/content-resource-product.js +10 -11
- package/dist/lib/mysql/schemas/content/content-resource-resource.cjs +125 -78
- package/dist/lib/mysql/schemas/content/content-resource-resource.cjs.map +1 -1
- package/dist/lib/mysql/schemas/content/content-resource-resource.d.cts +44 -0
- package/dist/lib/mysql/schemas/content/content-resource-resource.d.ts +44 -0
- package/dist/lib/mysql/schemas/content/content-resource-resource.js +10 -11
- package/dist/lib/mysql/schemas/content/content-resource-tag.cjs +305 -0
- package/dist/lib/mysql/schemas/content/content-resource-tag.cjs.map +1 -0
- package/dist/lib/mysql/schemas/content/content-resource-tag.d.cts +113 -0
- package/dist/lib/mysql/schemas/content/content-resource-tag.d.ts +113 -0
- package/dist/lib/mysql/schemas/content/content-resource-tag.js +20 -0
- package/dist/lib/mysql/schemas/content/content-resource-tag.js.map +1 -0
- package/dist/lib/mysql/schemas/content/content-resource-version.cjs +315 -0
- package/dist/lib/mysql/schemas/content/content-resource-version.cjs.map +1 -0
- package/dist/lib/mysql/schemas/content/content-resource-version.d.cts +146 -0
- package/dist/lib/mysql/schemas/content/content-resource-version.d.ts +146 -0
- package/dist/lib/mysql/schemas/content/content-resource-version.js +20 -0
- package/dist/lib/mysql/schemas/content/content-resource-version.js.map +1 -0
- package/dist/lib/mysql/schemas/content/content-resource.cjs +332 -115
- package/dist/lib/mysql/schemas/content/content-resource.cjs.map +1 -1
- package/dist/lib/mysql/schemas/content/content-resource.d.cts +80 -0
- package/dist/lib/mysql/schemas/content/content-resource.d.ts +80 -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 +48 -0
- package/dist/lib/mysql/schemas/content/contribution-types.d.ts +48 -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 +72 -0
- package/dist/lib/mysql/schemas/content/lesson-progress.d.ts +72 -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 +56 -0
- package/dist/lib/mysql/schemas/content/resource-progress.d.ts +56 -0
- package/dist/lib/mysql/schemas/content/resource-progress.js +1 -1
- package/dist/lib/mysql/schemas/content/tag-tag.cjs +265 -0
- package/dist/lib/mysql/schemas/content/tag-tag.cjs.map +1 -0
- package/dist/lib/mysql/schemas/content/tag-tag.d.cts +145 -0
- package/dist/lib/mysql/schemas/content/tag-tag.d.ts +145 -0
- package/dist/lib/mysql/schemas/content/tag-tag.js +20 -0
- package/dist/lib/mysql/schemas/content/tag-tag.js.map +1 -0
- package/dist/lib/mysql/schemas/content/tag.cjs +291 -0
- package/dist/lib/mysql/schemas/content/tag.cjs.map +1 -0
- package/dist/lib/mysql/schemas/content/tag.d.cts +130 -0
- package/dist/lib/mysql/schemas/content/tag.d.ts +130 -0
- package/dist/lib/mysql/schemas/content/tag.js +20 -0
- package/dist/lib/mysql/schemas/content/tag.js.map +1 -0
- package/dist/lib/mysql/schemas/org/organization-membership-roles.cjs +301 -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 +129 -0
- package/dist/lib/mysql/schemas/org/organization-membership-roles.d.ts +129 -0
- package/dist/lib/mysql/schemas/org/organization-membership-roles.js +21 -0
- package/dist/lib/mysql/schemas/org/organization-membership-roles.js.map +1 -0
- package/dist/lib/mysql/schemas/org/organization-memberships.cjs +370 -0
- package/dist/lib/mysql/schemas/org/organization-memberships.cjs.map +1 -0
- package/dist/lib/mysql/schemas/org/organization-memberships.d.cts +131 -0
- package/dist/lib/mysql/schemas/org/organization-memberships.d.ts +131 -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 +349 -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/dist/lib/mysql/utils.d.cts +1 -0
- package/dist/lib/mysql/utils.d.ts +1 -0
- package/dist/lib/utils.d.cts +1 -0
- package/dist/lib/utils.d.ts +1 -0
- package/package.json +6 -6
- package/src/lib/mysql/index.ts +151 -0
- package/src/lib/mysql/schemas/auth/device-access-token.ts +3 -0
- package/src/lib/mysql/schemas/auth/roles.ts +3 -0
- 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 +5 -0
- 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 +71 -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 +61 -0
- package/src/lib/mysql/schemas/content/content-resource-version.ts +71 -0
- package/src/lib/mysql/schemas/content/content-resource.ts +34 -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 +61 -0
- package/src/lib/mysql/schemas/content/tag.ts +50 -0
- package/src/lib/mysql/schemas/org/organization-membership-roles.ts +68 -0
- package/src/lib/mysql/schemas/org/organization-memberships.ts +69 -0
- package/src/lib/mysql/schemas/org/organizations.ts +50 -0
- package/dist/chunk-SRTIWWLG.js +0 -96
- package/dist/chunk-UHH4OVKA.js +0 -1196
|
@@ -0,0 +1,1987 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getContributionTypesSchema
|
|
3
|
+
} from "./chunk-MP4CUWYC.js";
|
|
4
|
+
import {
|
|
5
|
+
getCommunicationChannelSchema
|
|
6
|
+
} from "./chunk-WJWJ6E5Y.js";
|
|
7
|
+
import {
|
|
8
|
+
getCommunicationPreferenceTypesSchema
|
|
9
|
+
} from "./chunk-EHRARBRS.js";
|
|
10
|
+
import {
|
|
11
|
+
getMerchantAccountSchema
|
|
12
|
+
} from "./chunk-DKJO4Y3K.js";
|
|
13
|
+
import {
|
|
14
|
+
getMerchantCouponSchema
|
|
15
|
+
} from "./chunk-WPJZAYX7.js";
|
|
16
|
+
import {
|
|
17
|
+
getMerchantCustomerSchema
|
|
18
|
+
} from "./chunk-6MRFUIH5.js";
|
|
19
|
+
import {
|
|
20
|
+
getMerchantPriceSchema
|
|
21
|
+
} from "./chunk-MGZMGDQ5.js";
|
|
22
|
+
import {
|
|
23
|
+
getMerchantProductSchema
|
|
24
|
+
} from "./chunk-KPBVZ44W.js";
|
|
25
|
+
import {
|
|
26
|
+
getMerchantSessionSchema
|
|
27
|
+
} from "./chunk-BLDW3QUS.js";
|
|
28
|
+
import {
|
|
29
|
+
getPermissionsSchema
|
|
30
|
+
} from "./chunk-LZHZDFNZ.js";
|
|
31
|
+
import {
|
|
32
|
+
__name
|
|
33
|
+
} from "./chunk-H736K5TN.js";
|
|
34
|
+
|
|
35
|
+
// src/lib/mysql/schemas/commerce/merchant-charge.ts
|
|
36
|
+
import { relations as relations25, sql as sql19 } from "drizzle-orm";
|
|
37
|
+
import { index as index25, int as int7, primaryKey as primaryKey16, timestamp as timestamp24, unique as unique4, varchar as varchar25 } from "drizzle-orm/mysql-core";
|
|
38
|
+
|
|
39
|
+
// src/lib/mysql/schemas/commerce/merchant-subscription.ts
|
|
40
|
+
import { relations as relations24, sql as sql18 } from "drizzle-orm";
|
|
41
|
+
import { index as index24, int as int6, primaryKey as primaryKey15, timestamp as timestamp23, varchar as varchar24 } from "drizzle-orm/mysql-core";
|
|
42
|
+
|
|
43
|
+
// src/lib/mysql/schemas/commerce/subscription.ts
|
|
44
|
+
import { relations as relations23, sql as sql17 } from "drizzle-orm";
|
|
45
|
+
import { index as index23, json as json16, primaryKey as primaryKey14, timestamp as timestamp22, varchar as varchar23 } from "drizzle-orm/mysql-core";
|
|
46
|
+
|
|
47
|
+
// src/lib/mysql/schemas/org/organizations.ts
|
|
48
|
+
import { relations as relations22, sql as sql16 } from "drizzle-orm";
|
|
49
|
+
import { index as index22, json as json15, timestamp as timestamp21, varchar as varchar22 } from "drizzle-orm/mysql-core";
|
|
50
|
+
|
|
51
|
+
// src/lib/mysql/schemas/commerce/purchase.ts
|
|
52
|
+
import { relations as relations21, sql as sql15 } from "drizzle-orm";
|
|
53
|
+
import { decimal as decimal3, index as index21, json as json14, primaryKey as primaryKey13, timestamp as timestamp20, unique as unique3, varchar as varchar21 } from "drizzle-orm/mysql-core";
|
|
54
|
+
|
|
55
|
+
// src/lib/mysql/schemas/auth/users.ts
|
|
56
|
+
import { relations as relations19, sql as sql13 } from "drizzle-orm";
|
|
57
|
+
import { index as index19, json as json12, timestamp as timestamp18, varchar as varchar19 } from "drizzle-orm/mysql-core";
|
|
58
|
+
|
|
59
|
+
// src/lib/mysql/schemas/communication/comment.ts
|
|
60
|
+
import { relations as relations2, sql as sql2 } from "drizzle-orm";
|
|
61
|
+
import { index as index2, json as json2, primaryKey, text, timestamp as timestamp2, varchar as varchar2 } from "drizzle-orm/mysql-core";
|
|
62
|
+
|
|
63
|
+
// src/lib/mysql/schemas/org/organization-memberships.ts
|
|
64
|
+
import { relations, sql } from "drizzle-orm";
|
|
65
|
+
import { index, json, timestamp, varchar } from "drizzle-orm/mysql-core";
|
|
66
|
+
function getOrganizationMembershipsSchema(mysqlTable) {
|
|
67
|
+
return mysqlTable("OrganizationMembership", {
|
|
68
|
+
id: varchar("id", {
|
|
69
|
+
length: 255
|
|
70
|
+
}).notNull().primaryKey(),
|
|
71
|
+
organizationId: varchar("organizationId", {
|
|
72
|
+
length: 191
|
|
73
|
+
}),
|
|
74
|
+
role: varchar("role", {
|
|
75
|
+
length: 191
|
|
76
|
+
}).notNull().default("user"),
|
|
77
|
+
invitedById: varchar("invitedById", {
|
|
78
|
+
length: 255
|
|
79
|
+
}).notNull(),
|
|
80
|
+
userId: varchar("userId", {
|
|
81
|
+
length: 255
|
|
82
|
+
}).notNull(),
|
|
83
|
+
fields: json("fields").$type().default({}),
|
|
84
|
+
createdAt: timestamp("createdAt", {
|
|
85
|
+
mode: "date",
|
|
86
|
+
fsp: 3
|
|
87
|
+
}).default(sql`CURRENT_TIMESTAMP(3)`)
|
|
88
|
+
}, (organizationMembership) => ({
|
|
89
|
+
roleIdx: index("role_idx").on(organizationMembership.role),
|
|
90
|
+
createdAtIdx: index("created_at_idx").on(organizationMembership.createdAt),
|
|
91
|
+
organizationIdIdx: index("organizationId_idx").on(organizationMembership.organizationId)
|
|
92
|
+
}));
|
|
93
|
+
}
|
|
94
|
+
__name(getOrganizationMembershipsSchema, "getOrganizationMembershipsSchema");
|
|
95
|
+
function getOrganizationMembershipsRelationsSchema(mysqlTable) {
|
|
96
|
+
const users = getUsersSchema(mysqlTable);
|
|
97
|
+
const organizationMemberships = getOrganizationMembershipsSchema(mysqlTable);
|
|
98
|
+
const purchases = getPurchaseSchema(mysqlTable);
|
|
99
|
+
const organizations = getOrganizationsSchema(mysqlTable);
|
|
100
|
+
return relations(organizationMemberships, ({ one, many }) => ({
|
|
101
|
+
user: one(users, {
|
|
102
|
+
fields: [
|
|
103
|
+
organizationMemberships.userId
|
|
104
|
+
],
|
|
105
|
+
references: [
|
|
106
|
+
users.id
|
|
107
|
+
],
|
|
108
|
+
relationName: "user"
|
|
109
|
+
}),
|
|
110
|
+
invitedBy: one(users, {
|
|
111
|
+
fields: [
|
|
112
|
+
organizationMemberships.invitedById
|
|
113
|
+
],
|
|
114
|
+
references: [
|
|
115
|
+
users.id
|
|
116
|
+
],
|
|
117
|
+
relationName: "invitedBy"
|
|
118
|
+
}),
|
|
119
|
+
purchases: many(purchases),
|
|
120
|
+
organization: one(organizations, {
|
|
121
|
+
fields: [
|
|
122
|
+
organizationMemberships.organizationId
|
|
123
|
+
],
|
|
124
|
+
references: [
|
|
125
|
+
organizations.id
|
|
126
|
+
],
|
|
127
|
+
relationName: "organization"
|
|
128
|
+
})
|
|
129
|
+
}));
|
|
130
|
+
}
|
|
131
|
+
__name(getOrganizationMembershipsRelationsSchema, "getOrganizationMembershipsRelationsSchema");
|
|
132
|
+
|
|
133
|
+
// src/lib/mysql/schemas/communication/comment.ts
|
|
134
|
+
function getCommentsSchema(mysqlTable) {
|
|
135
|
+
return mysqlTable("Comment", {
|
|
136
|
+
id: varchar2("id", {
|
|
137
|
+
length: 191
|
|
138
|
+
}).notNull(),
|
|
139
|
+
userId: varchar2("userId", {
|
|
140
|
+
length: 255
|
|
141
|
+
}).notNull(),
|
|
142
|
+
organizationMembershipId: varchar2("organizationMembershipId", {
|
|
143
|
+
length: 255
|
|
144
|
+
}),
|
|
145
|
+
context: json2("context").$type().default({}),
|
|
146
|
+
text: text("text").notNull(),
|
|
147
|
+
createdAt: timestamp2("createdAt", {
|
|
148
|
+
mode: "date",
|
|
149
|
+
fsp: 3
|
|
150
|
+
}).default(sql2`CURRENT_TIMESTAMP(3)`),
|
|
151
|
+
updatedAt: timestamp2("updatedAt", {
|
|
152
|
+
mode: "date",
|
|
153
|
+
fsp: 3
|
|
154
|
+
}).default(sql2`CURRENT_TIMESTAMP(3)`),
|
|
155
|
+
deletedAt: timestamp2("deletedAt", {
|
|
156
|
+
mode: "date",
|
|
157
|
+
fsp: 3
|
|
158
|
+
})
|
|
159
|
+
}, (crr) => ({
|
|
160
|
+
pk: primaryKey({
|
|
161
|
+
columns: [
|
|
162
|
+
crr.id
|
|
163
|
+
]
|
|
164
|
+
}),
|
|
165
|
+
crrUserIdIdKey: index2("crr_userIdId_idx").on(crr.userId),
|
|
166
|
+
organizationMembershipIdIdx: index2("organizationMembershipId_idx").on(crr.organizationMembershipId)
|
|
167
|
+
}));
|
|
168
|
+
}
|
|
169
|
+
__name(getCommentsSchema, "getCommentsSchema");
|
|
170
|
+
function getCommentRelationsSchema(mysqlTable) {
|
|
171
|
+
const comment = getCommentsSchema(mysqlTable);
|
|
172
|
+
const user = getUsersSchema(mysqlTable);
|
|
173
|
+
const organizationMemberships = getOrganizationMembershipsSchema(mysqlTable);
|
|
174
|
+
return relations2(comment, ({ one }) => ({
|
|
175
|
+
user: one(user, {
|
|
176
|
+
fields: [
|
|
177
|
+
comment.userId
|
|
178
|
+
],
|
|
179
|
+
references: [
|
|
180
|
+
user.id
|
|
181
|
+
],
|
|
182
|
+
relationName: "user"
|
|
183
|
+
}),
|
|
184
|
+
organizationMembership: one(organizationMemberships, {
|
|
185
|
+
fields: [
|
|
186
|
+
comment.organizationMembershipId
|
|
187
|
+
],
|
|
188
|
+
references: [
|
|
189
|
+
organizationMemberships.id
|
|
190
|
+
],
|
|
191
|
+
relationName: "organizationMembership"
|
|
192
|
+
})
|
|
193
|
+
}));
|
|
194
|
+
}
|
|
195
|
+
__name(getCommentRelationsSchema, "getCommentRelationsSchema");
|
|
196
|
+
|
|
197
|
+
// src/lib/mysql/schemas/communication/communication-preferences.ts
|
|
198
|
+
import { relations as relations3 } from "drizzle-orm";
|
|
199
|
+
import { boolean, index as index3, mysqlEnum, timestamp as timestamp3, varchar as varchar3 } from "drizzle-orm/mysql-core";
|
|
200
|
+
function getCommunicationPreferencesSchema(mysqlTable) {
|
|
201
|
+
return mysqlTable("CommunicationPreference", {
|
|
202
|
+
id: varchar3("id", {
|
|
203
|
+
length: 255
|
|
204
|
+
}).notNull().primaryKey(),
|
|
205
|
+
organizationId: varchar3("organizationId", {
|
|
206
|
+
length: 191
|
|
207
|
+
}),
|
|
208
|
+
userId: varchar3("userId", {
|
|
209
|
+
length: 255
|
|
210
|
+
}).notNull(),
|
|
211
|
+
organizationMembershipId: varchar3("organizationMembershipId", {
|
|
212
|
+
length: 255
|
|
213
|
+
}),
|
|
214
|
+
channelId: varchar3("channelId", {
|
|
215
|
+
length: 255
|
|
216
|
+
}).notNull(),
|
|
217
|
+
preferenceLevel: mysqlEnum("preferenceLevel", [
|
|
218
|
+
"low",
|
|
219
|
+
"medium",
|
|
220
|
+
"high"
|
|
221
|
+
]).notNull().default("medium"),
|
|
222
|
+
preferenceTypeId: varchar3("preferenceTypeId", {
|
|
223
|
+
length: 255
|
|
224
|
+
}).notNull(),
|
|
225
|
+
active: boolean("active").notNull().default(true),
|
|
226
|
+
createdAt: timestamp3("createdAt", {
|
|
227
|
+
mode: "date",
|
|
228
|
+
fsp: 3
|
|
229
|
+
}).defaultNow(),
|
|
230
|
+
optInAt: timestamp3("optInAt", {
|
|
231
|
+
mode: "date",
|
|
232
|
+
fsp: 3
|
|
233
|
+
}),
|
|
234
|
+
optOutAt: timestamp3("optOutAt", {
|
|
235
|
+
mode: "date",
|
|
236
|
+
fsp: 3
|
|
237
|
+
}),
|
|
238
|
+
updatedAt: timestamp3("updatedAt", {
|
|
239
|
+
mode: "date",
|
|
240
|
+
fsp: 3
|
|
241
|
+
}).defaultNow(),
|
|
242
|
+
deletedAt: timestamp3("deletedAt", {
|
|
243
|
+
mode: "date",
|
|
244
|
+
fsp: 3
|
|
245
|
+
})
|
|
246
|
+
}, (cp) => ({
|
|
247
|
+
userIdIdx: index3("userId_idx").on(cp.userId),
|
|
248
|
+
preferenceTypeIdx: index3("preferenceTypeId_idx").on(cp.preferenceTypeId),
|
|
249
|
+
channelIdIdx: index3("channelId_idx").on(cp.channelId),
|
|
250
|
+
organizationMembershipIdIdx: index3("organizationMembershipId_idx").on(cp.organizationMembershipId)
|
|
251
|
+
}));
|
|
252
|
+
}
|
|
253
|
+
__name(getCommunicationPreferencesSchema, "getCommunicationPreferencesSchema");
|
|
254
|
+
function getCommunicationPreferencesRelationsSchema(mysqlTable) {
|
|
255
|
+
const communicationPreferences = getCommunicationPreferencesSchema(mysqlTable);
|
|
256
|
+
const users = getUsersSchema(mysqlTable);
|
|
257
|
+
const communicationChannel = getCommunicationChannelSchema(mysqlTable);
|
|
258
|
+
const communicationPreferenceTypes = getCommunicationPreferenceTypesSchema(mysqlTable);
|
|
259
|
+
const organizationMemberships = getOrganizationMembershipsSchema(mysqlTable);
|
|
260
|
+
return relations3(communicationPreferences, ({ one }) => ({
|
|
261
|
+
user: one(users, {
|
|
262
|
+
fields: [
|
|
263
|
+
communicationPreferences.userId
|
|
264
|
+
],
|
|
265
|
+
references: [
|
|
266
|
+
users.id
|
|
267
|
+
],
|
|
268
|
+
relationName: "user"
|
|
269
|
+
}),
|
|
270
|
+
organizationMembership: one(organizationMemberships, {
|
|
271
|
+
fields: [
|
|
272
|
+
communicationPreferences.organizationMembershipId
|
|
273
|
+
],
|
|
274
|
+
references: [
|
|
275
|
+
organizationMemberships.id
|
|
276
|
+
],
|
|
277
|
+
relationName: "organizationMembership"
|
|
278
|
+
}),
|
|
279
|
+
channel: one(communicationChannel, {
|
|
280
|
+
fields: [
|
|
281
|
+
communicationPreferences.channelId
|
|
282
|
+
],
|
|
283
|
+
references: [
|
|
284
|
+
communicationChannel.id
|
|
285
|
+
],
|
|
286
|
+
relationName: "channel"
|
|
287
|
+
}),
|
|
288
|
+
preferenceType: one(communicationPreferenceTypes, {
|
|
289
|
+
fields: [
|
|
290
|
+
communicationPreferences.preferenceTypeId
|
|
291
|
+
],
|
|
292
|
+
references: [
|
|
293
|
+
communicationPreferenceTypes.id
|
|
294
|
+
],
|
|
295
|
+
relationName: "preferenceType"
|
|
296
|
+
})
|
|
297
|
+
}));
|
|
298
|
+
}
|
|
299
|
+
__name(getCommunicationPreferencesRelationsSchema, "getCommunicationPreferencesRelationsSchema");
|
|
300
|
+
|
|
301
|
+
// src/lib/mysql/schemas/content/content-contributions.ts
|
|
302
|
+
import { relations as relations13 } from "drizzle-orm";
|
|
303
|
+
import { boolean as boolean2, index as index13, timestamp as timestamp13, varchar as varchar13 } from "drizzle-orm/mysql-core";
|
|
304
|
+
|
|
305
|
+
// src/lib/mysql/schemas/content/content-resource.ts
|
|
306
|
+
import { relations as relations12, sql as sql11 } from "drizzle-orm";
|
|
307
|
+
import { index as index12, json as json10, timestamp as timestamp12, varchar as varchar12 } from "drizzle-orm/mysql-core";
|
|
308
|
+
|
|
309
|
+
// src/lib/mysql/schemas/content/content-resource-product.ts
|
|
310
|
+
import { relations as relations6, sql as sql5 } from "drizzle-orm";
|
|
311
|
+
import { double, index as index6, json as json5, primaryKey as primaryKey4, timestamp as timestamp6, varchar as varchar6 } from "drizzle-orm/mysql-core";
|
|
312
|
+
|
|
313
|
+
// src/lib/mysql/schemas/commerce/product.ts
|
|
314
|
+
import { relations as relations5, sql as sql4 } from "drizzle-orm";
|
|
315
|
+
import { index as index5, int as int2, json as json4, primaryKey as primaryKey3, timestamp as timestamp5, varchar as varchar5 } from "drizzle-orm/mysql-core";
|
|
316
|
+
|
|
317
|
+
// src/lib/mysql/schemas/commerce/price.ts
|
|
318
|
+
import { relations as relations4, sql as sql3 } from "drizzle-orm";
|
|
319
|
+
import { decimal, index as index4, int, json as json3, primaryKey as primaryKey2, timestamp as timestamp4, varchar as varchar4 } from "drizzle-orm/mysql-core";
|
|
320
|
+
function getPriceSchema(mysqlTable) {
|
|
321
|
+
return mysqlTable("Price", {
|
|
322
|
+
id: varchar4("id", {
|
|
323
|
+
length: 191
|
|
324
|
+
}).notNull(),
|
|
325
|
+
productId: varchar4("productId", {
|
|
326
|
+
length: 191
|
|
327
|
+
}),
|
|
328
|
+
organizationId: varchar4("organizationId", {
|
|
329
|
+
length: 191
|
|
330
|
+
}),
|
|
331
|
+
nickname: varchar4("nickname", {
|
|
332
|
+
length: 191
|
|
333
|
+
}),
|
|
334
|
+
status: int("status").default(0).notNull(),
|
|
335
|
+
unitAmount: decimal("unitAmount", {
|
|
336
|
+
precision: 10,
|
|
337
|
+
scale: 2
|
|
338
|
+
}).notNull(),
|
|
339
|
+
createdAt: timestamp4("createdAt", {
|
|
340
|
+
mode: "date",
|
|
341
|
+
fsp: 3
|
|
342
|
+
}).default(sql3`CURRENT_TIMESTAMP(3)`).notNull(),
|
|
343
|
+
fields: json3("fields").$type().default({})
|
|
344
|
+
}, (table) => {
|
|
345
|
+
return {
|
|
346
|
+
priceId: primaryKey2({
|
|
347
|
+
columns: [
|
|
348
|
+
table.id
|
|
349
|
+
],
|
|
350
|
+
name: "Price_id"
|
|
351
|
+
}),
|
|
352
|
+
organizationIdIdx: index4("organizationId_idx").on(table.organizationId)
|
|
353
|
+
};
|
|
354
|
+
});
|
|
355
|
+
}
|
|
356
|
+
__name(getPriceSchema, "getPriceSchema");
|
|
357
|
+
function getProductRelationsSchema(mysqlTable) {
|
|
358
|
+
const product = getProductSchema(mysqlTable);
|
|
359
|
+
const price = getPriceSchema(mysqlTable);
|
|
360
|
+
const merchantPrice = getMerchantPriceSchema(mysqlTable);
|
|
361
|
+
return relations4(price, ({ one, many }) => ({
|
|
362
|
+
product: one(product, {
|
|
363
|
+
fields: [
|
|
364
|
+
price.productId
|
|
365
|
+
],
|
|
366
|
+
references: [
|
|
367
|
+
product.id
|
|
368
|
+
],
|
|
369
|
+
relationName: "user"
|
|
370
|
+
}),
|
|
371
|
+
merchantPrice: one(merchantPrice, {
|
|
372
|
+
fields: [
|
|
373
|
+
price.id
|
|
374
|
+
],
|
|
375
|
+
references: [
|
|
376
|
+
merchantPrice.priceId
|
|
377
|
+
],
|
|
378
|
+
relationName: "merchantPrice"
|
|
379
|
+
})
|
|
380
|
+
}));
|
|
381
|
+
}
|
|
382
|
+
__name(getProductRelationsSchema, "getProductRelationsSchema");
|
|
383
|
+
|
|
384
|
+
// src/lib/mysql/schemas/commerce/product.ts
|
|
385
|
+
function getProductSchema(mysqlTable) {
|
|
386
|
+
return mysqlTable("Product", {
|
|
387
|
+
id: varchar5("id", {
|
|
388
|
+
length: 191
|
|
389
|
+
}).notNull(),
|
|
390
|
+
organizationId: varchar5("organizationId", {
|
|
391
|
+
length: 191
|
|
392
|
+
}),
|
|
393
|
+
name: varchar5("name", {
|
|
394
|
+
length: 191
|
|
395
|
+
}).notNull(),
|
|
396
|
+
key: varchar5("key", {
|
|
397
|
+
length: 191
|
|
398
|
+
}),
|
|
399
|
+
type: varchar5("type", {
|
|
400
|
+
length: 191
|
|
401
|
+
}),
|
|
402
|
+
fields: json4("fields").$type().default({}),
|
|
403
|
+
createdAt: timestamp5("createdAt", {
|
|
404
|
+
mode: "date",
|
|
405
|
+
fsp: 3
|
|
406
|
+
}).default(sql4`CURRENT_TIMESTAMP(3)`).notNull(),
|
|
407
|
+
status: int2("status").default(0).notNull(),
|
|
408
|
+
quantityAvailable: int2("quantityAvailable").default(-1).notNull()
|
|
409
|
+
}, (table) => {
|
|
410
|
+
return {
|
|
411
|
+
productId: primaryKey3({
|
|
412
|
+
columns: [
|
|
413
|
+
table.id
|
|
414
|
+
],
|
|
415
|
+
name: "Product_id"
|
|
416
|
+
}),
|
|
417
|
+
organizationIdIdx: index5("organizationId_idx").on(table.organizationId)
|
|
418
|
+
};
|
|
419
|
+
});
|
|
420
|
+
}
|
|
421
|
+
__name(getProductSchema, "getProductSchema");
|
|
422
|
+
function getProductRelationsSchema2(mysqlTable) {
|
|
423
|
+
const product = getProductSchema(mysqlTable);
|
|
424
|
+
const price = getPriceSchema(mysqlTable);
|
|
425
|
+
const merchantProduct = getMerchantProductSchema(mysqlTable);
|
|
426
|
+
const contentResourceProduct = getContentResourceProductSchema(mysqlTable);
|
|
427
|
+
return relations5(product, ({ one, many }) => ({
|
|
428
|
+
price: one(price, {
|
|
429
|
+
fields: [
|
|
430
|
+
product.id
|
|
431
|
+
],
|
|
432
|
+
references: [
|
|
433
|
+
price.productId
|
|
434
|
+
],
|
|
435
|
+
relationName: "price"
|
|
436
|
+
}),
|
|
437
|
+
resources: many(contentResourceProduct, {
|
|
438
|
+
relationName: "product"
|
|
439
|
+
}),
|
|
440
|
+
merchantProduct: one(merchantProduct, {
|
|
441
|
+
fields: [
|
|
442
|
+
product.id
|
|
443
|
+
],
|
|
444
|
+
references: [
|
|
445
|
+
merchantProduct.productId
|
|
446
|
+
],
|
|
447
|
+
relationName: "merchantProduct"
|
|
448
|
+
})
|
|
449
|
+
}));
|
|
450
|
+
}
|
|
451
|
+
__name(getProductRelationsSchema2, "getProductRelationsSchema");
|
|
452
|
+
|
|
453
|
+
// src/lib/mysql/schemas/content/content-resource-product.ts
|
|
454
|
+
function getContentResourceProductSchema(mysqlTable) {
|
|
455
|
+
return mysqlTable("ContentResourceProduct", {
|
|
456
|
+
productId: varchar6("productId", {
|
|
457
|
+
length: 255
|
|
458
|
+
}).notNull(),
|
|
459
|
+
resourceId: varchar6("resourceId", {
|
|
460
|
+
length: 255
|
|
461
|
+
}).notNull(),
|
|
462
|
+
organizationId: varchar6("organizationId", {
|
|
463
|
+
length: 191
|
|
464
|
+
}),
|
|
465
|
+
position: double("position").notNull().default(0),
|
|
466
|
+
metadata: json5("metadata").$type().default({}),
|
|
467
|
+
createdAt: timestamp6("createdAt", {
|
|
468
|
+
mode: "date",
|
|
469
|
+
fsp: 3
|
|
470
|
+
}).default(sql5`CURRENT_TIMESTAMP(3)`),
|
|
471
|
+
updatedAt: timestamp6("updatedAt", {
|
|
472
|
+
mode: "date",
|
|
473
|
+
fsp: 3
|
|
474
|
+
}).default(sql5`CURRENT_TIMESTAMP(3)`),
|
|
475
|
+
deletedAt: timestamp6("deletedAt", {
|
|
476
|
+
mode: "date",
|
|
477
|
+
fsp: 3
|
|
478
|
+
})
|
|
479
|
+
}, (crr) => ({
|
|
480
|
+
pk: primaryKey4({
|
|
481
|
+
columns: [
|
|
482
|
+
crr.productId,
|
|
483
|
+
crr.resourceId
|
|
484
|
+
]
|
|
485
|
+
}),
|
|
486
|
+
contentResourceIdIdx: index6("contentResourceId_idx").on(crr.productId),
|
|
487
|
+
resourceIdIdx: index6("resourceId_idx").on(crr.resourceId),
|
|
488
|
+
organizationIdIdx: index6("organizationId_idx").on(crr.organizationId)
|
|
489
|
+
}));
|
|
490
|
+
}
|
|
491
|
+
__name(getContentResourceProductSchema, "getContentResourceProductSchema");
|
|
492
|
+
function getContentResourceProductRelationsSchema(mysqlTable) {
|
|
493
|
+
const contentResource = getContentResourceSchema(mysqlTable);
|
|
494
|
+
const contentResourceProduct = getContentResourceProductSchema(mysqlTable);
|
|
495
|
+
const product = getProductSchema(mysqlTable);
|
|
496
|
+
return relations6(contentResourceProduct, ({ one }) => ({
|
|
497
|
+
product: one(product, {
|
|
498
|
+
fields: [
|
|
499
|
+
contentResourceProduct.productId
|
|
500
|
+
],
|
|
501
|
+
references: [
|
|
502
|
+
product.id
|
|
503
|
+
],
|
|
504
|
+
relationName: "product"
|
|
505
|
+
}),
|
|
506
|
+
resource: one(contentResource, {
|
|
507
|
+
fields: [
|
|
508
|
+
contentResourceProduct.resourceId
|
|
509
|
+
],
|
|
510
|
+
references: [
|
|
511
|
+
contentResource.id
|
|
512
|
+
],
|
|
513
|
+
relationName: "resource"
|
|
514
|
+
})
|
|
515
|
+
}));
|
|
516
|
+
}
|
|
517
|
+
__name(getContentResourceProductRelationsSchema, "getContentResourceProductRelationsSchema");
|
|
518
|
+
|
|
519
|
+
// src/lib/mysql/schemas/content/content-resource-resource.ts
|
|
520
|
+
import { relations as relations7, sql as sql6 } from "drizzle-orm";
|
|
521
|
+
import { double as double2, index as index7, json as json6, primaryKey as primaryKey5, timestamp as timestamp7, varchar as varchar7 } from "drizzle-orm/mysql-core";
|
|
522
|
+
function getContentResourceResourceSchema(mysqlTable) {
|
|
523
|
+
return mysqlTable("ContentResourceResource", {
|
|
524
|
+
resourceOfId: varchar7("resourceOfId", {
|
|
525
|
+
length: 255
|
|
526
|
+
}).notNull(),
|
|
527
|
+
resourceId: varchar7("resourceId", {
|
|
528
|
+
length: 255
|
|
529
|
+
}).notNull(),
|
|
530
|
+
position: double2("position").notNull().default(0),
|
|
531
|
+
metadata: json6("metadata").$type().default({}),
|
|
532
|
+
organizationId: varchar7("organizationId", {
|
|
533
|
+
length: 191
|
|
534
|
+
}),
|
|
535
|
+
createdAt: timestamp7("createdAt", {
|
|
536
|
+
mode: "date",
|
|
537
|
+
fsp: 3
|
|
538
|
+
}).default(sql6`CURRENT_TIMESTAMP(3)`),
|
|
539
|
+
updatedAt: timestamp7("updatedAt", {
|
|
540
|
+
mode: "date",
|
|
541
|
+
fsp: 3
|
|
542
|
+
}).default(sql6`CURRENT_TIMESTAMP(3)`),
|
|
543
|
+
deletedAt: timestamp7("deletedAt", {
|
|
544
|
+
mode: "date",
|
|
545
|
+
fsp: 3
|
|
546
|
+
})
|
|
547
|
+
}, (crr) => ({
|
|
548
|
+
pk: primaryKey5({
|
|
549
|
+
columns: [
|
|
550
|
+
crr.resourceOfId,
|
|
551
|
+
crr.resourceId
|
|
552
|
+
]
|
|
553
|
+
}),
|
|
554
|
+
contentResourceIdIdx: index7("contentResourceId_idx").on(crr.resourceOfId),
|
|
555
|
+
resourceIdIdx: index7("resourceId_idx").on(crr.resourceId),
|
|
556
|
+
organizationIdIdx: index7("organizationId_idx").on(crr.organizationId)
|
|
557
|
+
}));
|
|
558
|
+
}
|
|
559
|
+
__name(getContentResourceResourceSchema, "getContentResourceResourceSchema");
|
|
560
|
+
function getContentResourceResourceRelationsSchema(mysqlTable) {
|
|
561
|
+
const contentResource = getContentResourceSchema(mysqlTable);
|
|
562
|
+
const contentResourceResource = getContentResourceResourceSchema(mysqlTable);
|
|
563
|
+
return relations7(contentResourceResource, ({ one }) => ({
|
|
564
|
+
resourceOf: one(contentResource, {
|
|
565
|
+
fields: [
|
|
566
|
+
contentResourceResource.resourceOfId
|
|
567
|
+
],
|
|
568
|
+
references: [
|
|
569
|
+
contentResource.id
|
|
570
|
+
],
|
|
571
|
+
relationName: "resourceOf"
|
|
572
|
+
}),
|
|
573
|
+
resource: one(contentResource, {
|
|
574
|
+
fields: [
|
|
575
|
+
contentResourceResource.resourceId
|
|
576
|
+
],
|
|
577
|
+
references: [
|
|
578
|
+
contentResource.id
|
|
579
|
+
],
|
|
580
|
+
relationName: "resource"
|
|
581
|
+
})
|
|
582
|
+
}));
|
|
583
|
+
}
|
|
584
|
+
__name(getContentResourceResourceRelationsSchema, "getContentResourceResourceRelationsSchema");
|
|
585
|
+
|
|
586
|
+
// src/lib/mysql/schemas/content/content-resource-tag.ts
|
|
587
|
+
import { relations as relations10, sql as sql9 } from "drizzle-orm";
|
|
588
|
+
import { double as double4, index as index10, primaryKey as primaryKey7, timestamp as timestamp10, varchar as varchar10 } from "drizzle-orm/mysql-core";
|
|
589
|
+
|
|
590
|
+
// src/lib/mysql/schemas/content/tag.ts
|
|
591
|
+
import { relations as relations9, sql as sql8 } from "drizzle-orm";
|
|
592
|
+
import { index as index9, json as json8, timestamp as timestamp9, varchar as varchar9 } from "drizzle-orm/mysql-core";
|
|
593
|
+
|
|
594
|
+
// src/lib/mysql/schemas/content/tag-tag.ts
|
|
595
|
+
import { relations as relations8, sql as sql7 } from "drizzle-orm";
|
|
596
|
+
import { double as double3, index as index8, json as json7, primaryKey as primaryKey6, timestamp as timestamp8, varchar as varchar8 } from "drizzle-orm/mysql-core";
|
|
597
|
+
function getTagTagSchema(mysqlTable) {
|
|
598
|
+
return mysqlTable("TagTag", {
|
|
599
|
+
parentTagId: varchar8("parentTagId", {
|
|
600
|
+
length: 255
|
|
601
|
+
}).notNull(),
|
|
602
|
+
childTagId: varchar8("childTagId", {
|
|
603
|
+
length: 255
|
|
604
|
+
}).notNull(),
|
|
605
|
+
position: double3("position").notNull().default(0),
|
|
606
|
+
metadata: json7("metadata").$type().default({}),
|
|
607
|
+
organizationId: varchar8("organizationId", {
|
|
608
|
+
length: 191
|
|
609
|
+
}),
|
|
610
|
+
createdAt: timestamp8("createdAt", {
|
|
611
|
+
mode: "date",
|
|
612
|
+
fsp: 3
|
|
613
|
+
}).default(sql7`CURRENT_TIMESTAMP(3)`),
|
|
614
|
+
updatedAt: timestamp8("updatedAt", {
|
|
615
|
+
mode: "date",
|
|
616
|
+
fsp: 3
|
|
617
|
+
}).default(sql7`CURRENT_TIMESTAMP(3)`),
|
|
618
|
+
deletedAt: timestamp8("deletedAt", {
|
|
619
|
+
mode: "date",
|
|
620
|
+
fsp: 3
|
|
621
|
+
})
|
|
622
|
+
}, (tt) => ({
|
|
623
|
+
pk: primaryKey6({
|
|
624
|
+
columns: [
|
|
625
|
+
tt.parentTagId,
|
|
626
|
+
tt.childTagId
|
|
627
|
+
]
|
|
628
|
+
}),
|
|
629
|
+
parentTagIdIdx: index8("parentTagId_idx").on(tt.parentTagId),
|
|
630
|
+
childTagIdIdx: index8("childTagId_idx").on(tt.childTagId),
|
|
631
|
+
positionIdx: index8("position_idx").on(tt.position),
|
|
632
|
+
organizationIdIdx: index8("organizationId_idx").on(tt.organizationId)
|
|
633
|
+
}));
|
|
634
|
+
}
|
|
635
|
+
__name(getTagTagSchema, "getTagTagSchema");
|
|
636
|
+
function getTagTagRelationsSchema(mysqlTable) {
|
|
637
|
+
const tag = getTagSchema(mysqlTable);
|
|
638
|
+
const tagTag = getTagTagSchema(mysqlTable);
|
|
639
|
+
return relations8(tagTag, ({ one }) => ({
|
|
640
|
+
parentTag: one(tag, {
|
|
641
|
+
fields: [
|
|
642
|
+
tagTag.parentTagId
|
|
643
|
+
],
|
|
644
|
+
references: [
|
|
645
|
+
tag.id
|
|
646
|
+
],
|
|
647
|
+
relationName: "parentTag"
|
|
648
|
+
}),
|
|
649
|
+
childTag: one(tag, {
|
|
650
|
+
fields: [
|
|
651
|
+
tagTag.childTagId
|
|
652
|
+
],
|
|
653
|
+
references: [
|
|
654
|
+
tag.id
|
|
655
|
+
],
|
|
656
|
+
relationName: "childTag"
|
|
657
|
+
})
|
|
658
|
+
}));
|
|
659
|
+
}
|
|
660
|
+
__name(getTagTagRelationsSchema, "getTagTagRelationsSchema");
|
|
661
|
+
|
|
662
|
+
// src/lib/mysql/schemas/content/tag.ts
|
|
663
|
+
function getTagSchema(mysqlTable) {
|
|
664
|
+
return mysqlTable("Tag", {
|
|
665
|
+
id: varchar9("id", {
|
|
666
|
+
length: 255
|
|
667
|
+
}).notNull().primaryKey(),
|
|
668
|
+
organizationId: varchar9("organizationId", {
|
|
669
|
+
length: 191
|
|
670
|
+
}),
|
|
671
|
+
type: varchar9("type", {
|
|
672
|
+
length: 255
|
|
673
|
+
}).notNull(),
|
|
674
|
+
fields: json8("fields").$type().default({}),
|
|
675
|
+
createdAt: timestamp9("createdAt", {
|
|
676
|
+
mode: "date",
|
|
677
|
+
fsp: 3
|
|
678
|
+
}).default(sql8`CURRENT_TIMESTAMP(3)`),
|
|
679
|
+
updatedAt: timestamp9("updatedAt", {
|
|
680
|
+
mode: "date",
|
|
681
|
+
fsp: 3
|
|
682
|
+
}).default(sql8`CURRENT_TIMESTAMP(3)`),
|
|
683
|
+
deletedAt: timestamp9("deletedAt", {
|
|
684
|
+
mode: "date",
|
|
685
|
+
fsp: 3
|
|
686
|
+
})
|
|
687
|
+
}, (t) => ({
|
|
688
|
+
typeIdx: index9("type_idx").on(t.type),
|
|
689
|
+
organizationIdIdx: index9("organizationId_idx").on(t.organizationId)
|
|
690
|
+
}));
|
|
691
|
+
}
|
|
692
|
+
__name(getTagSchema, "getTagSchema");
|
|
693
|
+
function getTagRelationsSchema(mysqlTable) {
|
|
694
|
+
const tag = getTagSchema(mysqlTable);
|
|
695
|
+
const contentResourceTag = getContentResourceTagSchema(mysqlTable);
|
|
696
|
+
const tagTag = getTagTagSchema(mysqlTable);
|
|
697
|
+
return relations9(tag, ({ many }) => ({
|
|
698
|
+
resources: many(contentResourceTag, {
|
|
699
|
+
relationName: "contentResource"
|
|
700
|
+
}),
|
|
701
|
+
parentTags: many(tagTag, {
|
|
702
|
+
relationName: "childTag"
|
|
703
|
+
}),
|
|
704
|
+
childTags: many(tagTag, {
|
|
705
|
+
relationName: "parentTag"
|
|
706
|
+
})
|
|
707
|
+
}));
|
|
708
|
+
}
|
|
709
|
+
__name(getTagRelationsSchema, "getTagRelationsSchema");
|
|
710
|
+
|
|
711
|
+
// src/lib/mysql/schemas/content/content-resource-tag.ts
|
|
712
|
+
function getContentResourceTagSchema(mysqlTable) {
|
|
713
|
+
return mysqlTable("ContentResourceTag", {
|
|
714
|
+
contentResourceId: varchar10("contentResourceId", {
|
|
715
|
+
length: 255
|
|
716
|
+
}).notNull(),
|
|
717
|
+
organizationId: varchar10("organizationId", {
|
|
718
|
+
length: 191
|
|
719
|
+
}),
|
|
720
|
+
tagId: varchar10("tagId", {
|
|
721
|
+
length: 255
|
|
722
|
+
}).notNull(),
|
|
723
|
+
position: double4("position").notNull().default(0),
|
|
724
|
+
createdAt: timestamp10("createdAt", {
|
|
725
|
+
mode: "date",
|
|
726
|
+
fsp: 3
|
|
727
|
+
}).default(sql9`CURRENT_TIMESTAMP(3)`),
|
|
728
|
+
updatedAt: timestamp10("updatedAt", {
|
|
729
|
+
mode: "date",
|
|
730
|
+
fsp: 3
|
|
731
|
+
}).default(sql9`CURRENT_TIMESTAMP(3)`)
|
|
732
|
+
}, (crt) => ({
|
|
733
|
+
pk: primaryKey7({
|
|
734
|
+
columns: [
|
|
735
|
+
crt.contentResourceId,
|
|
736
|
+
crt.tagId
|
|
737
|
+
]
|
|
738
|
+
}),
|
|
739
|
+
contentResourceIdIdx: index10("contentResourceId_idx").on(crt.contentResourceId),
|
|
740
|
+
tagIdIdx: index10("tagId_idx").on(crt.tagId),
|
|
741
|
+
positionIdx: index10("position_idx").on(crt.position),
|
|
742
|
+
organizationIdIdx: index10("organizationId_idx").on(crt.organizationId)
|
|
743
|
+
}));
|
|
744
|
+
}
|
|
745
|
+
__name(getContentResourceTagSchema, "getContentResourceTagSchema");
|
|
746
|
+
function getContentResourceTagRelationsSchema(mysqlTable) {
|
|
747
|
+
const contentResource = getContentResourceSchema(mysqlTable);
|
|
748
|
+
const tag = getTagSchema(mysqlTable);
|
|
749
|
+
const contentResourceTag = getContentResourceTagSchema(mysqlTable);
|
|
750
|
+
return relations10(contentResourceTag, ({ one }) => ({
|
|
751
|
+
contentResource: one(contentResource, {
|
|
752
|
+
fields: [
|
|
753
|
+
contentResourceTag.contentResourceId
|
|
754
|
+
],
|
|
755
|
+
references: [
|
|
756
|
+
contentResource.id
|
|
757
|
+
],
|
|
758
|
+
relationName: "contentResource"
|
|
759
|
+
}),
|
|
760
|
+
tag: one(tag, {
|
|
761
|
+
fields: [
|
|
762
|
+
contentResourceTag.tagId
|
|
763
|
+
],
|
|
764
|
+
references: [
|
|
765
|
+
tag.id
|
|
766
|
+
],
|
|
767
|
+
relationName: "tag"
|
|
768
|
+
})
|
|
769
|
+
}));
|
|
770
|
+
}
|
|
771
|
+
__name(getContentResourceTagRelationsSchema, "getContentResourceTagRelationsSchema");
|
|
772
|
+
|
|
773
|
+
// src/lib/mysql/schemas/content/content-resource-version.ts
|
|
774
|
+
import { relations as relations11, sql as sql10 } from "drizzle-orm";
|
|
775
|
+
import { index as index11, int as int3, json as json9, timestamp as timestamp11, unique, varchar as varchar11 } from "drizzle-orm/mysql-core";
|
|
776
|
+
function getContentResourceVersionSchema(mysqlTable) {
|
|
777
|
+
return mysqlTable("ContentResourceVersion", {
|
|
778
|
+
id: varchar11("id", {
|
|
779
|
+
length: 255
|
|
780
|
+
}).notNull().primaryKey(),
|
|
781
|
+
organizationId: varchar11("organizationId", {
|
|
782
|
+
length: 191
|
|
783
|
+
}),
|
|
784
|
+
resourceId: varchar11("resourceId", {
|
|
785
|
+
length: 255
|
|
786
|
+
}).notNull(),
|
|
787
|
+
parentVersionId: varchar11("parentVersionId", {
|
|
788
|
+
length: 255
|
|
789
|
+
}),
|
|
790
|
+
versionNumber: int3("versionNumber").notNull(),
|
|
791
|
+
fields: json9("fields").$type().default({}),
|
|
792
|
+
createdAt: timestamp11("createdAt", {
|
|
793
|
+
mode: "date",
|
|
794
|
+
fsp: 3
|
|
795
|
+
}).default(sql10`CURRENT_TIMESTAMP(3)`),
|
|
796
|
+
createdById: varchar11("createdById", {
|
|
797
|
+
length: 255
|
|
798
|
+
}).notNull()
|
|
799
|
+
}, (crv) => ({
|
|
800
|
+
resourceIdIdx: index11("resourceId_idx").on(crv.resourceId),
|
|
801
|
+
parentVersionIdIdx: index11("parentVersionId_idx").on(crv.parentVersionId),
|
|
802
|
+
resourceIdVersionNumberIdx: index11("resourceId_versionNumber_idx").on(crv.resourceId, crv.versionNumber),
|
|
803
|
+
uniqueResourceVersion: unique("uq_resource_version_number").on(crv.resourceId, crv.versionNumber),
|
|
804
|
+
organizationIdIdx: index11("organizationId_idx").on(crv.organizationId)
|
|
805
|
+
}));
|
|
806
|
+
}
|
|
807
|
+
__name(getContentResourceVersionSchema, "getContentResourceVersionSchema");
|
|
808
|
+
function getContentResourceVersionRelationsSchema(mysqlTable) {
|
|
809
|
+
const contentResourceVersion = getContentResourceVersionSchema(mysqlTable);
|
|
810
|
+
const contentResource = getContentResourceSchema(mysqlTable);
|
|
811
|
+
const users = getUsersSchema(mysqlTable);
|
|
812
|
+
return relations11(contentResourceVersion, ({ one }) => ({
|
|
813
|
+
resource: one(contentResource, {
|
|
814
|
+
fields: [
|
|
815
|
+
contentResourceVersion.resourceId
|
|
816
|
+
],
|
|
817
|
+
references: [
|
|
818
|
+
contentResource.id
|
|
819
|
+
],
|
|
820
|
+
relationName: "versions"
|
|
821
|
+
}),
|
|
822
|
+
parentVersion: one(contentResourceVersion, {
|
|
823
|
+
fields: [
|
|
824
|
+
contentResourceVersion.parentVersionId
|
|
825
|
+
],
|
|
826
|
+
references: [
|
|
827
|
+
contentResourceVersion.id
|
|
828
|
+
],
|
|
829
|
+
relationName: "childVersions"
|
|
830
|
+
}),
|
|
831
|
+
createdBy: one(users, {
|
|
832
|
+
fields: [
|
|
833
|
+
contentResourceVersion.createdById
|
|
834
|
+
],
|
|
835
|
+
references: [
|
|
836
|
+
users.id
|
|
837
|
+
],
|
|
838
|
+
relationName: "createdVersions"
|
|
839
|
+
})
|
|
840
|
+
}));
|
|
841
|
+
}
|
|
842
|
+
__name(getContentResourceVersionRelationsSchema, "getContentResourceVersionRelationsSchema");
|
|
843
|
+
|
|
844
|
+
// src/lib/mysql/schemas/content/content-resource.ts
|
|
845
|
+
function getContentResourceSchema(mysqlTable) {
|
|
846
|
+
return mysqlTable("ContentResource", {
|
|
847
|
+
id: varchar12("id", {
|
|
848
|
+
length: 255
|
|
849
|
+
}).notNull().primaryKey(),
|
|
850
|
+
organizationId: varchar12("organizationId", {
|
|
851
|
+
length: 191
|
|
852
|
+
}),
|
|
853
|
+
createdByOrganizationMembershipId: varchar12("createdByOrganizationMembershipId", {
|
|
854
|
+
length: 191
|
|
855
|
+
}),
|
|
856
|
+
type: varchar12("type", {
|
|
857
|
+
length: 255
|
|
858
|
+
}).notNull(),
|
|
859
|
+
createdById: varchar12("createdById", {
|
|
860
|
+
length: 255
|
|
861
|
+
}).notNull(),
|
|
862
|
+
fields: json10("fields").$type().default({}),
|
|
863
|
+
currentVersionId: varchar12("currentVersionId", {
|
|
864
|
+
length: 255
|
|
865
|
+
}),
|
|
866
|
+
createdAt: timestamp12("createdAt", {
|
|
867
|
+
mode: "date",
|
|
868
|
+
fsp: 3
|
|
869
|
+
}).default(sql11`CURRENT_TIMESTAMP(3)`),
|
|
870
|
+
updatedAt: timestamp12("updatedAt", {
|
|
871
|
+
mode: "date",
|
|
872
|
+
fsp: 3
|
|
873
|
+
}).default(sql11`CURRENT_TIMESTAMP(3)`),
|
|
874
|
+
deletedAt: timestamp12("deletedAt", {
|
|
875
|
+
mode: "date",
|
|
876
|
+
fsp: 3
|
|
877
|
+
})
|
|
878
|
+
}, (cm) => ({
|
|
879
|
+
typeIdx: index12("type_idx").on(cm.type),
|
|
880
|
+
createdByIdx: index12("createdById_idx").on(cm.createdById),
|
|
881
|
+
createdAtIdx: index12("createdAt_idx").on(cm.createdAt),
|
|
882
|
+
currentVersionIdIdx: index12("currentVersionId_idx").on(cm.currentVersionId),
|
|
883
|
+
createdByOrganizationMembershipIdIdx: index12("createdByOrganizationMembershipId_idx").on(cm.createdByOrganizationMembershipId)
|
|
884
|
+
}));
|
|
885
|
+
}
|
|
886
|
+
__name(getContentResourceSchema, "getContentResourceSchema");
|
|
887
|
+
function getContentResourceRelationsSchema(mysqlTable) {
|
|
888
|
+
const contentResource = getContentResourceSchema(mysqlTable);
|
|
889
|
+
const users = getUsersSchema(mysqlTable);
|
|
890
|
+
const contentResourceResource = getContentResourceResourceSchema(mysqlTable);
|
|
891
|
+
const contentResourceProduct = getContentResourceProductSchema(mysqlTable);
|
|
892
|
+
const contentContributions = getContentContributionsSchema(mysqlTable);
|
|
893
|
+
const contentResourceTag = getContentResourceTagSchema(mysqlTable);
|
|
894
|
+
const contentResourceVersion = getContentResourceVersionSchema(mysqlTable);
|
|
895
|
+
const organizationMemberships = getOrganizationMembershipsSchema(mysqlTable);
|
|
896
|
+
const tag = getTagSchema(mysqlTable);
|
|
897
|
+
return relations12(contentResource, ({ one, many }) => ({
|
|
898
|
+
createdBy: one(users, {
|
|
899
|
+
fields: [
|
|
900
|
+
contentResource.createdById
|
|
901
|
+
],
|
|
902
|
+
references: [
|
|
903
|
+
users.id
|
|
904
|
+
],
|
|
905
|
+
relationName: "creator"
|
|
906
|
+
}),
|
|
907
|
+
createdByOrganizationMembership: one(organizationMemberships, {
|
|
908
|
+
fields: [
|
|
909
|
+
contentResource.createdByOrganizationMembershipId
|
|
910
|
+
],
|
|
911
|
+
references: [
|
|
912
|
+
organizationMemberships.id
|
|
913
|
+
],
|
|
914
|
+
relationName: "createdByOrganizationMembership"
|
|
915
|
+
}),
|
|
916
|
+
tags: many(contentResourceTag, {
|
|
917
|
+
relationName: "contentResource"
|
|
918
|
+
}),
|
|
919
|
+
resources: many(contentResourceResource, {
|
|
920
|
+
relationName: "resourceOf"
|
|
921
|
+
}),
|
|
922
|
+
resourceOf: many(contentResourceResource, {
|
|
923
|
+
relationName: "resource"
|
|
924
|
+
}),
|
|
925
|
+
resourceProducts: many(contentResourceProduct, {
|
|
926
|
+
relationName: "resource"
|
|
927
|
+
}),
|
|
928
|
+
contributions: many(contentContributions, {
|
|
929
|
+
relationName: "contributions"
|
|
930
|
+
}),
|
|
931
|
+
currentVersion: one(contentResourceVersion, {
|
|
932
|
+
fields: [
|
|
933
|
+
contentResource.currentVersionId
|
|
934
|
+
],
|
|
935
|
+
references: [
|
|
936
|
+
contentResourceVersion.id
|
|
937
|
+
],
|
|
938
|
+
relationName: "currentVersionResource"
|
|
939
|
+
}),
|
|
940
|
+
versions: many(contentResourceVersion, {
|
|
941
|
+
relationName: "resource"
|
|
942
|
+
})
|
|
943
|
+
}));
|
|
944
|
+
}
|
|
945
|
+
__name(getContentResourceRelationsSchema, "getContentResourceRelationsSchema");
|
|
946
|
+
|
|
947
|
+
// src/lib/mysql/schemas/content/content-contributions.ts
|
|
948
|
+
function getContentContributionsSchema(mysqlTable) {
|
|
949
|
+
return mysqlTable("ContentContribution", {
|
|
950
|
+
id: varchar13("id", {
|
|
951
|
+
length: 255
|
|
952
|
+
}).notNull().primaryKey(),
|
|
953
|
+
userId: varchar13("userId", {
|
|
954
|
+
length: 255
|
|
955
|
+
}).notNull(),
|
|
956
|
+
organizationId: varchar13("organizationId", {
|
|
957
|
+
length: 191
|
|
958
|
+
}),
|
|
959
|
+
organizationMembershipId: varchar13("organizationMembershipId", {
|
|
960
|
+
length: 255
|
|
961
|
+
}),
|
|
962
|
+
contentId: varchar13("contentId", {
|
|
963
|
+
length: 255
|
|
964
|
+
}).notNull(),
|
|
965
|
+
contributionTypeId: varchar13("contributionTypeId", {
|
|
966
|
+
length: 255
|
|
967
|
+
}).notNull(),
|
|
968
|
+
active: boolean2("active").notNull().default(true),
|
|
969
|
+
createdAt: timestamp13("createdAt", {
|
|
970
|
+
mode: "date",
|
|
971
|
+
fsp: 3
|
|
972
|
+
}).defaultNow(),
|
|
973
|
+
updatedAt: timestamp13("updatedAt", {
|
|
974
|
+
mode: "date",
|
|
975
|
+
fsp: 3
|
|
976
|
+
}).defaultNow(),
|
|
977
|
+
deletedAt: timestamp13("deletedAt", {
|
|
978
|
+
mode: "date",
|
|
979
|
+
fsp: 3
|
|
980
|
+
})
|
|
981
|
+
}, (cc) => ({
|
|
982
|
+
userIdIdx: index13("userId_idx").on(cc.userId),
|
|
983
|
+
contentIdIdx: index13("contentId_idx").on(cc.contentId),
|
|
984
|
+
contributionTypeIdIdx: index13("contributionTypeId_idx").on(cc.contributionTypeId),
|
|
985
|
+
organizationMembershipIdIdx: index13("organizationMembershipId_idx").on(cc.organizationMembershipId)
|
|
986
|
+
}));
|
|
987
|
+
}
|
|
988
|
+
__name(getContentContributionsSchema, "getContentContributionsSchema");
|
|
989
|
+
function getContentContributionRelationsSchema(mysqlTable) {
|
|
990
|
+
const contentContributions = getContentContributionsSchema(mysqlTable);
|
|
991
|
+
const users = getUsersSchema(mysqlTable);
|
|
992
|
+
const contentResource = getContentResourceSchema(mysqlTable);
|
|
993
|
+
const contributionTypes = getContributionTypesSchema(mysqlTable);
|
|
994
|
+
const organizationMemberships = getOrganizationMembershipsSchema(mysqlTable);
|
|
995
|
+
return relations13(contentContributions, ({ one }) => ({
|
|
996
|
+
user: one(users, {
|
|
997
|
+
fields: [
|
|
998
|
+
contentContributions.userId
|
|
999
|
+
],
|
|
1000
|
+
references: [
|
|
1001
|
+
users.id
|
|
1002
|
+
],
|
|
1003
|
+
relationName: "user"
|
|
1004
|
+
}),
|
|
1005
|
+
content: one(contentResource, {
|
|
1006
|
+
fields: [
|
|
1007
|
+
contentContributions.contentId
|
|
1008
|
+
],
|
|
1009
|
+
references: [
|
|
1010
|
+
contentResource.id
|
|
1011
|
+
],
|
|
1012
|
+
relationName: "contributions"
|
|
1013
|
+
}),
|
|
1014
|
+
contributionType: one(contributionTypes, {
|
|
1015
|
+
fields: [
|
|
1016
|
+
contentContributions.contributionTypeId
|
|
1017
|
+
],
|
|
1018
|
+
references: [
|
|
1019
|
+
contributionTypes.id
|
|
1020
|
+
],
|
|
1021
|
+
relationName: "contributionType"
|
|
1022
|
+
}),
|
|
1023
|
+
organizationMembership: one(organizationMemberships, {
|
|
1024
|
+
fields: [
|
|
1025
|
+
contentContributions.organizationMembershipId
|
|
1026
|
+
],
|
|
1027
|
+
references: [
|
|
1028
|
+
organizationMemberships.id
|
|
1029
|
+
],
|
|
1030
|
+
relationName: "organizationMembership"
|
|
1031
|
+
})
|
|
1032
|
+
}));
|
|
1033
|
+
}
|
|
1034
|
+
__name(getContentContributionRelationsSchema, "getContentContributionRelationsSchema");
|
|
1035
|
+
|
|
1036
|
+
// src/lib/mysql/schemas/auth/accounts.ts
|
|
1037
|
+
import { relations as relations14 } from "drizzle-orm";
|
|
1038
|
+
import { index as index14, int as int4, primaryKey as primaryKey8, text as text2, varchar as varchar14 } from "drizzle-orm/mysql-core";
|
|
1039
|
+
function getAccountsSchema(mysqlTable) {
|
|
1040
|
+
return mysqlTable("Account", {
|
|
1041
|
+
userId: varchar14("userId", {
|
|
1042
|
+
length: 255
|
|
1043
|
+
}).notNull(),
|
|
1044
|
+
type: varchar14("type", {
|
|
1045
|
+
length: 255
|
|
1046
|
+
}).$type().notNull(),
|
|
1047
|
+
provider: varchar14("provider", {
|
|
1048
|
+
length: 255
|
|
1049
|
+
}).notNull(),
|
|
1050
|
+
providerAccountId: varchar14("providerAccountId", {
|
|
1051
|
+
length: 255
|
|
1052
|
+
}).notNull(),
|
|
1053
|
+
refresh_token: text2("refresh_token"),
|
|
1054
|
+
access_token: text2("access_token"),
|
|
1055
|
+
oauth_token: text2("oauth_token"),
|
|
1056
|
+
oauth_token_secret: text2("oauth_token_secret"),
|
|
1057
|
+
expires_at: int4("expires_at"),
|
|
1058
|
+
token_type: varchar14("token_type", {
|
|
1059
|
+
length: 255
|
|
1060
|
+
}),
|
|
1061
|
+
scope: varchar14("scope", {
|
|
1062
|
+
length: 255
|
|
1063
|
+
}),
|
|
1064
|
+
id_token: text2("id_token"),
|
|
1065
|
+
session_state: varchar14("session_state", {
|
|
1066
|
+
length: 255
|
|
1067
|
+
}),
|
|
1068
|
+
refresh_token_expires_in: int4("refresh_token_expires_in")
|
|
1069
|
+
}, (account) => ({
|
|
1070
|
+
pk: primaryKey8({
|
|
1071
|
+
columns: [
|
|
1072
|
+
account.provider,
|
|
1073
|
+
account.providerAccountId
|
|
1074
|
+
]
|
|
1075
|
+
}),
|
|
1076
|
+
userIdIdx: index14("userId_idx").on(account.userId)
|
|
1077
|
+
}));
|
|
1078
|
+
}
|
|
1079
|
+
__name(getAccountsSchema, "getAccountsSchema");
|
|
1080
|
+
function getAccountsRelationsSchema(mysqlTable) {
|
|
1081
|
+
const accounts = getAccountsSchema(mysqlTable);
|
|
1082
|
+
const users = getUsersSchema(mysqlTable);
|
|
1083
|
+
return relations14(accounts, ({ one }) => ({
|
|
1084
|
+
user: one(users, {
|
|
1085
|
+
fields: [
|
|
1086
|
+
accounts.userId
|
|
1087
|
+
],
|
|
1088
|
+
references: [
|
|
1089
|
+
users.id
|
|
1090
|
+
],
|
|
1091
|
+
relationName: "user"
|
|
1092
|
+
})
|
|
1093
|
+
}));
|
|
1094
|
+
}
|
|
1095
|
+
__name(getAccountsRelationsSchema, "getAccountsRelationsSchema");
|
|
1096
|
+
|
|
1097
|
+
// src/lib/mysql/schemas/auth/user-permissions.ts
|
|
1098
|
+
import { relations as relations15 } from "drizzle-orm";
|
|
1099
|
+
import { boolean as boolean3, index as index15, primaryKey as primaryKey9, timestamp as timestamp14, varchar as varchar15 } from "drizzle-orm/mysql-core";
|
|
1100
|
+
function getUserPermissionsSchema(mysqlTable) {
|
|
1101
|
+
return mysqlTable("UserPermission", {
|
|
1102
|
+
userId: varchar15("userId", {
|
|
1103
|
+
length: 255
|
|
1104
|
+
}).notNull(),
|
|
1105
|
+
organizationId: varchar15("organizationId", {
|
|
1106
|
+
length: 191
|
|
1107
|
+
}),
|
|
1108
|
+
permissionId: varchar15("permissionId", {
|
|
1109
|
+
length: 255
|
|
1110
|
+
}).notNull(),
|
|
1111
|
+
active: boolean3("active").notNull().default(true),
|
|
1112
|
+
createdAt: timestamp14("createdAt", {
|
|
1113
|
+
mode: "date",
|
|
1114
|
+
fsp: 3
|
|
1115
|
+
}).defaultNow(),
|
|
1116
|
+
updatedAt: timestamp14("updatedAt", {
|
|
1117
|
+
mode: "date",
|
|
1118
|
+
fsp: 3
|
|
1119
|
+
}).defaultNow(),
|
|
1120
|
+
deletedAt: timestamp14("deletedAt", {
|
|
1121
|
+
mode: "date",
|
|
1122
|
+
fsp: 3
|
|
1123
|
+
})
|
|
1124
|
+
}, (up) => ({
|
|
1125
|
+
pk: primaryKey9({
|
|
1126
|
+
columns: [
|
|
1127
|
+
up.userId,
|
|
1128
|
+
up.permissionId
|
|
1129
|
+
]
|
|
1130
|
+
}),
|
|
1131
|
+
userIdIdx: index15("userId_idx").on(up.userId),
|
|
1132
|
+
permissionIdIdx: index15("permissionId_idx").on(up.permissionId),
|
|
1133
|
+
organizationIdIdx: index15("organizationId_idx").on(up.organizationId)
|
|
1134
|
+
}));
|
|
1135
|
+
}
|
|
1136
|
+
__name(getUserPermissionsSchema, "getUserPermissionsSchema");
|
|
1137
|
+
function getUserPermissionsRelationsSchema(mysqlTable) {
|
|
1138
|
+
const userPermissions = getUserPermissionsSchema(mysqlTable);
|
|
1139
|
+
const users = getUsersSchema(mysqlTable);
|
|
1140
|
+
const permissions = getPermissionsSchema(mysqlTable);
|
|
1141
|
+
return relations15(userPermissions, ({ one }) => ({
|
|
1142
|
+
user: one(users, {
|
|
1143
|
+
fields: [
|
|
1144
|
+
userPermissions.userId
|
|
1145
|
+
],
|
|
1146
|
+
references: [
|
|
1147
|
+
users.id
|
|
1148
|
+
],
|
|
1149
|
+
relationName: "user"
|
|
1150
|
+
}),
|
|
1151
|
+
permission: one(permissions, {
|
|
1152
|
+
fields: [
|
|
1153
|
+
userPermissions.permissionId
|
|
1154
|
+
],
|
|
1155
|
+
references: [
|
|
1156
|
+
permissions.id
|
|
1157
|
+
],
|
|
1158
|
+
relationName: "permission"
|
|
1159
|
+
})
|
|
1160
|
+
}));
|
|
1161
|
+
}
|
|
1162
|
+
__name(getUserPermissionsRelationsSchema, "getUserPermissionsRelationsSchema");
|
|
1163
|
+
|
|
1164
|
+
// src/lib/mysql/schemas/auth/user-prefs.ts
|
|
1165
|
+
import { relations as relations16, sql as sql12 } from "drizzle-orm";
|
|
1166
|
+
import { index as index16, json as json11, primaryKey as primaryKey10, timestamp as timestamp15, varchar as varchar16 } from "drizzle-orm/mysql-core";
|
|
1167
|
+
function getUserPrefsSchema(mysqlTable) {
|
|
1168
|
+
return mysqlTable("UserPrefs", {
|
|
1169
|
+
id: varchar16("id", {
|
|
1170
|
+
length: 191
|
|
1171
|
+
}).notNull(),
|
|
1172
|
+
organizationId: varchar16("organizationId", {
|
|
1173
|
+
length: 191
|
|
1174
|
+
}),
|
|
1175
|
+
type: varchar16("type", {
|
|
1176
|
+
length: 191
|
|
1177
|
+
}).default("Global").notNull(),
|
|
1178
|
+
userId: varchar16("userId", {
|
|
1179
|
+
length: 255
|
|
1180
|
+
}).notNull(),
|
|
1181
|
+
fields: json11("fields").$type().default({}),
|
|
1182
|
+
createdAt: timestamp15("createdAt", {
|
|
1183
|
+
mode: "date",
|
|
1184
|
+
fsp: 3
|
|
1185
|
+
}).default(sql12`CURRENT_TIMESTAMP(3)`),
|
|
1186
|
+
updatedAt: timestamp15("updatedAt", {
|
|
1187
|
+
mode: "date",
|
|
1188
|
+
fsp: 3
|
|
1189
|
+
}).default(sql12`CURRENT_TIMESTAMP(3)`),
|
|
1190
|
+
deletedAt: timestamp15("deletedAt", {
|
|
1191
|
+
mode: "date",
|
|
1192
|
+
fsp: 3
|
|
1193
|
+
})
|
|
1194
|
+
}, (crr) => ({
|
|
1195
|
+
pk: primaryKey10({
|
|
1196
|
+
columns: [
|
|
1197
|
+
crr.id
|
|
1198
|
+
]
|
|
1199
|
+
}),
|
|
1200
|
+
crrUserIdIdKey: index16("crr_userIdId_idx").on(crr.userId),
|
|
1201
|
+
organizationIdIdx: index16("organizationId_idx").on(crr.organizationId)
|
|
1202
|
+
}));
|
|
1203
|
+
}
|
|
1204
|
+
__name(getUserPrefsSchema, "getUserPrefsSchema");
|
|
1205
|
+
function getUserPrefsRelationsSchema(mysqlTable) {
|
|
1206
|
+
const userPrefs = getUserPrefsSchema(mysqlTable);
|
|
1207
|
+
const user = getUsersSchema(mysqlTable);
|
|
1208
|
+
return relations16(userPrefs, ({ one }) => ({
|
|
1209
|
+
user: one(user, {
|
|
1210
|
+
fields: [
|
|
1211
|
+
userPrefs.userId
|
|
1212
|
+
],
|
|
1213
|
+
references: [
|
|
1214
|
+
user.id
|
|
1215
|
+
],
|
|
1216
|
+
relationName: "user"
|
|
1217
|
+
})
|
|
1218
|
+
}));
|
|
1219
|
+
}
|
|
1220
|
+
__name(getUserPrefsRelationsSchema, "getUserPrefsRelationsSchema");
|
|
1221
|
+
|
|
1222
|
+
// src/lib/mysql/schemas/auth/user-roles.ts
|
|
1223
|
+
import { relations as relations18 } from "drizzle-orm";
|
|
1224
|
+
import { boolean as boolean5, index as index18, primaryKey as primaryKey11, timestamp as timestamp17, varchar as varchar18 } from "drizzle-orm/mysql-core";
|
|
1225
|
+
|
|
1226
|
+
// src/lib/mysql/schemas/auth/roles.ts
|
|
1227
|
+
import { relations as relations17 } from "drizzle-orm";
|
|
1228
|
+
import { boolean as boolean4, index as index17, text as text3, timestamp as timestamp16, varchar as varchar17 } from "drizzle-orm/mysql-core";
|
|
1229
|
+
function getRolesSchema(mysqlTable) {
|
|
1230
|
+
return mysqlTable("Role", {
|
|
1231
|
+
id: varchar17("id", {
|
|
1232
|
+
length: 255
|
|
1233
|
+
}).notNull().primaryKey(),
|
|
1234
|
+
organizationId: varchar17("organizationId", {
|
|
1235
|
+
length: 191
|
|
1236
|
+
}),
|
|
1237
|
+
name: varchar17("name", {
|
|
1238
|
+
length: 255
|
|
1239
|
+
}).notNull().unique(),
|
|
1240
|
+
description: text3("description"),
|
|
1241
|
+
active: boolean4("active").notNull().default(true),
|
|
1242
|
+
createdAt: timestamp16("createdAt", {
|
|
1243
|
+
mode: "date",
|
|
1244
|
+
fsp: 3
|
|
1245
|
+
}).defaultNow(),
|
|
1246
|
+
updatedAt: timestamp16("updatedAt", {
|
|
1247
|
+
mode: "date",
|
|
1248
|
+
fsp: 3
|
|
1249
|
+
}).defaultNow(),
|
|
1250
|
+
deletedAt: timestamp16("deletedAt", {
|
|
1251
|
+
mode: "date",
|
|
1252
|
+
fsp: 3
|
|
1253
|
+
})
|
|
1254
|
+
}, (role) => ({
|
|
1255
|
+
nameIdx: index17("name_idx").on(role.name),
|
|
1256
|
+
organizationIdIdx: index17("organizationId_idx").on(role.organizationId)
|
|
1257
|
+
}));
|
|
1258
|
+
}
|
|
1259
|
+
__name(getRolesSchema, "getRolesSchema");
|
|
1260
|
+
function getRolesRelationsSchema(mysqlTable) {
|
|
1261
|
+
const roles = getRolesSchema(mysqlTable);
|
|
1262
|
+
const userRoles = getUserRolesSchema(mysqlTable);
|
|
1263
|
+
return relations17(roles, ({ many }) => ({
|
|
1264
|
+
userRoles: many(userRoles, {
|
|
1265
|
+
relationName: "role"
|
|
1266
|
+
})
|
|
1267
|
+
}));
|
|
1268
|
+
}
|
|
1269
|
+
__name(getRolesRelationsSchema, "getRolesRelationsSchema");
|
|
1270
|
+
|
|
1271
|
+
// src/lib/mysql/schemas/auth/user-roles.ts
|
|
1272
|
+
function getUserRolesSchema(mysqlTable) {
|
|
1273
|
+
return mysqlTable("UserRole", {
|
|
1274
|
+
userId: varchar18("userId", {
|
|
1275
|
+
length: 255
|
|
1276
|
+
}).notNull(),
|
|
1277
|
+
roleId: varchar18("roleId", {
|
|
1278
|
+
length: 255
|
|
1279
|
+
}).notNull(),
|
|
1280
|
+
active: boolean5("active").notNull().default(true),
|
|
1281
|
+
organizationId: varchar18("organizationId", {
|
|
1282
|
+
length: 191
|
|
1283
|
+
}),
|
|
1284
|
+
createdAt: timestamp17("createdAt", {
|
|
1285
|
+
mode: "date",
|
|
1286
|
+
fsp: 3
|
|
1287
|
+
}).defaultNow(),
|
|
1288
|
+
updatedAt: timestamp17("updatedAt", {
|
|
1289
|
+
mode: "date",
|
|
1290
|
+
fsp: 3
|
|
1291
|
+
}).defaultNow(),
|
|
1292
|
+
deletedAt: timestamp17("deletedAt", {
|
|
1293
|
+
mode: "date",
|
|
1294
|
+
fsp: 3
|
|
1295
|
+
})
|
|
1296
|
+
}, (ur) => ({
|
|
1297
|
+
pk: primaryKey11({
|
|
1298
|
+
columns: [
|
|
1299
|
+
ur.userId,
|
|
1300
|
+
ur.roleId
|
|
1301
|
+
]
|
|
1302
|
+
}),
|
|
1303
|
+
userIdIdx: index18("userId_idx").on(ur.userId),
|
|
1304
|
+
roleIdIdx: index18("roleId_idx").on(ur.roleId),
|
|
1305
|
+
organizationIdIdx: index18("organizationId_idx").on(ur.organizationId)
|
|
1306
|
+
}));
|
|
1307
|
+
}
|
|
1308
|
+
__name(getUserRolesSchema, "getUserRolesSchema");
|
|
1309
|
+
function getUserRolesRelationsSchema(mysqlTable) {
|
|
1310
|
+
const userRoles = getUserRolesSchema(mysqlTable);
|
|
1311
|
+
const users = getUsersSchema(mysqlTable);
|
|
1312
|
+
const roles = getRolesSchema(mysqlTable);
|
|
1313
|
+
return relations18(userRoles, ({ one }) => ({
|
|
1314
|
+
user: one(users, {
|
|
1315
|
+
fields: [
|
|
1316
|
+
userRoles.userId
|
|
1317
|
+
],
|
|
1318
|
+
references: [
|
|
1319
|
+
users.id
|
|
1320
|
+
],
|
|
1321
|
+
relationName: "user"
|
|
1322
|
+
}),
|
|
1323
|
+
role: one(roles, {
|
|
1324
|
+
fields: [
|
|
1325
|
+
userRoles.roleId
|
|
1326
|
+
],
|
|
1327
|
+
references: [
|
|
1328
|
+
roles.id
|
|
1329
|
+
],
|
|
1330
|
+
relationName: "role"
|
|
1331
|
+
})
|
|
1332
|
+
}));
|
|
1333
|
+
}
|
|
1334
|
+
__name(getUserRolesRelationsSchema, "getUserRolesRelationsSchema");
|
|
1335
|
+
|
|
1336
|
+
// src/lib/mysql/schemas/auth/users.ts
|
|
1337
|
+
function getUsersSchema(mysqlTable) {
|
|
1338
|
+
return mysqlTable("User", {
|
|
1339
|
+
id: varchar19("id", {
|
|
1340
|
+
length: 255
|
|
1341
|
+
}).notNull().primaryKey(),
|
|
1342
|
+
name: varchar19("name", {
|
|
1343
|
+
length: 255
|
|
1344
|
+
}),
|
|
1345
|
+
role: varchar19("role", {
|
|
1346
|
+
length: 191
|
|
1347
|
+
}).notNull().default("user"),
|
|
1348
|
+
email: varchar19("email", {
|
|
1349
|
+
length: 255
|
|
1350
|
+
}).notNull().unique(),
|
|
1351
|
+
fields: json12("fields").$type().default({}),
|
|
1352
|
+
emailVerified: timestamp18("emailVerified", {
|
|
1353
|
+
mode: "date",
|
|
1354
|
+
fsp: 3
|
|
1355
|
+
}),
|
|
1356
|
+
image: varchar19("image", {
|
|
1357
|
+
length: 255
|
|
1358
|
+
}),
|
|
1359
|
+
createdAt: timestamp18("createdAt", {
|
|
1360
|
+
mode: "date",
|
|
1361
|
+
fsp: 3
|
|
1362
|
+
}).default(sql13`CURRENT_TIMESTAMP(3)`)
|
|
1363
|
+
}, (user) => ({
|
|
1364
|
+
emailIdx: index19("email_idx").on(user.email),
|
|
1365
|
+
roleIdx: index19("role_idx").on(user.role),
|
|
1366
|
+
createdAtIdx: index19("created_at_idx").on(user.createdAt)
|
|
1367
|
+
}));
|
|
1368
|
+
}
|
|
1369
|
+
__name(getUsersSchema, "getUsersSchema");
|
|
1370
|
+
function getUsersRelationsSchema(mysqlTable) {
|
|
1371
|
+
const users = getUsersSchema(mysqlTable);
|
|
1372
|
+
const accounts = getAccountsSchema(mysqlTable);
|
|
1373
|
+
const communicationPreferences = getCommunicationPreferencesSchema(mysqlTable);
|
|
1374
|
+
const userRoles = getUserRolesSchema(mysqlTable);
|
|
1375
|
+
const userPermissions = getUserPermissionsSchema(mysqlTable);
|
|
1376
|
+
const contentContributions = getContentContributionsSchema(mysqlTable);
|
|
1377
|
+
const contentResource = getContentResourceSchema(mysqlTable);
|
|
1378
|
+
const purchases = getPurchaseSchema(mysqlTable);
|
|
1379
|
+
const comments = getCommentsSchema(mysqlTable);
|
|
1380
|
+
const userPrefs = getUserPrefsSchema(mysqlTable);
|
|
1381
|
+
const organizationMemberships = getOrganizationMembershipsSchema(mysqlTable);
|
|
1382
|
+
return relations19(users, ({ many }) => ({
|
|
1383
|
+
accounts: many(accounts, {
|
|
1384
|
+
relationName: "user"
|
|
1385
|
+
}),
|
|
1386
|
+
purchases: many(purchases, {
|
|
1387
|
+
relationName: "user"
|
|
1388
|
+
}),
|
|
1389
|
+
communicationPreferences: many(communicationPreferences, {
|
|
1390
|
+
relationName: "user"
|
|
1391
|
+
}),
|
|
1392
|
+
roles: many(userRoles, {
|
|
1393
|
+
relationName: "user"
|
|
1394
|
+
}),
|
|
1395
|
+
userPermissions: many(userPermissions, {
|
|
1396
|
+
relationName: "user"
|
|
1397
|
+
}),
|
|
1398
|
+
contributions: many(contentContributions, {
|
|
1399
|
+
relationName: "user"
|
|
1400
|
+
}),
|
|
1401
|
+
createdContent: many(contentResource, {
|
|
1402
|
+
relationName: "user"
|
|
1403
|
+
}),
|
|
1404
|
+
comments: many(comments, {
|
|
1405
|
+
relationName: "user"
|
|
1406
|
+
}),
|
|
1407
|
+
prefs: many(userPrefs, {
|
|
1408
|
+
relationName: "user"
|
|
1409
|
+
}),
|
|
1410
|
+
organizationMemberships: many(organizationMemberships, {
|
|
1411
|
+
relationName: "user"
|
|
1412
|
+
})
|
|
1413
|
+
}));
|
|
1414
|
+
}
|
|
1415
|
+
__name(getUsersRelationsSchema, "getUsersRelationsSchema");
|
|
1416
|
+
|
|
1417
|
+
// src/lib/mysql/schemas/commerce/coupon.ts
|
|
1418
|
+
import { relations as relations20, sql as sql14 } from "drizzle-orm";
|
|
1419
|
+
import { boolean as boolean6, decimal as decimal2, index as index20, int as int5, json as json13, primaryKey as primaryKey12, timestamp as timestamp19, unique as unique2, varchar as varchar20 } from "drizzle-orm/mysql-core";
|
|
1420
|
+
function getCouponSchema(mysqlTable) {
|
|
1421
|
+
return mysqlTable("Coupon", {
|
|
1422
|
+
id: varchar20("id", {
|
|
1423
|
+
length: 191
|
|
1424
|
+
}).notNull(),
|
|
1425
|
+
organizationId: varchar20("organizationId", {
|
|
1426
|
+
length: 191
|
|
1427
|
+
}),
|
|
1428
|
+
code: varchar20("code", {
|
|
1429
|
+
length: 191
|
|
1430
|
+
}),
|
|
1431
|
+
createdAt: timestamp19("createdAt", {
|
|
1432
|
+
mode: "date",
|
|
1433
|
+
fsp: 3
|
|
1434
|
+
}).default(sql14`CURRENT_TIMESTAMP(3)`).notNull(),
|
|
1435
|
+
expires: timestamp19("expires", {
|
|
1436
|
+
mode: "date",
|
|
1437
|
+
fsp: 3
|
|
1438
|
+
}),
|
|
1439
|
+
fields: json13("fields").$type().default({}),
|
|
1440
|
+
maxUses: int5("maxUses").default(-1).notNull(),
|
|
1441
|
+
default: boolean6("default").default(false).notNull(),
|
|
1442
|
+
merchantCouponId: varchar20("merchantCouponId", {
|
|
1443
|
+
length: 191
|
|
1444
|
+
}),
|
|
1445
|
+
status: int5("status").default(0).notNull(),
|
|
1446
|
+
usedCount: int5("usedCount").default(0).notNull(),
|
|
1447
|
+
percentageDiscount: decimal2("percentageDiscount", {
|
|
1448
|
+
precision: 3,
|
|
1449
|
+
scale: 2
|
|
1450
|
+
}).notNull(),
|
|
1451
|
+
restrictedToProductId: varchar20("restrictedToProductId", {
|
|
1452
|
+
length: 191
|
|
1453
|
+
})
|
|
1454
|
+
}, (table) => {
|
|
1455
|
+
return {
|
|
1456
|
+
couponIdCodeIndex: index20("Coupon_id_code_index").on(table.id, table.code),
|
|
1457
|
+
couponId: primaryKey12({
|
|
1458
|
+
columns: [
|
|
1459
|
+
table.id
|
|
1460
|
+
],
|
|
1461
|
+
name: "Coupon_id"
|
|
1462
|
+
}),
|
|
1463
|
+
couponCodeKey: unique2("Coupon_code_key").on(table.code),
|
|
1464
|
+
organizationIdIdx: index20("organizationId_idx").on(table.organizationId)
|
|
1465
|
+
};
|
|
1466
|
+
});
|
|
1467
|
+
}
|
|
1468
|
+
__name(getCouponSchema, "getCouponSchema");
|
|
1469
|
+
function getCouponRelationsSchema(mysqlTable) {
|
|
1470
|
+
const purchase = getPurchaseSchema(mysqlTable);
|
|
1471
|
+
const coupon = getCouponSchema(mysqlTable);
|
|
1472
|
+
const merchantCoupon = getMerchantCouponSchema(mysqlTable);
|
|
1473
|
+
return relations20(coupon, ({ many, one }) => ({
|
|
1474
|
+
redeemedBulkCouponPurchases: many(purchase, {
|
|
1475
|
+
relationName: "redeemedBulkCoupon"
|
|
1476
|
+
}),
|
|
1477
|
+
merchantCoupon: one(merchantCoupon, {
|
|
1478
|
+
fields: [
|
|
1479
|
+
coupon.merchantCouponId
|
|
1480
|
+
],
|
|
1481
|
+
references: [
|
|
1482
|
+
merchantCoupon.id
|
|
1483
|
+
],
|
|
1484
|
+
relationName: "merchantCoupon"
|
|
1485
|
+
}),
|
|
1486
|
+
product: one(getProductSchema(mysqlTable), {
|
|
1487
|
+
fields: [
|
|
1488
|
+
coupon.restrictedToProductId
|
|
1489
|
+
],
|
|
1490
|
+
references: [
|
|
1491
|
+
getProductSchema(mysqlTable).id
|
|
1492
|
+
],
|
|
1493
|
+
relationName: "product"
|
|
1494
|
+
}),
|
|
1495
|
+
bulkPurchases: many(purchase, {
|
|
1496
|
+
relationName: "bulkCoupon"
|
|
1497
|
+
})
|
|
1498
|
+
}));
|
|
1499
|
+
}
|
|
1500
|
+
__name(getCouponRelationsSchema, "getCouponRelationsSchema");
|
|
1501
|
+
|
|
1502
|
+
// src/lib/mysql/schemas/commerce/purchase.ts
|
|
1503
|
+
function getPurchaseSchema(mysqlTable) {
|
|
1504
|
+
return mysqlTable("Purchase", {
|
|
1505
|
+
id: varchar21("id", {
|
|
1506
|
+
length: 191
|
|
1507
|
+
}).notNull(),
|
|
1508
|
+
userId: varchar21("userId", {
|
|
1509
|
+
length: 191
|
|
1510
|
+
}),
|
|
1511
|
+
purchasedByorganizationMembershipId: varchar21("organizationMembershipId", {
|
|
1512
|
+
length: 191
|
|
1513
|
+
}),
|
|
1514
|
+
organizationId: varchar21("organizationId", {
|
|
1515
|
+
length: 191
|
|
1516
|
+
}),
|
|
1517
|
+
createdAt: timestamp20("createdAt", {
|
|
1518
|
+
mode: "date",
|
|
1519
|
+
fsp: 3
|
|
1520
|
+
}).default(sql15`CURRENT_TIMESTAMP(3)`).notNull(),
|
|
1521
|
+
totalAmount: decimal3("totalAmount", {
|
|
1522
|
+
precision: 65,
|
|
1523
|
+
scale: 30
|
|
1524
|
+
}).notNull(),
|
|
1525
|
+
ipAddress: varchar21("ip_address", {
|
|
1526
|
+
length: 191
|
|
1527
|
+
}),
|
|
1528
|
+
city: varchar21("city", {
|
|
1529
|
+
length: 191
|
|
1530
|
+
}),
|
|
1531
|
+
state: varchar21("state", {
|
|
1532
|
+
length: 191
|
|
1533
|
+
}),
|
|
1534
|
+
country: varchar21("country", {
|
|
1535
|
+
length: 191
|
|
1536
|
+
}),
|
|
1537
|
+
couponId: varchar21("couponId", {
|
|
1538
|
+
length: 191
|
|
1539
|
+
}),
|
|
1540
|
+
productId: varchar21("productId", {
|
|
1541
|
+
length: 191
|
|
1542
|
+
}).notNull(),
|
|
1543
|
+
merchantChargeId: varchar21("merchantChargeId", {
|
|
1544
|
+
length: 191
|
|
1545
|
+
}),
|
|
1546
|
+
upgradedFromId: varchar21("upgradedFromId", {
|
|
1547
|
+
length: 191
|
|
1548
|
+
}),
|
|
1549
|
+
status: varchar21("status", {
|
|
1550
|
+
length: 191
|
|
1551
|
+
}).default("Valid").notNull(),
|
|
1552
|
+
bulkCouponId: varchar21("bulkCouponId", {
|
|
1553
|
+
length: 191
|
|
1554
|
+
}),
|
|
1555
|
+
merchantSessionId: varchar21("merchantSessionId", {
|
|
1556
|
+
length: 191
|
|
1557
|
+
}),
|
|
1558
|
+
redeemedBulkCouponId: varchar21("redeemedBulkCouponId", {
|
|
1559
|
+
length: 191
|
|
1560
|
+
}),
|
|
1561
|
+
fields: json14("fields").$type().default({})
|
|
1562
|
+
}, (table) => {
|
|
1563
|
+
return {
|
|
1564
|
+
purchaseId: primaryKey13({
|
|
1565
|
+
columns: [
|
|
1566
|
+
table.id
|
|
1567
|
+
],
|
|
1568
|
+
name: "Purchase_id"
|
|
1569
|
+
}),
|
|
1570
|
+
merchantChargeIdIdx: index21("idx_Purchase_on_merchantChargeId").on(table.merchantChargeId),
|
|
1571
|
+
purchaseUpgradedFromIdKey: unique3("Purchase_upgradedFromId_key").on(table.upgradedFromId),
|
|
1572
|
+
organizationIdIdx: index21("organizationId_idx").on(table.organizationId),
|
|
1573
|
+
organizationMembershipIdIdx: index21("organizationMembershipId_idx").on(table.purchasedByorganizationMembershipId)
|
|
1574
|
+
};
|
|
1575
|
+
});
|
|
1576
|
+
}
|
|
1577
|
+
__name(getPurchaseSchema, "getPurchaseSchema");
|
|
1578
|
+
function getPurchaseRelationsSchema(mysqlTable) {
|
|
1579
|
+
const purchases = getPurchaseSchema(mysqlTable);
|
|
1580
|
+
const users = getUsersSchema(mysqlTable);
|
|
1581
|
+
const products = getProductSchema(mysqlTable);
|
|
1582
|
+
const merchantCharges = getMerchantChargeSchema(mysqlTable);
|
|
1583
|
+
const merchantSessions = getMerchantSessionSchema(mysqlTable);
|
|
1584
|
+
const coupons = getCouponSchema(mysqlTable);
|
|
1585
|
+
const organizations = getOrganizationsSchema(mysqlTable);
|
|
1586
|
+
const organizationMemberships = getOrganizationMembershipsSchema(mysqlTable);
|
|
1587
|
+
return relations21(purchases, ({ many, one }) => ({
|
|
1588
|
+
redeemedBulkCoupon: one(coupons, {
|
|
1589
|
+
fields: [
|
|
1590
|
+
purchases.redeemedBulkCouponId
|
|
1591
|
+
],
|
|
1592
|
+
references: [
|
|
1593
|
+
coupons.id
|
|
1594
|
+
],
|
|
1595
|
+
relationName: "redeemedBulkCoupon"
|
|
1596
|
+
}),
|
|
1597
|
+
user: one(users, {
|
|
1598
|
+
fields: [
|
|
1599
|
+
purchases.userId
|
|
1600
|
+
],
|
|
1601
|
+
references: [
|
|
1602
|
+
users.id
|
|
1603
|
+
],
|
|
1604
|
+
relationName: "user"
|
|
1605
|
+
}),
|
|
1606
|
+
organization: one(organizations, {
|
|
1607
|
+
fields: [
|
|
1608
|
+
purchases.organizationId
|
|
1609
|
+
],
|
|
1610
|
+
references: [
|
|
1611
|
+
organizations.id
|
|
1612
|
+
],
|
|
1613
|
+
relationName: "organization"
|
|
1614
|
+
}),
|
|
1615
|
+
purchasedBy: one(organizationMemberships, {
|
|
1616
|
+
fields: [
|
|
1617
|
+
purchases.purchasedByorganizationMembershipId
|
|
1618
|
+
],
|
|
1619
|
+
references: [
|
|
1620
|
+
organizationMemberships.id
|
|
1621
|
+
],
|
|
1622
|
+
relationName: "organizationMembership"
|
|
1623
|
+
}),
|
|
1624
|
+
product: one(products, {
|
|
1625
|
+
fields: [
|
|
1626
|
+
purchases.productId
|
|
1627
|
+
],
|
|
1628
|
+
references: [
|
|
1629
|
+
products.id
|
|
1630
|
+
],
|
|
1631
|
+
relationName: "product"
|
|
1632
|
+
}),
|
|
1633
|
+
bulkCoupon: one(coupons, {
|
|
1634
|
+
fields: [
|
|
1635
|
+
purchases.bulkCouponId
|
|
1636
|
+
],
|
|
1637
|
+
references: [
|
|
1638
|
+
coupons.id
|
|
1639
|
+
],
|
|
1640
|
+
relationName: "bulkCoupon"
|
|
1641
|
+
}),
|
|
1642
|
+
merchantCharge: one(merchantCharges, {
|
|
1643
|
+
fields: [
|
|
1644
|
+
purchases.merchantChargeId
|
|
1645
|
+
],
|
|
1646
|
+
references: [
|
|
1647
|
+
merchantCharges.id
|
|
1648
|
+
],
|
|
1649
|
+
relationName: "merchantCharge"
|
|
1650
|
+
}),
|
|
1651
|
+
merchantSession: one(merchantSessions, {
|
|
1652
|
+
fields: [
|
|
1653
|
+
purchases.merchantSessionId
|
|
1654
|
+
],
|
|
1655
|
+
references: [
|
|
1656
|
+
merchantSessions.id
|
|
1657
|
+
],
|
|
1658
|
+
relationName: "merchantSession"
|
|
1659
|
+
})
|
|
1660
|
+
}));
|
|
1661
|
+
}
|
|
1662
|
+
__name(getPurchaseRelationsSchema, "getPurchaseRelationsSchema");
|
|
1663
|
+
|
|
1664
|
+
// src/lib/mysql/schemas/org/organizations.ts
|
|
1665
|
+
function getOrganizationsSchema(mysqlTable) {
|
|
1666
|
+
return mysqlTable("Organization", {
|
|
1667
|
+
id: varchar22("id", {
|
|
1668
|
+
length: 255
|
|
1669
|
+
}).notNull().primaryKey(),
|
|
1670
|
+
name: varchar22("name", {
|
|
1671
|
+
length: 255
|
|
1672
|
+
}),
|
|
1673
|
+
fields: json15("fields").$type().default({}),
|
|
1674
|
+
image: varchar22("image", {
|
|
1675
|
+
length: 255
|
|
1676
|
+
}),
|
|
1677
|
+
createdAt: timestamp21("createdAt", {
|
|
1678
|
+
mode: "date",
|
|
1679
|
+
fsp: 3
|
|
1680
|
+
}).default(sql16`CURRENT_TIMESTAMP(3)`)
|
|
1681
|
+
}, (organization) => ({
|
|
1682
|
+
createdAtIdx: index22("created_at_idx").on(organization.createdAt)
|
|
1683
|
+
}));
|
|
1684
|
+
}
|
|
1685
|
+
__name(getOrganizationsSchema, "getOrganizationsSchema");
|
|
1686
|
+
function getOrganizationsRelationsSchema(mysqlTable) {
|
|
1687
|
+
const organizations = getOrganizationsSchema(mysqlTable);
|
|
1688
|
+
const purchases = getPurchaseSchema(mysqlTable);
|
|
1689
|
+
const subscriptions = getSubscriptionSchema(mysqlTable);
|
|
1690
|
+
const organizationMemberships = getOrganizationMembershipsSchema(mysqlTable);
|
|
1691
|
+
return relations22(organizations, ({ many }) => ({
|
|
1692
|
+
purchases: many(purchases, {
|
|
1693
|
+
relationName: "organization"
|
|
1694
|
+
}),
|
|
1695
|
+
subscriptions: many(subscriptions, {
|
|
1696
|
+
relationName: "organization"
|
|
1697
|
+
}),
|
|
1698
|
+
members: many(organizationMemberships, {
|
|
1699
|
+
relationName: "organization"
|
|
1700
|
+
})
|
|
1701
|
+
}));
|
|
1702
|
+
}
|
|
1703
|
+
__name(getOrganizationsRelationsSchema, "getOrganizationsRelationsSchema");
|
|
1704
|
+
|
|
1705
|
+
// src/lib/mysql/schemas/commerce/subscription.ts
|
|
1706
|
+
function getSubscriptionSchema(mysqlTable) {
|
|
1707
|
+
return mysqlTable("Subscription", {
|
|
1708
|
+
id: varchar23("id", {
|
|
1709
|
+
length: 191
|
|
1710
|
+
}).notNull(),
|
|
1711
|
+
organizationId: varchar23("organizationId", {
|
|
1712
|
+
length: 191
|
|
1713
|
+
}),
|
|
1714
|
+
productId: varchar23("productId", {
|
|
1715
|
+
length: 191
|
|
1716
|
+
}).notNull(),
|
|
1717
|
+
createdAt: timestamp22("createdAt", {
|
|
1718
|
+
mode: "date",
|
|
1719
|
+
fsp: 3
|
|
1720
|
+
}).default(sql17`CURRENT_TIMESTAMP(3)`).notNull(),
|
|
1721
|
+
merchantSubscriptionId: varchar23("merchantSubscriptionId", {
|
|
1722
|
+
length: 191
|
|
1723
|
+
}).notNull(),
|
|
1724
|
+
status: varchar23("status", {
|
|
1725
|
+
length: 191
|
|
1726
|
+
}).default("Valid").notNull(),
|
|
1727
|
+
fields: json16("fields").$type().default({})
|
|
1728
|
+
}, (table) => {
|
|
1729
|
+
return {
|
|
1730
|
+
subscriptionId: primaryKey14({
|
|
1731
|
+
columns: [
|
|
1732
|
+
table.id
|
|
1733
|
+
],
|
|
1734
|
+
name: "Subscription_id"
|
|
1735
|
+
}),
|
|
1736
|
+
organizationIdIdx: index23("organizationId_idx").on(table.organizationId)
|
|
1737
|
+
};
|
|
1738
|
+
});
|
|
1739
|
+
}
|
|
1740
|
+
__name(getSubscriptionSchema, "getSubscriptionSchema");
|
|
1741
|
+
function getSubscriptionRelationsSchema(mysqlTable) {
|
|
1742
|
+
const subscriptions = getSubscriptionSchema(mysqlTable);
|
|
1743
|
+
const products = getProductSchema(mysqlTable);
|
|
1744
|
+
const organizations = getOrganizationsSchema(mysqlTable);
|
|
1745
|
+
const merchantSubscriptions = getMerchantSubscriptionSchema(mysqlTable);
|
|
1746
|
+
return relations23(subscriptions, ({ many, one }) => ({
|
|
1747
|
+
organization: one(organizations, {
|
|
1748
|
+
fields: [
|
|
1749
|
+
subscriptions.organizationId
|
|
1750
|
+
],
|
|
1751
|
+
references: [
|
|
1752
|
+
organizations.id
|
|
1753
|
+
],
|
|
1754
|
+
relationName: "organization"
|
|
1755
|
+
}),
|
|
1756
|
+
product: one(products, {
|
|
1757
|
+
fields: [
|
|
1758
|
+
subscriptions.productId
|
|
1759
|
+
],
|
|
1760
|
+
references: [
|
|
1761
|
+
products.id
|
|
1762
|
+
],
|
|
1763
|
+
relationName: "product"
|
|
1764
|
+
}),
|
|
1765
|
+
merchantSubscription: one(merchantSubscriptions, {
|
|
1766
|
+
fields: [
|
|
1767
|
+
subscriptions.merchantSubscriptionId
|
|
1768
|
+
],
|
|
1769
|
+
references: [
|
|
1770
|
+
merchantSubscriptions.id
|
|
1771
|
+
],
|
|
1772
|
+
relationName: "merchantSubscription"
|
|
1773
|
+
})
|
|
1774
|
+
}));
|
|
1775
|
+
}
|
|
1776
|
+
__name(getSubscriptionRelationsSchema, "getSubscriptionRelationsSchema");
|
|
1777
|
+
|
|
1778
|
+
// src/lib/mysql/schemas/commerce/merchant-subscription.ts
|
|
1779
|
+
function getMerchantSubscriptionSchema(mysqlTable) {
|
|
1780
|
+
return mysqlTable("MerchantSubscription", {
|
|
1781
|
+
id: varchar24("id", {
|
|
1782
|
+
length: 191
|
|
1783
|
+
}).notNull(),
|
|
1784
|
+
organizationId: varchar24("organizationId", {
|
|
1785
|
+
length: 191
|
|
1786
|
+
}),
|
|
1787
|
+
merchantAccountId: varchar24("merchantAccountId", {
|
|
1788
|
+
length: 191
|
|
1789
|
+
}).notNull(),
|
|
1790
|
+
status: int6("status").default(0).notNull(),
|
|
1791
|
+
createdAt: timestamp23("createdAt", {
|
|
1792
|
+
mode: "date",
|
|
1793
|
+
fsp: 3
|
|
1794
|
+
}).default(sql18`CURRENT_TIMESTAMP(3)`).notNull(),
|
|
1795
|
+
label: varchar24("label", {
|
|
1796
|
+
length: 191
|
|
1797
|
+
}),
|
|
1798
|
+
identifier: varchar24("identifier", {
|
|
1799
|
+
length: 191
|
|
1800
|
+
}),
|
|
1801
|
+
merchantCustomerId: varchar24("merchantCustomerId", {
|
|
1802
|
+
length: 191
|
|
1803
|
+
}).notNull(),
|
|
1804
|
+
merchantProductId: varchar24("merchantProductId", {
|
|
1805
|
+
length: 191
|
|
1806
|
+
}).notNull()
|
|
1807
|
+
}, (table) => {
|
|
1808
|
+
return {
|
|
1809
|
+
merchantSubscriptionId: primaryKey15({
|
|
1810
|
+
columns: [
|
|
1811
|
+
table.id
|
|
1812
|
+
],
|
|
1813
|
+
name: "MerchantSubscription_id"
|
|
1814
|
+
}),
|
|
1815
|
+
organizationIdIdx: index24("organizationId_idx").on(table.organizationId)
|
|
1816
|
+
};
|
|
1817
|
+
});
|
|
1818
|
+
}
|
|
1819
|
+
__name(getMerchantSubscriptionSchema, "getMerchantSubscriptionSchema");
|
|
1820
|
+
function getMerchantSubscriptionRelationsSchema(mysqlTable) {
|
|
1821
|
+
const merchantSubscription = getMerchantSubscriptionSchema(mysqlTable);
|
|
1822
|
+
const merchantCharge = getMerchantChargeSchema(mysqlTable);
|
|
1823
|
+
const subscription = getSubscriptionSchema(mysqlTable);
|
|
1824
|
+
return relations24(merchantSubscription, ({ many, one }) => ({
|
|
1825
|
+
merchantCharges: many(merchantCharge, {
|
|
1826
|
+
relationName: "merchantSubscription"
|
|
1827
|
+
}),
|
|
1828
|
+
subscription: one(subscription, {
|
|
1829
|
+
fields: [
|
|
1830
|
+
merchantSubscription.id
|
|
1831
|
+
],
|
|
1832
|
+
references: [
|
|
1833
|
+
subscription.merchantSubscriptionId
|
|
1834
|
+
],
|
|
1835
|
+
relationName: "subscription"
|
|
1836
|
+
})
|
|
1837
|
+
}));
|
|
1838
|
+
}
|
|
1839
|
+
__name(getMerchantSubscriptionRelationsSchema, "getMerchantSubscriptionRelationsSchema");
|
|
1840
|
+
|
|
1841
|
+
// src/lib/mysql/schemas/commerce/merchant-charge.ts
|
|
1842
|
+
function getMerchantChargeSchema(mysqlTable) {
|
|
1843
|
+
return mysqlTable("MerchantCharge", {
|
|
1844
|
+
id: varchar25("id", {
|
|
1845
|
+
length: 191
|
|
1846
|
+
}).notNull(),
|
|
1847
|
+
organizationId: varchar25("organizationId", {
|
|
1848
|
+
length: 191
|
|
1849
|
+
}),
|
|
1850
|
+
status: int7("status").default(0).notNull(),
|
|
1851
|
+
identifier: varchar25("identifier", {
|
|
1852
|
+
length: 191
|
|
1853
|
+
}).notNull(),
|
|
1854
|
+
userId: varchar25("userId", {
|
|
1855
|
+
length: 191
|
|
1856
|
+
}).notNull(),
|
|
1857
|
+
merchantAccountId: varchar25("merchantAccountId", {
|
|
1858
|
+
length: 191
|
|
1859
|
+
}).notNull(),
|
|
1860
|
+
merchantProductId: varchar25("merchantProductId", {
|
|
1861
|
+
length: 191
|
|
1862
|
+
}).notNull(),
|
|
1863
|
+
merchantSubscriptionId: varchar25("merchantSubscriptionId", {
|
|
1864
|
+
length: 191
|
|
1865
|
+
}),
|
|
1866
|
+
createdAt: timestamp24("createdAt", {
|
|
1867
|
+
mode: "date",
|
|
1868
|
+
fsp: 3
|
|
1869
|
+
}).default(sql19`CURRENT_TIMESTAMP(3)`).notNull(),
|
|
1870
|
+
merchantCustomerId: varchar25("merchantCustomerId", {
|
|
1871
|
+
length: 191
|
|
1872
|
+
}).notNull()
|
|
1873
|
+
}, (table) => {
|
|
1874
|
+
return {
|
|
1875
|
+
merchantChargeId: primaryKey16({
|
|
1876
|
+
columns: [
|
|
1877
|
+
table.id
|
|
1878
|
+
],
|
|
1879
|
+
name: "MerchantCharge_id"
|
|
1880
|
+
}),
|
|
1881
|
+
merchantChargeIdentifierKey: unique4("MerchantCharge_identifier_key").on(table.identifier),
|
|
1882
|
+
merchantSubscriptionIdIdx: index25("merchantSubscriptionId_idx").on(table.merchantSubscriptionId),
|
|
1883
|
+
organizationIdIdx: index25("organizationId_idx").on(table.organizationId)
|
|
1884
|
+
};
|
|
1885
|
+
});
|
|
1886
|
+
}
|
|
1887
|
+
__name(getMerchantChargeSchema, "getMerchantChargeSchema");
|
|
1888
|
+
function getMerchantChargeRelationsSchema(mysqlTable) {
|
|
1889
|
+
const merchantCharge = getMerchantChargeSchema(mysqlTable);
|
|
1890
|
+
const merchantAccount = getMerchantAccountSchema(mysqlTable);
|
|
1891
|
+
const merchantProduct = getMerchantProductSchema(mysqlTable);
|
|
1892
|
+
const merchantCustomer = getMerchantCustomerSchema(mysqlTable);
|
|
1893
|
+
const merchantSubscription = getMerchantSubscriptionSchema(mysqlTable);
|
|
1894
|
+
return relations25(merchantCharge, ({ one }) => ({
|
|
1895
|
+
merchantAccount: one(merchantAccount, {
|
|
1896
|
+
fields: [
|
|
1897
|
+
merchantCharge.merchantAccountId
|
|
1898
|
+
],
|
|
1899
|
+
references: [
|
|
1900
|
+
merchantAccount.id
|
|
1901
|
+
],
|
|
1902
|
+
relationName: "merchantAccount"
|
|
1903
|
+
}),
|
|
1904
|
+
merchantProduct: one(merchantProduct, {
|
|
1905
|
+
fields: [
|
|
1906
|
+
merchantCharge.merchantProductId
|
|
1907
|
+
],
|
|
1908
|
+
references: [
|
|
1909
|
+
merchantProduct.id
|
|
1910
|
+
],
|
|
1911
|
+
relationName: "merchantProduct"
|
|
1912
|
+
}),
|
|
1913
|
+
merchantCustomer: one(merchantCustomer, {
|
|
1914
|
+
fields: [
|
|
1915
|
+
merchantCharge.merchantCustomerId
|
|
1916
|
+
],
|
|
1917
|
+
references: [
|
|
1918
|
+
merchantCustomer.id
|
|
1919
|
+
],
|
|
1920
|
+
relationName: "merchantCustomer"
|
|
1921
|
+
}),
|
|
1922
|
+
merchantSubscription: one(merchantSubscription, {
|
|
1923
|
+
fields: [
|
|
1924
|
+
merchantCharge.merchantSubscriptionId
|
|
1925
|
+
],
|
|
1926
|
+
references: [
|
|
1927
|
+
merchantSubscription.id
|
|
1928
|
+
],
|
|
1929
|
+
relationName: "merchantSubscription"
|
|
1930
|
+
})
|
|
1931
|
+
}));
|
|
1932
|
+
}
|
|
1933
|
+
__name(getMerchantChargeRelationsSchema, "getMerchantChargeRelationsSchema");
|
|
1934
|
+
|
|
1935
|
+
export {
|
|
1936
|
+
getMerchantChargeSchema,
|
|
1937
|
+
getMerchantChargeRelationsSchema,
|
|
1938
|
+
getMerchantSubscriptionSchema,
|
|
1939
|
+
getMerchantSubscriptionRelationsSchema,
|
|
1940
|
+
getContentContributionsSchema,
|
|
1941
|
+
getContentContributionRelationsSchema,
|
|
1942
|
+
getContentResourceResourceSchema,
|
|
1943
|
+
getContentResourceResourceRelationsSchema,
|
|
1944
|
+
getTagTagSchema,
|
|
1945
|
+
getTagTagRelationsSchema,
|
|
1946
|
+
getTagSchema,
|
|
1947
|
+
getTagRelationsSchema,
|
|
1948
|
+
getContentResourceTagSchema,
|
|
1949
|
+
getContentResourceTagRelationsSchema,
|
|
1950
|
+
getContentResourceVersionSchema,
|
|
1951
|
+
getContentResourceVersionRelationsSchema,
|
|
1952
|
+
getContentResourceSchema,
|
|
1953
|
+
getContentResourceRelationsSchema,
|
|
1954
|
+
getContentResourceProductSchema,
|
|
1955
|
+
getContentResourceProductRelationsSchema,
|
|
1956
|
+
getPriceSchema,
|
|
1957
|
+
getProductRelationsSchema,
|
|
1958
|
+
getProductSchema,
|
|
1959
|
+
getProductRelationsSchema2,
|
|
1960
|
+
getSubscriptionSchema,
|
|
1961
|
+
getSubscriptionRelationsSchema,
|
|
1962
|
+
getOrganizationsSchema,
|
|
1963
|
+
getOrganizationsRelationsSchema,
|
|
1964
|
+
getOrganizationMembershipsSchema,
|
|
1965
|
+
getOrganizationMembershipsRelationsSchema,
|
|
1966
|
+
getCouponSchema,
|
|
1967
|
+
getCouponRelationsSchema,
|
|
1968
|
+
getPurchaseSchema,
|
|
1969
|
+
getPurchaseRelationsSchema,
|
|
1970
|
+
getCommentsSchema,
|
|
1971
|
+
getCommentRelationsSchema,
|
|
1972
|
+
getCommunicationPreferencesSchema,
|
|
1973
|
+
getCommunicationPreferencesRelationsSchema,
|
|
1974
|
+
getUserPermissionsSchema,
|
|
1975
|
+
getUserPermissionsRelationsSchema,
|
|
1976
|
+
getUserPrefsSchema,
|
|
1977
|
+
getUserPrefsRelationsSchema,
|
|
1978
|
+
getRolesSchema,
|
|
1979
|
+
getRolesRelationsSchema,
|
|
1980
|
+
getUserRolesSchema,
|
|
1981
|
+
getUserRolesRelationsSchema,
|
|
1982
|
+
getUsersSchema,
|
|
1983
|
+
getUsersRelationsSchema,
|
|
1984
|
+
getAccountsSchema,
|
|
1985
|
+
getAccountsRelationsSchema
|
|
1986
|
+
};
|
|
1987
|
+
//# sourceMappingURL=chunk-QGZ2F5SW.js.map
|