@coursebuilder/adapter-drizzle 1.0.4 → 1.0.6
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-KPBVZ44W.js → chunk-2I7NIOKI.js} +2 -2
- package/dist/chunk-2X5XVNDN.js +12 -0
- package/dist/{chunk-BLDW3QUS.js → chunk-5NNBQJUP.js} +2 -2
- package/dist/{chunk-HWIQUI7O.js → chunk-5WMUBNWJ.js} +6 -5
- package/dist/{chunk-WJWJ6E5Y.js → chunk-65H5Y4PD.js} +2 -2
- package/dist/{chunk-MP4CUWYC.js → chunk-6SJORFGN.js} +2 -2
- package/dist/{chunk-ET3QAIY7.js → chunk-CCXVDMTA.js} +2 -2
- package/dist/{chunk-DKJO4Y3K.js → chunk-DNBW5D64.js} +2 -2
- package/dist/{chunk-OBUGOZKM.js → chunk-EJ7UDN4T.js} +6 -5
- package/dist/{chunk-YQNIXCD3.js → chunk-ENIKVP6O.js} +6 -5
- package/dist/{chunk-ARHWIBFG.js → chunk-HEQ5MII4.js} +2789 -1237
- package/dist/chunk-MQSLKVLJ.js +101 -0
- package/dist/{chunk-LPJ2P2KJ.js → chunk-MUFYDXA7.js} +65 -44
- package/dist/{chunk-WPJZAYX7.js → chunk-NON5CXDH.js} +4 -3
- package/dist/{chunk-ORRM7KVW.js → chunk-OFZECDCQ.js} +2 -2
- package/dist/{chunk-LERR6HQ3.js → chunk-OUJPUONP.js} +2 -2
- package/dist/{chunk-MGZMGDQ5.js → chunk-PMCOC5PM.js} +2 -2
- package/dist/{chunk-EHRARBRS.js → chunk-QKFITIXC.js} +2 -2
- package/dist/{chunk-6MRFUIH5.js → chunk-SIZFEXIS.js} +2 -2
- package/dist/chunk-SOOAUY4E.js +63 -0
- package/dist/{chunk-3GONHHMY.js → chunk-SUOPB24V.js} +4 -4
- package/dist/{chunk-253RMSB3.js → chunk-U6XVAMCK.js} +6 -5
- package/dist/{chunk-LZHZDFNZ.js → chunk-UWUDJCJM.js} +2 -2
- package/dist/{chunk-6YPHJWS2.js → chunk-WMCZWSAG.js} +2 -2
- package/dist/{chunk-FPAQINSA.js → chunk-XKCPXM63.js} +3 -3
- package/dist/{chunk-PBTEHA7F.js → chunk-YMVONZZW.js} +6 -5
- package/dist/index.d.ts +1 -0
- package/dist/index.js +26 -24
- package/dist/lib/mysql/index.cjs +3205 -1495
- package/dist/lib/mysql/index.cjs.map +1 -1
- package/dist/lib/mysql/index.d.cts +759 -238
- package/dist/lib/mysql/index.d.ts +759 -238
- package/dist/lib/mysql/index.js +30 -26
- package/dist/lib/mysql/schemas/auth/accounts.cjs +3 -2
- package/dist/lib/mysql/schemas/auth/accounts.cjs.map +1 -1
- package/dist/lib/mysql/schemas/auth/accounts.d.cts +2 -1
- package/dist/lib/mysql/schemas/auth/accounts.d.ts +2 -1
- package/dist/lib/mysql/schemas/auth/accounts.js +12 -12
- package/dist/lib/mysql/schemas/auth/device-access-token.cjs +3 -2
- package/dist/lib/mysql/schemas/auth/device-access-token.cjs.map +1 -1
- package/dist/lib/mysql/schemas/auth/device-access-token.d.cts +2 -1
- package/dist/lib/mysql/schemas/auth/device-access-token.d.ts +2 -1
- package/dist/lib/mysql/schemas/auth/device-access-token.js +13 -13
- package/dist/lib/mysql/schemas/auth/device-verification.cjs +3 -2
- package/dist/lib/mysql/schemas/auth/device-verification.cjs.map +1 -1
- package/dist/lib/mysql/schemas/auth/device-verification.d.cts +2 -1
- package/dist/lib/mysql/schemas/auth/device-verification.d.ts +2 -1
- package/dist/lib/mysql/schemas/auth/device-verification.js +13 -13
- package/dist/lib/mysql/schemas/auth/permissions.js +2 -2
- package/dist/lib/mysql/schemas/auth/profiles.cjs +3 -2
- package/dist/lib/mysql/schemas/auth/profiles.cjs.map +1 -1
- package/dist/lib/mysql/schemas/auth/profiles.d.cts +2 -1
- package/dist/lib/mysql/schemas/auth/profiles.d.ts +2 -1
- package/dist/lib/mysql/schemas/auth/profiles.js +12 -12
- package/dist/lib/mysql/schemas/auth/role-permissions.cjs.map +1 -1
- package/dist/lib/mysql/schemas/auth/role-permissions.js +13 -13
- package/dist/lib/mysql/schemas/auth/roles.cjs.map +1 -1
- package/dist/lib/mysql/schemas/auth/roles.js +12 -12
- package/dist/lib/mysql/schemas/auth/sessions.cjs +3 -2
- package/dist/lib/mysql/schemas/auth/sessions.cjs.map +1 -1
- package/dist/lib/mysql/schemas/auth/sessions.d.cts +2 -1
- package/dist/lib/mysql/schemas/auth/sessions.d.ts +2 -1
- package/dist/lib/mysql/schemas/auth/sessions.js +13 -13
- package/dist/lib/mysql/schemas/auth/user-permissions.cjs +3 -2
- package/dist/lib/mysql/schemas/auth/user-permissions.cjs.map +1 -1
- package/dist/lib/mysql/schemas/auth/user-permissions.d.cts +2 -1
- package/dist/lib/mysql/schemas/auth/user-permissions.d.ts +2 -1
- package/dist/lib/mysql/schemas/auth/user-permissions.js +12 -12
- package/dist/lib/mysql/schemas/auth/user-prefs.cjs +3 -2
- package/dist/lib/mysql/schemas/auth/user-prefs.cjs.map +1 -1
- package/dist/lib/mysql/schemas/auth/user-prefs.d.cts +2 -1
- package/dist/lib/mysql/schemas/auth/user-prefs.d.ts +2 -1
- package/dist/lib/mysql/schemas/auth/user-prefs.js +12 -12
- package/dist/lib/mysql/schemas/auth/user-roles.cjs +3 -2
- package/dist/lib/mysql/schemas/auth/user-roles.cjs.map +1 -1
- package/dist/lib/mysql/schemas/auth/user-roles.d.cts +2 -1
- package/dist/lib/mysql/schemas/auth/user-roles.d.ts +2 -1
- package/dist/lib/mysql/schemas/auth/user-roles.js +12 -12
- package/dist/lib/mysql/schemas/auth/users.cjs +11 -3
- package/dist/lib/mysql/schemas/auth/users.cjs.map +1 -1
- package/dist/lib/mysql/schemas/auth/users.d.cts +5 -2
- package/dist/lib/mysql/schemas/auth/users.d.ts +5 -2
- package/dist/lib/mysql/schemas/auth/users.js +12 -12
- package/dist/lib/mysql/schemas/auth/verification-tokens.js +2 -2
- package/dist/lib/mysql/schemas/commerce/coupon.cjs +4 -2
- package/dist/lib/mysql/schemas/commerce/coupon.cjs.map +1 -1
- package/dist/lib/mysql/schemas/commerce/coupon.d.cts +17 -1
- package/dist/lib/mysql/schemas/commerce/coupon.d.ts +17 -1
- package/dist/lib/mysql/schemas/commerce/coupon.js +12 -12
- package/dist/lib/mysql/schemas/commerce/merchant-account.js +2 -2
- package/dist/lib/mysql/schemas/commerce/merchant-charge.cjs.map +1 -1
- package/dist/lib/mysql/schemas/commerce/merchant-charge.js +12 -12
- package/dist/lib/mysql/schemas/commerce/merchant-coupon.cjs +2 -1
- package/dist/lib/mysql/schemas/commerce/merchant-coupon.cjs.map +1 -1
- package/dist/lib/mysql/schemas/commerce/merchant-coupon.d.cts +17 -1
- package/dist/lib/mysql/schemas/commerce/merchant-coupon.d.ts +17 -1
- package/dist/lib/mysql/schemas/commerce/merchant-coupon.js +2 -2
- package/dist/lib/mysql/schemas/commerce/merchant-customer.js +2 -2
- package/dist/lib/mysql/schemas/commerce/merchant-events.cjs +120 -0
- package/dist/lib/mysql/schemas/commerce/merchant-events.cjs.map +1 -0
- package/dist/lib/mysql/schemas/commerce/merchant-events.d.cts +101 -0
- package/dist/lib/mysql/schemas/commerce/merchant-events.d.ts +101 -0
- package/dist/lib/mysql/schemas/commerce/merchant-events.js +11 -0
- package/dist/lib/mysql/schemas/commerce/merchant-events.js.map +1 -0
- package/dist/lib/mysql/schemas/commerce/merchant-price.js +2 -2
- package/dist/lib/mysql/schemas/commerce/merchant-product.js +2 -2
- package/dist/lib/mysql/schemas/commerce/merchant-session.js +2 -2
- package/dist/lib/mysql/schemas/commerce/merchant-subscription.cjs.map +1 -1
- package/dist/lib/mysql/schemas/commerce/merchant-subscription.js +12 -12
- package/dist/lib/mysql/schemas/commerce/price.cjs.map +1 -1
- package/dist/lib/mysql/schemas/commerce/price.js +12 -12
- package/dist/lib/mysql/schemas/commerce/product.cjs.map +1 -1
- package/dist/lib/mysql/schemas/commerce/product.js +12 -12
- package/dist/lib/mysql/schemas/commerce/purchase-user-transfer.cjs +3 -2
- package/dist/lib/mysql/schemas/commerce/purchase-user-transfer.cjs.map +1 -1
- package/dist/lib/mysql/schemas/commerce/purchase-user-transfer.d.cts +2 -1
- package/dist/lib/mysql/schemas/commerce/purchase-user-transfer.d.ts +2 -1
- package/dist/lib/mysql/schemas/commerce/purchase-user-transfer.js +13 -13
- package/dist/lib/mysql/schemas/commerce/purchase.cjs +5 -3
- package/dist/lib/mysql/schemas/commerce/purchase.cjs.map +1 -1
- package/dist/lib/mysql/schemas/commerce/purchase.d.cts +2 -1
- package/dist/lib/mysql/schemas/commerce/purchase.d.ts +2 -1
- package/dist/lib/mysql/schemas/commerce/purchase.js +12 -12
- package/dist/lib/mysql/schemas/commerce/subscription.cjs.map +1 -1
- package/dist/lib/mysql/schemas/commerce/subscription.js +12 -12
- package/dist/lib/mysql/schemas/commerce/upgradable-products.cjs.map +1 -1
- package/dist/lib/mysql/schemas/commerce/upgradable-products.js +13 -13
- package/dist/lib/mysql/schemas/communication/comment.cjs +3 -2
- package/dist/lib/mysql/schemas/communication/comment.cjs.map +1 -1
- package/dist/lib/mysql/schemas/communication/comment.d.cts +2 -1
- package/dist/lib/mysql/schemas/communication/comment.d.ts +2 -1
- package/dist/lib/mysql/schemas/communication/comment.js +12 -12
- package/dist/lib/mysql/schemas/communication/communication-channel.js +2 -2
- package/dist/lib/mysql/schemas/communication/communication-preference-types.js +2 -2
- package/dist/lib/mysql/schemas/communication/communication-preferences.cjs +3 -2
- package/dist/lib/mysql/schemas/communication/communication-preferences.cjs.map +1 -1
- package/dist/lib/mysql/schemas/communication/communication-preferences.d.cts +2 -1
- package/dist/lib/mysql/schemas/communication/communication-preferences.d.ts +2 -1
- package/dist/lib/mysql/schemas/communication/communication-preferences.js +12 -12
- package/dist/lib/mysql/schemas/communication/question-response.cjs +351 -0
- package/dist/lib/mysql/schemas/communication/question-response.cjs.map +1 -0
- package/dist/lib/mysql/schemas/communication/question-response.d.cts +200 -0
- package/dist/lib/mysql/schemas/communication/question-response.d.ts +200 -0
- package/dist/lib/mysql/schemas/communication/question-response.js +21 -0
- package/dist/lib/mysql/schemas/communication/question-response.js.map +1 -0
- package/dist/lib/mysql/schemas/content/content-contributions.cjs +11 -3
- package/dist/lib/mysql/schemas/content/content-contributions.cjs.map +1 -1
- package/dist/lib/mysql/schemas/content/content-contributions.d.cts +2 -1
- package/dist/lib/mysql/schemas/content/content-contributions.d.ts +2 -1
- package/dist/lib/mysql/schemas/content/content-contributions.js +12 -12
- package/dist/lib/mysql/schemas/content/content-resource-product.cjs +8 -1
- package/dist/lib/mysql/schemas/content/content-resource-product.cjs.map +1 -1
- package/dist/lib/mysql/schemas/content/content-resource-product.js +12 -12
- package/dist/lib/mysql/schemas/content/content-resource-resource.cjs +8 -1
- package/dist/lib/mysql/schemas/content/content-resource-resource.cjs.map +1 -1
- package/dist/lib/mysql/schemas/content/content-resource-resource.js +12 -12
- package/dist/lib/mysql/schemas/content/content-resource-tag.cjs +8 -1
- package/dist/lib/mysql/schemas/content/content-resource-tag.cjs.map +1 -1
- package/dist/lib/mysql/schemas/content/content-resource-tag.js +12 -12
- package/dist/lib/mysql/schemas/content/content-resource-version.cjs +11 -3
- package/dist/lib/mysql/schemas/content/content-resource-version.cjs.map +1 -1
- package/dist/lib/mysql/schemas/content/content-resource-version.d.cts +2 -1
- package/dist/lib/mysql/schemas/content/content-resource-version.d.ts +2 -1
- package/dist/lib/mysql/schemas/content/content-resource-version.js +12 -12
- package/dist/lib/mysql/schemas/content/content-resource.cjs +11 -3
- package/dist/lib/mysql/schemas/content/content-resource.cjs.map +1 -1
- package/dist/lib/mysql/schemas/content/content-resource.d.cts +18 -1
- package/dist/lib/mysql/schemas/content/content-resource.d.ts +18 -1
- package/dist/lib/mysql/schemas/content/content-resource.js +12 -12
- package/dist/lib/mysql/schemas/content/contribution-types.js +2 -2
- package/dist/lib/mysql/schemas/content/lesson-progress.js +2 -2
- package/dist/lib/mysql/schemas/content/resource-progress.js +2 -2
- package/dist/lib/mysql/schemas/content/tag-tag.cjs.map +1 -1
- package/dist/lib/mysql/schemas/content/tag-tag.js +12 -12
- package/dist/lib/mysql/schemas/content/tag.cjs.map +1 -1
- package/dist/lib/mysql/schemas/content/tag.js +12 -12
- package/dist/lib/mysql/schemas/entitlements/entitlement-type.js +2 -2
- package/dist/lib/mysql/schemas/entitlements/entitlement.cjs +3 -2
- package/dist/lib/mysql/schemas/entitlements/entitlement.cjs.map +1 -1
- package/dist/lib/mysql/schemas/entitlements/entitlement.d.cts +2 -1
- package/dist/lib/mysql/schemas/entitlements/entitlement.d.ts +2 -1
- package/dist/lib/mysql/schemas/entitlements/entitlement.js +13 -13
- package/dist/lib/mysql/schemas/org/organization-membership-roles.cjs.map +1 -1
- package/dist/lib/mysql/schemas/org/organization-membership-roles.js +12 -12
- package/dist/lib/mysql/schemas/org/organization-memberships.cjs +3 -2
- package/dist/lib/mysql/schemas/org/organization-memberships.cjs.map +1 -1
- package/dist/lib/mysql/schemas/org/organization-memberships.d.cts +2 -1
- package/dist/lib/mysql/schemas/org/organization-memberships.d.ts +2 -1
- package/dist/lib/mysql/schemas/org/organization-memberships.js +12 -12
- package/dist/lib/mysql/schemas/org/organizations.cjs.map +1 -1
- package/dist/lib/mysql/schemas/org/organizations.js +12 -12
- package/dist/lib/mysql/utils.js +1 -1
- package/dist/lib/utils.d.cts +1 -0
- package/dist/lib/utils.d.ts +1 -0
- package/dist/lib/utils.js +1 -1
- package/package.json +7 -7
- package/src/lib/mysql/index.ts +1887 -153
- package/src/lib/mysql/schemas/auth/accounts.ts +7 -3
- package/src/lib/mysql/schemas/auth/device-access-token.ts +7 -3
- package/src/lib/mysql/schemas/auth/device-verification.ts +7 -3
- package/src/lib/mysql/schemas/auth/profiles.ts +7 -3
- package/src/lib/mysql/schemas/auth/sessions.ts +7 -3
- package/src/lib/mysql/schemas/auth/user-permissions.ts +7 -3
- package/src/lib/mysql/schemas/auth/user-prefs.ts +7 -3
- package/src/lib/mysql/schemas/auth/user-roles.ts +7 -3
- package/src/lib/mysql/schemas/auth/users.ts +17 -3
- package/src/lib/mysql/schemas/commerce/coupon.ts +2 -1
- package/src/lib/mysql/schemas/commerce/merchant-coupon.ts +2 -1
- package/src/lib/mysql/schemas/commerce/merchant-events.ts +62 -0
- package/src/lib/mysql/schemas/commerce/purchase-user-transfer.ts +4 -2
- package/src/lib/mysql/schemas/commerce/purchase.ts +7 -3
- package/src/lib/mysql/schemas/communication/comment.ts +7 -3
- package/src/lib/mysql/schemas/communication/communication-preferences.ts +4 -2
- package/src/lib/mysql/schemas/communication/question-response.ts +90 -0
- package/src/lib/mysql/schemas/content/content-contributions.ts +4 -2
- package/src/lib/mysql/schemas/content/content-resource-version.ts +4 -2
- package/src/lib/mysql/schemas/content/content-resource.ts +13 -3
- package/src/lib/mysql/schemas/entitlements/entitlement.ts +7 -3
- package/src/lib/mysql/schemas/org/organization-memberships.ts +4 -2
- package/dist/chunk-H736K5TN.js +0 -7
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
varchar,
|
|
10
10
|
} from 'drizzle-orm/mysql-core'
|
|
11
11
|
|
|
12
|
-
import { getUsersSchema } from './users.js'
|
|
12
|
+
import { getUsersSchema, type UsersSchemaOverrides } from './users.js'
|
|
13
13
|
|
|
14
14
|
export function getAccountsSchema(mysqlTable: MySqlTableFn) {
|
|
15
15
|
return mysqlTable(
|
|
@@ -43,9 +43,13 @@ export function getAccountsSchema(mysqlTable: MySqlTableFn) {
|
|
|
43
43
|
)
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
export function getAccountsRelationsSchema(
|
|
46
|
+
export function getAccountsRelationsSchema(
|
|
47
|
+
mysqlTable: MySqlTableFn,
|
|
48
|
+
overrides: UsersSchemaOverrides = {},
|
|
49
|
+
) {
|
|
47
50
|
const accounts = getAccountsSchema(mysqlTable)
|
|
48
|
-
const
|
|
51
|
+
const resolveUsersSchema = overrides.getUsersSchema ?? getUsersSchema
|
|
52
|
+
const users = resolveUsersSchema(mysqlTable)
|
|
49
53
|
return relations(accounts, ({ one }) => ({
|
|
50
54
|
user: one(users, {
|
|
51
55
|
fields: [accounts.userId],
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
varchar,
|
|
8
8
|
} from 'drizzle-orm/mysql-core'
|
|
9
9
|
|
|
10
|
-
import { getUsersSchema } from './users.js'
|
|
10
|
+
import { getUsersSchema, type UsersSchemaOverrides } from './users.js'
|
|
11
11
|
|
|
12
12
|
export function getDeviceAccessTokenSchema(mysqlTable: MySqlTableFn) {
|
|
13
13
|
return mysqlTable(
|
|
@@ -30,9 +30,13 @@ export function getDeviceAccessTokenSchema(mysqlTable: MySqlTableFn) {
|
|
|
30
30
|
)
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
export function getDeviceAccessTokenRelationsSchema(
|
|
33
|
+
export function getDeviceAccessTokenRelationsSchema(
|
|
34
|
+
mysqlTable: MySqlTableFn,
|
|
35
|
+
overrides: UsersSchemaOverrides = {},
|
|
36
|
+
) {
|
|
34
37
|
const deviceAccessToken = getDeviceAccessTokenSchema(mysqlTable)
|
|
35
|
-
const
|
|
38
|
+
const resolveUsersSchema = overrides.getUsersSchema ?? getUsersSchema
|
|
39
|
+
const user = resolveUsersSchema(mysqlTable)
|
|
36
40
|
return relations(deviceAccessToken, ({ one }) => ({
|
|
37
41
|
verifiedBy: one(user, {
|
|
38
42
|
fields: [deviceAccessToken.userId],
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
varchar,
|
|
8
8
|
} from 'drizzle-orm/mysql-core'
|
|
9
9
|
|
|
10
|
-
import { getUsersSchema } from './users.js'
|
|
10
|
+
import { getUsersSchema, type UsersSchemaOverrides } from './users.js'
|
|
11
11
|
|
|
12
12
|
export function getDeviceVerificationSchema(mysqlTable: MySqlTableFn) {
|
|
13
13
|
return mysqlTable(
|
|
@@ -35,9 +35,13 @@ export function getDeviceVerificationSchema(mysqlTable: MySqlTableFn) {
|
|
|
35
35
|
)
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
export function getDeviceVerificationRelationsSchema(
|
|
38
|
+
export function getDeviceVerificationRelationsSchema(
|
|
39
|
+
mysqlTable: MySqlTableFn,
|
|
40
|
+
overrides: UsersSchemaOverrides = {},
|
|
41
|
+
) {
|
|
39
42
|
const deviceVerification = getDeviceVerificationSchema(mysqlTable)
|
|
40
|
-
const
|
|
43
|
+
const resolveUsersSchema = overrides.getUsersSchema ?? getUsersSchema
|
|
44
|
+
const user = resolveUsersSchema(mysqlTable)
|
|
41
45
|
return relations(deviceVerification, ({ one }) => ({
|
|
42
46
|
verifiedBy: one(user, {
|
|
43
47
|
fields: [deviceVerification.verifiedByUserId],
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
varchar,
|
|
9
9
|
} from 'drizzle-orm/mysql-core'
|
|
10
10
|
|
|
11
|
-
import { getUsersSchema } from './users.js'
|
|
11
|
+
import { getUsersSchema, type UsersSchemaOverrides } from './users.js'
|
|
12
12
|
|
|
13
13
|
export function getProfilesSchema(mysqlTable: MySqlTableFn) {
|
|
14
14
|
return mysqlTable(
|
|
@@ -37,9 +37,13 @@ export function getProfilesSchema(mysqlTable: MySqlTableFn) {
|
|
|
37
37
|
)
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
export function getProfilesRelationsSchema(
|
|
40
|
+
export function getProfilesRelationsSchema(
|
|
41
|
+
mysqlTable: MySqlTableFn,
|
|
42
|
+
overrides: UsersSchemaOverrides = {},
|
|
43
|
+
) {
|
|
41
44
|
const profiles = getProfilesSchema(mysqlTable)
|
|
42
|
-
const
|
|
45
|
+
const resolveUsersSchema = overrides.getUsersSchema ?? getUsersSchema
|
|
46
|
+
const users = resolveUsersSchema(mysqlTable)
|
|
43
47
|
return relations(profiles, ({ one }) => ({
|
|
44
48
|
user: one(users, {
|
|
45
49
|
fields: [profiles.userId],
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { relations } from 'drizzle-orm'
|
|
2
2
|
import { index, MySqlTableFn, timestamp, varchar } from 'drizzle-orm/mysql-core'
|
|
3
3
|
|
|
4
|
-
import { getUsersSchema } from './users.js'
|
|
4
|
+
import { getUsersSchema, type UsersSchemaOverrides } from './users.js'
|
|
5
5
|
|
|
6
6
|
export function getSessionsSchema(mysqlTable: MySqlTableFn) {
|
|
7
7
|
return mysqlTable(
|
|
@@ -19,9 +19,13 @@ export function getSessionsSchema(mysqlTable: MySqlTableFn) {
|
|
|
19
19
|
)
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
export function getSessionRelationsSchema(
|
|
22
|
+
export function getSessionRelationsSchema(
|
|
23
|
+
mysqlTable: MySqlTableFn,
|
|
24
|
+
overrides: UsersSchemaOverrides = {},
|
|
25
|
+
) {
|
|
23
26
|
const sessions = getSessionsSchema(mysqlTable)
|
|
24
|
-
const
|
|
27
|
+
const resolveUsersSchema = overrides.getUsersSchema ?? getUsersSchema
|
|
28
|
+
const users = resolveUsersSchema(mysqlTable)
|
|
25
29
|
return relations(sessions, ({ one }) => ({
|
|
26
30
|
user: one(users, {
|
|
27
31
|
fields: [sessions.userId],
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
} from 'drizzle-orm/mysql-core'
|
|
10
10
|
|
|
11
11
|
import { getPermissionsSchema } from './permissions.js'
|
|
12
|
-
import { getUsersSchema } from './users.js'
|
|
12
|
+
import { getUsersSchema, type UsersSchemaOverrides } from './users.js'
|
|
13
13
|
|
|
14
14
|
export function getUserPermissionsSchema(mysqlTable: MySqlTableFn) {
|
|
15
15
|
return mysqlTable(
|
|
@@ -41,9 +41,13 @@ export function getUserPermissionsSchema(mysqlTable: MySqlTableFn) {
|
|
|
41
41
|
)
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
export function getUserPermissionsRelationsSchema(
|
|
44
|
+
export function getUserPermissionsRelationsSchema(
|
|
45
|
+
mysqlTable: MySqlTableFn,
|
|
46
|
+
overrides: UsersSchemaOverrides = {},
|
|
47
|
+
) {
|
|
45
48
|
const userPermissions = getUserPermissionsSchema(mysqlTable)
|
|
46
|
-
const
|
|
49
|
+
const resolveUsersSchema = overrides.getUsersSchema ?? getUsersSchema
|
|
50
|
+
const users = resolveUsersSchema(mysqlTable)
|
|
47
51
|
const permissions = getPermissionsSchema(mysqlTable)
|
|
48
52
|
return relations(userPermissions, ({ one }) => ({
|
|
49
53
|
user: one(users, {
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
varchar,
|
|
10
10
|
} from 'drizzle-orm/mysql-core'
|
|
11
11
|
|
|
12
|
-
import { getUsersSchema } from '../auth/users.js'
|
|
12
|
+
import { getUsersSchema, type UsersSchemaOverrides } from '../auth/users.js'
|
|
13
13
|
|
|
14
14
|
export function getUserPrefsSchema(mysqlTable: MySqlTableFn) {
|
|
15
15
|
return mysqlTable(
|
|
@@ -41,9 +41,13 @@ export function getUserPrefsSchema(mysqlTable: MySqlTableFn) {
|
|
|
41
41
|
)
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
export function getUserPrefsRelationsSchema(
|
|
44
|
+
export function getUserPrefsRelationsSchema(
|
|
45
|
+
mysqlTable: MySqlTableFn,
|
|
46
|
+
overrides: UsersSchemaOverrides = {},
|
|
47
|
+
) {
|
|
45
48
|
const userPrefs = getUserPrefsSchema(mysqlTable)
|
|
46
|
-
const
|
|
49
|
+
const resolveUsersSchema = overrides.getUsersSchema ?? getUsersSchema
|
|
50
|
+
const user = resolveUsersSchema(mysqlTable)
|
|
47
51
|
return relations(userPrefs, ({ one }) => ({
|
|
48
52
|
user: one(user, {
|
|
49
53
|
fields: [userPrefs.userId],
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
} from 'drizzle-orm/mysql-core'
|
|
10
10
|
|
|
11
11
|
import { getRolesSchema } from './roles.js'
|
|
12
|
-
import { getUsersSchema } from './users.js'
|
|
12
|
+
import { getUsersSchema, type UsersSchemaOverrides } from './users.js'
|
|
13
13
|
|
|
14
14
|
export function getUserRolesSchema(mysqlTable: MySqlTableFn) {
|
|
15
15
|
return mysqlTable(
|
|
@@ -41,9 +41,13 @@ export function getUserRolesSchema(mysqlTable: MySqlTableFn) {
|
|
|
41
41
|
)
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
export function getUserRolesRelationsSchema(
|
|
44
|
+
export function getUserRolesRelationsSchema(
|
|
45
|
+
mysqlTable: MySqlTableFn,
|
|
46
|
+
overrides: UsersSchemaOverrides = {},
|
|
47
|
+
) {
|
|
45
48
|
const userRoles = getUserRolesSchema(mysqlTable)
|
|
46
|
-
const
|
|
49
|
+
const resolveUsersSchema = overrides.getUsersSchema ?? getUsersSchema
|
|
50
|
+
const users = resolveUsersSchema(mysqlTable)
|
|
47
51
|
const roles = getRolesSchema(mysqlTable)
|
|
48
52
|
return relations(userRoles, ({ one }) => ({
|
|
49
53
|
user: one(users, {
|
|
@@ -2,7 +2,6 @@ import { relations, sql } from 'drizzle-orm'
|
|
|
2
2
|
import {
|
|
3
3
|
index,
|
|
4
4
|
json,
|
|
5
|
-
mysqlEnum,
|
|
6
5
|
MySqlTableFn,
|
|
7
6
|
timestamp,
|
|
8
7
|
varchar,
|
|
@@ -47,8 +46,23 @@ export function getUsersSchema(mysqlTable: MySqlTableFn) {
|
|
|
47
46
|
)
|
|
48
47
|
}
|
|
49
48
|
|
|
50
|
-
export
|
|
51
|
-
|
|
49
|
+
export type UsersSchemaOverrides<
|
|
50
|
+
TUsers extends ReturnType<typeof getUsersSchema> = ReturnType<
|
|
51
|
+
typeof getUsersSchema
|
|
52
|
+
>,
|
|
53
|
+
> = {
|
|
54
|
+
getUsersSchema?: (mysqlTable: MySqlTableFn) => TUsers
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export function getUsersRelationsSchema<
|
|
58
|
+
TUsers extends ReturnType<typeof getUsersSchema> = ReturnType<
|
|
59
|
+
typeof getUsersSchema
|
|
60
|
+
>,
|
|
61
|
+
>(mysqlTable: MySqlTableFn, overrides: UsersSchemaOverrides<TUsers> = {}) {
|
|
62
|
+
const resolveUsersSchema = (overrides.getUsersSchema ?? getUsersSchema) as (
|
|
63
|
+
mysqlTable: MySqlTableFn,
|
|
64
|
+
) => TUsers
|
|
65
|
+
const users = resolveUsersSchema(mysqlTable)
|
|
52
66
|
const profiles = getProfilesSchema(mysqlTable)
|
|
53
67
|
const accounts = getAccountsSchema(mysqlTable)
|
|
54
68
|
const communicationPreferences = getCommunicationPreferencesSchema(mysqlTable)
|
|
@@ -36,7 +36,8 @@ export function getCouponSchema(mysqlTable: MySqlTableFn) {
|
|
|
36
36
|
percentageDiscount: decimal('percentageDiscount', {
|
|
37
37
|
precision: 3,
|
|
38
38
|
scale: 2,
|
|
39
|
-
})
|
|
39
|
+
}),
|
|
40
|
+
amountDiscount: int('amountDiscount'),
|
|
40
41
|
restrictedToProductId: varchar('restrictedToProductId', { length: 191 }),
|
|
41
42
|
},
|
|
42
43
|
(table) => {
|
|
@@ -22,7 +22,8 @@ export function getMerchantCouponSchema(mysqlTable: MySqlTableFn) {
|
|
|
22
22
|
percentageDiscount: decimal('percentageDiscount', {
|
|
23
23
|
precision: 3,
|
|
24
24
|
scale: 2,
|
|
25
|
-
})
|
|
25
|
+
}),
|
|
26
|
+
amountDiscount: int('amountDiscount'),
|
|
26
27
|
type: varchar('type', { length: 191 }),
|
|
27
28
|
},
|
|
28
29
|
(table) => {
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { relations, sql } from 'drizzle-orm'
|
|
2
|
+
import {
|
|
3
|
+
index,
|
|
4
|
+
json,
|
|
5
|
+
MySqlTableFn,
|
|
6
|
+
primaryKey,
|
|
7
|
+
timestamp,
|
|
8
|
+
unique,
|
|
9
|
+
varchar,
|
|
10
|
+
} from 'drizzle-orm/mysql-core'
|
|
11
|
+
|
|
12
|
+
import { getMerchantAccountSchema } from './merchant-account.js'
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* MerchantEvents table for tracking webhook events from payment providers
|
|
16
|
+
* This provides an audit trail of what webhooks we received, regardless of
|
|
17
|
+
* whether Inngest successfully processed them or not.
|
|
18
|
+
*/
|
|
19
|
+
export function getMerchantEventsSchema(mysqlTable: MySqlTableFn) {
|
|
20
|
+
return mysqlTable(
|
|
21
|
+
'MerchantEvents',
|
|
22
|
+
{
|
|
23
|
+
id: varchar('id', { length: 191 }).notNull(),
|
|
24
|
+
merchantAccountId: varchar('merchantAccountId', {
|
|
25
|
+
length: 191,
|
|
26
|
+
}).notNull(),
|
|
27
|
+
identifier: varchar('identifier', { length: 191 }).notNull(),
|
|
28
|
+
payload: json('payload').notNull(),
|
|
29
|
+
createdAt: timestamp('createdAt', { mode: 'date', fsp: 3 })
|
|
30
|
+
.default(sql`CURRENT_TIMESTAMP(3)`)
|
|
31
|
+
.notNull(),
|
|
32
|
+
},
|
|
33
|
+
(table) => {
|
|
34
|
+
return {
|
|
35
|
+
merchantEventsId: primaryKey({
|
|
36
|
+
columns: [table.id],
|
|
37
|
+
name: 'MerchantEvents_id',
|
|
38
|
+
}),
|
|
39
|
+
merchantEventsIdentifierKey: unique('MerchantEvents_identifier_key').on(
|
|
40
|
+
table.identifier,
|
|
41
|
+
),
|
|
42
|
+
merchantAccountIdIdx: index('merchantAccountId_idx').on(
|
|
43
|
+
table.merchantAccountId,
|
|
44
|
+
),
|
|
45
|
+
createdAtIdx: index('createdAt_idx').on(table.createdAt),
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
)
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export function getMerchantEventsRelationsSchema(mysqlTable: MySqlTableFn) {
|
|
52
|
+
const merchantEvents = getMerchantEventsSchema(mysqlTable)
|
|
53
|
+
const merchantAccount = getMerchantAccountSchema(mysqlTable)
|
|
54
|
+
|
|
55
|
+
return relations(merchantEvents, ({ one }) => ({
|
|
56
|
+
merchantAccount: one(merchantAccount, {
|
|
57
|
+
fields: [merchantEvents.merchantAccountId],
|
|
58
|
+
references: [merchantAccount.id],
|
|
59
|
+
relationName: 'merchantAccount',
|
|
60
|
+
}),
|
|
61
|
+
}))
|
|
62
|
+
}
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
varchar,
|
|
9
9
|
} from 'drizzle-orm/mysql-core'
|
|
10
10
|
|
|
11
|
-
import { getUsersSchema } from '../auth/users.js'
|
|
11
|
+
import { getUsersSchema, type UsersSchemaOverrides } from '../auth/users.js'
|
|
12
12
|
import { getPurchaseSchema } from './purchase.js'
|
|
13
13
|
|
|
14
14
|
export function getPurchaseUserTransferSchema(mysqlTable: MySqlTableFn) {
|
|
@@ -53,9 +53,11 @@ export function getPurchaseUserTransferSchema(mysqlTable: MySqlTableFn) {
|
|
|
53
53
|
|
|
54
54
|
export function getPurchaseUserTransferRelationsSchema(
|
|
55
55
|
mysqlTable: MySqlTableFn,
|
|
56
|
+
overrides: UsersSchemaOverrides = {},
|
|
56
57
|
) {
|
|
57
58
|
const purchaseUserTransfer = getPurchaseUserTransferSchema(mysqlTable)
|
|
58
|
-
const
|
|
59
|
+
const resolveUsersSchema = overrides.getUsersSchema ?? getUsersSchema
|
|
60
|
+
const user = resolveUsersSchema(mysqlTable)
|
|
59
61
|
const purchase = getPurchaseSchema(mysqlTable)
|
|
60
62
|
return relations(purchaseUserTransfer, ({ one }) => ({
|
|
61
63
|
sourceUser: one(user, {
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
varchar,
|
|
11
11
|
} from 'drizzle-orm/mysql-core'
|
|
12
12
|
|
|
13
|
-
import { getUsersSchema } from '../auth/users.js'
|
|
13
|
+
import { getUsersSchema, type UsersSchemaOverrides } from '../auth/users.js'
|
|
14
14
|
import { getOrganizationMembershipsSchema } from '../org/organization-memberships.js'
|
|
15
15
|
import { getOrganizationsSchema } from '../org/organizations.js'
|
|
16
16
|
import { getCouponSchema } from './coupon.js'
|
|
@@ -67,9 +67,13 @@ export function getPurchaseSchema(mysqlTable: MySqlTableFn) {
|
|
|
67
67
|
)
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
-
export function getPurchaseRelationsSchema(
|
|
70
|
+
export function getPurchaseRelationsSchema(
|
|
71
|
+
mysqlTable: MySqlTableFn,
|
|
72
|
+
overrides: UsersSchemaOverrides = {},
|
|
73
|
+
) {
|
|
71
74
|
const purchases = getPurchaseSchema(mysqlTable)
|
|
72
|
-
const
|
|
75
|
+
const resolveUsersSchema = overrides.getUsersSchema ?? getUsersSchema
|
|
76
|
+
const users = resolveUsersSchema(mysqlTable)
|
|
73
77
|
const products = getProductSchema(mysqlTable)
|
|
74
78
|
const merchantCharges = getMerchantChargeSchema(mysqlTable)
|
|
75
79
|
const merchantSessions = getMerchantSessionSchema(mysqlTable)
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
varchar,
|
|
10
10
|
} from 'drizzle-orm/mysql-core'
|
|
11
11
|
|
|
12
|
-
import { getUsersSchema } from '../auth/users.js'
|
|
12
|
+
import { getUsersSchema, type UsersSchemaOverrides } from '../auth/users.js'
|
|
13
13
|
import { getOrganizationMembershipsSchema } from '../org/organization-memberships.js'
|
|
14
14
|
|
|
15
15
|
export function getCommentsSchema(mysqlTable: MySqlTableFn) {
|
|
@@ -46,9 +46,13 @@ export function getCommentsSchema(mysqlTable: MySqlTableFn) {
|
|
|
46
46
|
)
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
export function getCommentRelationsSchema(
|
|
49
|
+
export function getCommentRelationsSchema(
|
|
50
|
+
mysqlTable: MySqlTableFn,
|
|
51
|
+
overrides: UsersSchemaOverrides = {},
|
|
52
|
+
) {
|
|
50
53
|
const comment = getCommentsSchema(mysqlTable)
|
|
51
|
-
const
|
|
54
|
+
const resolveUsersSchema = overrides.getUsersSchema ?? getUsersSchema
|
|
55
|
+
const user = resolveUsersSchema(mysqlTable)
|
|
52
56
|
const organizationMemberships = getOrganizationMembershipsSchema(mysqlTable)
|
|
53
57
|
return relations(comment, ({ one }) => ({
|
|
54
58
|
user: one(user, {
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
varchar,
|
|
9
9
|
} from 'drizzle-orm/mysql-core'
|
|
10
10
|
|
|
11
|
-
import { getUsersSchema } from '../auth/users.js'
|
|
11
|
+
import { getUsersSchema, type UsersSchemaOverrides } from '../auth/users.js'
|
|
12
12
|
import { getOrganizationMembershipsSchema } from '../org/organization-memberships.js'
|
|
13
13
|
import { getCommunicationChannelSchema } from './communication-channel.js'
|
|
14
14
|
import { getCommunicationPreferenceTypesSchema } from './communication-preference-types.js'
|
|
@@ -63,9 +63,11 @@ export function getCommunicationPreferencesSchema(mysqlTable: MySqlTableFn) {
|
|
|
63
63
|
|
|
64
64
|
export function getCommunicationPreferencesRelationsSchema(
|
|
65
65
|
mysqlTable: MySqlTableFn,
|
|
66
|
+
overrides: UsersSchemaOverrides = {},
|
|
66
67
|
) {
|
|
67
68
|
const communicationPreferences = getCommunicationPreferencesSchema(mysqlTable)
|
|
68
|
-
const
|
|
69
|
+
const resolveUsersSchema = overrides.getUsersSchema ?? getUsersSchema
|
|
70
|
+
const users = resolveUsersSchema(mysqlTable)
|
|
69
71
|
const communicationChannel = getCommunicationChannelSchema(mysqlTable)
|
|
70
72
|
const communicationPreferenceTypes =
|
|
71
73
|
getCommunicationPreferenceTypesSchema(mysqlTable)
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { relations, sql } from 'drizzle-orm'
|
|
2
|
+
import {
|
|
3
|
+
index,
|
|
4
|
+
json,
|
|
5
|
+
MySqlTableFn,
|
|
6
|
+
timestamp,
|
|
7
|
+
uniqueIndex,
|
|
8
|
+
varchar,
|
|
9
|
+
} from 'drizzle-orm/mysql-core'
|
|
10
|
+
|
|
11
|
+
import { getUsersSchema, type UsersSchemaOverrides } from '../auth/users.js'
|
|
12
|
+
import { getContentResourceSchema } from '../content/content-resource.js'
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Question response table - stores individual question responses
|
|
16
|
+
* Supports surveys, quizzes, polls, and other question-based interactions
|
|
17
|
+
* Works for both authenticated users and anonymous email subscribers
|
|
18
|
+
*/
|
|
19
|
+
export function getQuestionResponseSchema(mysqlTable: MySqlTableFn) {
|
|
20
|
+
return mysqlTable(
|
|
21
|
+
'QuestionResponse',
|
|
22
|
+
{
|
|
23
|
+
id: varchar('id', { length: 255 }).notNull().primaryKey(),
|
|
24
|
+
surveyId: varchar('surveyId', { length: 255 }).notNull(),
|
|
25
|
+
questionId: varchar('questionId', { length: 255 }).notNull(),
|
|
26
|
+
respondentKey: varchar('respondentKey', { length: 255 }),
|
|
27
|
+
surveySessionId: varchar('surveySessionId', { length: 255 }),
|
|
28
|
+
userId: varchar('userId', { length: 255 }),
|
|
29
|
+
emailListSubscriberId: varchar('emailListSubscriberId', { length: 255 }),
|
|
30
|
+
fields: json('fields').$type<Record<string, any>>().default({}),
|
|
31
|
+
createdAt: timestamp('createdAt', {
|
|
32
|
+
mode: 'date',
|
|
33
|
+
fsp: 3,
|
|
34
|
+
}).default(sql`CURRENT_TIMESTAMP(3)`),
|
|
35
|
+
updatedAt: timestamp('updatedAt', {
|
|
36
|
+
mode: 'date',
|
|
37
|
+
fsp: 3,
|
|
38
|
+
}).default(sql`CURRENT_TIMESTAMP(3)`),
|
|
39
|
+
deletedAt: timestamp('deletedAt', {
|
|
40
|
+
mode: 'date',
|
|
41
|
+
fsp: 3,
|
|
42
|
+
}),
|
|
43
|
+
},
|
|
44
|
+
(qr) => ({
|
|
45
|
+
surveyIdIdx: index('surveyId_idx').on(qr.surveyId),
|
|
46
|
+
questionIdIdx: index('questionId_idx').on(qr.questionId),
|
|
47
|
+
respondentKeyIdx: index('respondent_key_idx').on(qr.respondentKey),
|
|
48
|
+
surveySessionIdIdx: index('survey_session_id_idx').on(qr.surveySessionId),
|
|
49
|
+
userIdIdx: index('userId_idx').on(qr.userId),
|
|
50
|
+
emailListSubscriberIdIdx: index('emailListSubscriberId_idx').on(
|
|
51
|
+
qr.emailListSubscriberId,
|
|
52
|
+
),
|
|
53
|
+
surveySubscriberIdx: index('survey_subscriber_idx').on(
|
|
54
|
+
qr.surveyId,
|
|
55
|
+
qr.emailListSubscriberId,
|
|
56
|
+
),
|
|
57
|
+
surveyQuestionRespondentIdx: uniqueIndex(
|
|
58
|
+
'survey_question_respondent_unique',
|
|
59
|
+
).on(qr.surveyId, qr.questionId, qr.respondentKey),
|
|
60
|
+
}),
|
|
61
|
+
)
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export function getQuestionResponseRelationsSchema(
|
|
65
|
+
mysqlTable: MySqlTableFn,
|
|
66
|
+
overrides: UsersSchemaOverrides = {},
|
|
67
|
+
) {
|
|
68
|
+
const questionResponse = getQuestionResponseSchema(mysqlTable)
|
|
69
|
+
const resolveUsersSchema = overrides.getUsersSchema ?? getUsersSchema
|
|
70
|
+
const users = resolveUsersSchema(mysqlTable)
|
|
71
|
+
const contentResource = getContentResourceSchema(mysqlTable)
|
|
72
|
+
|
|
73
|
+
return relations(questionResponse, ({ one }) => ({
|
|
74
|
+
user: one(users, {
|
|
75
|
+
fields: [questionResponse.userId],
|
|
76
|
+
references: [users.id],
|
|
77
|
+
relationName: 'questionResponseUser',
|
|
78
|
+
}),
|
|
79
|
+
survey: one(contentResource, {
|
|
80
|
+
fields: [questionResponse.surveyId],
|
|
81
|
+
references: [contentResource.id],
|
|
82
|
+
relationName: 'questionResponseSurvey',
|
|
83
|
+
}),
|
|
84
|
+
question: one(contentResource, {
|
|
85
|
+
fields: [questionResponse.questionId],
|
|
86
|
+
references: [contentResource.id],
|
|
87
|
+
relationName: 'questionResponseQuestion',
|
|
88
|
+
}),
|
|
89
|
+
}))
|
|
90
|
+
}
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
varchar,
|
|
8
8
|
} from 'drizzle-orm/mysql-core'
|
|
9
9
|
|
|
10
|
-
import { getUsersSchema } from '../auth/users.js'
|
|
10
|
+
import { getUsersSchema, type UsersSchemaOverrides } from '../auth/users.js'
|
|
11
11
|
import { getOrganizationMembershipsSchema } from '../org/organization-memberships.js'
|
|
12
12
|
import { getContentResourceSchema } from './content-resource.js'
|
|
13
13
|
import { getContributionTypesSchema } from './contribution-types.js'
|
|
@@ -55,9 +55,11 @@ export function getContentContributionsSchema(mysqlTable: MySqlTableFn) {
|
|
|
55
55
|
|
|
56
56
|
export function getContentContributionRelationsSchema(
|
|
57
57
|
mysqlTable: MySqlTableFn,
|
|
58
|
+
overrides: UsersSchemaOverrides = {},
|
|
58
59
|
) {
|
|
59
60
|
const contentContributions = getContentContributionsSchema(mysqlTable)
|
|
60
|
-
const
|
|
61
|
+
const resolveUsersSchema = overrides.getUsersSchema ?? getUsersSchema
|
|
62
|
+
const users = resolveUsersSchema(mysqlTable)
|
|
61
63
|
const contentResource = getContentResourceSchema(mysqlTable)
|
|
62
64
|
const contributionTypes = getContributionTypesSchema(mysqlTable)
|
|
63
65
|
const organizationMemberships = getOrganizationMembershipsSchema(mysqlTable)
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
varchar,
|
|
10
10
|
} from 'drizzle-orm/mysql-core'
|
|
11
11
|
|
|
12
|
-
import { getUsersSchema } from '../auth/users.js'
|
|
12
|
+
import { getUsersSchema, type UsersSchemaOverrides } from '../auth/users.js'
|
|
13
13
|
import { getContentResourceSchema } from './content-resource.js'
|
|
14
14
|
|
|
15
15
|
export function getContentResourceVersionSchema(mysqlTable: MySqlTableFn) {
|
|
@@ -46,10 +46,12 @@ export function getContentResourceVersionSchema(mysqlTable: MySqlTableFn) {
|
|
|
46
46
|
|
|
47
47
|
export function getContentResourceVersionRelationsSchema(
|
|
48
48
|
mysqlTable: MySqlTableFn,
|
|
49
|
+
overrides: UsersSchemaOverrides = {},
|
|
49
50
|
) {
|
|
50
51
|
const contentResourceVersion = getContentResourceVersionSchema(mysqlTable)
|
|
51
52
|
const contentResource = getContentResourceSchema(mysqlTable)
|
|
52
|
-
const
|
|
53
|
+
const resolveUsersSchema = overrides.getUsersSchema ?? getUsersSchema
|
|
54
|
+
const users = resolveUsersSchema(mysqlTable)
|
|
53
55
|
|
|
54
56
|
return relations(contentResourceVersion, ({ one }) => ({
|
|
55
57
|
resource: one(contentResource, {
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
varchar,
|
|
8
8
|
} from 'drizzle-orm/mysql-core'
|
|
9
9
|
|
|
10
|
-
import { getUsersSchema } from '../auth/users.js'
|
|
10
|
+
import { getUsersSchema, type UsersSchemaOverrides } from '../auth/users.js'
|
|
11
11
|
import { getOrganizationMembershipsSchema } from '../org/organization-memberships.js'
|
|
12
12
|
import { getContentContributionsSchema } from './content-contributions.js'
|
|
13
13
|
import { getContentResourceProductSchema } from './content-resource-product.js'
|
|
@@ -31,6 +31,11 @@ export function getContentResourceSchema(mysqlTable: MySqlTableFn) {
|
|
|
31
31
|
type: varchar('type', { length: 255 }).notNull(),
|
|
32
32
|
createdById: varchar('createdById', { length: 255 }).notNull(),
|
|
33
33
|
fields: json('fields').$type<Record<string, any>>().default({}),
|
|
34
|
+
// Generated column for indexing JSON slug field
|
|
35
|
+
slug: varchar('slug', { length: 255 }).generatedAlwaysAs(
|
|
36
|
+
sql`(fields->>'$.slug')`,
|
|
37
|
+
{ mode: 'stored' },
|
|
38
|
+
),
|
|
34
39
|
currentVersionId: varchar('currentVersionId', { length: 255 }),
|
|
35
40
|
createdAt: timestamp('createdAt', {
|
|
36
41
|
mode: 'date',
|
|
@@ -55,13 +60,18 @@ export function getContentResourceSchema(mysqlTable: MySqlTableFn) {
|
|
|
55
60
|
createdByOrganizationMembershipIdIdx: index(
|
|
56
61
|
'createdByOrganizationMembershipId_idx',
|
|
57
62
|
).on(cm.createdByOrganizationMembershipId),
|
|
63
|
+
slugIdx: index('slug_idx').on(cm.slug),
|
|
58
64
|
}),
|
|
59
65
|
)
|
|
60
66
|
}
|
|
61
67
|
|
|
62
|
-
export function getContentResourceRelationsSchema(
|
|
68
|
+
export function getContentResourceRelationsSchema(
|
|
69
|
+
mysqlTable: MySqlTableFn,
|
|
70
|
+
overrides: UsersSchemaOverrides = {},
|
|
71
|
+
) {
|
|
63
72
|
const contentResource = getContentResourceSchema(mysqlTable)
|
|
64
|
-
const
|
|
73
|
+
const resolveUsersSchema = overrides.getUsersSchema ?? getUsersSchema
|
|
74
|
+
const users = resolveUsersSchema(mysqlTable)
|
|
65
75
|
const contentResourceResource = getContentResourceResourceSchema(mysqlTable)
|
|
66
76
|
const contentResourceProduct = getContentResourceProductSchema(mysqlTable)
|
|
67
77
|
const contentContributions = getContentContributionsSchema(mysqlTable)
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
varchar,
|
|
8
8
|
} from 'drizzle-orm/mysql-core'
|
|
9
9
|
|
|
10
|
-
import { getUsersSchema } from '../auth/users.js'
|
|
10
|
+
import { getUsersSchema, type UsersSchemaOverrides } from '../auth/users.js'
|
|
11
11
|
import { getOrganizationMembershipsSchema } from '../org/organization-memberships.js'
|
|
12
12
|
import { getOrganizationsSchema } from '../org/organizations.js'
|
|
13
13
|
|
|
@@ -43,9 +43,13 @@ export function getEntitlementsSchema(mysqlTable: MySqlTableFn) {
|
|
|
43
43
|
)
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
export function getEntitlementRelationsSchema(
|
|
46
|
+
export function getEntitlementRelationsSchema(
|
|
47
|
+
mysqlTable: MySqlTableFn,
|
|
48
|
+
overrides: UsersSchemaOverrides = {},
|
|
49
|
+
) {
|
|
47
50
|
const entitlements = getEntitlementsSchema(mysqlTable)
|
|
48
|
-
const
|
|
51
|
+
const resolveUsersSchema = overrides.getUsersSchema ?? getUsersSchema
|
|
52
|
+
const users = resolveUsersSchema(mysqlTable)
|
|
49
53
|
const orgs = getOrganizationsSchema(mysqlTable)
|
|
50
54
|
const memberships = getOrganizationMembershipsSchema(mysqlTable)
|
|
51
55
|
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
varchar,
|
|
9
9
|
} from 'drizzle-orm/mysql-core'
|
|
10
10
|
|
|
11
|
-
import { getUsersSchema } from '../auth/users.js'
|
|
11
|
+
import { getUsersSchema, type UsersSchemaOverrides } from '../auth/users.js'
|
|
12
12
|
import { getPurchaseSchema } from '../commerce/purchase.js'
|
|
13
13
|
import { getOrganizationMembershipRolesSchema } from './organization-membership-roles.js'
|
|
14
14
|
import { getOrganizationsSchema } from './organizations.js'
|
|
@@ -42,8 +42,10 @@ export function getOrganizationMembershipsSchema(mysqlTable: MySqlTableFn) {
|
|
|
42
42
|
|
|
43
43
|
export function getOrganizationMembershipsRelationsSchema(
|
|
44
44
|
mysqlTable: MySqlTableFn,
|
|
45
|
+
overrides: UsersSchemaOverrides = {},
|
|
45
46
|
) {
|
|
46
|
-
const
|
|
47
|
+
const resolveUsersSchema = overrides.getUsersSchema ?? getUsersSchema
|
|
48
|
+
const users = resolveUsersSchema(mysqlTable)
|
|
47
49
|
|
|
48
50
|
const organizationMemberships = getOrganizationMembershipsSchema(mysqlTable)
|
|
49
51
|
const purchases = getPurchaseSchema(mysqlTable)
|