@coursebuilder/adapter-drizzle 0.5.0 → 0.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-BM5UKWXI.js → chunk-27UC2HEP.js} +2 -2
- package/dist/{chunk-QTGVGIRO.js → chunk-6SLQW6OM.js} +2 -2
- package/dist/{chunk-TBM3AK3P.js → chunk-EFVZ7IN4.js} +2 -2
- package/dist/{chunk-FRA4ZCRA.js → chunk-JW2PFVLO.js} +485 -223
- package/dist/{chunk-O6JECJRY.js → chunk-QQA7STVO.js} +2 -2
- package/dist/{chunk-CQNKTFXE.js → chunk-XJXCDN7B.js} +2 -2
- package/dist/{chunk-JZQ666KH.js → chunk-YMFPIZMO.js} +2 -2
- package/dist/{chunk-Z245DYMP.js → chunk-ZYQYJNLK.js} +569 -198
- package/dist/index.d.ts +3 -1
- package/dist/index.js +12 -12
- package/dist/lib/mysql/index.cjs +1349 -721
- package/dist/lib/mysql/index.cjs.map +1 -1
- package/dist/lib/mysql/index.d.cts +3147 -126
- package/dist/lib/mysql/index.d.ts +3147 -126
- package/dist/lib/mysql/index.js +10 -8
- package/dist/lib/mysql/schemas/auth/accounts.cjs +87 -71
- package/dist/lib/mysql/schemas/auth/accounts.cjs.map +1 -1
- package/dist/lib/mysql/schemas/auth/accounts.d.cts +58 -1
- package/dist/lib/mysql/schemas/auth/accounts.d.ts +58 -1
- package/dist/lib/mysql/schemas/auth/accounts.js +1 -1
- package/dist/lib/mysql/schemas/auth/device-access-token.cjs +79 -63
- package/dist/lib/mysql/schemas/auth/device-access-token.cjs.map +1 -1
- package/dist/lib/mysql/schemas/auth/device-access-token.d.cts +12 -0
- package/dist/lib/mysql/schemas/auth/device-access-token.d.ts +12 -0
- package/dist/lib/mysql/schemas/auth/device-access-token.js +2 -2
- package/dist/lib/mysql/schemas/auth/device-verification.cjs +81 -65
- package/dist/lib/mysql/schemas/auth/device-verification.cjs.map +1 -1
- package/dist/lib/mysql/schemas/auth/device-verification.d.cts +24 -0
- package/dist/lib/mysql/schemas/auth/device-verification.d.ts +24 -0
- package/dist/lib/mysql/schemas/auth/device-verification.js +2 -2
- package/dist/lib/mysql/schemas/auth/permissions.d.cts +28 -0
- package/dist/lib/mysql/schemas/auth/permissions.d.ts +28 -0
- package/dist/lib/mysql/schemas/auth/role-permissions.cjs +76 -60
- package/dist/lib/mysql/schemas/auth/role-permissions.cjs.map +1 -1
- package/dist/lib/mysql/schemas/auth/role-permissions.d.cts +24 -0
- package/dist/lib/mysql/schemas/auth/role-permissions.d.ts +24 -0
- package/dist/lib/mysql/schemas/auth/role-permissions.js +2 -2
- package/dist/lib/mysql/schemas/auth/roles.cjs +76 -60
- package/dist/lib/mysql/schemas/auth/roles.cjs.map +1 -1
- package/dist/lib/mysql/schemas/auth/roles.d.cts +28 -0
- package/dist/lib/mysql/schemas/auth/roles.d.ts +28 -0
- package/dist/lib/mysql/schemas/auth/roles.js +1 -1
- package/dist/lib/mysql/schemas/auth/sessions.cjs +77 -61
- package/dist/lib/mysql/schemas/auth/sessions.cjs.map +1 -1
- package/dist/lib/mysql/schemas/auth/sessions.d.cts +12 -0
- package/dist/lib/mysql/schemas/auth/sessions.d.ts +12 -0
- package/dist/lib/mysql/schemas/auth/sessions.js +2 -2
- package/dist/lib/mysql/schemas/auth/user-permissions.cjs +78 -62
- package/dist/lib/mysql/schemas/auth/user-permissions.cjs.map +1 -1
- package/dist/lib/mysql/schemas/auth/user-permissions.d.cts +24 -0
- package/dist/lib/mysql/schemas/auth/user-permissions.d.ts +24 -0
- package/dist/lib/mysql/schemas/auth/user-permissions.js +1 -1
- package/dist/lib/mysql/schemas/auth/user-prefs.cjs +82 -66
- package/dist/lib/mysql/schemas/auth/user-prefs.cjs.map +1 -1
- package/dist/lib/mysql/schemas/auth/user-prefs.d.cts +28 -0
- package/dist/lib/mysql/schemas/auth/user-prefs.d.ts +28 -0
- package/dist/lib/mysql/schemas/auth/user-prefs.js +1 -1
- package/dist/lib/mysql/schemas/auth/user-roles.cjs +78 -62
- package/dist/lib/mysql/schemas/auth/user-roles.cjs.map +1 -1
- package/dist/lib/mysql/schemas/auth/user-roles.d.cts +24 -0
- package/dist/lib/mysql/schemas/auth/user-roles.d.ts +24 -0
- package/dist/lib/mysql/schemas/auth/user-roles.js +1 -1
- package/dist/lib/mysql/schemas/auth/users.cjs +179 -159
- package/dist/lib/mysql/schemas/auth/users.cjs.map +1 -1
- package/dist/lib/mysql/schemas/auth/users.d.cts +32 -0
- package/dist/lib/mysql/schemas/auth/users.d.ts +32 -0
- package/dist/lib/mysql/schemas/auth/users.js +1 -1
- package/dist/lib/mysql/schemas/auth/verification-tokens.d.cts +16 -0
- package/dist/lib/mysql/schemas/auth/verification-tokens.d.ts +16 -0
- package/dist/lib/mysql/schemas/commerce/coupon.cjs +57 -51
- package/dist/lib/mysql/schemas/commerce/coupon.cjs.map +1 -1
- package/dist/lib/mysql/schemas/commerce/coupon.d.cts +50 -14
- package/dist/lib/mysql/schemas/commerce/coupon.d.ts +50 -14
- package/dist/lib/mysql/schemas/commerce/coupon.js +1 -1
- package/dist/lib/mysql/schemas/commerce/merchant-account.d.cts +20 -0
- package/dist/lib/mysql/schemas/commerce/merchant-account.d.ts +20 -0
- package/dist/lib/mysql/schemas/commerce/merchant-charge.d.cts +32 -0
- package/dist/lib/mysql/schemas/commerce/merchant-charge.d.ts +32 -0
- package/dist/lib/mysql/schemas/commerce/merchant-coupon.d.cts +24 -0
- package/dist/lib/mysql/schemas/commerce/merchant-coupon.d.ts +24 -0
- package/dist/lib/mysql/schemas/commerce/merchant-customer.d.cts +24 -0
- package/dist/lib/mysql/schemas/commerce/merchant-customer.d.ts +24 -0
- package/dist/lib/mysql/schemas/commerce/merchant-price.d.cts +28 -0
- package/dist/lib/mysql/schemas/commerce/merchant-price.d.ts +28 -0
- package/dist/lib/mysql/schemas/commerce/merchant-product.d.cts +24 -0
- package/dist/lib/mysql/schemas/commerce/merchant-product.d.ts +24 -0
- package/dist/lib/mysql/schemas/commerce/merchant-session.d.cts +12 -0
- package/dist/lib/mysql/schemas/commerce/merchant-session.d.ts +12 -0
- package/dist/lib/mysql/schemas/commerce/price.cjs +44 -28
- package/dist/lib/mysql/schemas/commerce/price.cjs.map +1 -1
- package/dist/lib/mysql/schemas/commerce/price.d.cts +28 -0
- package/dist/lib/mysql/schemas/commerce/price.d.ts +28 -0
- package/dist/lib/mysql/schemas/commerce/price.js +1 -1
- package/dist/lib/mysql/schemas/commerce/product.cjs +58 -42
- package/dist/lib/mysql/schemas/commerce/product.cjs.map +1 -1
- package/dist/lib/mysql/schemas/commerce/product.d.cts +32 -0
- package/dist/lib/mysql/schemas/commerce/product.d.ts +32 -0
- package/dist/lib/mysql/schemas/commerce/product.js +1 -1
- package/dist/lib/mysql/schemas/commerce/purchase-user-transfer.cjs +106 -90
- package/dist/lib/mysql/schemas/commerce/purchase-user-transfer.cjs.map +1 -1
- package/dist/lib/mysql/schemas/commerce/purchase-user-transfer.d.cts +40 -0
- package/dist/lib/mysql/schemas/commerce/purchase-user-transfer.d.ts +40 -0
- package/dist/lib/mysql/schemas/commerce/purchase-user-transfer.js +2 -2
- package/dist/lib/mysql/schemas/commerce/purchase.cjs +110 -98
- package/dist/lib/mysql/schemas/commerce/purchase.cjs.map +1 -1
- package/dist/lib/mysql/schemas/commerce/purchase.d.cts +68 -0
- package/dist/lib/mysql/schemas/commerce/purchase.d.ts +68 -0
- package/dist/lib/mysql/schemas/commerce/purchase.js +1 -1
- package/dist/lib/mysql/schemas/commerce/upgradable-products.cjs +50 -34
- package/dist/lib/mysql/schemas/commerce/upgradable-products.cjs.map +1 -1
- package/dist/lib/mysql/schemas/commerce/upgradable-products.d.cts +28 -0
- package/dist/lib/mysql/schemas/commerce/upgradable-products.d.ts +28 -0
- package/dist/lib/mysql/schemas/commerce/upgradable-products.js +2 -2
- package/dist/lib/mysql/schemas/communication/comment.cjs +82 -66
- package/dist/lib/mysql/schemas/communication/comment.cjs.map +1 -1
- package/dist/lib/mysql/schemas/communication/comment.d.cts +28 -0
- package/dist/lib/mysql/schemas/communication/comment.d.ts +28 -0
- package/dist/lib/mysql/schemas/communication/comment.js +1 -1
- package/dist/lib/mysql/schemas/communication/communication-channel.d.cts +28 -0
- package/dist/lib/mysql/schemas/communication/communication-channel.d.ts +28 -0
- package/dist/lib/mysql/schemas/communication/communication-preference-types.d.cts +28 -0
- package/dist/lib/mysql/schemas/communication/communication-preference-types.d.ts +28 -0
- package/dist/lib/mysql/schemas/communication/communication-preferences.cjs +100 -84
- package/dist/lib/mysql/schemas/communication/communication-preferences.cjs.map +1 -1
- package/dist/lib/mysql/schemas/communication/communication-preferences.d.cts +44 -0
- package/dist/lib/mysql/schemas/communication/communication-preferences.d.ts +44 -0
- package/dist/lib/mysql/schemas/communication/communication-preferences.js +1 -1
- package/dist/lib/mysql/schemas/content/content-contributions.cjs +112 -92
- package/dist/lib/mysql/schemas/content/content-contributions.cjs.map +1 -1
- package/dist/lib/mysql/schemas/content/content-contributions.d.cts +32 -0
- package/dist/lib/mysql/schemas/content/content-contributions.d.ts +32 -0
- package/dist/lib/mysql/schemas/content/content-contributions.js +1 -1
- package/dist/lib/mysql/schemas/content/content-resource-product.cjs +49 -29
- package/dist/lib/mysql/schemas/content/content-resource-product.cjs.map +1 -1
- package/dist/lib/mysql/schemas/content/content-resource-product.d.cts +28 -0
- package/dist/lib/mysql/schemas/content/content-resource-product.d.ts +28 -0
- package/dist/lib/mysql/schemas/content/content-resource-product.js +1 -1
- package/dist/lib/mysql/schemas/content/content-resource-resource.cjs +49 -29
- package/dist/lib/mysql/schemas/content/content-resource-resource.cjs.map +1 -1
- package/dist/lib/mysql/schemas/content/content-resource-resource.d.cts +28 -0
- package/dist/lib/mysql/schemas/content/content-resource-resource.d.ts +28 -0
- package/dist/lib/mysql/schemas/content/content-resource-resource.js +1 -1
- package/dist/lib/mysql/schemas/content/content-resource-tag.cjs +274 -0
- package/dist/lib/mysql/schemas/content/content-resource-tag.cjs.map +1 -0
- package/dist/lib/mysql/schemas/content/content-resource-tag.d.cts +97 -0
- package/dist/lib/mysql/schemas/content/content-resource-tag.d.ts +97 -0
- package/dist/lib/mysql/schemas/content/content-resource-tag.js +21 -0
- package/dist/lib/mysql/schemas/content/content-resource-tag.js.map +1 -0
- package/dist/lib/mysql/schemas/content/content-resource-version.cjs +288 -0
- package/dist/lib/mysql/schemas/content/content-resource-version.cjs.map +1 -0
- package/dist/lib/mysql/schemas/content/content-resource-version.d.cts +130 -0
- package/dist/lib/mysql/schemas/content/content-resource-version.d.ts +130 -0
- package/dist/lib/mysql/schemas/content/content-resource-version.js +21 -0
- package/dist/lib/mysql/schemas/content/content-resource-version.js.map +1 -0
- package/dist/lib/mysql/schemas/content/content-resource.cjs +141 -15
- package/dist/lib/mysql/schemas/content/content-resource.cjs.map +1 -1
- package/dist/lib/mysql/schemas/content/content-resource.d.cts +47 -0
- package/dist/lib/mysql/schemas/content/content-resource.d.ts +47 -0
- package/dist/lib/mysql/schemas/content/content-resource.js +1 -1
- package/dist/lib/mysql/schemas/content/contribution-types.d.cts +32 -0
- package/dist/lib/mysql/schemas/content/contribution-types.d.ts +32 -0
- package/dist/lib/mysql/schemas/content/lesson-progress.d.cts +40 -0
- package/dist/lib/mysql/schemas/content/lesson-progress.d.ts +40 -0
- package/dist/lib/mysql/schemas/content/resource-progress.d.cts +24 -0
- package/dist/lib/mysql/schemas/content/resource-progress.d.ts +24 -0
- package/dist/lib/mysql/schemas/content/tag-tag.cjs +241 -0
- package/dist/lib/mysql/schemas/content/tag-tag.cjs.map +1 -0
- package/dist/lib/mysql/schemas/content/tag-tag.d.cts +129 -0
- package/dist/lib/mysql/schemas/content/tag-tag.d.ts +129 -0
- package/dist/lib/mysql/schemas/content/tag-tag.js +21 -0
- package/dist/lib/mysql/schemas/content/tag-tag.js.map +1 -0
- package/dist/lib/mysql/schemas/content/tag.cjs +263 -0
- package/dist/lib/mysql/schemas/content/tag.cjs.map +1 -0
- package/dist/lib/mysql/schemas/content/tag.d.cts +114 -0
- package/dist/lib/mysql/schemas/content/tag.d.ts +114 -0
- package/dist/lib/mysql/schemas/content/tag.js +21 -0
- package/dist/lib/mysql/schemas/content/tag.js.map +1 -0
- package/dist/lib/mysql/utils.d.cts +1 -0
- package/dist/lib/mysql/utils.d.ts +1 -0
- package/dist/lib/utils.d.cts +2 -0
- package/dist/lib/utils.d.ts +2 -0
- package/package.json +8 -6
- package/src/index.ts +14 -4
- package/src/lib/mysql/index.ts +718 -182
- package/src/lib/mysql/schemas/commerce/coupon.ts +3 -9
- package/src/lib/mysql/schemas/content/content-resource-tag.ts +59 -0
- package/src/lib/mysql/schemas/content/content-resource-version.ts +69 -0
- package/src/lib/mysql/schemas/content/content-resource.ts +17 -0
- package/src/lib/mysql/schemas/content/tag-tag.ts +59 -0
- package/src/lib/mysql/schemas/content/tag.ts +48 -0
|
@@ -30,32 +30,32 @@ import {
|
|
|
30
30
|
} from "./chunk-H736K5TN.js";
|
|
31
31
|
|
|
32
32
|
// src/lib/mysql/schemas/content/content-contributions.ts
|
|
33
|
-
import { relations as
|
|
34
|
-
import { boolean as boolean6, index as
|
|
33
|
+
import { relations as relations20 } from "drizzle-orm";
|
|
34
|
+
import { boolean as boolean6, index as index18, timestamp as timestamp19, varchar as varchar20 } from "drizzle-orm/mysql-core";
|
|
35
35
|
|
|
36
36
|
// src/lib/mysql/schemas/auth/users.ts
|
|
37
|
-
import { relations as
|
|
38
|
-
import { index as
|
|
37
|
+
import { relations as relations19, sql as sql14 } from "drizzle-orm";
|
|
38
|
+
import { index as index17, json as json13, timestamp as timestamp18, varchar as varchar19 } from "drizzle-orm/mysql-core";
|
|
39
39
|
|
|
40
40
|
// src/lib/mysql/schemas/commerce/purchase.ts
|
|
41
|
-
import { relations as
|
|
42
|
-
import { decimal as decimal3, index as
|
|
41
|
+
import { relations as relations11, sql as sql11 } from "drizzle-orm";
|
|
42
|
+
import { decimal as decimal3, index as index9, json as json10, primaryKey as primaryKey8, timestamp as timestamp11, unique as unique3, varchar as varchar11 } from "drizzle-orm/mysql-core";
|
|
43
43
|
|
|
44
44
|
// src/lib/mysql/schemas/commerce/coupon.ts
|
|
45
|
-
import { relations as
|
|
46
|
-
import { boolean, decimal as decimal2, index as
|
|
45
|
+
import { relations as relations10, sql as sql10 } from "drizzle-orm";
|
|
46
|
+
import { boolean, decimal as decimal2, index as index8, int as int4, json as json9, primaryKey as primaryKey7, timestamp as timestamp10, unique as unique2, varchar as varchar10 } from "drizzle-orm/mysql-core";
|
|
47
47
|
|
|
48
48
|
// src/lib/mysql/schemas/commerce/product.ts
|
|
49
|
-
import { relations as
|
|
50
|
-
import { int as
|
|
49
|
+
import { relations as relations9, sql as sql9 } from "drizzle-orm";
|
|
50
|
+
import { int as int3, json as json8, primaryKey as primaryKey6, timestamp as timestamp9, varchar as varchar9 } from "drizzle-orm/mysql-core";
|
|
51
51
|
|
|
52
52
|
// src/lib/mysql/schemas/content/content-resource-product.ts
|
|
53
|
-
import { relations as
|
|
54
|
-
import { double as
|
|
53
|
+
import { relations as relations7, sql as sql7 } from "drizzle-orm";
|
|
54
|
+
import { double as double4, index as index7, json as json6, primaryKey as primaryKey4, timestamp as timestamp7, varchar as varchar7 } from "drizzle-orm/mysql-core";
|
|
55
55
|
|
|
56
56
|
// src/lib/mysql/schemas/content/content-resource.ts
|
|
57
|
-
import { relations as
|
|
58
|
-
import { index as
|
|
57
|
+
import { relations as relations6, sql as sql6 } from "drizzle-orm";
|
|
58
|
+
import { index as index6, json as json5, timestamp as timestamp6, varchar as varchar6 } from "drizzle-orm/mysql-core";
|
|
59
59
|
|
|
60
60
|
// src/lib/mysql/schemas/content/content-resource-resource.ts
|
|
61
61
|
import { relations, sql } from "drizzle-orm";
|
|
@@ -120,19 +120,27 @@ function getContentResourceResourceRelationsSchema(mysqlTable) {
|
|
|
120
120
|
}
|
|
121
121
|
__name(getContentResourceResourceRelationsSchema, "getContentResourceResourceRelationsSchema");
|
|
122
122
|
|
|
123
|
-
// src/lib/mysql/schemas/content/content-resource.ts
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
123
|
+
// src/lib/mysql/schemas/content/content-resource-tag.ts
|
|
124
|
+
import { relations as relations4, sql as sql4 } from "drizzle-orm";
|
|
125
|
+
import { double as double3, index as index4, primaryKey as primaryKey3, timestamp as timestamp4, varchar as varchar4 } from "drizzle-orm/mysql-core";
|
|
126
|
+
|
|
127
|
+
// src/lib/mysql/schemas/content/tag.ts
|
|
128
|
+
import { relations as relations3, sql as sql3 } from "drizzle-orm";
|
|
129
|
+
import { index as index3, json as json3, timestamp as timestamp3, varchar as varchar3 } from "drizzle-orm/mysql-core";
|
|
130
|
+
|
|
131
|
+
// src/lib/mysql/schemas/content/tag-tag.ts
|
|
132
|
+
import { relations as relations2, sql as sql2 } from "drizzle-orm";
|
|
133
|
+
import { double as double2, index as index2, json as json2, primaryKey as primaryKey2, timestamp as timestamp2, varchar as varchar2 } from "drizzle-orm/mysql-core";
|
|
134
|
+
function getTagTagSchema(mysqlTable) {
|
|
135
|
+
return mysqlTable("TagTag", {
|
|
136
|
+
parentTagId: varchar2("parentTagId", {
|
|
130
137
|
length: 255
|
|
131
138
|
}).notNull(),
|
|
132
|
-
|
|
139
|
+
childTagId: varchar2("childTagId", {
|
|
133
140
|
length: 255
|
|
134
141
|
}).notNull(),
|
|
135
|
-
|
|
142
|
+
position: double2("position").notNull().default(0),
|
|
143
|
+
metadata: json2("metadata").$type().default({}),
|
|
136
144
|
createdAt: timestamp2("createdAt", {
|
|
137
145
|
mode: "date",
|
|
138
146
|
fsp: 3
|
|
@@ -145,10 +153,248 @@ function getContentResourceSchema(mysqlTable) {
|
|
|
145
153
|
mode: "date",
|
|
146
154
|
fsp: 3
|
|
147
155
|
})
|
|
156
|
+
}, (tt) => ({
|
|
157
|
+
pk: primaryKey2({
|
|
158
|
+
columns: [
|
|
159
|
+
tt.parentTagId,
|
|
160
|
+
tt.childTagId
|
|
161
|
+
]
|
|
162
|
+
}),
|
|
163
|
+
parentTagIdIdx: index2("parentTagId_idx").on(tt.parentTagId),
|
|
164
|
+
childTagIdIdx: index2("childTagId_idx").on(tt.childTagId),
|
|
165
|
+
positionIdx: index2("position_idx").on(tt.position)
|
|
166
|
+
}));
|
|
167
|
+
}
|
|
168
|
+
__name(getTagTagSchema, "getTagTagSchema");
|
|
169
|
+
function getTagTagRelationsSchema(mysqlTable) {
|
|
170
|
+
const tag = getTagSchema(mysqlTable);
|
|
171
|
+
const tagTag = getTagTagSchema(mysqlTable);
|
|
172
|
+
return relations2(tagTag, ({ one }) => ({
|
|
173
|
+
parentTag: one(tag, {
|
|
174
|
+
fields: [
|
|
175
|
+
tagTag.parentTagId
|
|
176
|
+
],
|
|
177
|
+
references: [
|
|
178
|
+
tag.id
|
|
179
|
+
],
|
|
180
|
+
relationName: "parentTag"
|
|
181
|
+
}),
|
|
182
|
+
childTag: one(tag, {
|
|
183
|
+
fields: [
|
|
184
|
+
tagTag.childTagId
|
|
185
|
+
],
|
|
186
|
+
references: [
|
|
187
|
+
tag.id
|
|
188
|
+
],
|
|
189
|
+
relationName: "childTag"
|
|
190
|
+
})
|
|
191
|
+
}));
|
|
192
|
+
}
|
|
193
|
+
__name(getTagTagRelationsSchema, "getTagTagRelationsSchema");
|
|
194
|
+
|
|
195
|
+
// src/lib/mysql/schemas/content/tag.ts
|
|
196
|
+
function getTagSchema(mysqlTable) {
|
|
197
|
+
return mysqlTable("Tag", {
|
|
198
|
+
id: varchar3("id", {
|
|
199
|
+
length: 255
|
|
200
|
+
}).notNull().primaryKey(),
|
|
201
|
+
type: varchar3("type", {
|
|
202
|
+
length: 255
|
|
203
|
+
}).notNull(),
|
|
204
|
+
fields: json3("fields").$type().default({}),
|
|
205
|
+
createdAt: timestamp3("createdAt", {
|
|
206
|
+
mode: "date",
|
|
207
|
+
fsp: 3
|
|
208
|
+
}).default(sql3`CURRENT_TIMESTAMP(3)`),
|
|
209
|
+
updatedAt: timestamp3("updatedAt", {
|
|
210
|
+
mode: "date",
|
|
211
|
+
fsp: 3
|
|
212
|
+
}).default(sql3`CURRENT_TIMESTAMP(3)`),
|
|
213
|
+
deletedAt: timestamp3("deletedAt", {
|
|
214
|
+
mode: "date",
|
|
215
|
+
fsp: 3
|
|
216
|
+
})
|
|
217
|
+
}, (t) => ({
|
|
218
|
+
typeIdx: index3("type_idx").on(t.type)
|
|
219
|
+
}));
|
|
220
|
+
}
|
|
221
|
+
__name(getTagSchema, "getTagSchema");
|
|
222
|
+
function getTagRelationsSchema(mysqlTable) {
|
|
223
|
+
const tag = getTagSchema(mysqlTable);
|
|
224
|
+
const contentResourceTag = getContentResourceTagSchema(mysqlTable);
|
|
225
|
+
const tagTag = getTagTagSchema(mysqlTable);
|
|
226
|
+
return relations3(tag, ({ many }) => ({
|
|
227
|
+
resources: many(contentResourceTag, {
|
|
228
|
+
relationName: "contentResource"
|
|
229
|
+
}),
|
|
230
|
+
parentTags: many(tagTag, {
|
|
231
|
+
relationName: "childTag"
|
|
232
|
+
}),
|
|
233
|
+
childTags: many(tagTag, {
|
|
234
|
+
relationName: "parentTag"
|
|
235
|
+
})
|
|
236
|
+
}));
|
|
237
|
+
}
|
|
238
|
+
__name(getTagRelationsSchema, "getTagRelationsSchema");
|
|
239
|
+
|
|
240
|
+
// src/lib/mysql/schemas/content/content-resource-tag.ts
|
|
241
|
+
function getContentResourceTagSchema(mysqlTable) {
|
|
242
|
+
return mysqlTable("ContentResourceTag", {
|
|
243
|
+
contentResourceId: varchar4("contentResourceId", {
|
|
244
|
+
length: 255
|
|
245
|
+
}).notNull(),
|
|
246
|
+
tagId: varchar4("tagId", {
|
|
247
|
+
length: 255
|
|
248
|
+
}).notNull(),
|
|
249
|
+
position: double3("position").notNull().default(0),
|
|
250
|
+
createdAt: timestamp4("createdAt", {
|
|
251
|
+
mode: "date",
|
|
252
|
+
fsp: 3
|
|
253
|
+
}).default(sql4`CURRENT_TIMESTAMP(3)`),
|
|
254
|
+
updatedAt: timestamp4("updatedAt", {
|
|
255
|
+
mode: "date",
|
|
256
|
+
fsp: 3
|
|
257
|
+
}).default(sql4`CURRENT_TIMESTAMP(3)`)
|
|
258
|
+
}, (crt) => ({
|
|
259
|
+
pk: primaryKey3({
|
|
260
|
+
columns: [
|
|
261
|
+
crt.contentResourceId,
|
|
262
|
+
crt.tagId
|
|
263
|
+
]
|
|
264
|
+
}),
|
|
265
|
+
contentResourceIdIdx: index4("contentResourceId_idx").on(crt.contentResourceId),
|
|
266
|
+
tagIdIdx: index4("tagId_idx").on(crt.tagId),
|
|
267
|
+
positionIdx: index4("position_idx").on(crt.position)
|
|
268
|
+
}));
|
|
269
|
+
}
|
|
270
|
+
__name(getContentResourceTagSchema, "getContentResourceTagSchema");
|
|
271
|
+
function getContentResourceTagRelationsSchema(mysqlTable) {
|
|
272
|
+
const contentResource = getContentResourceSchema(mysqlTable);
|
|
273
|
+
const tag = getTagSchema(mysqlTable);
|
|
274
|
+
const contentResourceTag = getContentResourceTagSchema(mysqlTable);
|
|
275
|
+
return relations4(contentResourceTag, ({ one }) => ({
|
|
276
|
+
contentResource: one(contentResource, {
|
|
277
|
+
fields: [
|
|
278
|
+
contentResourceTag.contentResourceId
|
|
279
|
+
],
|
|
280
|
+
references: [
|
|
281
|
+
contentResource.id
|
|
282
|
+
],
|
|
283
|
+
relationName: "contentResource"
|
|
284
|
+
}),
|
|
285
|
+
tag: one(tag, {
|
|
286
|
+
fields: [
|
|
287
|
+
contentResourceTag.tagId
|
|
288
|
+
],
|
|
289
|
+
references: [
|
|
290
|
+
tag.id
|
|
291
|
+
],
|
|
292
|
+
relationName: "tag"
|
|
293
|
+
})
|
|
294
|
+
}));
|
|
295
|
+
}
|
|
296
|
+
__name(getContentResourceTagRelationsSchema, "getContentResourceTagRelationsSchema");
|
|
297
|
+
|
|
298
|
+
// src/lib/mysql/schemas/content/content-resource-version.ts
|
|
299
|
+
import { relations as relations5, sql as sql5 } from "drizzle-orm";
|
|
300
|
+
import { index as index5, int, json as json4, timestamp as timestamp5, unique, varchar as varchar5 } from "drizzle-orm/mysql-core";
|
|
301
|
+
function getContentResourceVersionSchema(mysqlTable) {
|
|
302
|
+
return mysqlTable("ContentResourceVersion", {
|
|
303
|
+
id: varchar5("id", {
|
|
304
|
+
length: 255
|
|
305
|
+
}).notNull().primaryKey(),
|
|
306
|
+
resourceId: varchar5("resourceId", {
|
|
307
|
+
length: 255
|
|
308
|
+
}).notNull(),
|
|
309
|
+
parentVersionId: varchar5("parentVersionId", {
|
|
310
|
+
length: 255
|
|
311
|
+
}),
|
|
312
|
+
versionNumber: int("versionNumber").notNull(),
|
|
313
|
+
fields: json4("fields").$type().default({}),
|
|
314
|
+
createdAt: timestamp5("createdAt", {
|
|
315
|
+
mode: "date",
|
|
316
|
+
fsp: 3
|
|
317
|
+
}).default(sql5`CURRENT_TIMESTAMP(3)`),
|
|
318
|
+
createdById: varchar5("createdById", {
|
|
319
|
+
length: 255
|
|
320
|
+
}).notNull()
|
|
321
|
+
}, (crv) => ({
|
|
322
|
+
resourceIdIdx: index5("resourceId_idx").on(crv.resourceId),
|
|
323
|
+
parentVersionIdIdx: index5("parentVersionId_idx").on(crv.parentVersionId),
|
|
324
|
+
resourceIdVersionNumberIdx: index5("resourceId_versionNumber_idx").on(crv.resourceId, crv.versionNumber),
|
|
325
|
+
uniqueResourceVersion: unique("uq_resource_version_number").on(crv.resourceId, crv.versionNumber)
|
|
326
|
+
}));
|
|
327
|
+
}
|
|
328
|
+
__name(getContentResourceVersionSchema, "getContentResourceVersionSchema");
|
|
329
|
+
function getContentResourceVersionRelationsSchema(mysqlTable) {
|
|
330
|
+
const contentResourceVersion = getContentResourceVersionSchema(mysqlTable);
|
|
331
|
+
const contentResource = getContentResourceSchema(mysqlTable);
|
|
332
|
+
const users = getUsersSchema(mysqlTable);
|
|
333
|
+
return relations5(contentResourceVersion, ({ one }) => ({
|
|
334
|
+
resource: one(contentResource, {
|
|
335
|
+
fields: [
|
|
336
|
+
contentResourceVersion.resourceId
|
|
337
|
+
],
|
|
338
|
+
references: [
|
|
339
|
+
contentResource.id
|
|
340
|
+
],
|
|
341
|
+
relationName: "versions"
|
|
342
|
+
}),
|
|
343
|
+
parentVersion: one(contentResourceVersion, {
|
|
344
|
+
fields: [
|
|
345
|
+
contentResourceVersion.parentVersionId
|
|
346
|
+
],
|
|
347
|
+
references: [
|
|
348
|
+
contentResourceVersion.id
|
|
349
|
+
],
|
|
350
|
+
relationName: "childVersions"
|
|
351
|
+
}),
|
|
352
|
+
createdBy: one(users, {
|
|
353
|
+
fields: [
|
|
354
|
+
contentResourceVersion.createdById
|
|
355
|
+
],
|
|
356
|
+
references: [
|
|
357
|
+
users.id
|
|
358
|
+
],
|
|
359
|
+
relationName: "createdVersions"
|
|
360
|
+
})
|
|
361
|
+
}));
|
|
362
|
+
}
|
|
363
|
+
__name(getContentResourceVersionRelationsSchema, "getContentResourceVersionRelationsSchema");
|
|
364
|
+
|
|
365
|
+
// src/lib/mysql/schemas/content/content-resource.ts
|
|
366
|
+
function getContentResourceSchema(mysqlTable) {
|
|
367
|
+
return mysqlTable("ContentResource", {
|
|
368
|
+
id: varchar6("id", {
|
|
369
|
+
length: 255
|
|
370
|
+
}).notNull().primaryKey(),
|
|
371
|
+
type: varchar6("type", {
|
|
372
|
+
length: 255
|
|
373
|
+
}).notNull(),
|
|
374
|
+
createdById: varchar6("createdById", {
|
|
375
|
+
length: 255
|
|
376
|
+
}).notNull(),
|
|
377
|
+
fields: json5("fields").$type().default({}),
|
|
378
|
+
currentVersionId: varchar6("currentVersionId", {
|
|
379
|
+
length: 255
|
|
380
|
+
}),
|
|
381
|
+
createdAt: timestamp6("createdAt", {
|
|
382
|
+
mode: "date",
|
|
383
|
+
fsp: 3
|
|
384
|
+
}).default(sql6`CURRENT_TIMESTAMP(3)`),
|
|
385
|
+
updatedAt: timestamp6("updatedAt", {
|
|
386
|
+
mode: "date",
|
|
387
|
+
fsp: 3
|
|
388
|
+
}).default(sql6`CURRENT_TIMESTAMP(3)`),
|
|
389
|
+
deletedAt: timestamp6("deletedAt", {
|
|
390
|
+
mode: "date",
|
|
391
|
+
fsp: 3
|
|
392
|
+
})
|
|
148
393
|
}, (cm) => ({
|
|
149
|
-
typeIdx:
|
|
150
|
-
createdByIdx:
|
|
151
|
-
createdAtIdx:
|
|
394
|
+
typeIdx: index6("type_idx").on(cm.type),
|
|
395
|
+
createdByIdx: index6("createdById_idx").on(cm.createdById),
|
|
396
|
+
createdAtIdx: index6("createdAt_idx").on(cm.createdAt),
|
|
397
|
+
currentVersionIdIdx: index6("currentVersionId_idx").on(cm.currentVersionId)
|
|
152
398
|
}));
|
|
153
399
|
}
|
|
154
400
|
__name(getContentResourceSchema, "getContentResourceSchema");
|
|
@@ -158,7 +404,10 @@ function getContentResourceRelationsSchema(mysqlTable) {
|
|
|
158
404
|
const contentResourceResource = getContentResourceResourceSchema(mysqlTable);
|
|
159
405
|
const contentResourceProduct = getContentResourceProductSchema(mysqlTable);
|
|
160
406
|
const contentContributions = getContentContributionsSchema(mysqlTable);
|
|
161
|
-
|
|
407
|
+
const contentResourceTag = getContentResourceTagSchema(mysqlTable);
|
|
408
|
+
const contentResourceVersion = getContentResourceVersionSchema(mysqlTable);
|
|
409
|
+
const tag = getTagSchema(mysqlTable);
|
|
410
|
+
return relations6(contentResource, ({ one, many }) => ({
|
|
162
411
|
createdBy: one(users, {
|
|
163
412
|
fields: [
|
|
164
413
|
contentResource.createdById
|
|
@@ -168,6 +417,9 @@ function getContentResourceRelationsSchema(mysqlTable) {
|
|
|
168
417
|
],
|
|
169
418
|
relationName: "creator"
|
|
170
419
|
}),
|
|
420
|
+
tags: many(contentResourceTag, {
|
|
421
|
+
relationName: "contentResource"
|
|
422
|
+
}),
|
|
171
423
|
resources: many(contentResourceResource, {
|
|
172
424
|
relationName: "resourceOf"
|
|
173
425
|
}),
|
|
@@ -179,6 +431,18 @@ function getContentResourceRelationsSchema(mysqlTable) {
|
|
|
179
431
|
}),
|
|
180
432
|
contributions: many(contentContributions, {
|
|
181
433
|
relationName: "contributions"
|
|
434
|
+
}),
|
|
435
|
+
currentVersion: one(contentResourceVersion, {
|
|
436
|
+
fields: [
|
|
437
|
+
contentResource.currentVersionId
|
|
438
|
+
],
|
|
439
|
+
references: [
|
|
440
|
+
contentResourceVersion.id
|
|
441
|
+
],
|
|
442
|
+
relationName: "currentVersionResource"
|
|
443
|
+
}),
|
|
444
|
+
versions: many(contentResourceVersion, {
|
|
445
|
+
relationName: "resource"
|
|
182
446
|
})
|
|
183
447
|
}));
|
|
184
448
|
}
|
|
@@ -187,35 +451,35 @@ __name(getContentResourceRelationsSchema, "getContentResourceRelationsSchema");
|
|
|
187
451
|
// src/lib/mysql/schemas/content/content-resource-product.ts
|
|
188
452
|
function getContentResourceProductSchema(mysqlTable) {
|
|
189
453
|
return mysqlTable("ContentResourceProduct", {
|
|
190
|
-
productId:
|
|
454
|
+
productId: varchar7("productId", {
|
|
191
455
|
length: 255
|
|
192
456
|
}).notNull(),
|
|
193
|
-
resourceId:
|
|
457
|
+
resourceId: varchar7("resourceId", {
|
|
194
458
|
length: 255
|
|
195
459
|
}).notNull(),
|
|
196
|
-
position:
|
|
197
|
-
metadata:
|
|
198
|
-
createdAt:
|
|
460
|
+
position: double4("position").notNull().default(0),
|
|
461
|
+
metadata: json6("metadata").$type().default({}),
|
|
462
|
+
createdAt: timestamp7("createdAt", {
|
|
199
463
|
mode: "date",
|
|
200
464
|
fsp: 3
|
|
201
|
-
}).default(
|
|
202
|
-
updatedAt:
|
|
465
|
+
}).default(sql7`CURRENT_TIMESTAMP(3)`),
|
|
466
|
+
updatedAt: timestamp7("updatedAt", {
|
|
203
467
|
mode: "date",
|
|
204
468
|
fsp: 3
|
|
205
|
-
}).default(
|
|
206
|
-
deletedAt:
|
|
469
|
+
}).default(sql7`CURRENT_TIMESTAMP(3)`),
|
|
470
|
+
deletedAt: timestamp7("deletedAt", {
|
|
207
471
|
mode: "date",
|
|
208
472
|
fsp: 3
|
|
209
473
|
})
|
|
210
474
|
}, (crr) => ({
|
|
211
|
-
pk:
|
|
475
|
+
pk: primaryKey4({
|
|
212
476
|
columns: [
|
|
213
477
|
crr.productId,
|
|
214
478
|
crr.resourceId
|
|
215
479
|
]
|
|
216
480
|
}),
|
|
217
|
-
contentResourceIdIdx:
|
|
218
|
-
resourceIdIdx:
|
|
481
|
+
contentResourceIdIdx: index7("contentResourceId_idx").on(crr.productId),
|
|
482
|
+
resourceIdIdx: index7("resourceId_idx").on(crr.resourceId)
|
|
219
483
|
}));
|
|
220
484
|
}
|
|
221
485
|
__name(getContentResourceProductSchema, "getContentResourceProductSchema");
|
|
@@ -223,7 +487,7 @@ function getContentResourceProductRelationsSchema(mysqlTable) {
|
|
|
223
487
|
const contentResource = getContentResourceSchema(mysqlTable);
|
|
224
488
|
const contentResourceProduct = getContentResourceProductSchema(mysqlTable);
|
|
225
489
|
const product = getProductSchema(mysqlTable);
|
|
226
|
-
return
|
|
490
|
+
return relations7(contentResourceProduct, ({ one }) => ({
|
|
227
491
|
product: one(product, {
|
|
228
492
|
fields: [
|
|
229
493
|
contentResourceProduct.productId
|
|
@@ -247,32 +511,32 @@ function getContentResourceProductRelationsSchema(mysqlTable) {
|
|
|
247
511
|
__name(getContentResourceProductRelationsSchema, "getContentResourceProductRelationsSchema");
|
|
248
512
|
|
|
249
513
|
// src/lib/mysql/schemas/commerce/price.ts
|
|
250
|
-
import { relations as
|
|
251
|
-
import { decimal, int, json as
|
|
514
|
+
import { relations as relations8, sql as sql8 } from "drizzle-orm";
|
|
515
|
+
import { decimal, int as int2, json as json7, primaryKey as primaryKey5, timestamp as timestamp8, varchar as varchar8 } from "drizzle-orm/mysql-core";
|
|
252
516
|
function getPriceSchema(mysqlTable) {
|
|
253
517
|
return mysqlTable("Price", {
|
|
254
|
-
id:
|
|
518
|
+
id: varchar8("id", {
|
|
255
519
|
length: 191
|
|
256
520
|
}).notNull(),
|
|
257
|
-
productId:
|
|
521
|
+
productId: varchar8("productId", {
|
|
258
522
|
length: 191
|
|
259
523
|
}),
|
|
260
|
-
nickname:
|
|
524
|
+
nickname: varchar8("nickname", {
|
|
261
525
|
length: 191
|
|
262
526
|
}),
|
|
263
|
-
status:
|
|
527
|
+
status: int2("status").default(0).notNull(),
|
|
264
528
|
unitAmount: decimal("unitAmount", {
|
|
265
529
|
precision: 10,
|
|
266
530
|
scale: 2
|
|
267
531
|
}).notNull(),
|
|
268
|
-
createdAt:
|
|
532
|
+
createdAt: timestamp8("createdAt", {
|
|
269
533
|
mode: "date",
|
|
270
534
|
fsp: 3
|
|
271
|
-
}).default(
|
|
272
|
-
fields:
|
|
535
|
+
}).default(sql8`CURRENT_TIMESTAMP(3)`).notNull(),
|
|
536
|
+
fields: json7("fields").$type().default({})
|
|
273
537
|
}, (table) => {
|
|
274
538
|
return {
|
|
275
|
-
priceId:
|
|
539
|
+
priceId: primaryKey5({
|
|
276
540
|
columns: [
|
|
277
541
|
table.id
|
|
278
542
|
],
|
|
@@ -286,7 +550,7 @@ function getProductRelationsSchema(mysqlTable) {
|
|
|
286
550
|
const product = getProductSchema(mysqlTable);
|
|
287
551
|
const price = getPriceSchema(mysqlTable);
|
|
288
552
|
const merchantPrice = getMerchantPriceSchema(mysqlTable);
|
|
289
|
-
return
|
|
553
|
+
return relations8(price, ({ one, many }) => ({
|
|
290
554
|
product: one(product, {
|
|
291
555
|
fields: [
|
|
292
556
|
price.productId
|
|
@@ -312,28 +576,28 @@ __name(getProductRelationsSchema, "getProductRelationsSchema");
|
|
|
312
576
|
// src/lib/mysql/schemas/commerce/product.ts
|
|
313
577
|
function getProductSchema(mysqlTable) {
|
|
314
578
|
return mysqlTable("Product", {
|
|
315
|
-
id:
|
|
579
|
+
id: varchar9("id", {
|
|
316
580
|
length: 191
|
|
317
581
|
}).notNull(),
|
|
318
|
-
name:
|
|
582
|
+
name: varchar9("name", {
|
|
319
583
|
length: 191
|
|
320
584
|
}).notNull(),
|
|
321
|
-
key:
|
|
585
|
+
key: varchar9("key", {
|
|
322
586
|
length: 191
|
|
323
587
|
}),
|
|
324
|
-
type:
|
|
588
|
+
type: varchar9("type", {
|
|
325
589
|
length: 191
|
|
326
590
|
}),
|
|
327
|
-
fields:
|
|
328
|
-
createdAt:
|
|
591
|
+
fields: json8("fields").$type().default({}),
|
|
592
|
+
createdAt: timestamp9("createdAt", {
|
|
329
593
|
mode: "date",
|
|
330
594
|
fsp: 3
|
|
331
|
-
}).default(
|
|
332
|
-
status:
|
|
333
|
-
quantityAvailable:
|
|
595
|
+
}).default(sql9`CURRENT_TIMESTAMP(3)`).notNull(),
|
|
596
|
+
status: int3("status").default(0).notNull(),
|
|
597
|
+
quantityAvailable: int3("quantityAvailable").default(-1).notNull()
|
|
334
598
|
}, (table) => {
|
|
335
599
|
return {
|
|
336
|
-
productId:
|
|
600
|
+
productId: primaryKey6({
|
|
337
601
|
columns: [
|
|
338
602
|
table.id
|
|
339
603
|
],
|
|
@@ -348,7 +612,7 @@ function getProductRelationsSchema2(mysqlTable) {
|
|
|
348
612
|
const price = getPriceSchema(mysqlTable);
|
|
349
613
|
const merchantProduct = getMerchantProductSchema(mysqlTable);
|
|
350
614
|
const contentResourceProduct = getContentResourceProductSchema(mysqlTable);
|
|
351
|
-
return
|
|
615
|
+
return relations9(product, ({ one, many }) => ({
|
|
352
616
|
price: one(price, {
|
|
353
617
|
fields: [
|
|
354
618
|
product.id
|
|
@@ -377,49 +641,45 @@ __name(getProductRelationsSchema2, "getProductRelationsSchema");
|
|
|
377
641
|
// src/lib/mysql/schemas/commerce/coupon.ts
|
|
378
642
|
function getCouponSchema(mysqlTable) {
|
|
379
643
|
return mysqlTable("Coupon", {
|
|
380
|
-
id:
|
|
644
|
+
id: varchar10("id", {
|
|
381
645
|
length: 191
|
|
382
646
|
}).notNull(),
|
|
383
|
-
code:
|
|
647
|
+
code: varchar10("code", {
|
|
384
648
|
length: 191
|
|
385
649
|
}),
|
|
386
|
-
createdAt:
|
|
650
|
+
createdAt: timestamp10("createdAt", {
|
|
387
651
|
mode: "date",
|
|
388
652
|
fsp: 3
|
|
389
|
-
}).default(
|
|
390
|
-
expires:
|
|
653
|
+
}).default(sql10`CURRENT_TIMESTAMP(3)`).notNull(),
|
|
654
|
+
expires: timestamp10("expires", {
|
|
391
655
|
mode: "date",
|
|
392
656
|
fsp: 3
|
|
393
657
|
}),
|
|
394
|
-
fields:
|
|
395
|
-
maxUses:
|
|
658
|
+
fields: json9("fields").$type().default({}),
|
|
659
|
+
maxUses: int4("maxUses").default(-1).notNull(),
|
|
396
660
|
default: boolean("default").default(false).notNull(),
|
|
397
|
-
merchantCouponId:
|
|
661
|
+
merchantCouponId: varchar10("merchantCouponId", {
|
|
398
662
|
length: 191
|
|
399
663
|
}),
|
|
400
|
-
status:
|
|
401
|
-
usedCount:
|
|
664
|
+
status: int4("status").default(0).notNull(),
|
|
665
|
+
usedCount: int4("usedCount").default(0).notNull(),
|
|
402
666
|
percentageDiscount: decimal2("percentageDiscount", {
|
|
403
667
|
precision: 3,
|
|
404
668
|
scale: 2
|
|
405
669
|
}).notNull(),
|
|
406
|
-
restrictedToProductId:
|
|
407
|
-
length: 191
|
|
408
|
-
}),
|
|
409
|
-
bulkPurchaseId: varchar6("bulkPurchaseId", {
|
|
670
|
+
restrictedToProductId: varchar10("restrictedToProductId", {
|
|
410
671
|
length: 191
|
|
411
672
|
})
|
|
412
673
|
}, (table) => {
|
|
413
674
|
return {
|
|
414
|
-
couponIdCodeIndex:
|
|
415
|
-
couponId:
|
|
675
|
+
couponIdCodeIndex: index8("Coupon_id_code_index").on(table.id, table.code),
|
|
676
|
+
couponId: primaryKey7({
|
|
416
677
|
columns: [
|
|
417
678
|
table.id
|
|
418
679
|
],
|
|
419
680
|
name: "Coupon_id"
|
|
420
681
|
}),
|
|
421
|
-
|
|
422
|
-
couponCodeKey: unique("Coupon_code_key").on(table.code)
|
|
682
|
+
couponCodeKey: unique2("Coupon_code_key").on(table.code)
|
|
423
683
|
};
|
|
424
684
|
});
|
|
425
685
|
}
|
|
@@ -428,8 +688,8 @@ function getCouponRelationsSchema(mysqlTable) {
|
|
|
428
688
|
const purchase = getPurchaseSchema(mysqlTable);
|
|
429
689
|
const coupon = getCouponSchema(mysqlTable);
|
|
430
690
|
const merchantCoupon = getMerchantCouponSchema(mysqlTable);
|
|
431
|
-
return
|
|
432
|
-
|
|
691
|
+
return relations10(coupon, ({ many, one }) => ({
|
|
692
|
+
redeemedBulkCouponPurchases: many(purchase, {
|
|
433
693
|
relationName: "redeemedBulkCoupon"
|
|
434
694
|
}),
|
|
435
695
|
merchantCoupon: one(merchantCoupon, {
|
|
@@ -450,14 +710,8 @@ function getCouponRelationsSchema(mysqlTable) {
|
|
|
450
710
|
],
|
|
451
711
|
relationName: "product"
|
|
452
712
|
}),
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
coupon.bulkPurchaseId
|
|
456
|
-
],
|
|
457
|
-
references: [
|
|
458
|
-
purchase.id
|
|
459
|
-
],
|
|
460
|
-
relationName: "bulkPurchase"
|
|
713
|
+
bulkPurchases: many(purchase, {
|
|
714
|
+
relationName: "bulkCoupon"
|
|
461
715
|
})
|
|
462
716
|
}));
|
|
463
717
|
}
|
|
@@ -466,67 +720,67 @@ __name(getCouponRelationsSchema, "getCouponRelationsSchema");
|
|
|
466
720
|
// src/lib/mysql/schemas/commerce/purchase.ts
|
|
467
721
|
function getPurchaseSchema(mysqlTable) {
|
|
468
722
|
return mysqlTable("Purchase", {
|
|
469
|
-
id:
|
|
723
|
+
id: varchar11("id", {
|
|
470
724
|
length: 191
|
|
471
725
|
}).notNull(),
|
|
472
|
-
userId:
|
|
726
|
+
userId: varchar11("userId", {
|
|
473
727
|
length: 191
|
|
474
728
|
}),
|
|
475
|
-
createdAt:
|
|
729
|
+
createdAt: timestamp11("createdAt", {
|
|
476
730
|
mode: "date",
|
|
477
731
|
fsp: 3
|
|
478
|
-
}).default(
|
|
732
|
+
}).default(sql11`CURRENT_TIMESTAMP(3)`).notNull(),
|
|
479
733
|
totalAmount: decimal3("totalAmount", {
|
|
480
734
|
precision: 65,
|
|
481
735
|
scale: 30
|
|
482
736
|
}).notNull(),
|
|
483
|
-
ipAddress:
|
|
737
|
+
ipAddress: varchar11("ip_address", {
|
|
484
738
|
length: 191
|
|
485
739
|
}),
|
|
486
|
-
city:
|
|
740
|
+
city: varchar11("city", {
|
|
487
741
|
length: 191
|
|
488
742
|
}),
|
|
489
|
-
state:
|
|
743
|
+
state: varchar11("state", {
|
|
490
744
|
length: 191
|
|
491
745
|
}),
|
|
492
|
-
country:
|
|
746
|
+
country: varchar11("country", {
|
|
493
747
|
length: 191
|
|
494
748
|
}),
|
|
495
|
-
couponId:
|
|
749
|
+
couponId: varchar11("couponId", {
|
|
496
750
|
length: 191
|
|
497
751
|
}),
|
|
498
|
-
productId:
|
|
752
|
+
productId: varchar11("productId", {
|
|
499
753
|
length: 191
|
|
500
754
|
}).notNull(),
|
|
501
|
-
merchantChargeId:
|
|
755
|
+
merchantChargeId: varchar11("merchantChargeId", {
|
|
502
756
|
length: 191
|
|
503
757
|
}),
|
|
504
|
-
upgradedFromId:
|
|
758
|
+
upgradedFromId: varchar11("upgradedFromId", {
|
|
505
759
|
length: 191
|
|
506
760
|
}),
|
|
507
|
-
status:
|
|
761
|
+
status: varchar11("status", {
|
|
508
762
|
length: 191
|
|
509
763
|
}).default("Valid").notNull(),
|
|
510
|
-
bulkCouponId:
|
|
764
|
+
bulkCouponId: varchar11("bulkCouponId", {
|
|
511
765
|
length: 191
|
|
512
766
|
}),
|
|
513
|
-
merchantSessionId:
|
|
767
|
+
merchantSessionId: varchar11("merchantSessionId", {
|
|
514
768
|
length: 191
|
|
515
769
|
}),
|
|
516
|
-
redeemedBulkCouponId:
|
|
770
|
+
redeemedBulkCouponId: varchar11("redeemedBulkCouponId", {
|
|
517
771
|
length: 191
|
|
518
772
|
}),
|
|
519
|
-
fields:
|
|
773
|
+
fields: json10("fields").$type().default({})
|
|
520
774
|
}, (table) => {
|
|
521
775
|
return {
|
|
522
|
-
purchaseId:
|
|
776
|
+
purchaseId: primaryKey8({
|
|
523
777
|
columns: [
|
|
524
778
|
table.id
|
|
525
779
|
],
|
|
526
780
|
name: "Purchase_id"
|
|
527
781
|
}),
|
|
528
|
-
merchantChargeIdIdx:
|
|
529
|
-
purchaseUpgradedFromIdKey:
|
|
782
|
+
merchantChargeIdIdx: index9("idx_Purchase_on_merchantChargeId").on(table.merchantChargeId),
|
|
783
|
+
purchaseUpgradedFromIdKey: unique3("Purchase_upgradedFromId_key").on(table.upgradedFromId)
|
|
530
784
|
};
|
|
531
785
|
});
|
|
532
786
|
}
|
|
@@ -538,7 +792,7 @@ function getPurchaseRelationsSchema(mysqlTable) {
|
|
|
538
792
|
const merchantCharges = getMerchantChargeSchema(mysqlTable);
|
|
539
793
|
const merchantSessions = getMerchantSessionSchema(mysqlTable);
|
|
540
794
|
const coupons = getCouponSchema(mysqlTable);
|
|
541
|
-
return
|
|
795
|
+
return relations11(purchases, ({ many, one }) => ({
|
|
542
796
|
redeemedBulkCoupon: one(coupons, {
|
|
543
797
|
fields: [
|
|
544
798
|
purchases.redeemedBulkCouponId
|
|
@@ -598,44 +852,44 @@ function getPurchaseRelationsSchema(mysqlTable) {
|
|
|
598
852
|
__name(getPurchaseRelationsSchema, "getPurchaseRelationsSchema");
|
|
599
853
|
|
|
600
854
|
// src/lib/mysql/schemas/communication/comment.ts
|
|
601
|
-
import { relations as
|
|
602
|
-
import { index as
|
|
855
|
+
import { relations as relations12, sql as sql12 } from "drizzle-orm";
|
|
856
|
+
import { index as index10, json as json11, primaryKey as primaryKey9, text, timestamp as timestamp12, varchar as varchar12 } from "drizzle-orm/mysql-core";
|
|
603
857
|
function getCommentsSchema(mysqlTable) {
|
|
604
858
|
return mysqlTable("Comment", {
|
|
605
|
-
id:
|
|
859
|
+
id: varchar12("id", {
|
|
606
860
|
length: 191
|
|
607
861
|
}).notNull(),
|
|
608
|
-
userId:
|
|
862
|
+
userId: varchar12("userId", {
|
|
609
863
|
length: 255
|
|
610
864
|
}).notNull(),
|
|
611
|
-
context:
|
|
865
|
+
context: json11("context").$type().default({}),
|
|
612
866
|
text: text("text").notNull(),
|
|
613
|
-
createdAt:
|
|
867
|
+
createdAt: timestamp12("createdAt", {
|
|
614
868
|
mode: "date",
|
|
615
869
|
fsp: 3
|
|
616
|
-
}).default(
|
|
617
|
-
updatedAt:
|
|
870
|
+
}).default(sql12`CURRENT_TIMESTAMP(3)`),
|
|
871
|
+
updatedAt: timestamp12("updatedAt", {
|
|
618
872
|
mode: "date",
|
|
619
873
|
fsp: 3
|
|
620
|
-
}).default(
|
|
621
|
-
deletedAt:
|
|
874
|
+
}).default(sql12`CURRENT_TIMESTAMP(3)`),
|
|
875
|
+
deletedAt: timestamp12("deletedAt", {
|
|
622
876
|
mode: "date",
|
|
623
877
|
fsp: 3
|
|
624
878
|
})
|
|
625
879
|
}, (crr) => ({
|
|
626
|
-
pk:
|
|
880
|
+
pk: primaryKey9({
|
|
627
881
|
columns: [
|
|
628
882
|
crr.id
|
|
629
883
|
]
|
|
630
884
|
}),
|
|
631
|
-
crrUserIdIdKey:
|
|
885
|
+
crrUserIdIdKey: index10("crr_userIdId_idx").on(crr.userId)
|
|
632
886
|
}));
|
|
633
887
|
}
|
|
634
888
|
__name(getCommentsSchema, "getCommentsSchema");
|
|
635
889
|
function getCommentRelationsSchema(mysqlTable) {
|
|
636
890
|
const comment = getCommentsSchema(mysqlTable);
|
|
637
891
|
const user = getUsersSchema(mysqlTable);
|
|
638
|
-
return
|
|
892
|
+
return relations12(comment, ({ one }) => ({
|
|
639
893
|
user: one(user, {
|
|
640
894
|
fields: [
|
|
641
895
|
comment.userId
|
|
@@ -650,17 +904,17 @@ function getCommentRelationsSchema(mysqlTable) {
|
|
|
650
904
|
__name(getCommentRelationsSchema, "getCommentRelationsSchema");
|
|
651
905
|
|
|
652
906
|
// src/lib/mysql/schemas/communication/communication-preferences.ts
|
|
653
|
-
import { relations as
|
|
654
|
-
import { boolean as boolean2, index as
|
|
907
|
+
import { relations as relations13 } from "drizzle-orm";
|
|
908
|
+
import { boolean as boolean2, index as index11, mysqlEnum, timestamp as timestamp13, varchar as varchar13 } from "drizzle-orm/mysql-core";
|
|
655
909
|
function getCommunicationPreferencesSchema(mysqlTable) {
|
|
656
910
|
return mysqlTable("CommunicationPreference", {
|
|
657
|
-
id:
|
|
911
|
+
id: varchar13("id", {
|
|
658
912
|
length: 255
|
|
659
913
|
}).notNull().primaryKey(),
|
|
660
|
-
userId:
|
|
914
|
+
userId: varchar13("userId", {
|
|
661
915
|
length: 255
|
|
662
916
|
}).notNull(),
|
|
663
|
-
channelId:
|
|
917
|
+
channelId: varchar13("channelId", {
|
|
664
918
|
length: 255
|
|
665
919
|
}).notNull(),
|
|
666
920
|
preferenceLevel: mysqlEnum("preferenceLevel", [
|
|
@@ -668,34 +922,34 @@ function getCommunicationPreferencesSchema(mysqlTable) {
|
|
|
668
922
|
"medium",
|
|
669
923
|
"high"
|
|
670
924
|
]).notNull().default("medium"),
|
|
671
|
-
preferenceTypeId:
|
|
925
|
+
preferenceTypeId: varchar13("preferenceTypeId", {
|
|
672
926
|
length: 255
|
|
673
927
|
}).notNull(),
|
|
674
928
|
active: boolean2("active").notNull().default(true),
|
|
675
|
-
createdAt:
|
|
929
|
+
createdAt: timestamp13("createdAt", {
|
|
676
930
|
mode: "date",
|
|
677
931
|
fsp: 3
|
|
678
932
|
}).defaultNow(),
|
|
679
|
-
optInAt:
|
|
933
|
+
optInAt: timestamp13("optInAt", {
|
|
680
934
|
mode: "date",
|
|
681
935
|
fsp: 3
|
|
682
936
|
}),
|
|
683
|
-
optOutAt:
|
|
937
|
+
optOutAt: timestamp13("optOutAt", {
|
|
684
938
|
mode: "date",
|
|
685
939
|
fsp: 3
|
|
686
940
|
}),
|
|
687
|
-
updatedAt:
|
|
941
|
+
updatedAt: timestamp13("updatedAt", {
|
|
688
942
|
mode: "date",
|
|
689
943
|
fsp: 3
|
|
690
944
|
}).defaultNow(),
|
|
691
|
-
deletedAt:
|
|
945
|
+
deletedAt: timestamp13("deletedAt", {
|
|
692
946
|
mode: "date",
|
|
693
947
|
fsp: 3
|
|
694
948
|
})
|
|
695
949
|
}, (cp) => ({
|
|
696
|
-
userIdIdx:
|
|
697
|
-
preferenceTypeIdx:
|
|
698
|
-
channelIdIdx:
|
|
950
|
+
userIdIdx: index11("userId_idx").on(cp.userId),
|
|
951
|
+
preferenceTypeIdx: index11("preferenceTypeId_idx").on(cp.preferenceTypeId),
|
|
952
|
+
channelIdIdx: index11("channelId_idx").on(cp.channelId)
|
|
699
953
|
}));
|
|
700
954
|
}
|
|
701
955
|
__name(getCommunicationPreferencesSchema, "getCommunicationPreferencesSchema");
|
|
@@ -704,7 +958,7 @@ function getCommunicationPreferencesRelationsSchema(mysqlTable) {
|
|
|
704
958
|
const users = getUsersSchema(mysqlTable);
|
|
705
959
|
const communicationChannel = getCommunicationChannelSchema(mysqlTable);
|
|
706
960
|
const communicationPreferenceTypes = getCommunicationPreferenceTypesSchema(mysqlTable);
|
|
707
|
-
return
|
|
961
|
+
return relations13(communicationPreferences, ({ one }) => ({
|
|
708
962
|
user: one(users, {
|
|
709
963
|
fields: [
|
|
710
964
|
communicationPreferences.userId
|
|
@@ -737,53 +991,53 @@ function getCommunicationPreferencesRelationsSchema(mysqlTable) {
|
|
|
737
991
|
__name(getCommunicationPreferencesRelationsSchema, "getCommunicationPreferencesRelationsSchema");
|
|
738
992
|
|
|
739
993
|
// src/lib/mysql/schemas/auth/accounts.ts
|
|
740
|
-
import { relations as
|
|
741
|
-
import { index as
|
|
994
|
+
import { relations as relations14 } from "drizzle-orm";
|
|
995
|
+
import { index as index12, int as int5, primaryKey as primaryKey10, text as text2, varchar as varchar14 } from "drizzle-orm/mysql-core";
|
|
742
996
|
function getAccountsSchema(mysqlTable) {
|
|
743
997
|
return mysqlTable("Account", {
|
|
744
|
-
userId:
|
|
998
|
+
userId: varchar14("userId", {
|
|
745
999
|
length: 255
|
|
746
1000
|
}).notNull(),
|
|
747
|
-
type:
|
|
1001
|
+
type: varchar14("type", {
|
|
748
1002
|
length: 255
|
|
749
1003
|
}).$type().notNull(),
|
|
750
|
-
provider:
|
|
1004
|
+
provider: varchar14("provider", {
|
|
751
1005
|
length: 255
|
|
752
1006
|
}).notNull(),
|
|
753
|
-
providerAccountId:
|
|
1007
|
+
providerAccountId: varchar14("providerAccountId", {
|
|
754
1008
|
length: 255
|
|
755
1009
|
}).notNull(),
|
|
756
1010
|
refresh_token: text2("refresh_token"),
|
|
757
1011
|
access_token: text2("access_token"),
|
|
758
1012
|
oauth_token: text2("oauth_token"),
|
|
759
1013
|
oauth_token_secret: text2("oauth_token_secret"),
|
|
760
|
-
expires_at:
|
|
761
|
-
token_type:
|
|
1014
|
+
expires_at: int5("expires_at"),
|
|
1015
|
+
token_type: varchar14("token_type", {
|
|
762
1016
|
length: 255
|
|
763
1017
|
}),
|
|
764
|
-
scope:
|
|
1018
|
+
scope: varchar14("scope", {
|
|
765
1019
|
length: 255
|
|
766
1020
|
}),
|
|
767
1021
|
id_token: text2("id_token"),
|
|
768
|
-
session_state:
|
|
1022
|
+
session_state: varchar14("session_state", {
|
|
769
1023
|
length: 255
|
|
770
1024
|
}),
|
|
771
|
-
refresh_token_expires_in:
|
|
1025
|
+
refresh_token_expires_in: int5("refresh_token_expires_in")
|
|
772
1026
|
}, (account) => ({
|
|
773
|
-
pk:
|
|
1027
|
+
pk: primaryKey10({
|
|
774
1028
|
columns: [
|
|
775
1029
|
account.provider,
|
|
776
1030
|
account.providerAccountId
|
|
777
1031
|
]
|
|
778
1032
|
}),
|
|
779
|
-
userIdIdx:
|
|
1033
|
+
userIdIdx: index12("userId_idx").on(account.userId)
|
|
780
1034
|
}));
|
|
781
1035
|
}
|
|
782
1036
|
__name(getAccountsSchema, "getAccountsSchema");
|
|
783
1037
|
function getAccountsRelationsSchema(mysqlTable) {
|
|
784
1038
|
const accounts = getAccountsSchema(mysqlTable);
|
|
785
1039
|
const users = getUsersSchema(mysqlTable);
|
|
786
|
-
return
|
|
1040
|
+
return relations14(accounts, ({ one }) => ({
|
|
787
1041
|
user: one(users, {
|
|
788
1042
|
fields: [
|
|
789
1043
|
accounts.userId
|
|
@@ -798,38 +1052,38 @@ function getAccountsRelationsSchema(mysqlTable) {
|
|
|
798
1052
|
__name(getAccountsRelationsSchema, "getAccountsRelationsSchema");
|
|
799
1053
|
|
|
800
1054
|
// src/lib/mysql/schemas/auth/user-permissions.ts
|
|
801
|
-
import { relations as
|
|
802
|
-
import { boolean as boolean3, index as
|
|
1055
|
+
import { relations as relations15 } from "drizzle-orm";
|
|
1056
|
+
import { boolean as boolean3, index as index13, primaryKey as primaryKey11, timestamp as timestamp14, varchar as varchar15 } from "drizzle-orm/mysql-core";
|
|
803
1057
|
function getUserPermissionsSchema(mysqlTable) {
|
|
804
1058
|
return mysqlTable("UserPermission", {
|
|
805
|
-
userId:
|
|
1059
|
+
userId: varchar15("userId", {
|
|
806
1060
|
length: 255
|
|
807
1061
|
}).notNull(),
|
|
808
|
-
permissionId:
|
|
1062
|
+
permissionId: varchar15("permissionId", {
|
|
809
1063
|
length: 255
|
|
810
1064
|
}).notNull(),
|
|
811
1065
|
active: boolean3("active").notNull().default(true),
|
|
812
|
-
createdAt:
|
|
1066
|
+
createdAt: timestamp14("createdAt", {
|
|
813
1067
|
mode: "date",
|
|
814
1068
|
fsp: 3
|
|
815
1069
|
}).defaultNow(),
|
|
816
|
-
updatedAt:
|
|
1070
|
+
updatedAt: timestamp14("updatedAt", {
|
|
817
1071
|
mode: "date",
|
|
818
1072
|
fsp: 3
|
|
819
1073
|
}).defaultNow(),
|
|
820
|
-
deletedAt:
|
|
1074
|
+
deletedAt: timestamp14("deletedAt", {
|
|
821
1075
|
mode: "date",
|
|
822
1076
|
fsp: 3
|
|
823
1077
|
})
|
|
824
1078
|
}, (up) => ({
|
|
825
|
-
pk:
|
|
1079
|
+
pk: primaryKey11({
|
|
826
1080
|
columns: [
|
|
827
1081
|
up.userId,
|
|
828
1082
|
up.permissionId
|
|
829
1083
|
]
|
|
830
1084
|
}),
|
|
831
|
-
userIdIdx:
|
|
832
|
-
permissionIdIdx:
|
|
1085
|
+
userIdIdx: index13("userId_idx").on(up.userId),
|
|
1086
|
+
permissionIdIdx: index13("permissionId_idx").on(up.permissionId)
|
|
833
1087
|
}));
|
|
834
1088
|
}
|
|
835
1089
|
__name(getUserPermissionsSchema, "getUserPermissionsSchema");
|
|
@@ -837,7 +1091,7 @@ function getUserPermissionsRelationsSchema(mysqlTable) {
|
|
|
837
1091
|
const userPermissions = getUserPermissionsSchema(mysqlTable);
|
|
838
1092
|
const users = getUsersSchema(mysqlTable);
|
|
839
1093
|
const permissions = getPermissionsSchema(mysqlTable);
|
|
840
|
-
return
|
|
1094
|
+
return relations15(userPermissions, ({ one }) => ({
|
|
841
1095
|
user: one(users, {
|
|
842
1096
|
fields: [
|
|
843
1097
|
userPermissions.userId
|
|
@@ -861,46 +1115,46 @@ function getUserPermissionsRelationsSchema(mysqlTable) {
|
|
|
861
1115
|
__name(getUserPermissionsRelationsSchema, "getUserPermissionsRelationsSchema");
|
|
862
1116
|
|
|
863
1117
|
// src/lib/mysql/schemas/auth/user-prefs.ts
|
|
864
|
-
import { relations as
|
|
865
|
-
import { index as
|
|
1118
|
+
import { relations as relations16, sql as sql13 } from "drizzle-orm";
|
|
1119
|
+
import { index as index14, json as json12, primaryKey as primaryKey12, timestamp as timestamp15, varchar as varchar16 } from "drizzle-orm/mysql-core";
|
|
866
1120
|
function getUserPrefsSchema(mysqlTable) {
|
|
867
1121
|
return mysqlTable("UserPrefs", {
|
|
868
|
-
id:
|
|
1122
|
+
id: varchar16("id", {
|
|
869
1123
|
length: 191
|
|
870
1124
|
}).notNull(),
|
|
871
|
-
type:
|
|
1125
|
+
type: varchar16("type", {
|
|
872
1126
|
length: 191
|
|
873
1127
|
}).default("Global").notNull(),
|
|
874
|
-
userId:
|
|
1128
|
+
userId: varchar16("userId", {
|
|
875
1129
|
length: 255
|
|
876
1130
|
}).notNull(),
|
|
877
|
-
fields:
|
|
878
|
-
createdAt:
|
|
1131
|
+
fields: json12("fields").$type().default({}),
|
|
1132
|
+
createdAt: timestamp15("createdAt", {
|
|
879
1133
|
mode: "date",
|
|
880
1134
|
fsp: 3
|
|
881
|
-
}).default(
|
|
882
|
-
updatedAt:
|
|
1135
|
+
}).default(sql13`CURRENT_TIMESTAMP(3)`),
|
|
1136
|
+
updatedAt: timestamp15("updatedAt", {
|
|
883
1137
|
mode: "date",
|
|
884
1138
|
fsp: 3
|
|
885
|
-
}).default(
|
|
886
|
-
deletedAt:
|
|
1139
|
+
}).default(sql13`CURRENT_TIMESTAMP(3)`),
|
|
1140
|
+
deletedAt: timestamp15("deletedAt", {
|
|
887
1141
|
mode: "date",
|
|
888
1142
|
fsp: 3
|
|
889
1143
|
})
|
|
890
1144
|
}, (crr) => ({
|
|
891
|
-
pk:
|
|
1145
|
+
pk: primaryKey12({
|
|
892
1146
|
columns: [
|
|
893
1147
|
crr.id
|
|
894
1148
|
]
|
|
895
1149
|
}),
|
|
896
|
-
crrUserIdIdKey:
|
|
1150
|
+
crrUserIdIdKey: index14("crr_userIdId_idx").on(crr.userId)
|
|
897
1151
|
}));
|
|
898
1152
|
}
|
|
899
1153
|
__name(getUserPrefsSchema, "getUserPrefsSchema");
|
|
900
1154
|
function getUserPrefsRelationsSchema(mysqlTable) {
|
|
901
1155
|
const userPrefs = getUserPrefsSchema(mysqlTable);
|
|
902
1156
|
const user = getUsersSchema(mysqlTable);
|
|
903
|
-
return
|
|
1157
|
+
return relations16(userPrefs, ({ one }) => ({
|
|
904
1158
|
user: one(user, {
|
|
905
1159
|
fields: [
|
|
906
1160
|
userPrefs.userId
|
|
@@ -915,43 +1169,43 @@ function getUserPrefsRelationsSchema(mysqlTable) {
|
|
|
915
1169
|
__name(getUserPrefsRelationsSchema, "getUserPrefsRelationsSchema");
|
|
916
1170
|
|
|
917
1171
|
// src/lib/mysql/schemas/auth/user-roles.ts
|
|
918
|
-
import { relations as
|
|
919
|
-
import { boolean as boolean5, index as
|
|
1172
|
+
import { relations as relations18 } from "drizzle-orm";
|
|
1173
|
+
import { boolean as boolean5, index as index16, primaryKey as primaryKey13, timestamp as timestamp17, varchar as varchar18 } from "drizzle-orm/mysql-core";
|
|
920
1174
|
|
|
921
1175
|
// src/lib/mysql/schemas/auth/roles.ts
|
|
922
|
-
import { relations as
|
|
923
|
-
import { boolean as boolean4, index as
|
|
1176
|
+
import { relations as relations17 } from "drizzle-orm";
|
|
1177
|
+
import { boolean as boolean4, index as index15, text as text3, timestamp as timestamp16, varchar as varchar17 } from "drizzle-orm/mysql-core";
|
|
924
1178
|
function getRolesSchema(mysqlTable) {
|
|
925
1179
|
return mysqlTable("Role", {
|
|
926
|
-
id:
|
|
1180
|
+
id: varchar17("id", {
|
|
927
1181
|
length: 255
|
|
928
1182
|
}).notNull().primaryKey(),
|
|
929
|
-
name:
|
|
1183
|
+
name: varchar17("name", {
|
|
930
1184
|
length: 255
|
|
931
1185
|
}).notNull().unique(),
|
|
932
1186
|
description: text3("description"),
|
|
933
1187
|
active: boolean4("active").notNull().default(true),
|
|
934
|
-
createdAt:
|
|
1188
|
+
createdAt: timestamp16("createdAt", {
|
|
935
1189
|
mode: "date",
|
|
936
1190
|
fsp: 3
|
|
937
1191
|
}).defaultNow(),
|
|
938
|
-
updatedAt:
|
|
1192
|
+
updatedAt: timestamp16("updatedAt", {
|
|
939
1193
|
mode: "date",
|
|
940
1194
|
fsp: 3
|
|
941
1195
|
}).defaultNow(),
|
|
942
|
-
deletedAt:
|
|
1196
|
+
deletedAt: timestamp16("deletedAt", {
|
|
943
1197
|
mode: "date",
|
|
944
1198
|
fsp: 3
|
|
945
1199
|
})
|
|
946
1200
|
}, (role) => ({
|
|
947
|
-
nameIdx:
|
|
1201
|
+
nameIdx: index15("name_idx").on(role.name)
|
|
948
1202
|
}));
|
|
949
1203
|
}
|
|
950
1204
|
__name(getRolesSchema, "getRolesSchema");
|
|
951
1205
|
function getRolesRelationsSchema(mysqlTable) {
|
|
952
1206
|
const roles = getRolesSchema(mysqlTable);
|
|
953
1207
|
const userRoles = getUserRolesSchema(mysqlTable);
|
|
954
|
-
return
|
|
1208
|
+
return relations17(roles, ({ many }) => ({
|
|
955
1209
|
userRoles: many(userRoles, {
|
|
956
1210
|
relationName: "role"
|
|
957
1211
|
})
|
|
@@ -962,34 +1216,34 @@ __name(getRolesRelationsSchema, "getRolesRelationsSchema");
|
|
|
962
1216
|
// src/lib/mysql/schemas/auth/user-roles.ts
|
|
963
1217
|
function getUserRolesSchema(mysqlTable) {
|
|
964
1218
|
return mysqlTable("UserRole", {
|
|
965
|
-
userId:
|
|
1219
|
+
userId: varchar18("userId", {
|
|
966
1220
|
length: 255
|
|
967
1221
|
}).notNull(),
|
|
968
|
-
roleId:
|
|
1222
|
+
roleId: varchar18("roleId", {
|
|
969
1223
|
length: 255
|
|
970
1224
|
}).notNull(),
|
|
971
1225
|
active: boolean5("active").notNull().default(true),
|
|
972
|
-
createdAt:
|
|
1226
|
+
createdAt: timestamp17("createdAt", {
|
|
973
1227
|
mode: "date",
|
|
974
1228
|
fsp: 3
|
|
975
1229
|
}).defaultNow(),
|
|
976
|
-
updatedAt:
|
|
1230
|
+
updatedAt: timestamp17("updatedAt", {
|
|
977
1231
|
mode: "date",
|
|
978
1232
|
fsp: 3
|
|
979
1233
|
}).defaultNow(),
|
|
980
|
-
deletedAt:
|
|
1234
|
+
deletedAt: timestamp17("deletedAt", {
|
|
981
1235
|
mode: "date",
|
|
982
1236
|
fsp: 3
|
|
983
1237
|
})
|
|
984
1238
|
}, (ur) => ({
|
|
985
|
-
pk:
|
|
1239
|
+
pk: primaryKey13({
|
|
986
1240
|
columns: [
|
|
987
1241
|
ur.userId,
|
|
988
1242
|
ur.roleId
|
|
989
1243
|
]
|
|
990
1244
|
}),
|
|
991
|
-
userIdIdx:
|
|
992
|
-
roleIdIdx:
|
|
1245
|
+
userIdIdx: index16("userId_idx").on(ur.userId),
|
|
1246
|
+
roleIdIdx: index16("roleId_idx").on(ur.roleId)
|
|
993
1247
|
}));
|
|
994
1248
|
}
|
|
995
1249
|
__name(getUserRolesSchema, "getUserRolesSchema");
|
|
@@ -997,7 +1251,7 @@ function getUserRolesRelationsSchema(mysqlTable) {
|
|
|
997
1251
|
const userRoles = getUserRolesSchema(mysqlTable);
|
|
998
1252
|
const users = getUsersSchema(mysqlTable);
|
|
999
1253
|
const roles = getRolesSchema(mysqlTable);
|
|
1000
|
-
return
|
|
1254
|
+
return relations18(userRoles, ({ one }) => ({
|
|
1001
1255
|
user: one(users, {
|
|
1002
1256
|
fields: [
|
|
1003
1257
|
userRoles.userId
|
|
@@ -1023,34 +1277,34 @@ __name(getUserRolesRelationsSchema, "getUserRolesRelationsSchema");
|
|
|
1023
1277
|
// src/lib/mysql/schemas/auth/users.ts
|
|
1024
1278
|
function getUsersSchema(mysqlTable) {
|
|
1025
1279
|
return mysqlTable("User", {
|
|
1026
|
-
id:
|
|
1280
|
+
id: varchar19("id", {
|
|
1027
1281
|
length: 255
|
|
1028
1282
|
}).notNull().primaryKey(),
|
|
1029
|
-
name:
|
|
1283
|
+
name: varchar19("name", {
|
|
1030
1284
|
length: 255
|
|
1031
1285
|
}),
|
|
1032
|
-
role:
|
|
1286
|
+
role: varchar19("role", {
|
|
1033
1287
|
length: 191
|
|
1034
1288
|
}).notNull().default("user"),
|
|
1035
|
-
email:
|
|
1289
|
+
email: varchar19("email", {
|
|
1036
1290
|
length: 255
|
|
1037
1291
|
}).notNull().unique(),
|
|
1038
|
-
fields:
|
|
1039
|
-
emailVerified:
|
|
1292
|
+
fields: json13("fields").$type().default({}),
|
|
1293
|
+
emailVerified: timestamp18("emailVerified", {
|
|
1040
1294
|
mode: "date",
|
|
1041
1295
|
fsp: 3
|
|
1042
1296
|
}),
|
|
1043
|
-
image:
|
|
1297
|
+
image: varchar19("image", {
|
|
1044
1298
|
length: 255
|
|
1045
1299
|
}),
|
|
1046
|
-
createdAt:
|
|
1300
|
+
createdAt: timestamp18("createdAt", {
|
|
1047
1301
|
mode: "date",
|
|
1048
1302
|
fsp: 3
|
|
1049
|
-
}).default(
|
|
1303
|
+
}).default(sql14`CURRENT_TIMESTAMP(3)`)
|
|
1050
1304
|
}, (user) => ({
|
|
1051
|
-
emailIdx:
|
|
1052
|
-
roleIdx:
|
|
1053
|
-
createdAtIdx:
|
|
1305
|
+
emailIdx: index17("email_idx").on(user.email),
|
|
1306
|
+
roleIdx: index17("role_idx").on(user.role),
|
|
1307
|
+
createdAtIdx: index17("created_at_idx").on(user.createdAt)
|
|
1054
1308
|
}));
|
|
1055
1309
|
}
|
|
1056
1310
|
__name(getUsersSchema, "getUsersSchema");
|
|
@@ -1065,7 +1319,7 @@ function getUsersRelationsSchema(mysqlTable) {
|
|
|
1065
1319
|
const purchases = getPurchaseSchema(mysqlTable);
|
|
1066
1320
|
const comments = getCommentsSchema(mysqlTable);
|
|
1067
1321
|
const userPrefs = getUserPrefsSchema(mysqlTable);
|
|
1068
|
-
return
|
|
1322
|
+
return relations19(users, ({ many }) => ({
|
|
1069
1323
|
accounts: many(accounts, {
|
|
1070
1324
|
relationName: "user"
|
|
1071
1325
|
}),
|
|
@@ -1100,35 +1354,35 @@ __name(getUsersRelationsSchema, "getUsersRelationsSchema");
|
|
|
1100
1354
|
// src/lib/mysql/schemas/content/content-contributions.ts
|
|
1101
1355
|
function getContentContributionsSchema(mysqlTable) {
|
|
1102
1356
|
return mysqlTable("ContentContribution", {
|
|
1103
|
-
id:
|
|
1357
|
+
id: varchar20("id", {
|
|
1104
1358
|
length: 255
|
|
1105
1359
|
}).notNull().primaryKey(),
|
|
1106
|
-
userId:
|
|
1360
|
+
userId: varchar20("userId", {
|
|
1107
1361
|
length: 255
|
|
1108
1362
|
}).notNull(),
|
|
1109
|
-
contentId:
|
|
1363
|
+
contentId: varchar20("contentId", {
|
|
1110
1364
|
length: 255
|
|
1111
1365
|
}).notNull(),
|
|
1112
|
-
contributionTypeId:
|
|
1366
|
+
contributionTypeId: varchar20("contributionTypeId", {
|
|
1113
1367
|
length: 255
|
|
1114
1368
|
}).notNull(),
|
|
1115
1369
|
active: boolean6("active").notNull().default(true),
|
|
1116
|
-
createdAt:
|
|
1370
|
+
createdAt: timestamp19("createdAt", {
|
|
1117
1371
|
mode: "date",
|
|
1118
1372
|
fsp: 3
|
|
1119
1373
|
}).defaultNow(),
|
|
1120
|
-
updatedAt:
|
|
1374
|
+
updatedAt: timestamp19("updatedAt", {
|
|
1121
1375
|
mode: "date",
|
|
1122
1376
|
fsp: 3
|
|
1123
1377
|
}).defaultNow(),
|
|
1124
|
-
deletedAt:
|
|
1378
|
+
deletedAt: timestamp19("deletedAt", {
|
|
1125
1379
|
mode: "date",
|
|
1126
1380
|
fsp: 3
|
|
1127
1381
|
})
|
|
1128
1382
|
}, (cc) => ({
|
|
1129
|
-
userIdIdx:
|
|
1130
|
-
contentIdIdx:
|
|
1131
|
-
contributionTypeIdIdx:
|
|
1383
|
+
userIdIdx: index18("userId_idx").on(cc.userId),
|
|
1384
|
+
contentIdIdx: index18("contentId_idx").on(cc.contentId),
|
|
1385
|
+
contributionTypeIdIdx: index18("contributionTypeId_idx").on(cc.contributionTypeId)
|
|
1132
1386
|
}));
|
|
1133
1387
|
}
|
|
1134
1388
|
__name(getContentContributionsSchema, "getContentContributionsSchema");
|
|
@@ -1137,7 +1391,7 @@ function getContentContributionRelationsSchema(mysqlTable) {
|
|
|
1137
1391
|
const users = getUsersSchema(mysqlTable);
|
|
1138
1392
|
const contentResource = getContentResourceSchema(mysqlTable);
|
|
1139
1393
|
const contributionTypes = getContributionTypesSchema(mysqlTable);
|
|
1140
|
-
return
|
|
1394
|
+
return relations20(contentContributions, ({ one }) => ({
|
|
1141
1395
|
user: one(users, {
|
|
1142
1396
|
fields: [
|
|
1143
1397
|
contentContributions.userId
|
|
@@ -1174,6 +1428,14 @@ export {
|
|
|
1174
1428
|
getContentContributionRelationsSchema,
|
|
1175
1429
|
getContentResourceResourceSchema,
|
|
1176
1430
|
getContentResourceResourceRelationsSchema,
|
|
1431
|
+
getTagTagSchema,
|
|
1432
|
+
getTagTagRelationsSchema,
|
|
1433
|
+
getTagSchema,
|
|
1434
|
+
getTagRelationsSchema,
|
|
1435
|
+
getContentResourceTagSchema,
|
|
1436
|
+
getContentResourceTagRelationsSchema,
|
|
1437
|
+
getContentResourceVersionSchema,
|
|
1438
|
+
getContentResourceVersionRelationsSchema,
|
|
1177
1439
|
getContentResourceSchema,
|
|
1178
1440
|
getContentResourceRelationsSchema,
|
|
1179
1441
|
getContentResourceProductSchema,
|
|
@@ -1203,4 +1465,4 @@ export {
|
|
|
1203
1465
|
getAccountsSchema,
|
|
1204
1466
|
getAccountsRelationsSchema
|
|
1205
1467
|
};
|
|
1206
|
-
//# sourceMappingURL=chunk-
|
|
1468
|
+
//# sourceMappingURL=chunk-JW2PFVLO.js.map
|