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