@coursebuilder/adapter-drizzle 0.5.2 → 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-QQA7STVO.js → chunk-3WYG5OE7.js} +2 -2
- package/dist/{chunk-6SLQW6OM.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-EFVZ7IN4.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-YMFPIZMO.js → chunk-GAKWXOAY.js} +2 -2
- package/dist/{chunk-4ZWS76VQ.js → chunk-KPBVZ44W.js} +7 -3
- package/dist/{chunk-ZYQYJNLK.js → chunk-L5ZAWSTN.js} +51 -29
- package/dist/{chunk-6ON2O6UD.js → chunk-MGZMGDQ5.js} +7 -3
- package/dist/{chunk-KDEWFXEP.js → chunk-MP4CUWYC.js} +6 -2
- package/dist/{chunk-JW2PFVLO.js → chunk-QGZ2F5SW.js} +1387 -868
- package/dist/{chunk-XJXCDN7B.js → chunk-RCL6HPBL.js} +8 -4
- package/dist/chunk-RP66NZN3.js +81 -0
- package/dist/{chunk-27UC2HEP.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.js +20 -20
- package/dist/lib/mysql/index.cjs +1355 -787
- package/dist/lib/mysql/index.cjs.map +1 -1
- package/dist/lib/mysql/index.d.cts +4201 -1667
- package/dist/lib/mysql/index.d.ts +4201 -1667
- package/dist/lib/mysql/index.js +20 -20
- package/dist/lib/mysql/schemas/auth/accounts.cjs +109 -93
- package/dist/lib/mysql/schemas/auth/accounts.cjs.map +1 -1
- package/dist/lib/mysql/schemas/auth/accounts.js +10 -11
- package/dist/lib/mysql/schemas/auth/device-access-token.cjs +104 -85
- package/dist/lib/mysql/schemas/auth/device-access-token.cjs.map +1 -1
- package/dist/lib/mysql/schemas/auth/device-access-token.d.cts +16 -0
- package/dist/lib/mysql/schemas/auth/device-access-token.d.ts +16 -0
- package/dist/lib/mysql/schemas/auth/device-access-token.js +11 -12
- package/dist/lib/mysql/schemas/auth/device-verification.cjs +103 -87
- package/dist/lib/mysql/schemas/auth/device-verification.cjs.map +1 -1
- package/dist/lib/mysql/schemas/auth/device-verification.js +11 -12
- package/dist/lib/mysql/schemas/auth/role-permissions.cjs +102 -82
- package/dist/lib/mysql/schemas/auth/role-permissions.cjs.map +1 -1
- package/dist/lib/mysql/schemas/auth/role-permissions.js +11 -12
- package/dist/lib/mysql/schemas/auth/roles.cjs +106 -82
- package/dist/lib/mysql/schemas/auth/roles.cjs.map +1 -1
- package/dist/lib/mysql/schemas/auth/roles.d.cts +16 -0
- package/dist/lib/mysql/schemas/auth/roles.d.ts +16 -0
- package/dist/lib/mysql/schemas/auth/roles.js +10 -11
- package/dist/lib/mysql/schemas/auth/sessions.cjs +99 -83
- package/dist/lib/mysql/schemas/auth/sessions.cjs.map +1 -1
- package/dist/lib/mysql/schemas/auth/sessions.js +11 -12
- package/dist/lib/mysql/schemas/auth/user-permissions.cjs +104 -84
- package/dist/lib/mysql/schemas/auth/user-permissions.cjs.map +1 -1
- package/dist/lib/mysql/schemas/auth/user-permissions.d.cts +16 -0
- package/dist/lib/mysql/schemas/auth/user-permissions.d.ts +16 -0
- package/dist/lib/mysql/schemas/auth/user-permissions.js +10 -11
- package/dist/lib/mysql/schemas/auth/user-prefs.cjs +108 -88
- package/dist/lib/mysql/schemas/auth/user-prefs.cjs.map +1 -1
- package/dist/lib/mysql/schemas/auth/user-prefs.d.cts +16 -0
- package/dist/lib/mysql/schemas/auth/user-prefs.d.ts +16 -0
- package/dist/lib/mysql/schemas/auth/user-prefs.js +10 -11
- package/dist/lib/mysql/schemas/auth/user-roles.cjs +109 -85
- package/dist/lib/mysql/schemas/auth/user-roles.cjs.map +1 -1
- package/dist/lib/mysql/schemas/auth/user-roles.d.cts +16 -0
- package/dist/lib/mysql/schemas/auth/user-roles.d.ts +16 -0
- package/dist/lib/mysql/schemas/auth/user-roles.js +10 -11
- package/dist/lib/mysql/schemas/auth/users.cjs +288 -192
- package/dist/lib/mysql/schemas/auth/users.cjs.map +1 -1
- package/dist/lib/mysql/schemas/auth/users.d.cts +1 -0
- package/dist/lib/mysql/schemas/auth/users.d.ts +1 -0
- package/dist/lib/mysql/schemas/auth/users.js +10 -11
- package/dist/lib/mysql/schemas/commerce/coupon.cjs +134 -98
- package/dist/lib/mysql/schemas/commerce/coupon.cjs.map +1 -1
- package/dist/lib/mysql/schemas/commerce/coupon.d.cts +16 -0
- package/dist/lib/mysql/schemas/commerce/coupon.d.ts +16 -0
- package/dist/lib/mysql/schemas/commerce/coupon.js +10 -11
- package/dist/lib/mysql/schemas/commerce/merchant-account.cjs +5 -1
- package/dist/lib/mysql/schemas/commerce/merchant-account.cjs.map +1 -1
- package/dist/lib/mysql/schemas/commerce/merchant-account.d.cts +16 -0
- package/dist/lib/mysql/schemas/commerce/merchant-account.d.ts +16 -0
- package/dist/lib/mysql/schemas/commerce/merchant-account.js +1 -1
- package/dist/lib/mysql/schemas/commerce/merchant-charge.cjs +210 -17
- package/dist/lib/mysql/schemas/commerce/merchant-charge.cjs.map +1 -1
- package/dist/lib/mysql/schemas/commerce/merchant-charge.d.cts +33 -0
- package/dist/lib/mysql/schemas/commerce/merchant-charge.d.ts +33 -0
- package/dist/lib/mysql/schemas/commerce/merchant-charge.js +11 -4
- package/dist/lib/mysql/schemas/commerce/merchant-coupon.cjs +5 -1
- package/dist/lib/mysql/schemas/commerce/merchant-coupon.cjs.map +1 -1
- package/dist/lib/mysql/schemas/commerce/merchant-coupon.d.cts +16 -0
- package/dist/lib/mysql/schemas/commerce/merchant-coupon.d.ts +16 -0
- package/dist/lib/mysql/schemas/commerce/merchant-coupon.js +1 -1
- package/dist/lib/mysql/schemas/commerce/merchant-customer.cjs +5 -1
- package/dist/lib/mysql/schemas/commerce/merchant-customer.cjs.map +1 -1
- package/dist/lib/mysql/schemas/commerce/merchant-customer.d.cts +16 -0
- package/dist/lib/mysql/schemas/commerce/merchant-customer.d.ts +16 -0
- package/dist/lib/mysql/schemas/commerce/merchant-customer.js +1 -1
- package/dist/lib/mysql/schemas/commerce/merchant-price.cjs +5 -1
- package/dist/lib/mysql/schemas/commerce/merchant-price.cjs.map +1 -1
- package/dist/lib/mysql/schemas/commerce/merchant-price.d.cts +16 -0
- package/dist/lib/mysql/schemas/commerce/merchant-price.d.ts +16 -0
- package/dist/lib/mysql/schemas/commerce/merchant-price.js +1 -1
- package/dist/lib/mysql/schemas/commerce/merchant-product.cjs +5 -1
- package/dist/lib/mysql/schemas/commerce/merchant-product.cjs.map +1 -1
- package/dist/lib/mysql/schemas/commerce/merchant-product.d.cts +16 -0
- package/dist/lib/mysql/schemas/commerce/merchant-product.d.ts +16 -0
- package/dist/lib/mysql/schemas/commerce/merchant-product.js +1 -1
- package/dist/lib/mysql/schemas/commerce/merchant-session.cjs +5 -1
- package/dist/lib/mysql/schemas/commerce/merchant-session.cjs.map +1 -1
- package/dist/lib/mysql/schemas/commerce/merchant-session.d.cts +16 -0
- package/dist/lib/mysql/schemas/commerce/merchant-session.d.ts +16 -0
- package/dist/lib/mysql/schemas/commerce/merchant-session.js +1 -1
- package/dist/lib/mysql/schemas/commerce/merchant-subscription.cjs +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 +108 -80
- package/dist/lib/mysql/schemas/commerce/price.cjs.map +1 -1
- package/dist/lib/mysql/schemas/commerce/price.d.cts +16 -0
- package/dist/lib/mysql/schemas/commerce/price.d.ts +16 -0
- package/dist/lib/mysql/schemas/commerce/price.js +10 -11
- package/dist/lib/mysql/schemas/commerce/product.cjs +134 -102
- package/dist/lib/mysql/schemas/commerce/product.cjs.map +1 -1
- package/dist/lib/mysql/schemas/commerce/product.d.cts +16 -0
- package/dist/lib/mysql/schemas/commerce/product.d.ts +16 -0
- package/dist/lib/mysql/schemas/commerce/product.js +10 -11
- package/dist/lib/mysql/schemas/commerce/purchase-user-transfer.cjs +141 -113
- package/dist/lib/mysql/schemas/commerce/purchase-user-transfer.cjs.map +1 -1
- package/dist/lib/mysql/schemas/commerce/purchase-user-transfer.d.cts +16 -0
- package/dist/lib/mysql/schemas/commerce/purchase-user-transfer.d.ts +16 -0
- package/dist/lib/mysql/schemas/commerce/purchase-user-transfer.js +11 -12
- package/dist/lib/mysql/schemas/commerce/purchase.cjs +293 -175
- package/dist/lib/mysql/schemas/commerce/purchase.cjs.map +1 -1
- package/dist/lib/mysql/schemas/commerce/purchase.d.cts +34 -0
- package/dist/lib/mysql/schemas/commerce/purchase.d.ts +34 -0
- package/dist/lib/mysql/schemas/commerce/purchase.js +10 -11
- package/dist/lib/mysql/schemas/commerce/subscription.cjs +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 +109 -85
- package/dist/lib/mysql/schemas/commerce/upgradable-products.cjs.map +1 -1
- package/dist/lib/mysql/schemas/commerce/upgradable-products.d.cts +16 -0
- package/dist/lib/mysql/schemas/commerce/upgradable-products.d.ts +16 -0
- package/dist/lib/mysql/schemas/commerce/upgradable-products.js +11 -12
- package/dist/lib/mysql/schemas/communication/comment.cjs +148 -87
- package/dist/lib/mysql/schemas/communication/comment.cjs.map +1 -1
- package/dist/lib/mysql/schemas/communication/comment.d.cts +17 -0
- package/dist/lib/mysql/schemas/communication/comment.d.ts +17 -0
- package/dist/lib/mysql/schemas/communication/comment.js +10 -11
- package/dist/lib/mysql/schemas/communication/communication-channel.cjs +5 -1
- package/dist/lib/mysql/schemas/communication/communication-channel.cjs.map +1 -1
- package/dist/lib/mysql/schemas/communication/communication-channel.d.cts +16 -0
- package/dist/lib/mysql/schemas/communication/communication-channel.d.ts +16 -0
- package/dist/lib/mysql/schemas/communication/communication-channel.js +1 -1
- package/dist/lib/mysql/schemas/communication/communication-preference-types.cjs +3 -0
- package/dist/lib/mysql/schemas/communication/communication-preference-types.cjs.map +1 -1
- package/dist/lib/mysql/schemas/communication/communication-preference-types.d.cts +16 -0
- package/dist/lib/mysql/schemas/communication/communication-preference-types.d.ts +16 -0
- package/dist/lib/mysql/schemas/communication/communication-preference-types.js +1 -1
- package/dist/lib/mysql/schemas/communication/communication-preferences.cjs +176 -105
- package/dist/lib/mysql/schemas/communication/communication-preferences.cjs.map +1 -1
- package/dist/lib/mysql/schemas/communication/communication-preferences.d.cts +33 -0
- package/dist/lib/mysql/schemas/communication/communication-preferences.d.ts +33 -0
- package/dist/lib/mysql/schemas/communication/communication-preferences.js +10 -11
- package/dist/lib/mysql/schemas/content/content-contributions.cjs +186 -111
- package/dist/lib/mysql/schemas/content/content-contributions.cjs.map +1 -1
- package/dist/lib/mysql/schemas/content/content-contributions.d.cts +33 -0
- package/dist/lib/mysql/schemas/content/content-contributions.d.ts +33 -0
- package/dist/lib/mysql/schemas/content/content-contributions.js +10 -11
- package/dist/lib/mysql/schemas/content/content-resource-product.cjs +110 -79
- package/dist/lib/mysql/schemas/content/content-resource-product.cjs.map +1 -1
- package/dist/lib/mysql/schemas/content/content-resource-product.d.cts +16 -0
- package/dist/lib/mysql/schemas/content/content-resource-product.d.ts +16 -0
- package/dist/lib/mysql/schemas/content/content-resource-product.js +10 -11
- package/dist/lib/mysql/schemas/content/content-resource-resource.cjs +115 -88
- package/dist/lib/mysql/schemas/content/content-resource-resource.cjs.map +1 -1
- package/dist/lib/mysql/schemas/content/content-resource-resource.d.cts +16 -0
- package/dist/lib/mysql/schemas/content/content-resource-resource.d.ts +16 -0
- package/dist/lib/mysql/schemas/content/content-resource-resource.js +10 -11
- package/dist/lib/mysql/schemas/content/content-resource-tag.cjs +127 -96
- package/dist/lib/mysql/schemas/content/content-resource-tag.cjs.map +1 -1
- package/dist/lib/mysql/schemas/content/content-resource-tag.d.cts +16 -0
- package/dist/lib/mysql/schemas/content/content-resource-tag.d.ts +16 -0
- package/dist/lib/mysql/schemas/content/content-resource-tag.js +10 -11
- package/dist/lib/mysql/schemas/content/content-resource-version.cjs +130 -103
- package/dist/lib/mysql/schemas/content/content-resource-version.cjs.map +1 -1
- package/dist/lib/mysql/schemas/content/content-resource-version.d.cts +16 -0
- package/dist/lib/mysql/schemas/content/content-resource-version.d.ts +16 -0
- package/dist/lib/mysql/schemas/content/content-resource-version.js +10 -11
- package/dist/lib/mysql/schemas/content/content-resource.cjs +248 -157
- package/dist/lib/mysql/schemas/content/content-resource.cjs.map +1 -1
- package/dist/lib/mysql/schemas/content/content-resource.d.cts +33 -0
- package/dist/lib/mysql/schemas/content/content-resource.d.ts +33 -0
- package/dist/lib/mysql/schemas/content/content-resource.js +10 -11
- package/dist/lib/mysql/schemas/content/contribution-types.cjs +5 -1
- package/dist/lib/mysql/schemas/content/contribution-types.cjs.map +1 -1
- package/dist/lib/mysql/schemas/content/contribution-types.d.cts +16 -0
- package/dist/lib/mysql/schemas/content/contribution-types.d.ts +16 -0
- package/dist/lib/mysql/schemas/content/contribution-types.js +1 -1
- package/dist/lib/mysql/schemas/content/lesson-progress.cjs +8 -1
- package/dist/lib/mysql/schemas/content/lesson-progress.cjs.map +1 -1
- package/dist/lib/mysql/schemas/content/lesson-progress.d.cts +32 -0
- package/dist/lib/mysql/schemas/content/lesson-progress.d.ts +32 -0
- package/dist/lib/mysql/schemas/content/lesson-progress.js +1 -1
- package/dist/lib/mysql/schemas/content/resource-progress.cjs +8 -1
- package/dist/lib/mysql/schemas/content/resource-progress.cjs.map +1 -1
- package/dist/lib/mysql/schemas/content/resource-progress.d.cts +32 -0
- package/dist/lib/mysql/schemas/content/resource-progress.d.ts +32 -0
- package/dist/lib/mysql/schemas/content/resource-progress.js +1 -1
- package/dist/lib/mysql/schemas/content/tag-tag.cjs +108 -84
- package/dist/lib/mysql/schemas/content/tag-tag.cjs.map +1 -1
- package/dist/lib/mysql/schemas/content/tag-tag.d.cts +16 -0
- package/dist/lib/mysql/schemas/content/tag-tag.d.ts +16 -0
- package/dist/lib/mysql/schemas/content/tag-tag.js +10 -11
- package/dist/lib/mysql/schemas/content/tag.cjs +123 -95
- package/dist/lib/mysql/schemas/content/tag.cjs.map +1 -1
- package/dist/lib/mysql/schemas/content/tag.d.cts +16 -0
- package/dist/lib/mysql/schemas/content/tag.d.ts +16 -0
- package/dist/lib/mysql/schemas/content/tag.js +10 -11
- package/dist/lib/mysql/schemas/org/organization-membership-roles.cjs +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/package.json +2 -2
- package/src/lib/mysql/index.ts +34 -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 +2 -0
- package/src/lib/mysql/schemas/content/content-resource-version.ts +2 -0
- package/src/lib/mysql/schemas/content/content-resource.ts +17 -0
- package/src/lib/mysql/schemas/content/contribution-types.ts +2 -0
- package/src/lib/mysql/schemas/content/lesson-progress.ts +7 -0
- package/src/lib/mysql/schemas/content/resource-progress.ts +7 -0
- package/src/lib/mysql/schemas/content/tag-tag.ts +2 -0
- package/src/lib/mysql/schemas/content/tag.ts +2 -0
- package/src/lib/mysql/schemas/org/organization-membership-roles.ts +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
|
@@ -1,27 +1,30 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getContributionTypesSchema
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-MP4CUWYC.js";
|
|
4
4
|
import {
|
|
5
5
|
getCommunicationChannelSchema
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-WJWJ6E5Y.js";
|
|
7
7
|
import {
|
|
8
8
|
getCommunicationPreferenceTypesSchema
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-EHRARBRS.js";
|
|
10
10
|
import {
|
|
11
|
-
|
|
12
|
-
} from "./chunk-
|
|
11
|
+
getMerchantAccountSchema
|
|
12
|
+
} from "./chunk-DKJO4Y3K.js";
|
|
13
13
|
import {
|
|
14
14
|
getMerchantCouponSchema
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-WPJZAYX7.js";
|
|
16
|
+
import {
|
|
17
|
+
getMerchantCustomerSchema
|
|
18
|
+
} from "./chunk-6MRFUIH5.js";
|
|
16
19
|
import {
|
|
17
20
|
getMerchantPriceSchema
|
|
18
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-MGZMGDQ5.js";
|
|
19
22
|
import {
|
|
20
23
|
getMerchantProductSchema
|
|
21
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-KPBVZ44W.js";
|
|
22
25
|
import {
|
|
23
26
|
getMerchantSessionSchema
|
|
24
|
-
} from "./chunk-
|
|
27
|
+
} from "./chunk-BLDW3QUS.js";
|
|
25
28
|
import {
|
|
26
29
|
getPermissionsSchema
|
|
27
30
|
} from "./chunk-LZHZDFNZ.js";
|
|
@@ -29,118 +32,118 @@ import {
|
|
|
29
32
|
__name
|
|
30
33
|
} from "./chunk-H736K5TN.js";
|
|
31
34
|
|
|
32
|
-
// src/lib/mysql/schemas/
|
|
33
|
-
import { relations as
|
|
34
|
-
import {
|
|
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";
|
|
35
38
|
|
|
36
|
-
// src/lib/mysql/schemas/
|
|
37
|
-
import { relations as
|
|
38
|
-
import { index as
|
|
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";
|
|
39
42
|
|
|
40
|
-
// src/lib/mysql/schemas/commerce/
|
|
41
|
-
import { relations as
|
|
42
|
-
import {
|
|
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";
|
|
43
46
|
|
|
44
|
-
// src/lib/mysql/schemas/
|
|
45
|
-
import { relations as
|
|
46
|
-
import {
|
|
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";
|
|
47
50
|
|
|
48
|
-
// src/lib/mysql/schemas/commerce/
|
|
49
|
-
import { relations as
|
|
50
|
-
import {
|
|
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";
|
|
51
54
|
|
|
52
|
-
// src/lib/mysql/schemas/
|
|
53
|
-
import { relations as
|
|
54
|
-
import {
|
|
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";
|
|
55
58
|
|
|
56
|
-
// src/lib/mysql/schemas/
|
|
57
|
-
import { relations as
|
|
58
|
-
import { index as
|
|
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";
|
|
59
62
|
|
|
60
|
-
// src/lib/mysql/schemas/
|
|
63
|
+
// src/lib/mysql/schemas/org/organization-memberships.ts
|
|
61
64
|
import { relations, sql } from "drizzle-orm";
|
|
62
|
-
import {
|
|
63
|
-
function
|
|
64
|
-
return mysqlTable("
|
|
65
|
-
|
|
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", {
|
|
66
78
|
length: 255
|
|
67
79
|
}).notNull(),
|
|
68
|
-
|
|
80
|
+
userId: varchar("userId", {
|
|
69
81
|
length: 255
|
|
70
82
|
}).notNull(),
|
|
71
|
-
|
|
72
|
-
metadata: json("metadata").$type().default({}),
|
|
83
|
+
fields: json("fields").$type().default({}),
|
|
73
84
|
createdAt: timestamp("createdAt", {
|
|
74
85
|
mode: "date",
|
|
75
86
|
fsp: 3
|
|
76
|
-
}).default(sql`CURRENT_TIMESTAMP(3)`)
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
deletedAt: timestamp("deletedAt", {
|
|
82
|
-
mode: "date",
|
|
83
|
-
fsp: 3
|
|
84
|
-
})
|
|
85
|
-
}, (crr) => ({
|
|
86
|
-
pk: primaryKey({
|
|
87
|
-
columns: [
|
|
88
|
-
crr.resourceOfId,
|
|
89
|
-
crr.resourceId
|
|
90
|
-
]
|
|
91
|
-
}),
|
|
92
|
-
contentResourceIdIdx: index("contentResourceId_idx").on(crr.resourceOfId),
|
|
93
|
-
resourceIdIdx: index("resourceId_idx").on(crr.resourceId)
|
|
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)
|
|
94
92
|
}));
|
|
95
93
|
}
|
|
96
|
-
__name(
|
|
97
|
-
function
|
|
98
|
-
const
|
|
99
|
-
const
|
|
100
|
-
|
|
101
|
-
|
|
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
102
|
fields: [
|
|
103
|
-
|
|
103
|
+
organizationMemberships.userId
|
|
104
104
|
],
|
|
105
105
|
references: [
|
|
106
|
-
|
|
106
|
+
users.id
|
|
107
107
|
],
|
|
108
|
-
relationName: "
|
|
108
|
+
relationName: "user"
|
|
109
109
|
}),
|
|
110
|
-
|
|
110
|
+
invitedBy: one(users, {
|
|
111
111
|
fields: [
|
|
112
|
-
|
|
112
|
+
organizationMemberships.invitedById
|
|
113
113
|
],
|
|
114
114
|
references: [
|
|
115
|
-
|
|
115
|
+
users.id
|
|
116
116
|
],
|
|
117
|
-
relationName: "
|
|
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"
|
|
118
128
|
})
|
|
119
129
|
}));
|
|
120
130
|
}
|
|
121
|
-
__name(
|
|
122
|
-
|
|
123
|
-
// src/lib/mysql/schemas/content/content-resource-tag.ts
|
|
124
|
-
import { relations as relations4, sql as sql4 } from "drizzle-orm";
|
|
125
|
-
import { double as double3, index as index4, primaryKey as primaryKey3, timestamp as timestamp4, varchar as varchar4 } from "drizzle-orm/mysql-core";
|
|
131
|
+
__name(getOrganizationMembershipsRelationsSchema, "getOrganizationMembershipsRelationsSchema");
|
|
126
132
|
|
|
127
|
-
// src/lib/mysql/schemas/
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
import { relations as relations2, sql as sql2 } from "drizzle-orm";
|
|
133
|
-
import { double as double2, index as index2, json as json2, primaryKey as primaryKey2, timestamp as timestamp2, varchar as varchar2 } from "drizzle-orm/mysql-core";
|
|
134
|
-
function getTagTagSchema(mysqlTable) {
|
|
135
|
-
return mysqlTable("TagTag", {
|
|
136
|
-
parentTagId: varchar2("parentTagId", {
|
|
137
|
-
length: 255
|
|
133
|
+
// src/lib/mysql/schemas/communication/comment.ts
|
|
134
|
+
function getCommentsSchema(mysqlTable) {
|
|
135
|
+
return mysqlTable("Comment", {
|
|
136
|
+
id: varchar2("id", {
|
|
137
|
+
length: 191
|
|
138
138
|
}).notNull(),
|
|
139
|
-
|
|
139
|
+
userId: varchar2("userId", {
|
|
140
140
|
length: 255
|
|
141
141
|
}).notNull(),
|
|
142
|
-
|
|
143
|
-
|
|
142
|
+
organizationMembershipId: varchar2("organizationMembershipId", {
|
|
143
|
+
length: 255
|
|
144
|
+
}),
|
|
145
|
+
context: json2("context").$type().default({}),
|
|
146
|
+
text: text("text").notNull(),
|
|
144
147
|
createdAt: timestamp2("createdAt", {
|
|
145
148
|
mode: "date",
|
|
146
149
|
fsp: 3
|
|
@@ -153,395 +156,200 @@ function getTagTagSchema(mysqlTable) {
|
|
|
153
156
|
mode: "date",
|
|
154
157
|
fsp: 3
|
|
155
158
|
})
|
|
156
|
-
}, (
|
|
157
|
-
pk:
|
|
159
|
+
}, (crr) => ({
|
|
160
|
+
pk: primaryKey({
|
|
158
161
|
columns: [
|
|
159
|
-
|
|
160
|
-
tt.childTagId
|
|
162
|
+
crr.id
|
|
161
163
|
]
|
|
162
164
|
}),
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
positionIdx: index2("position_idx").on(tt.position)
|
|
165
|
+
crrUserIdIdKey: index2("crr_userIdId_idx").on(crr.userId),
|
|
166
|
+
organizationMembershipIdIdx: index2("organizationMembershipId_idx").on(crr.organizationMembershipId)
|
|
166
167
|
}));
|
|
167
168
|
}
|
|
168
|
-
__name(
|
|
169
|
-
function
|
|
170
|
-
const
|
|
171
|
-
const
|
|
172
|
-
|
|
173
|
-
|
|
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, {
|
|
174
176
|
fields: [
|
|
175
|
-
|
|
177
|
+
comment.userId
|
|
176
178
|
],
|
|
177
179
|
references: [
|
|
178
|
-
|
|
180
|
+
user.id
|
|
179
181
|
],
|
|
180
|
-
relationName: "
|
|
182
|
+
relationName: "user"
|
|
181
183
|
}),
|
|
182
|
-
|
|
184
|
+
organizationMembership: one(organizationMemberships, {
|
|
183
185
|
fields: [
|
|
184
|
-
|
|
186
|
+
comment.organizationMembershipId
|
|
185
187
|
],
|
|
186
188
|
references: [
|
|
187
|
-
|
|
189
|
+
organizationMemberships.id
|
|
188
190
|
],
|
|
189
|
-
relationName: "
|
|
191
|
+
relationName: "organizationMembership"
|
|
190
192
|
})
|
|
191
193
|
}));
|
|
192
194
|
}
|
|
193
|
-
__name(
|
|
195
|
+
__name(getCommentRelationsSchema, "getCommentRelationsSchema");
|
|
194
196
|
|
|
195
|
-
// src/lib/mysql/schemas/
|
|
196
|
-
|
|
197
|
-
|
|
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", {
|
|
198
202
|
id: varchar3("id", {
|
|
199
203
|
length: 255
|
|
200
204
|
}).notNull().primaryKey(),
|
|
201
|
-
|
|
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", {
|
|
202
223
|
length: 255
|
|
203
224
|
}).notNull(),
|
|
204
|
-
|
|
225
|
+
active: boolean("active").notNull().default(true),
|
|
205
226
|
createdAt: timestamp3("createdAt", {
|
|
206
227
|
mode: "date",
|
|
207
228
|
fsp: 3
|
|
208
|
-
}).
|
|
209
|
-
|
|
229
|
+
}).defaultNow(),
|
|
230
|
+
optInAt: timestamp3("optInAt", {
|
|
210
231
|
mode: "date",
|
|
211
232
|
fsp: 3
|
|
212
|
-
})
|
|
213
|
-
|
|
233
|
+
}),
|
|
234
|
+
optOutAt: timestamp3("optOutAt", {
|
|
214
235
|
mode: "date",
|
|
215
236
|
fsp: 3
|
|
216
|
-
})
|
|
217
|
-
}, (t) => ({
|
|
218
|
-
typeIdx: index3("type_idx").on(t.type)
|
|
219
|
-
}));
|
|
220
|
-
}
|
|
221
|
-
__name(getTagSchema, "getTagSchema");
|
|
222
|
-
function getTagRelationsSchema(mysqlTable) {
|
|
223
|
-
const tag = getTagSchema(mysqlTable);
|
|
224
|
-
const contentResourceTag = getContentResourceTagSchema(mysqlTable);
|
|
225
|
-
const tagTag = getTagTagSchema(mysqlTable);
|
|
226
|
-
return relations3(tag, ({ many }) => ({
|
|
227
|
-
resources: many(contentResourceTag, {
|
|
228
|
-
relationName: "contentResource"
|
|
229
|
-
}),
|
|
230
|
-
parentTags: many(tagTag, {
|
|
231
|
-
relationName: "childTag"
|
|
232
237
|
}),
|
|
233
|
-
|
|
234
|
-
relationName: "parentTag"
|
|
235
|
-
})
|
|
236
|
-
}));
|
|
237
|
-
}
|
|
238
|
-
__name(getTagRelationsSchema, "getTagRelationsSchema");
|
|
239
|
-
|
|
240
|
-
// src/lib/mysql/schemas/content/content-resource-tag.ts
|
|
241
|
-
function getContentResourceTagSchema(mysqlTable) {
|
|
242
|
-
return mysqlTable("ContentResourceTag", {
|
|
243
|
-
contentResourceId: varchar4("contentResourceId", {
|
|
244
|
-
length: 255
|
|
245
|
-
}).notNull(),
|
|
246
|
-
tagId: varchar4("tagId", {
|
|
247
|
-
length: 255
|
|
248
|
-
}).notNull(),
|
|
249
|
-
position: double3("position").notNull().default(0),
|
|
250
|
-
createdAt: timestamp4("createdAt", {
|
|
238
|
+
updatedAt: timestamp3("updatedAt", {
|
|
251
239
|
mode: "date",
|
|
252
240
|
fsp: 3
|
|
253
|
-
}).
|
|
254
|
-
|
|
241
|
+
}).defaultNow(),
|
|
242
|
+
deletedAt: timestamp3("deletedAt", {
|
|
255
243
|
mode: "date",
|
|
256
244
|
fsp: 3
|
|
257
|
-
})
|
|
258
|
-
}, (
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
]
|
|
264
|
-
}),
|
|
265
|
-
contentResourceIdIdx: index4("contentResourceId_idx").on(crt.contentResourceId),
|
|
266
|
-
tagIdIdx: index4("tagId_idx").on(crt.tagId),
|
|
267
|
-
positionIdx: index4("position_idx").on(crt.position)
|
|
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)
|
|
268
251
|
}));
|
|
269
252
|
}
|
|
270
|
-
__name(
|
|
271
|
-
function
|
|
272
|
-
const
|
|
273
|
-
const
|
|
274
|
-
const
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
],
|
|
280
|
-
references: [
|
|
281
|
-
contentResource.id
|
|
282
|
-
],
|
|
283
|
-
relationName: "contentResource"
|
|
284
|
-
}),
|
|
285
|
-
tag: one(tag, {
|
|
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, {
|
|
286
262
|
fields: [
|
|
287
|
-
|
|
263
|
+
communicationPreferences.userId
|
|
288
264
|
],
|
|
289
265
|
references: [
|
|
290
|
-
|
|
266
|
+
users.id
|
|
291
267
|
],
|
|
292
|
-
relationName: "
|
|
293
|
-
})
|
|
294
|
-
}));
|
|
295
|
-
}
|
|
296
|
-
__name(getContentResourceTagRelationsSchema, "getContentResourceTagRelationsSchema");
|
|
297
|
-
|
|
298
|
-
// src/lib/mysql/schemas/content/content-resource-version.ts
|
|
299
|
-
import { relations as relations5, sql as sql5 } from "drizzle-orm";
|
|
300
|
-
import { index as index5, int, json as json4, timestamp as timestamp5, unique, varchar as varchar5 } from "drizzle-orm/mysql-core";
|
|
301
|
-
function getContentResourceVersionSchema(mysqlTable) {
|
|
302
|
-
return mysqlTable("ContentResourceVersion", {
|
|
303
|
-
id: varchar5("id", {
|
|
304
|
-
length: 255
|
|
305
|
-
}).notNull().primaryKey(),
|
|
306
|
-
resourceId: varchar5("resourceId", {
|
|
307
|
-
length: 255
|
|
308
|
-
}).notNull(),
|
|
309
|
-
parentVersionId: varchar5("parentVersionId", {
|
|
310
|
-
length: 255
|
|
268
|
+
relationName: "user"
|
|
311
269
|
}),
|
|
312
|
-
|
|
313
|
-
fields: json4("fields").$type().default({}),
|
|
314
|
-
createdAt: timestamp5("createdAt", {
|
|
315
|
-
mode: "date",
|
|
316
|
-
fsp: 3
|
|
317
|
-
}).default(sql5`CURRENT_TIMESTAMP(3)`),
|
|
318
|
-
createdById: varchar5("createdById", {
|
|
319
|
-
length: 255
|
|
320
|
-
}).notNull()
|
|
321
|
-
}, (crv) => ({
|
|
322
|
-
resourceIdIdx: index5("resourceId_idx").on(crv.resourceId),
|
|
323
|
-
parentVersionIdIdx: index5("parentVersionId_idx").on(crv.parentVersionId),
|
|
324
|
-
resourceIdVersionNumberIdx: index5("resourceId_versionNumber_idx").on(crv.resourceId, crv.versionNumber),
|
|
325
|
-
uniqueResourceVersion: unique("uq_resource_version_number").on(crv.resourceId, crv.versionNumber)
|
|
326
|
-
}));
|
|
327
|
-
}
|
|
328
|
-
__name(getContentResourceVersionSchema, "getContentResourceVersionSchema");
|
|
329
|
-
function getContentResourceVersionRelationsSchema(mysqlTable) {
|
|
330
|
-
const contentResourceVersion = getContentResourceVersionSchema(mysqlTable);
|
|
331
|
-
const contentResource = getContentResourceSchema(mysqlTable);
|
|
332
|
-
const users = getUsersSchema(mysqlTable);
|
|
333
|
-
return relations5(contentResourceVersion, ({ one }) => ({
|
|
334
|
-
resource: one(contentResource, {
|
|
270
|
+
organizationMembership: one(organizationMemberships, {
|
|
335
271
|
fields: [
|
|
336
|
-
|
|
272
|
+
communicationPreferences.organizationMembershipId
|
|
337
273
|
],
|
|
338
274
|
references: [
|
|
339
|
-
|
|
275
|
+
organizationMemberships.id
|
|
340
276
|
],
|
|
341
|
-
relationName: "
|
|
277
|
+
relationName: "organizationMembership"
|
|
342
278
|
}),
|
|
343
|
-
|
|
279
|
+
channel: one(communicationChannel, {
|
|
344
280
|
fields: [
|
|
345
|
-
|
|
281
|
+
communicationPreferences.channelId
|
|
346
282
|
],
|
|
347
283
|
references: [
|
|
348
|
-
|
|
284
|
+
communicationChannel.id
|
|
349
285
|
],
|
|
350
|
-
relationName: "
|
|
286
|
+
relationName: "channel"
|
|
351
287
|
}),
|
|
352
|
-
|
|
288
|
+
preferenceType: one(communicationPreferenceTypes, {
|
|
353
289
|
fields: [
|
|
354
|
-
|
|
290
|
+
communicationPreferences.preferenceTypeId
|
|
355
291
|
],
|
|
356
292
|
references: [
|
|
357
|
-
|
|
293
|
+
communicationPreferenceTypes.id
|
|
358
294
|
],
|
|
359
|
-
relationName: "
|
|
295
|
+
relationName: "preferenceType"
|
|
360
296
|
})
|
|
361
297
|
}));
|
|
362
298
|
}
|
|
363
|
-
__name(
|
|
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";
|
|
364
304
|
|
|
365
305
|
// src/lib/mysql/schemas/content/content-resource.ts
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
id: varchar6("id", {
|
|
369
|
-
length: 255
|
|
370
|
-
}).notNull().primaryKey(),
|
|
371
|
-
type: varchar6("type", {
|
|
372
|
-
length: 255
|
|
373
|
-
}).notNull(),
|
|
374
|
-
createdById: varchar6("createdById", {
|
|
375
|
-
length: 255
|
|
376
|
-
}).notNull(),
|
|
377
|
-
fields: json5("fields").$type().default({}),
|
|
378
|
-
currentVersionId: varchar6("currentVersionId", {
|
|
379
|
-
length: 255
|
|
380
|
-
}),
|
|
381
|
-
createdAt: timestamp6("createdAt", {
|
|
382
|
-
mode: "date",
|
|
383
|
-
fsp: 3
|
|
384
|
-
}).default(sql6`CURRENT_TIMESTAMP(3)`),
|
|
385
|
-
updatedAt: timestamp6("updatedAt", {
|
|
386
|
-
mode: "date",
|
|
387
|
-
fsp: 3
|
|
388
|
-
}).default(sql6`CURRENT_TIMESTAMP(3)`),
|
|
389
|
-
deletedAt: timestamp6("deletedAt", {
|
|
390
|
-
mode: "date",
|
|
391
|
-
fsp: 3
|
|
392
|
-
})
|
|
393
|
-
}, (cm) => ({
|
|
394
|
-
typeIdx: index6("type_idx").on(cm.type),
|
|
395
|
-
createdByIdx: index6("createdById_idx").on(cm.createdById),
|
|
396
|
-
createdAtIdx: index6("createdAt_idx").on(cm.createdAt),
|
|
397
|
-
currentVersionIdIdx: index6("currentVersionId_idx").on(cm.currentVersionId)
|
|
398
|
-
}));
|
|
399
|
-
}
|
|
400
|
-
__name(getContentResourceSchema, "getContentResourceSchema");
|
|
401
|
-
function getContentResourceRelationsSchema(mysqlTable) {
|
|
402
|
-
const contentResource = getContentResourceSchema(mysqlTable);
|
|
403
|
-
const users = getUsersSchema(mysqlTable);
|
|
404
|
-
const contentResourceResource = getContentResourceResourceSchema(mysqlTable);
|
|
405
|
-
const contentResourceProduct = getContentResourceProductSchema(mysqlTable);
|
|
406
|
-
const contentContributions = getContentContributionsSchema(mysqlTable);
|
|
407
|
-
const contentResourceTag = getContentResourceTagSchema(mysqlTable);
|
|
408
|
-
const contentResourceVersion = getContentResourceVersionSchema(mysqlTable);
|
|
409
|
-
const tag = getTagSchema(mysqlTable);
|
|
410
|
-
return relations6(contentResource, ({ one, many }) => ({
|
|
411
|
-
createdBy: one(users, {
|
|
412
|
-
fields: [
|
|
413
|
-
contentResource.createdById
|
|
414
|
-
],
|
|
415
|
-
references: [
|
|
416
|
-
users.id
|
|
417
|
-
],
|
|
418
|
-
relationName: "creator"
|
|
419
|
-
}),
|
|
420
|
-
tags: many(contentResourceTag, {
|
|
421
|
-
relationName: "contentResource"
|
|
422
|
-
}),
|
|
423
|
-
resources: many(contentResourceResource, {
|
|
424
|
-
relationName: "resourceOf"
|
|
425
|
-
}),
|
|
426
|
-
resourceOf: many(contentResourceResource, {
|
|
427
|
-
relationName: "resource"
|
|
428
|
-
}),
|
|
429
|
-
resourceProducts: many(contentResourceProduct, {
|
|
430
|
-
relationName: "resource"
|
|
431
|
-
}),
|
|
432
|
-
contributions: many(contentContributions, {
|
|
433
|
-
relationName: "contributions"
|
|
434
|
-
}),
|
|
435
|
-
currentVersion: one(contentResourceVersion, {
|
|
436
|
-
fields: [
|
|
437
|
-
contentResource.currentVersionId
|
|
438
|
-
],
|
|
439
|
-
references: [
|
|
440
|
-
contentResourceVersion.id
|
|
441
|
-
],
|
|
442
|
-
relationName: "currentVersionResource"
|
|
443
|
-
}),
|
|
444
|
-
versions: many(contentResourceVersion, {
|
|
445
|
-
relationName: "resource"
|
|
446
|
-
})
|
|
447
|
-
}));
|
|
448
|
-
}
|
|
449
|
-
__name(getContentResourceRelationsSchema, "getContentResourceRelationsSchema");
|
|
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";
|
|
450
308
|
|
|
451
309
|
// src/lib/mysql/schemas/content/content-resource-product.ts
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
length: 255
|
|
459
|
-
}).notNull(),
|
|
460
|
-
position: double4("position").notNull().default(0),
|
|
461
|
-
metadata: json6("metadata").$type().default({}),
|
|
462
|
-
createdAt: timestamp7("createdAt", {
|
|
463
|
-
mode: "date",
|
|
464
|
-
fsp: 3
|
|
465
|
-
}).default(sql7`CURRENT_TIMESTAMP(3)`),
|
|
466
|
-
updatedAt: timestamp7("updatedAt", {
|
|
467
|
-
mode: "date",
|
|
468
|
-
fsp: 3
|
|
469
|
-
}).default(sql7`CURRENT_TIMESTAMP(3)`),
|
|
470
|
-
deletedAt: timestamp7("deletedAt", {
|
|
471
|
-
mode: "date",
|
|
472
|
-
fsp: 3
|
|
473
|
-
})
|
|
474
|
-
}, (crr) => ({
|
|
475
|
-
pk: primaryKey4({
|
|
476
|
-
columns: [
|
|
477
|
-
crr.productId,
|
|
478
|
-
crr.resourceId
|
|
479
|
-
]
|
|
480
|
-
}),
|
|
481
|
-
contentResourceIdIdx: index7("contentResourceId_idx").on(crr.productId),
|
|
482
|
-
resourceIdIdx: index7("resourceId_idx").on(crr.resourceId)
|
|
483
|
-
}));
|
|
484
|
-
}
|
|
485
|
-
__name(getContentResourceProductSchema, "getContentResourceProductSchema");
|
|
486
|
-
function getContentResourceProductRelationsSchema(mysqlTable) {
|
|
487
|
-
const contentResource = getContentResourceSchema(mysqlTable);
|
|
488
|
-
const contentResourceProduct = getContentResourceProductSchema(mysqlTable);
|
|
489
|
-
const product = getProductSchema(mysqlTable);
|
|
490
|
-
return relations7(contentResourceProduct, ({ one }) => ({
|
|
491
|
-
product: one(product, {
|
|
492
|
-
fields: [
|
|
493
|
-
contentResourceProduct.productId
|
|
494
|
-
],
|
|
495
|
-
references: [
|
|
496
|
-
product.id
|
|
497
|
-
],
|
|
498
|
-
relationName: "product"
|
|
499
|
-
}),
|
|
500
|
-
resource: one(contentResource, {
|
|
501
|
-
fields: [
|
|
502
|
-
contentResourceProduct.resourceId
|
|
503
|
-
],
|
|
504
|
-
references: [
|
|
505
|
-
contentResource.id
|
|
506
|
-
],
|
|
507
|
-
relationName: "resource"
|
|
508
|
-
})
|
|
509
|
-
}));
|
|
510
|
-
}
|
|
511
|
-
__name(getContentResourceProductRelationsSchema, "getContentResourceProductRelationsSchema");
|
|
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";
|
|
512
316
|
|
|
513
317
|
// src/lib/mysql/schemas/commerce/price.ts
|
|
514
|
-
import { relations as
|
|
515
|
-
import { decimal,
|
|
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";
|
|
516
320
|
function getPriceSchema(mysqlTable) {
|
|
517
321
|
return mysqlTable("Price", {
|
|
518
|
-
id:
|
|
322
|
+
id: varchar4("id", {
|
|
519
323
|
length: 191
|
|
520
324
|
}).notNull(),
|
|
521
|
-
productId:
|
|
325
|
+
productId: varchar4("productId", {
|
|
522
326
|
length: 191
|
|
523
327
|
}),
|
|
524
|
-
|
|
328
|
+
organizationId: varchar4("organizationId", {
|
|
525
329
|
length: 191
|
|
526
330
|
}),
|
|
527
|
-
|
|
331
|
+
nickname: varchar4("nickname", {
|
|
332
|
+
length: 191
|
|
333
|
+
}),
|
|
334
|
+
status: int("status").default(0).notNull(),
|
|
528
335
|
unitAmount: decimal("unitAmount", {
|
|
529
336
|
precision: 10,
|
|
530
337
|
scale: 2
|
|
531
338
|
}).notNull(),
|
|
532
|
-
createdAt:
|
|
339
|
+
createdAt: timestamp4("createdAt", {
|
|
533
340
|
mode: "date",
|
|
534
341
|
fsp: 3
|
|
535
|
-
}).default(
|
|
536
|
-
fields:
|
|
342
|
+
}).default(sql3`CURRENT_TIMESTAMP(3)`).notNull(),
|
|
343
|
+
fields: json3("fields").$type().default({})
|
|
537
344
|
}, (table) => {
|
|
538
345
|
return {
|
|
539
|
-
priceId:
|
|
346
|
+
priceId: primaryKey2({
|
|
540
347
|
columns: [
|
|
541
348
|
table.id
|
|
542
349
|
],
|
|
543
350
|
name: "Price_id"
|
|
544
|
-
})
|
|
351
|
+
}),
|
|
352
|
+
organizationIdIdx: index4("organizationId_idx").on(table.organizationId)
|
|
545
353
|
};
|
|
546
354
|
});
|
|
547
355
|
}
|
|
@@ -550,7 +358,7 @@ function getProductRelationsSchema(mysqlTable) {
|
|
|
550
358
|
const product = getProductSchema(mysqlTable);
|
|
551
359
|
const price = getPriceSchema(mysqlTable);
|
|
552
360
|
const merchantPrice = getMerchantPriceSchema(mysqlTable);
|
|
553
|
-
return
|
|
361
|
+
return relations4(price, ({ one, many }) => ({
|
|
554
362
|
product: one(product, {
|
|
555
363
|
fields: [
|
|
556
364
|
price.productId
|
|
@@ -576,33 +384,37 @@ __name(getProductRelationsSchema, "getProductRelationsSchema");
|
|
|
576
384
|
// src/lib/mysql/schemas/commerce/product.ts
|
|
577
385
|
function getProductSchema(mysqlTable) {
|
|
578
386
|
return mysqlTable("Product", {
|
|
579
|
-
id:
|
|
387
|
+
id: varchar5("id", {
|
|
580
388
|
length: 191
|
|
581
389
|
}).notNull(),
|
|
582
|
-
|
|
390
|
+
organizationId: varchar5("organizationId", {
|
|
391
|
+
length: 191
|
|
392
|
+
}),
|
|
393
|
+
name: varchar5("name", {
|
|
583
394
|
length: 191
|
|
584
395
|
}).notNull(),
|
|
585
|
-
key:
|
|
396
|
+
key: varchar5("key", {
|
|
586
397
|
length: 191
|
|
587
398
|
}),
|
|
588
|
-
type:
|
|
399
|
+
type: varchar5("type", {
|
|
589
400
|
length: 191
|
|
590
401
|
}),
|
|
591
|
-
fields:
|
|
592
|
-
createdAt:
|
|
402
|
+
fields: json4("fields").$type().default({}),
|
|
403
|
+
createdAt: timestamp5("createdAt", {
|
|
593
404
|
mode: "date",
|
|
594
405
|
fsp: 3
|
|
595
|
-
}).default(
|
|
596
|
-
status:
|
|
597
|
-
quantityAvailable:
|
|
406
|
+
}).default(sql4`CURRENT_TIMESTAMP(3)`).notNull(),
|
|
407
|
+
status: int2("status").default(0).notNull(),
|
|
408
|
+
quantityAvailable: int2("quantityAvailable").default(-1).notNull()
|
|
598
409
|
}, (table) => {
|
|
599
410
|
return {
|
|
600
|
-
productId:
|
|
411
|
+
productId: primaryKey3({
|
|
601
412
|
columns: [
|
|
602
413
|
table.id
|
|
603
414
|
],
|
|
604
415
|
name: "Product_id"
|
|
605
|
-
})
|
|
416
|
+
}),
|
|
417
|
+
organizationIdIdx: index5("organizationId_idx").on(table.organizationId)
|
|
606
418
|
};
|
|
607
419
|
});
|
|
608
420
|
}
|
|
@@ -612,7 +424,7 @@ function getProductRelationsSchema2(mysqlTable) {
|
|
|
612
424
|
const price = getPriceSchema(mysqlTable);
|
|
613
425
|
const merchantProduct = getMerchantProductSchema(mysqlTable);
|
|
614
426
|
const contentResourceProduct = getContentResourceProductSchema(mysqlTable);
|
|
615
|
-
return
|
|
427
|
+
return relations5(product, ({ one, many }) => ({
|
|
616
428
|
price: one(price, {
|
|
617
429
|
fields: [
|
|
618
430
|
product.id
|
|
@@ -638,361 +450,592 @@ function getProductRelationsSchema2(mysqlTable) {
|
|
|
638
450
|
}
|
|
639
451
|
__name(getProductRelationsSchema2, "getProductRelationsSchema");
|
|
640
452
|
|
|
641
|
-
// src/lib/mysql/schemas/
|
|
642
|
-
function
|
|
643
|
-
return mysqlTable("
|
|
644
|
-
|
|
645
|
-
length:
|
|
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
|
|
646
461
|
}).notNull(),
|
|
647
|
-
|
|
462
|
+
organizationId: varchar6("organizationId", {
|
|
648
463
|
length: 191
|
|
649
464
|
}),
|
|
650
|
-
|
|
465
|
+
position: double("position").notNull().default(0),
|
|
466
|
+
metadata: json5("metadata").$type().default({}),
|
|
467
|
+
createdAt: timestamp6("createdAt", {
|
|
651
468
|
mode: "date",
|
|
652
469
|
fsp: 3
|
|
653
|
-
}).default(
|
|
654
|
-
|
|
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", {
|
|
655
476
|
mode: "date",
|
|
656
477
|
fsp: 3
|
|
657
|
-
}),
|
|
658
|
-
fields: json9("fields").$type().default({}),
|
|
659
|
-
maxUses: int4("maxUses").default(-1).notNull(),
|
|
660
|
-
default: boolean("default").default(false).notNull(),
|
|
661
|
-
merchantCouponId: varchar10("merchantCouponId", {
|
|
662
|
-
length: 191
|
|
663
|
-
}),
|
|
664
|
-
status: int4("status").default(0).notNull(),
|
|
665
|
-
usedCount: int4("usedCount").default(0).notNull(),
|
|
666
|
-
percentageDiscount: decimal2("percentageDiscount", {
|
|
667
|
-
precision: 3,
|
|
668
|
-
scale: 2
|
|
669
|
-
}).notNull(),
|
|
670
|
-
restrictedToProductId: varchar10("restrictedToProductId", {
|
|
671
|
-
length: 191
|
|
672
478
|
})
|
|
673
|
-
}, (
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
],
|
|
680
|
-
name: "Coupon_id"
|
|
681
|
-
}),
|
|
682
|
-
couponCodeKey: unique2("Coupon_code_key").on(table.code)
|
|
683
|
-
};
|
|
684
|
-
});
|
|
685
|
-
}
|
|
686
|
-
__name(getCouponSchema, "getCouponSchema");
|
|
687
|
-
function getCouponRelationsSchema(mysqlTable) {
|
|
688
|
-
const purchase = getPurchaseSchema(mysqlTable);
|
|
689
|
-
const coupon = getCouponSchema(mysqlTable);
|
|
690
|
-
const merchantCoupon = getMerchantCouponSchema(mysqlTable);
|
|
691
|
-
return relations10(coupon, ({ many, one }) => ({
|
|
692
|
-
redeemedBulkCouponPurchases: many(purchase, {
|
|
693
|
-
relationName: "redeemedBulkCoupon"
|
|
479
|
+
}, (crr) => ({
|
|
480
|
+
pk: primaryKey4({
|
|
481
|
+
columns: [
|
|
482
|
+
crr.productId,
|
|
483
|
+
crr.resourceId
|
|
484
|
+
]
|
|
694
485
|
}),
|
|
695
|
-
|
|
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, {
|
|
696
498
|
fields: [
|
|
697
|
-
|
|
499
|
+
contentResourceProduct.productId
|
|
698
500
|
],
|
|
699
501
|
references: [
|
|
700
|
-
|
|
502
|
+
product.id
|
|
701
503
|
],
|
|
702
|
-
relationName: "
|
|
504
|
+
relationName: "product"
|
|
703
505
|
}),
|
|
704
|
-
|
|
506
|
+
resource: one(contentResource, {
|
|
705
507
|
fields: [
|
|
706
|
-
|
|
508
|
+
contentResourceProduct.resourceId
|
|
707
509
|
],
|
|
708
510
|
references: [
|
|
709
|
-
|
|
511
|
+
contentResource.id
|
|
710
512
|
],
|
|
711
|
-
relationName: "
|
|
712
|
-
}),
|
|
713
|
-
bulkPurchases: many(purchase, {
|
|
714
|
-
relationName: "bulkCoupon"
|
|
513
|
+
relationName: "resource"
|
|
715
514
|
})
|
|
716
515
|
}));
|
|
717
516
|
}
|
|
718
|
-
__name(
|
|
517
|
+
__name(getContentResourceProductRelationsSchema, "getContentResourceProductRelationsSchema");
|
|
719
518
|
|
|
720
|
-
// src/lib/mysql/schemas/
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
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
|
|
725
529
|
}).notNull(),
|
|
726
|
-
|
|
530
|
+
position: double2("position").notNull().default(0),
|
|
531
|
+
metadata: json6("metadata").$type().default({}),
|
|
532
|
+
organizationId: varchar7("organizationId", {
|
|
727
533
|
length: 191
|
|
728
534
|
}),
|
|
729
|
-
createdAt:
|
|
535
|
+
createdAt: timestamp7("createdAt", {
|
|
730
536
|
mode: "date",
|
|
731
537
|
fsp: 3
|
|
732
|
-
}).default(
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
}).
|
|
737
|
-
|
|
738
|
-
|
|
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
|
+
]
|
|
739
553
|
}),
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
length: 191
|
|
745
|
-
}),
|
|
746
|
-
country: varchar11("country", {
|
|
747
|
-
length: 191
|
|
748
|
-
}),
|
|
749
|
-
couponId: varchar11("couponId", {
|
|
750
|
-
length: 191
|
|
751
|
-
}),
|
|
752
|
-
productId: varchar11("productId", {
|
|
753
|
-
length: 191
|
|
754
|
-
}).notNull(),
|
|
755
|
-
merchantChargeId: varchar11("merchantChargeId", {
|
|
756
|
-
length: 191
|
|
757
|
-
}),
|
|
758
|
-
upgradedFromId: varchar11("upgradedFromId", {
|
|
759
|
-
length: 191
|
|
760
|
-
}),
|
|
761
|
-
status: varchar11("status", {
|
|
762
|
-
length: 191
|
|
763
|
-
}).default("Valid").notNull(),
|
|
764
|
-
bulkCouponId: varchar11("bulkCouponId", {
|
|
765
|
-
length: 191
|
|
766
|
-
}),
|
|
767
|
-
merchantSessionId: varchar11("merchantSessionId", {
|
|
768
|
-
length: 191
|
|
769
|
-
}),
|
|
770
|
-
redeemedBulkCouponId: varchar11("redeemedBulkCouponId", {
|
|
771
|
-
length: 191
|
|
772
|
-
}),
|
|
773
|
-
fields: json10("fields").$type().default({})
|
|
774
|
-
}, (table) => {
|
|
775
|
-
return {
|
|
776
|
-
purchaseId: primaryKey8({
|
|
777
|
-
columns: [
|
|
778
|
-
table.id
|
|
779
|
-
],
|
|
780
|
-
name: "Purchase_id"
|
|
781
|
-
}),
|
|
782
|
-
merchantChargeIdIdx: index9("idx_Purchase_on_merchantChargeId").on(table.merchantChargeId),
|
|
783
|
-
purchaseUpgradedFromIdKey: unique3("Purchase_upgradedFromId_key").on(table.upgradedFromId)
|
|
784
|
-
};
|
|
785
|
-
});
|
|
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
|
+
}));
|
|
786
558
|
}
|
|
787
|
-
__name(
|
|
788
|
-
function
|
|
789
|
-
const
|
|
790
|
-
const
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
const merchantSessions = getMerchantSessionSchema(mysqlTable);
|
|
794
|
-
const coupons = getCouponSchema(mysqlTable);
|
|
795
|
-
return relations11(purchases, ({ many, one }) => ({
|
|
796
|
-
redeemedBulkCoupon: one(coupons, {
|
|
797
|
-
fields: [
|
|
798
|
-
purchases.redeemedBulkCouponId
|
|
799
|
-
],
|
|
800
|
-
references: [
|
|
801
|
-
coupons.id
|
|
802
|
-
],
|
|
803
|
-
relationName: "redeemedBulkCoupon"
|
|
804
|
-
}),
|
|
805
|
-
user: one(users, {
|
|
806
|
-
fields: [
|
|
807
|
-
purchases.userId
|
|
808
|
-
],
|
|
809
|
-
references: [
|
|
810
|
-
users.id
|
|
811
|
-
],
|
|
812
|
-
relationName: "user"
|
|
813
|
-
}),
|
|
814
|
-
product: one(products, {
|
|
815
|
-
fields: [
|
|
816
|
-
purchases.productId
|
|
817
|
-
],
|
|
818
|
-
references: [
|
|
819
|
-
products.id
|
|
820
|
-
],
|
|
821
|
-
relationName: "product"
|
|
822
|
-
}),
|
|
823
|
-
bulkCoupon: one(coupons, {
|
|
824
|
-
fields: [
|
|
825
|
-
purchases.bulkCouponId
|
|
826
|
-
],
|
|
827
|
-
references: [
|
|
828
|
-
coupons.id
|
|
829
|
-
],
|
|
830
|
-
relationName: "bulkCoupon"
|
|
831
|
-
}),
|
|
832
|
-
merchantCharge: one(merchantCharges, {
|
|
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, {
|
|
833
565
|
fields: [
|
|
834
|
-
|
|
566
|
+
contentResourceResource.resourceOfId
|
|
835
567
|
],
|
|
836
568
|
references: [
|
|
837
|
-
|
|
569
|
+
contentResource.id
|
|
838
570
|
],
|
|
839
|
-
relationName: "
|
|
571
|
+
relationName: "resourceOf"
|
|
840
572
|
}),
|
|
841
|
-
|
|
573
|
+
resource: one(contentResource, {
|
|
842
574
|
fields: [
|
|
843
|
-
|
|
575
|
+
contentResourceResource.resourceId
|
|
844
576
|
],
|
|
845
577
|
references: [
|
|
846
|
-
|
|
578
|
+
contentResource.id
|
|
847
579
|
],
|
|
848
|
-
relationName: "
|
|
580
|
+
relationName: "resource"
|
|
849
581
|
})
|
|
850
582
|
}));
|
|
851
583
|
}
|
|
852
|
-
__name(
|
|
584
|
+
__name(getContentResourceResourceRelationsSchema, "getContentResourceResourceRelationsSchema");
|
|
853
585
|
|
|
854
|
-
// src/lib/mysql/schemas/
|
|
855
|
-
import { relations as
|
|
856
|
-
import {
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
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
|
|
861
601
|
}).notNull(),
|
|
862
|
-
|
|
602
|
+
childTagId: varchar8("childTagId", {
|
|
863
603
|
length: 255
|
|
864
604
|
}).notNull(),
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
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", {
|
|
868
611
|
mode: "date",
|
|
869
612
|
fsp: 3
|
|
870
|
-
}).default(
|
|
871
|
-
updatedAt:
|
|
613
|
+
}).default(sql7`CURRENT_TIMESTAMP(3)`),
|
|
614
|
+
updatedAt: timestamp8("updatedAt", {
|
|
872
615
|
mode: "date",
|
|
873
616
|
fsp: 3
|
|
874
|
-
}).default(
|
|
875
|
-
deletedAt:
|
|
617
|
+
}).default(sql7`CURRENT_TIMESTAMP(3)`),
|
|
618
|
+
deletedAt: timestamp8("deletedAt", {
|
|
876
619
|
mode: "date",
|
|
877
620
|
fsp: 3
|
|
878
621
|
})
|
|
879
|
-
}, (
|
|
880
|
-
pk:
|
|
622
|
+
}, (tt) => ({
|
|
623
|
+
pk: primaryKey6({
|
|
881
624
|
columns: [
|
|
882
|
-
|
|
625
|
+
tt.parentTagId,
|
|
626
|
+
tt.childTagId
|
|
883
627
|
]
|
|
884
628
|
}),
|
|
885
|
-
|
|
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)
|
|
886
633
|
}));
|
|
887
634
|
}
|
|
888
|
-
__name(
|
|
889
|
-
function
|
|
890
|
-
const
|
|
891
|
-
const
|
|
892
|
-
return
|
|
893
|
-
|
|
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, {
|
|
894
641
|
fields: [
|
|
895
|
-
|
|
642
|
+
tagTag.parentTagId
|
|
896
643
|
],
|
|
897
644
|
references: [
|
|
898
|
-
|
|
645
|
+
tag.id
|
|
899
646
|
],
|
|
900
|
-
relationName: "
|
|
647
|
+
relationName: "parentTag"
|
|
648
|
+
}),
|
|
649
|
+
childTag: one(tag, {
|
|
650
|
+
fields: [
|
|
651
|
+
tagTag.childTagId
|
|
652
|
+
],
|
|
653
|
+
references: [
|
|
654
|
+
tag.id
|
|
655
|
+
],
|
|
656
|
+
relationName: "childTag"
|
|
901
657
|
})
|
|
902
658
|
}));
|
|
903
659
|
}
|
|
904
|
-
__name(
|
|
660
|
+
__name(getTagTagRelationsSchema, "getTagTagRelationsSchema");
|
|
905
661
|
|
|
906
|
-
// src/lib/mysql/schemas/
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
return mysqlTable("CommunicationPreference", {
|
|
911
|
-
id: varchar13("id", {
|
|
662
|
+
// src/lib/mysql/schemas/content/tag.ts
|
|
663
|
+
function getTagSchema(mysqlTable) {
|
|
664
|
+
return mysqlTable("Tag", {
|
|
665
|
+
id: varchar9("id", {
|
|
912
666
|
length: 255
|
|
913
667
|
}).notNull().primaryKey(),
|
|
914
|
-
|
|
915
|
-
length:
|
|
916
|
-
})
|
|
917
|
-
|
|
918
|
-
length: 255
|
|
919
|
-
}).notNull(),
|
|
920
|
-
preferenceLevel: mysqlEnum("preferenceLevel", [
|
|
921
|
-
"low",
|
|
922
|
-
"medium",
|
|
923
|
-
"high"
|
|
924
|
-
]).notNull().default("medium"),
|
|
925
|
-
preferenceTypeId: varchar13("preferenceTypeId", {
|
|
668
|
+
organizationId: varchar9("organizationId", {
|
|
669
|
+
length: 191
|
|
670
|
+
}),
|
|
671
|
+
type: varchar9("type", {
|
|
926
672
|
length: 255
|
|
927
673
|
}).notNull(),
|
|
928
|
-
|
|
929
|
-
createdAt:
|
|
674
|
+
fields: json8("fields").$type().default({}),
|
|
675
|
+
createdAt: timestamp9("createdAt", {
|
|
930
676
|
mode: "date",
|
|
931
677
|
fsp: 3
|
|
932
|
-
}).
|
|
933
|
-
|
|
678
|
+
}).default(sql8`CURRENT_TIMESTAMP(3)`),
|
|
679
|
+
updatedAt: timestamp9("updatedAt", {
|
|
934
680
|
mode: "date",
|
|
935
681
|
fsp: 3
|
|
936
|
-
}),
|
|
937
|
-
|
|
682
|
+
}).default(sql8`CURRENT_TIMESTAMP(3)`),
|
|
683
|
+
deletedAt: timestamp9("deletedAt", {
|
|
938
684
|
mode: "date",
|
|
939
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"
|
|
940
700
|
}),
|
|
941
|
-
|
|
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", {
|
|
942
725
|
mode: "date",
|
|
943
726
|
fsp: 3
|
|
944
|
-
}).
|
|
945
|
-
|
|
727
|
+
}).default(sql9`CURRENT_TIMESTAMP(3)`),
|
|
728
|
+
updatedAt: timestamp10("updatedAt", {
|
|
946
729
|
mode: "date",
|
|
947
730
|
fsp: 3
|
|
948
|
-
})
|
|
949
|
-
}, (
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
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)
|
|
953
743
|
}));
|
|
954
744
|
}
|
|
955
|
-
__name(
|
|
956
|
-
function
|
|
957
|
-
const
|
|
958
|
-
const
|
|
959
|
-
const
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
user: one(users, {
|
|
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, {
|
|
963
752
|
fields: [
|
|
964
|
-
|
|
753
|
+
contentResourceTag.contentResourceId
|
|
965
754
|
],
|
|
966
755
|
references: [
|
|
967
|
-
|
|
756
|
+
contentResource.id
|
|
968
757
|
],
|
|
969
|
-
relationName: "
|
|
758
|
+
relationName: "contentResource"
|
|
970
759
|
}),
|
|
971
|
-
|
|
760
|
+
tag: one(tag, {
|
|
972
761
|
fields: [
|
|
973
|
-
|
|
762
|
+
contentResourceTag.tagId
|
|
974
763
|
],
|
|
975
764
|
references: [
|
|
976
|
-
|
|
765
|
+
tag.id
|
|
977
766
|
],
|
|
978
|
-
relationName: "
|
|
979
|
-
})
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
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
|
|
983
816
|
],
|
|
984
817
|
references: [
|
|
985
|
-
|
|
818
|
+
contentResource.id
|
|
986
819
|
],
|
|
987
|
-
relationName: "
|
|
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"
|
|
988
839
|
})
|
|
989
840
|
}));
|
|
990
841
|
}
|
|
991
|
-
__name(
|
|
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");
|
|
992
1035
|
|
|
993
1036
|
// src/lib/mysql/schemas/auth/accounts.ts
|
|
994
1037
|
import { relations as relations14 } from "drizzle-orm";
|
|
995
|
-
import { index as
|
|
1038
|
+
import { index as index14, int as int4, primaryKey as primaryKey8, text as text2, varchar as varchar14 } from "drizzle-orm/mysql-core";
|
|
996
1039
|
function getAccountsSchema(mysqlTable) {
|
|
997
1040
|
return mysqlTable("Account", {
|
|
998
1041
|
userId: varchar14("userId", {
|
|
@@ -1011,7 +1054,7 @@ function getAccountsSchema(mysqlTable) {
|
|
|
1011
1054
|
access_token: text2("access_token"),
|
|
1012
1055
|
oauth_token: text2("oauth_token"),
|
|
1013
1056
|
oauth_token_secret: text2("oauth_token_secret"),
|
|
1014
|
-
expires_at:
|
|
1057
|
+
expires_at: int4("expires_at"),
|
|
1015
1058
|
token_type: varchar14("token_type", {
|
|
1016
1059
|
length: 255
|
|
1017
1060
|
}),
|
|
@@ -1022,15 +1065,15 @@ function getAccountsSchema(mysqlTable) {
|
|
|
1022
1065
|
session_state: varchar14("session_state", {
|
|
1023
1066
|
length: 255
|
|
1024
1067
|
}),
|
|
1025
|
-
refresh_token_expires_in:
|
|
1068
|
+
refresh_token_expires_in: int4("refresh_token_expires_in")
|
|
1026
1069
|
}, (account) => ({
|
|
1027
|
-
pk:
|
|
1070
|
+
pk: primaryKey8({
|
|
1028
1071
|
columns: [
|
|
1029
1072
|
account.provider,
|
|
1030
1073
|
account.providerAccountId
|
|
1031
1074
|
]
|
|
1032
1075
|
}),
|
|
1033
|
-
userIdIdx:
|
|
1076
|
+
userIdIdx: index14("userId_idx").on(account.userId)
|
|
1034
1077
|
}));
|
|
1035
1078
|
}
|
|
1036
1079
|
__name(getAccountsSchema, "getAccountsSchema");
|
|
@@ -1053,12 +1096,15 @@ __name(getAccountsRelationsSchema, "getAccountsRelationsSchema");
|
|
|
1053
1096
|
|
|
1054
1097
|
// src/lib/mysql/schemas/auth/user-permissions.ts
|
|
1055
1098
|
import { relations as relations15 } from "drizzle-orm";
|
|
1056
|
-
import { boolean as boolean3, index as
|
|
1099
|
+
import { boolean as boolean3, index as index15, primaryKey as primaryKey9, timestamp as timestamp14, varchar as varchar15 } from "drizzle-orm/mysql-core";
|
|
1057
1100
|
function getUserPermissionsSchema(mysqlTable) {
|
|
1058
1101
|
return mysqlTable("UserPermission", {
|
|
1059
1102
|
userId: varchar15("userId", {
|
|
1060
1103
|
length: 255
|
|
1061
1104
|
}).notNull(),
|
|
1105
|
+
organizationId: varchar15("organizationId", {
|
|
1106
|
+
length: 191
|
|
1107
|
+
}),
|
|
1062
1108
|
permissionId: varchar15("permissionId", {
|
|
1063
1109
|
length: 255
|
|
1064
1110
|
}).notNull(),
|
|
@@ -1076,14 +1122,15 @@ function getUserPermissionsSchema(mysqlTable) {
|
|
|
1076
1122
|
fsp: 3
|
|
1077
1123
|
})
|
|
1078
1124
|
}, (up) => ({
|
|
1079
|
-
pk:
|
|
1125
|
+
pk: primaryKey9({
|
|
1080
1126
|
columns: [
|
|
1081
1127
|
up.userId,
|
|
1082
1128
|
up.permissionId
|
|
1083
1129
|
]
|
|
1084
1130
|
}),
|
|
1085
|
-
userIdIdx:
|
|
1086
|
-
permissionIdIdx:
|
|
1131
|
+
userIdIdx: index15("userId_idx").on(up.userId),
|
|
1132
|
+
permissionIdIdx: index15("permissionId_idx").on(up.permissionId),
|
|
1133
|
+
organizationIdIdx: index15("organizationId_idx").on(up.organizationId)
|
|
1087
1134
|
}));
|
|
1088
1135
|
}
|
|
1089
1136
|
__name(getUserPermissionsSchema, "getUserPermissionsSchema");
|
|
@@ -1115,39 +1162,43 @@ function getUserPermissionsRelationsSchema(mysqlTable) {
|
|
|
1115
1162
|
__name(getUserPermissionsRelationsSchema, "getUserPermissionsRelationsSchema");
|
|
1116
1163
|
|
|
1117
1164
|
// src/lib/mysql/schemas/auth/user-prefs.ts
|
|
1118
|
-
import { relations as relations16, sql as
|
|
1119
|
-
import { index as
|
|
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";
|
|
1120
1167
|
function getUserPrefsSchema(mysqlTable) {
|
|
1121
1168
|
return mysqlTable("UserPrefs", {
|
|
1122
1169
|
id: varchar16("id", {
|
|
1123
1170
|
length: 191
|
|
1124
1171
|
}).notNull(),
|
|
1172
|
+
organizationId: varchar16("organizationId", {
|
|
1173
|
+
length: 191
|
|
1174
|
+
}),
|
|
1125
1175
|
type: varchar16("type", {
|
|
1126
1176
|
length: 191
|
|
1127
1177
|
}).default("Global").notNull(),
|
|
1128
1178
|
userId: varchar16("userId", {
|
|
1129
1179
|
length: 255
|
|
1130
1180
|
}).notNull(),
|
|
1131
|
-
fields:
|
|
1181
|
+
fields: json11("fields").$type().default({}),
|
|
1132
1182
|
createdAt: timestamp15("createdAt", {
|
|
1133
1183
|
mode: "date",
|
|
1134
1184
|
fsp: 3
|
|
1135
|
-
}).default(
|
|
1185
|
+
}).default(sql12`CURRENT_TIMESTAMP(3)`),
|
|
1136
1186
|
updatedAt: timestamp15("updatedAt", {
|
|
1137
1187
|
mode: "date",
|
|
1138
1188
|
fsp: 3
|
|
1139
|
-
}).default(
|
|
1189
|
+
}).default(sql12`CURRENT_TIMESTAMP(3)`),
|
|
1140
1190
|
deletedAt: timestamp15("deletedAt", {
|
|
1141
1191
|
mode: "date",
|
|
1142
1192
|
fsp: 3
|
|
1143
1193
|
})
|
|
1144
1194
|
}, (crr) => ({
|
|
1145
|
-
pk:
|
|
1195
|
+
pk: primaryKey10({
|
|
1146
1196
|
columns: [
|
|
1147
1197
|
crr.id
|
|
1148
1198
|
]
|
|
1149
1199
|
}),
|
|
1150
|
-
crrUserIdIdKey:
|
|
1200
|
+
crrUserIdIdKey: index16("crr_userIdId_idx").on(crr.userId),
|
|
1201
|
+
organizationIdIdx: index16("organizationId_idx").on(crr.organizationId)
|
|
1151
1202
|
}));
|
|
1152
1203
|
}
|
|
1153
1204
|
__name(getUserPrefsSchema, "getUserPrefsSchema");
|
|
@@ -1166,264 +1217,726 @@ function getUserPrefsRelationsSchema(mysqlTable) {
|
|
|
1166
1217
|
})
|
|
1167
1218
|
}));
|
|
1168
1219
|
}
|
|
1169
|
-
__name(getUserPrefsRelationsSchema, "getUserPrefsRelationsSchema");
|
|
1170
|
-
|
|
1171
|
-
// src/lib/mysql/schemas/auth/user-roles.ts
|
|
1172
|
-
import { relations as relations18 } from "drizzle-orm";
|
|
1173
|
-
import { boolean as boolean5, index as
|
|
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");
|
|
1174
1663
|
|
|
1175
|
-
// src/lib/mysql/schemas/
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
return mysqlTable("Role", {
|
|
1180
|
-
id: varchar17("id", {
|
|
1664
|
+
// src/lib/mysql/schemas/org/organizations.ts
|
|
1665
|
+
function getOrganizationsSchema(mysqlTable) {
|
|
1666
|
+
return mysqlTable("Organization", {
|
|
1667
|
+
id: varchar22("id", {
|
|
1181
1668
|
length: 255
|
|
1182
1669
|
}).notNull().primaryKey(),
|
|
1183
|
-
name:
|
|
1670
|
+
name: varchar22("name", {
|
|
1184
1671
|
length: 255
|
|
1185
|
-
})
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
}).defaultNow(),
|
|
1192
|
-
updatedAt: timestamp16("updatedAt", {
|
|
1193
|
-
mode: "date",
|
|
1194
|
-
fsp: 3
|
|
1195
|
-
}).defaultNow(),
|
|
1196
|
-
deletedAt: timestamp16("deletedAt", {
|
|
1672
|
+
}),
|
|
1673
|
+
fields: json15("fields").$type().default({}),
|
|
1674
|
+
image: varchar22("image", {
|
|
1675
|
+
length: 255
|
|
1676
|
+
}),
|
|
1677
|
+
createdAt: timestamp21("createdAt", {
|
|
1197
1678
|
mode: "date",
|
|
1198
1679
|
fsp: 3
|
|
1199
|
-
})
|
|
1200
|
-
}, (
|
|
1201
|
-
|
|
1680
|
+
}).default(sql16`CURRENT_TIMESTAMP(3)`)
|
|
1681
|
+
}, (organization) => ({
|
|
1682
|
+
createdAtIdx: index22("created_at_idx").on(organization.createdAt)
|
|
1202
1683
|
}));
|
|
1203
1684
|
}
|
|
1204
|
-
__name(
|
|
1205
|
-
function
|
|
1206
|
-
const
|
|
1207
|
-
const
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
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"
|
|
1211
1700
|
})
|
|
1212
1701
|
}));
|
|
1213
1702
|
}
|
|
1214
|
-
__name(
|
|
1703
|
+
__name(getOrganizationsRelationsSchema, "getOrganizationsRelationsSchema");
|
|
1215
1704
|
|
|
1216
|
-
// src/lib/mysql/schemas/
|
|
1217
|
-
function
|
|
1218
|
-
return mysqlTable("
|
|
1219
|
-
|
|
1220
|
-
length:
|
|
1705
|
+
// src/lib/mysql/schemas/commerce/subscription.ts
|
|
1706
|
+
function getSubscriptionSchema(mysqlTable) {
|
|
1707
|
+
return mysqlTable("Subscription", {
|
|
1708
|
+
id: varchar23("id", {
|
|
1709
|
+
length: 191
|
|
1221
1710
|
}).notNull(),
|
|
1222
|
-
|
|
1223
|
-
length:
|
|
1711
|
+
organizationId: varchar23("organizationId", {
|
|
1712
|
+
length: 191
|
|
1713
|
+
}),
|
|
1714
|
+
productId: varchar23("productId", {
|
|
1715
|
+
length: 191
|
|
1224
1716
|
}).notNull(),
|
|
1225
|
-
|
|
1226
|
-
createdAt: timestamp17("createdAt", {
|
|
1227
|
-
mode: "date",
|
|
1228
|
-
fsp: 3
|
|
1229
|
-
}).defaultNow(),
|
|
1230
|
-
updatedAt: timestamp17("updatedAt", {
|
|
1231
|
-
mode: "date",
|
|
1232
|
-
fsp: 3
|
|
1233
|
-
}).defaultNow(),
|
|
1234
|
-
deletedAt: timestamp17("deletedAt", {
|
|
1717
|
+
createdAt: timestamp22("createdAt", {
|
|
1235
1718
|
mode: "date",
|
|
1236
1719
|
fsp: 3
|
|
1237
|
-
})
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
})
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
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
|
+
});
|
|
1248
1739
|
}
|
|
1249
|
-
__name(
|
|
1250
|
-
function
|
|
1251
|
-
const
|
|
1252
|
-
const
|
|
1253
|
-
const
|
|
1254
|
-
|
|
1255
|
-
|
|
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, {
|
|
1256
1748
|
fields: [
|
|
1257
|
-
|
|
1749
|
+
subscriptions.organizationId
|
|
1258
1750
|
],
|
|
1259
1751
|
references: [
|
|
1260
|
-
|
|
1752
|
+
organizations.id
|
|
1261
1753
|
],
|
|
1262
|
-
relationName: "
|
|
1754
|
+
relationName: "organization"
|
|
1263
1755
|
}),
|
|
1264
|
-
|
|
1756
|
+
product: one(products, {
|
|
1265
1757
|
fields: [
|
|
1266
|
-
|
|
1758
|
+
subscriptions.productId
|
|
1267
1759
|
],
|
|
1268
1760
|
references: [
|
|
1269
|
-
|
|
1761
|
+
products.id
|
|
1270
1762
|
],
|
|
1271
|
-
relationName: "
|
|
1763
|
+
relationName: "product"
|
|
1764
|
+
}),
|
|
1765
|
+
merchantSubscription: one(merchantSubscriptions, {
|
|
1766
|
+
fields: [
|
|
1767
|
+
subscriptions.merchantSubscriptionId
|
|
1768
|
+
],
|
|
1769
|
+
references: [
|
|
1770
|
+
merchantSubscriptions.id
|
|
1771
|
+
],
|
|
1772
|
+
relationName: "merchantSubscription"
|
|
1272
1773
|
})
|
|
1273
1774
|
}));
|
|
1274
1775
|
}
|
|
1275
|
-
__name(
|
|
1776
|
+
__name(getSubscriptionRelationsSchema, "getSubscriptionRelationsSchema");
|
|
1276
1777
|
|
|
1277
|
-
// src/lib/mysql/schemas/
|
|
1278
|
-
function
|
|
1279
|
-
return mysqlTable("
|
|
1280
|
-
id:
|
|
1281
|
-
length:
|
|
1282
|
-
}).notNull()
|
|
1283
|
-
|
|
1284
|
-
length:
|
|
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
|
|
1285
1786
|
}),
|
|
1286
|
-
|
|
1787
|
+
merchantAccountId: varchar24("merchantAccountId", {
|
|
1287
1788
|
length: 191
|
|
1288
|
-
}).notNull()
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
}).notNull().unique(),
|
|
1292
|
-
fields: json13("fields").$type().default({}),
|
|
1293
|
-
emailVerified: timestamp18("emailVerified", {
|
|
1789
|
+
}).notNull(),
|
|
1790
|
+
status: int6("status").default(0).notNull(),
|
|
1791
|
+
createdAt: timestamp23("createdAt", {
|
|
1294
1792
|
mode: "date",
|
|
1295
1793
|
fsp: 3
|
|
1794
|
+
}).default(sql18`CURRENT_TIMESTAMP(3)`).notNull(),
|
|
1795
|
+
label: varchar24("label", {
|
|
1796
|
+
length: 191
|
|
1296
1797
|
}),
|
|
1297
|
-
|
|
1298
|
-
length:
|
|
1798
|
+
identifier: varchar24("identifier", {
|
|
1799
|
+
length: 191
|
|
1299
1800
|
}),
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
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
|
+
});
|
|
1309
1818
|
}
|
|
1310
|
-
__name(
|
|
1311
|
-
function
|
|
1312
|
-
const
|
|
1313
|
-
const
|
|
1314
|
-
const
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
relationName: "user"
|
|
1328
|
-
}),
|
|
1329
|
-
communicationPreferences: many(communicationPreferences, {
|
|
1330
|
-
relationName: "user"
|
|
1331
|
-
}),
|
|
1332
|
-
roles: many(userRoles, {
|
|
1333
|
-
relationName: "user"
|
|
1334
|
-
}),
|
|
1335
|
-
userPermissions: many(userPermissions, {
|
|
1336
|
-
relationName: "user"
|
|
1337
|
-
}),
|
|
1338
|
-
contributions: many(contentContributions, {
|
|
1339
|
-
relationName: "user"
|
|
1340
|
-
}),
|
|
1341
|
-
createdContent: many(contentResource, {
|
|
1342
|
-
relationName: "user"
|
|
1343
|
-
}),
|
|
1344
|
-
comments: many(comments, {
|
|
1345
|
-
relationName: "user"
|
|
1346
|
-
}),
|
|
1347
|
-
prefs: many(userPrefs, {
|
|
1348
|
-
relationName: "user"
|
|
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"
|
|
1349
1836
|
})
|
|
1350
1837
|
}));
|
|
1351
1838
|
}
|
|
1352
|
-
__name(
|
|
1839
|
+
__name(getMerchantSubscriptionRelationsSchema, "getMerchantSubscriptionRelationsSchema");
|
|
1353
1840
|
|
|
1354
|
-
// src/lib/mysql/schemas/
|
|
1355
|
-
function
|
|
1356
|
-
return mysqlTable("
|
|
1357
|
-
id:
|
|
1358
|
-
length:
|
|
1359
|
-
}).notNull().primaryKey(),
|
|
1360
|
-
userId: varchar20("userId", {
|
|
1361
|
-
length: 255
|
|
1841
|
+
// src/lib/mysql/schemas/commerce/merchant-charge.ts
|
|
1842
|
+
function getMerchantChargeSchema(mysqlTable) {
|
|
1843
|
+
return mysqlTable("MerchantCharge", {
|
|
1844
|
+
id: varchar25("id", {
|
|
1845
|
+
length: 191
|
|
1362
1846
|
}).notNull(),
|
|
1363
|
-
|
|
1364
|
-
length:
|
|
1847
|
+
organizationId: varchar25("organizationId", {
|
|
1848
|
+
length: 191
|
|
1849
|
+
}),
|
|
1850
|
+
status: int7("status").default(0).notNull(),
|
|
1851
|
+
identifier: varchar25("identifier", {
|
|
1852
|
+
length: 191
|
|
1365
1853
|
}).notNull(),
|
|
1366
|
-
|
|
1367
|
-
length:
|
|
1854
|
+
userId: varchar25("userId", {
|
|
1855
|
+
length: 191
|
|
1368
1856
|
}).notNull(),
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
})
|
|
1378
|
-
|
|
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", {
|
|
1379
1867
|
mode: "date",
|
|
1380
1868
|
fsp: 3
|
|
1381
|
-
})
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
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
|
+
});
|
|
1387
1886
|
}
|
|
1388
|
-
__name(
|
|
1389
|
-
function
|
|
1390
|
-
const
|
|
1391
|
-
const
|
|
1392
|
-
const
|
|
1393
|
-
const
|
|
1394
|
-
|
|
1395
|
-
|
|
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, {
|
|
1396
1896
|
fields: [
|
|
1397
|
-
|
|
1897
|
+
merchantCharge.merchantAccountId
|
|
1398
1898
|
],
|
|
1399
1899
|
references: [
|
|
1400
|
-
|
|
1900
|
+
merchantAccount.id
|
|
1401
1901
|
],
|
|
1402
|
-
relationName: "
|
|
1902
|
+
relationName: "merchantAccount"
|
|
1403
1903
|
}),
|
|
1404
|
-
|
|
1904
|
+
merchantProduct: one(merchantProduct, {
|
|
1405
1905
|
fields: [
|
|
1406
|
-
|
|
1906
|
+
merchantCharge.merchantProductId
|
|
1407
1907
|
],
|
|
1408
1908
|
references: [
|
|
1409
|
-
|
|
1909
|
+
merchantProduct.id
|
|
1410
1910
|
],
|
|
1411
|
-
relationName: "
|
|
1911
|
+
relationName: "merchantProduct"
|
|
1412
1912
|
}),
|
|
1413
|
-
|
|
1913
|
+
merchantCustomer: one(merchantCustomer, {
|
|
1414
1914
|
fields: [
|
|
1415
|
-
|
|
1915
|
+
merchantCharge.merchantCustomerId
|
|
1416
1916
|
],
|
|
1417
1917
|
references: [
|
|
1418
|
-
|
|
1918
|
+
merchantCustomer.id
|
|
1419
1919
|
],
|
|
1420
|
-
relationName: "
|
|
1920
|
+
relationName: "merchantCustomer"
|
|
1921
|
+
}),
|
|
1922
|
+
merchantSubscription: one(merchantSubscription, {
|
|
1923
|
+
fields: [
|
|
1924
|
+
merchantCharge.merchantSubscriptionId
|
|
1925
|
+
],
|
|
1926
|
+
references: [
|
|
1927
|
+
merchantSubscription.id
|
|
1928
|
+
],
|
|
1929
|
+
relationName: "merchantSubscription"
|
|
1421
1930
|
})
|
|
1422
1931
|
}));
|
|
1423
1932
|
}
|
|
1424
|
-
__name(
|
|
1933
|
+
__name(getMerchantChargeRelationsSchema, "getMerchantChargeRelationsSchema");
|
|
1425
1934
|
|
|
1426
1935
|
export {
|
|
1936
|
+
getMerchantChargeSchema,
|
|
1937
|
+
getMerchantChargeRelationsSchema,
|
|
1938
|
+
getMerchantSubscriptionSchema,
|
|
1939
|
+
getMerchantSubscriptionRelationsSchema,
|
|
1427
1940
|
getContentContributionsSchema,
|
|
1428
1941
|
getContentContributionRelationsSchema,
|
|
1429
1942
|
getContentResourceResourceSchema,
|
|
@@ -1444,6 +1957,12 @@ export {
|
|
|
1444
1957
|
getProductRelationsSchema,
|
|
1445
1958
|
getProductSchema,
|
|
1446
1959
|
getProductRelationsSchema2,
|
|
1960
|
+
getSubscriptionSchema,
|
|
1961
|
+
getSubscriptionRelationsSchema,
|
|
1962
|
+
getOrganizationsSchema,
|
|
1963
|
+
getOrganizationsRelationsSchema,
|
|
1964
|
+
getOrganizationMembershipsSchema,
|
|
1965
|
+
getOrganizationMembershipsRelationsSchema,
|
|
1447
1966
|
getCouponSchema,
|
|
1448
1967
|
getCouponRelationsSchema,
|
|
1449
1968
|
getPurchaseSchema,
|
|
@@ -1465,4 +1984,4 @@ export {
|
|
|
1465
1984
|
getAccountsSchema,
|
|
1466
1985
|
getAccountsRelationsSchema
|
|
1467
1986
|
};
|
|
1468
|
-
//# sourceMappingURL=chunk-
|
|
1987
|
+
//# sourceMappingURL=chunk-QGZ2F5SW.js.map
|