@coursebuilder/adapter-drizzle 0.1.3 → 0.1.4
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-XXZQBN6S.js → chunk-2CI3IGR2.js} +4 -4
- package/dist/{chunk-3LWFRGZT.js → chunk-3RJVKNXB.js} +458 -381
- package/dist/{chunk-NXFHRDLS.js → chunk-53266VWH.js} +3 -3
- package/dist/{chunk-OIUOQ3TT.js → chunk-57CX5SOI.js} +2 -2
- package/dist/{chunk-75V6F7LZ.js → chunk-5HT43CVZ.js} +2 -2
- package/dist/{chunk-SFJM6FKE.js → chunk-BX5SO2JG.js} +2 -2
- package/dist/{chunk-LSOPFMDB.js → chunk-FNYW3XKR.js} +3 -3
- package/dist/{chunk-V6QEDDFG.js → chunk-GLPDG7UE.js} +2 -2
- package/dist/{chunk-VNI36MMC.js → chunk-H736K5TN.js} +1 -1
- package/dist/{chunk-6CBAFOL3.js → chunk-J4LBG2TH.js} +2 -2
- package/dist/{chunk-JD4KFACE.js → chunk-JKOYOL7A.js} +2 -2
- package/dist/{chunk-TMQIGK3N.js → chunk-MBB4GIJI.js} +2 -2
- package/dist/{chunk-27KREOQW.js → chunk-PJHGIRZM.js} +2 -2
- package/dist/{chunk-L2TQQYG4.js → chunk-PPBEA4EM.js} +2 -2
- package/dist/{chunk-ULABK6XG.js → chunk-Q5WENQT6.js} +3 -3
- package/dist/{chunk-H4MXNDWO.js → chunk-V23SCQL7.js} +2 -2
- package/dist/{chunk-NZDLUQWP.js → chunk-VDVCCU7D.js} +2 -2
- package/dist/{chunk-IN6G6MTW.js → chunk-VXZRMVNY.js} +2 -2
- package/dist/{chunk-XSXWLOIN.js → chunk-WQ7UXKZC.js} +920 -482
- package/dist/{chunk-JKRFXYAR.js → chunk-Y7QZGEPT.js} +2 -2
- package/dist/index.js +20 -21
- package/dist/lib/mysql/index.cjs +926 -465
- package/dist/lib/mysql/index.cjs.map +1 -1
- package/dist/lib/mysql/index.d.cts +6143 -0
- package/dist/lib/mysql/index.d.ts +41 -9
- package/dist/lib/mysql/index.js +20 -21
- package/dist/lib/mysql/schemas/auth/accounts.cjs.map +1 -1
- package/dist/lib/mysql/schemas/auth/accounts.d.cts +184 -0
- package/dist/lib/mysql/schemas/auth/accounts.js +10 -11
- package/dist/lib/mysql/schemas/auth/permissions.d.cts +98 -0
- package/dist/lib/mysql/schemas/auth/permissions.js +2 -2
- package/dist/lib/mysql/schemas/auth/role-permissions.cjs.map +1 -1
- package/dist/lib/mysql/schemas/auth/role-permissions.d.cts +89 -0
- package/dist/lib/mysql/schemas/auth/role-permissions.js +11 -12
- package/dist/lib/mysql/schemas/auth/roles.cjs.map +1 -1
- package/dist/lib/mysql/schemas/auth/roles.d.cts +100 -0
- package/dist/lib/mysql/schemas/auth/roles.js +10 -11
- package/dist/lib/mysql/schemas/auth/sessions.cjs.map +1 -1
- package/dist/lib/mysql/schemas/auth/sessions.d.cts +52 -0
- package/dist/lib/mysql/schemas/auth/sessions.js +11 -12
- package/dist/lib/mysql/schemas/auth/user-permissions.cjs.map +1 -1
- package/dist/lib/mysql/schemas/auth/user-permissions.d.cts +89 -0
- package/dist/lib/mysql/schemas/auth/user-permissions.js +10 -11
- package/dist/lib/mysql/schemas/auth/user-roles.cjs.map +1 -1
- package/dist/lib/mysql/schemas/auth/user-roles.d.cts +89 -0
- package/dist/lib/mysql/schemas/auth/user-roles.js +10 -11
- package/dist/lib/mysql/schemas/auth/users.cjs +1 -1
- package/dist/lib/mysql/schemas/auth/users.cjs.map +1 -1
- package/dist/lib/mysql/schemas/auth/users.d.cts +106 -0
- package/dist/lib/mysql/schemas/auth/users.js +10 -11
- package/dist/lib/mysql/schemas/auth/verification-tokens.d.cts +60 -0
- package/dist/lib/mysql/schemas/auth/verification-tokens.js +2 -2
- package/dist/lib/mysql/schemas/commerce/coupon.cjs +180 -17
- package/dist/lib/mysql/schemas/commerce/coupon.cjs.map +1 -1
- package/dist/lib/mysql/schemas/commerce/coupon.d.cts +172 -0
- package/dist/lib/mysql/schemas/commerce/coupon.d.ts +6 -2
- package/dist/lib/mysql/schemas/commerce/coupon.js +12 -2
- package/dist/lib/mysql/schemas/commerce/merchant-account.d.cts +72 -0
- package/dist/lib/mysql/schemas/commerce/merchant-account.js +2 -2
- package/dist/lib/mysql/schemas/commerce/merchant-charge.d.cts +108 -0
- package/dist/lib/mysql/schemas/commerce/merchant-charge.js +2 -2
- package/dist/lib/mysql/schemas/commerce/merchant-coupon.d.cts +84 -0
- package/dist/lib/mysql/schemas/commerce/merchant-coupon.js +2 -2
- package/dist/lib/mysql/schemas/commerce/merchant-customer.d.cts +84 -0
- package/dist/lib/mysql/schemas/commerce/merchant-customer.js +2 -2
- package/dist/lib/mysql/schemas/commerce/merchant-price.d.cts +96 -0
- package/dist/lib/mysql/schemas/commerce/merchant-price.js +2 -2
- package/dist/lib/mysql/schemas/commerce/merchant-product.d.cts +84 -0
- package/dist/lib/mysql/schemas/commerce/merchant-product.js +2 -2
- package/dist/lib/mysql/schemas/commerce/merchant-session.d.cts +48 -0
- package/dist/lib/mysql/schemas/commerce/merchant-session.js +2 -2
- package/dist/lib/mysql/schemas/commerce/price.cjs +4 -1
- package/dist/lib/mysql/schemas/commerce/price.cjs.map +1 -1
- package/dist/lib/mysql/schemas/commerce/price.d.cts +101 -0
- package/dist/lib/mysql/schemas/commerce/price.d.ts +1 -1
- package/dist/lib/mysql/schemas/commerce/price.js +10 -11
- package/dist/lib/mysql/schemas/commerce/product.cjs +4 -1
- package/dist/lib/mysql/schemas/commerce/product.cjs.map +1 -1
- package/dist/lib/mysql/schemas/commerce/product.d.cts +114 -0
- package/dist/lib/mysql/schemas/commerce/product.d.ts +12 -0
- package/dist/lib/mysql/schemas/commerce/product.js +10 -11
- package/dist/lib/mysql/schemas/commerce/purchase-user-transfer.d.cts +132 -0
- package/dist/lib/mysql/schemas/commerce/purchase-user-transfer.js +2 -2
- package/dist/lib/mysql/schemas/commerce/purchase.cjs +14 -2
- package/dist/lib/mysql/schemas/commerce/purchase.cjs.map +1 -1
- package/dist/lib/mysql/schemas/commerce/purchase.d.cts +225 -0
- package/dist/lib/mysql/schemas/commerce/purchase.d.ts +2 -1
- package/dist/lib/mysql/schemas/commerce/purchase.js +10 -11
- package/dist/lib/mysql/schemas/commerce/upgradable-products.cjs +3 -0
- package/dist/lib/mysql/schemas/commerce/upgradable-products.cjs.map +1 -1
- package/dist/lib/mysql/schemas/commerce/upgradable-products.d.cts +101 -0
- package/dist/lib/mysql/schemas/commerce/upgradable-products.js +11 -12
- package/dist/lib/mysql/schemas/communication/communication-channel.d.cts +96 -0
- package/dist/lib/mysql/schemas/communication/communication-channel.js +2 -2
- package/dist/lib/mysql/schemas/communication/communication-preference-types.d.cts +96 -0
- package/dist/lib/mysql/schemas/communication/communication-preference-types.js +2 -2
- package/dist/lib/mysql/schemas/communication/communication-preferences.cjs.map +1 -1
- package/dist/lib/mysql/schemas/communication/communication-preferences.d.cts +150 -0
- package/dist/lib/mysql/schemas/communication/communication-preferences.js +10 -11
- package/dist/lib/mysql/schemas/content/content-contributions.cjs.map +1 -1
- package/dist/lib/mysql/schemas/content/content-contributions.d.cts +114 -0
- package/dist/lib/mysql/schemas/content/content-contributions.js +10 -11
- package/dist/lib/mysql/schemas/content/content-resource-product.cjs +3 -0
- package/dist/lib/mysql/schemas/content/content-resource-product.cjs.map +1 -1
- package/dist/lib/mysql/schemas/content/content-resource-product.d.cts +101 -0
- package/dist/lib/mysql/schemas/content/content-resource-product.js +10 -11
- package/dist/lib/mysql/schemas/content/content-resource-resource.cjs.map +1 -1
- package/dist/lib/mysql/schemas/content/content-resource-resource.d.cts +101 -0
- package/dist/lib/mysql/schemas/content/content-resource-resource.js +10 -11
- package/dist/lib/mysql/schemas/content/content-resource.cjs.map +1 -1
- package/dist/lib/mysql/schemas/content/content-resource.d.cts +103 -0
- package/dist/lib/mysql/schemas/content/content-resource.js +10 -11
- package/dist/lib/mysql/schemas/content/contribution-types.d.cts +110 -0
- package/dist/lib/mysql/schemas/content/contribution-types.js +2 -2
- package/dist/lib/mysql/schemas/content/resource-progress.cjs +1 -1
- package/dist/lib/mysql/schemas/content/resource-progress.cjs.map +1 -1
- package/dist/lib/mysql/schemas/content/resource-progress.d.cts +84 -0
- package/dist/lib/mysql/schemas/content/resource-progress.d.ts +1 -1
- package/dist/lib/mysql/schemas/content/resource-progress.js +2 -2
- package/dist/lib/mysql/utils.cjs.map +1 -1
- package/dist/lib/mysql/utils.d.cts +12 -0
- package/dist/lib/mysql/utils.js +1 -1
- package/dist/lib/mysql/utils.js.map +1 -1
- package/dist/lib/utils.d.cts +22 -0
- package/dist/lib/utils.d.ts +1 -1
- package/dist/lib/utils.js +1 -1
- package/package.json +5 -5
- package/src/lib/mysql/index.ts +464 -113
- package/src/lib/mysql/schemas/commerce/coupon.ts +18 -2
- package/src/lib/mysql/schemas/commerce/price.ts +1 -1
- package/src/lib/mysql/schemas/commerce/product.ts +1 -0
- package/src/lib/mysql/schemas/commerce/purchase.ts +6 -1
- package/src/lib/mysql/schemas/content/resource-progress.ts +1 -1
- package/dist/chunk-QK6CINAJ.js +0 -60
|
@@ -1,121 +1,149 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getContributionTypesSchema
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-GLPDG7UE.js";
|
|
4
4
|
import {
|
|
5
5
|
getCommunicationChannelSchema
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-J4LBG2TH.js";
|
|
7
7
|
import {
|
|
8
8
|
getCommunicationPreferenceTypesSchema
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-BX5SO2JG.js";
|
|
10
10
|
import {
|
|
11
11
|
getMerchantPriceSchema
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-PPBEA4EM.js";
|
|
13
13
|
import {
|
|
14
14
|
getMerchantProductSchema
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-Y7QZGEPT.js";
|
|
16
16
|
import {
|
|
17
17
|
getMerchantSessionSchema
|
|
18
|
-
} from "./chunk-
|
|
19
|
-
import {
|
|
20
|
-
getCouponSchema
|
|
21
|
-
} from "./chunk-QK6CINAJ.js";
|
|
18
|
+
} from "./chunk-V23SCQL7.js";
|
|
22
19
|
import {
|
|
23
20
|
getMerchantChargeSchema
|
|
24
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-PJHGIRZM.js";
|
|
25
22
|
import {
|
|
26
23
|
getPermissionsSchema
|
|
27
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-VDVCCU7D.js";
|
|
28
25
|
import {
|
|
29
26
|
__name
|
|
30
|
-
} from "./chunk-
|
|
27
|
+
} from "./chunk-H736K5TN.js";
|
|
31
28
|
|
|
32
|
-
// src/lib/mysql/schemas/
|
|
33
|
-
import { relations as
|
|
34
|
-
import {
|
|
35
|
-
|
|
36
|
-
// src/lib/mysql/schemas/content/content-resource.ts
|
|
37
|
-
import { relations as relations12, sql as sql6 } from "drizzle-orm";
|
|
38
|
-
import { index as index9, json as json5, timestamp as timestamp11, varchar as varchar12 } from "drizzle-orm/mysql-core";
|
|
39
|
-
|
|
40
|
-
// src/lib/mysql/schemas/auth/users.ts
|
|
41
|
-
import { relations as relations11, sql as sql5 } from "drizzle-orm";
|
|
42
|
-
import { index as index8, mysqlEnum as mysqlEnum2, timestamp as timestamp10, varchar as varchar11 } from "drizzle-orm/mysql-core";
|
|
29
|
+
// src/lib/mysql/schemas/commerce/coupon.ts
|
|
30
|
+
import { relations as relations14, sql as sql8 } from "drizzle-orm";
|
|
31
|
+
import { boolean as boolean6, decimal as decimal3, int as int4, json as json7, primaryKey as primaryKey9, timestamp as timestamp13, unique as unique2, varchar as varchar14 } from "drizzle-orm/mysql-core";
|
|
43
32
|
|
|
44
33
|
// src/lib/mysql/schemas/commerce/purchase.ts
|
|
45
|
-
import { relations as
|
|
46
|
-
import { decimal as decimal2, json as
|
|
34
|
+
import { relations as relations13, sql as sql7 } from "drizzle-orm";
|
|
35
|
+
import { decimal as decimal2, json as json6, primaryKey as primaryKey8, timestamp as timestamp12, unique, varchar as varchar13 } from "drizzle-orm/mysql-core";
|
|
47
36
|
|
|
48
|
-
// src/lib/mysql/schemas/
|
|
49
|
-
import { relations as
|
|
50
|
-
import {
|
|
37
|
+
// src/lib/mysql/schemas/auth/users.ts
|
|
38
|
+
import { relations as relations12, sql as sql6 } from "drizzle-orm";
|
|
39
|
+
import { index as index10, mysqlEnum as mysqlEnum2, timestamp as timestamp11, varchar as varchar12 } from "drizzle-orm/mysql-core";
|
|
51
40
|
|
|
52
|
-
// src/lib/mysql/schemas/
|
|
53
|
-
import { relations
|
|
54
|
-
import {
|
|
55
|
-
function
|
|
56
|
-
return mysqlTable("
|
|
57
|
-
|
|
41
|
+
// src/lib/mysql/schemas/communication/communication-preferences.ts
|
|
42
|
+
import { relations } from "drizzle-orm";
|
|
43
|
+
import { boolean, index, mysqlEnum, timestamp, varchar } from "drizzle-orm/mysql-core";
|
|
44
|
+
function getCommunicationPreferencesSchema(mysqlTable) {
|
|
45
|
+
return mysqlTable("communicationPreference", {
|
|
46
|
+
id: varchar("id", {
|
|
47
|
+
length: 255
|
|
48
|
+
}).notNull().primaryKey(),
|
|
49
|
+
userId: varchar("userId", {
|
|
58
50
|
length: 255
|
|
59
51
|
}).notNull(),
|
|
60
|
-
|
|
52
|
+
channelId: varchar("channelId", {
|
|
61
53
|
length: 255
|
|
62
54
|
}).notNull(),
|
|
63
|
-
|
|
64
|
-
|
|
55
|
+
preferenceLevel: mysqlEnum("preferenceLevel", [
|
|
56
|
+
"low",
|
|
57
|
+
"medium",
|
|
58
|
+
"high"
|
|
59
|
+
]).notNull().default("medium"),
|
|
60
|
+
preferenceTypeId: varchar("preferenceTypeId", {
|
|
61
|
+
length: 255
|
|
62
|
+
}).notNull(),
|
|
63
|
+
active: boolean("active").notNull().default(true),
|
|
65
64
|
createdAt: timestamp("createdAt", {
|
|
66
65
|
mode: "date",
|
|
67
66
|
fsp: 3
|
|
68
|
-
}).
|
|
67
|
+
}).defaultNow(),
|
|
68
|
+
optInAt: timestamp("optInAt", {
|
|
69
|
+
mode: "date",
|
|
70
|
+
fsp: 3
|
|
71
|
+
}),
|
|
72
|
+
optOutAt: timestamp("optOutAt", {
|
|
73
|
+
mode: "date",
|
|
74
|
+
fsp: 3
|
|
75
|
+
}),
|
|
69
76
|
updatedAt: timestamp("updatedAt", {
|
|
70
77
|
mode: "date",
|
|
71
78
|
fsp: 3
|
|
72
|
-
}).
|
|
79
|
+
}).defaultNow(),
|
|
73
80
|
deletedAt: timestamp("deletedAt", {
|
|
74
81
|
mode: "date",
|
|
75
82
|
fsp: 3
|
|
76
83
|
})
|
|
77
|
-
}, (
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
crr.resourceId
|
|
82
|
-
]
|
|
83
|
-
}),
|
|
84
|
-
contentResourceIdIdx: index("contentResourceId_idx").on(crr.productId),
|
|
85
|
-
resourceIdIdx: index("resourceId_idx").on(crr.resourceId)
|
|
84
|
+
}, (cp) => ({
|
|
85
|
+
userIdIdx: index("userId_idx").on(cp.userId),
|
|
86
|
+
preferenceTypeIdx: index("preferenceTypeId_idx").on(cp.preferenceTypeId),
|
|
87
|
+
channelIdIdx: index("channelId_idx").on(cp.channelId)
|
|
86
88
|
}));
|
|
87
89
|
}
|
|
88
|
-
__name(
|
|
89
|
-
function
|
|
90
|
-
const
|
|
91
|
-
const
|
|
92
|
-
const
|
|
93
|
-
|
|
94
|
-
|
|
90
|
+
__name(getCommunicationPreferencesSchema, "getCommunicationPreferencesSchema");
|
|
91
|
+
function getCommunicationPreferencesRelationsSchema(mysqlTable) {
|
|
92
|
+
const communicationPreferences = getCommunicationPreferencesSchema(mysqlTable);
|
|
93
|
+
const users = getUsersSchema(mysqlTable);
|
|
94
|
+
const communicationChannel = getCommunicationChannelSchema(mysqlTable);
|
|
95
|
+
const communicationPreferenceTypes = getCommunicationPreferenceTypesSchema(mysqlTable);
|
|
96
|
+
return relations(communicationPreferences, ({ one }) => ({
|
|
97
|
+
user: one(users, {
|
|
95
98
|
fields: [
|
|
96
|
-
|
|
99
|
+
communicationPreferences.userId
|
|
97
100
|
],
|
|
98
101
|
references: [
|
|
99
|
-
|
|
102
|
+
users.id
|
|
100
103
|
],
|
|
101
|
-
relationName: "
|
|
104
|
+
relationName: "user"
|
|
102
105
|
}),
|
|
103
|
-
|
|
106
|
+
channel: one(communicationChannel, {
|
|
104
107
|
fields: [
|
|
105
|
-
|
|
108
|
+
communicationPreferences.channelId
|
|
106
109
|
],
|
|
107
110
|
references: [
|
|
108
|
-
|
|
111
|
+
communicationChannel.id
|
|
109
112
|
],
|
|
110
|
-
relationName: "
|
|
113
|
+
relationName: "channel"
|
|
114
|
+
}),
|
|
115
|
+
preferenceType: one(communicationPreferenceTypes, {
|
|
116
|
+
fields: [
|
|
117
|
+
communicationPreferences.preferenceTypeId
|
|
118
|
+
],
|
|
119
|
+
references: [
|
|
120
|
+
communicationPreferenceTypes.id
|
|
121
|
+
],
|
|
122
|
+
relationName: "preferenceType"
|
|
111
123
|
})
|
|
112
124
|
}));
|
|
113
125
|
}
|
|
114
|
-
__name(
|
|
126
|
+
__name(getCommunicationPreferencesRelationsSchema, "getCommunicationPreferencesRelationsSchema");
|
|
127
|
+
|
|
128
|
+
// src/lib/mysql/schemas/content/content-contributions.ts
|
|
129
|
+
import { relations as relations7 } from "drizzle-orm";
|
|
130
|
+
import { boolean as boolean2, index as index5, timestamp as timestamp7, varchar as varchar7 } from "drizzle-orm/mysql-core";
|
|
131
|
+
|
|
132
|
+
// src/lib/mysql/schemas/content/content-resource.ts
|
|
133
|
+
import { relations as relations6, sql as sql5 } from "drizzle-orm";
|
|
134
|
+
import { index as index4, json as json5, timestamp as timestamp6, varchar as varchar6 } from "drizzle-orm/mysql-core";
|
|
135
|
+
|
|
136
|
+
// src/lib/mysql/schemas/content/content-resource-product.ts
|
|
137
|
+
import { relations as relations4, sql as sql3 } from "drizzle-orm";
|
|
138
|
+
import { double, index as index2, json as json3, primaryKey as primaryKey3, timestamp as timestamp4, varchar as varchar4 } from "drizzle-orm/mysql-core";
|
|
139
|
+
|
|
140
|
+
// src/lib/mysql/schemas/commerce/product.ts
|
|
141
|
+
import { relations as relations3, sql as sql2 } from "drizzle-orm";
|
|
142
|
+
import { int as int2, json as json2, primaryKey as primaryKey2, timestamp as timestamp3, varchar as varchar3 } from "drizzle-orm/mysql-core";
|
|
115
143
|
|
|
116
144
|
// src/lib/mysql/schemas/commerce/price.ts
|
|
117
|
-
import { relations as relations2, sql
|
|
118
|
-
import { decimal, int, json
|
|
145
|
+
import { relations as relations2, sql } from "drizzle-orm";
|
|
146
|
+
import { decimal, int, json, primaryKey, timestamp as timestamp2, varchar as varchar2 } from "drizzle-orm/mysql-core";
|
|
119
147
|
function getPriceSchema(mysqlTable) {
|
|
120
148
|
return mysqlTable("prices", {
|
|
121
149
|
id: varchar2("id", {
|
|
@@ -135,11 +163,11 @@ function getPriceSchema(mysqlTable) {
|
|
|
135
163
|
createdAt: timestamp2("createdAt", {
|
|
136
164
|
mode: "date",
|
|
137
165
|
fsp: 3
|
|
138
|
-
}).default(
|
|
139
|
-
|
|
166
|
+
}).default(sql`CURRENT_TIMESTAMP(3)`).notNull(),
|
|
167
|
+
fields: json("fields").$type().default({})
|
|
140
168
|
}, (table) => {
|
|
141
169
|
return {
|
|
142
|
-
priceId:
|
|
170
|
+
priceId: primaryKey({
|
|
143
171
|
columns: [
|
|
144
172
|
table.id
|
|
145
173
|
],
|
|
@@ -188,16 +216,19 @@ function getProductSchema(mysqlTable) {
|
|
|
188
216
|
key: varchar3("key", {
|
|
189
217
|
length: 191
|
|
190
218
|
}),
|
|
191
|
-
|
|
219
|
+
type: varchar3("type", {
|
|
220
|
+
length: 191
|
|
221
|
+
}),
|
|
222
|
+
fields: json2("fields").$type().default({}),
|
|
192
223
|
createdAt: timestamp3("createdAt", {
|
|
193
224
|
mode: "date",
|
|
194
225
|
fsp: 3
|
|
195
|
-
}).default(
|
|
226
|
+
}).default(sql2`CURRENT_TIMESTAMP(3)`).notNull(),
|
|
196
227
|
status: int2("status").default(0).notNull(),
|
|
197
228
|
quantityAvailable: int2("quantityAvailable").default(-1).notNull()
|
|
198
229
|
}, (table) => {
|
|
199
230
|
return {
|
|
200
|
-
productId:
|
|
231
|
+
productId: primaryKey2({
|
|
201
232
|
columns: [
|
|
202
233
|
table.id
|
|
203
234
|
],
|
|
@@ -238,251 +269,223 @@ function getProductRelationsSchema2(mysqlTable) {
|
|
|
238
269
|
}
|
|
239
270
|
__name(getProductRelationsSchema2, "getProductRelationsSchema");
|
|
240
271
|
|
|
241
|
-
// src/lib/mysql/schemas/
|
|
242
|
-
function
|
|
243
|
-
return mysqlTable("
|
|
244
|
-
|
|
245
|
-
length:
|
|
272
|
+
// src/lib/mysql/schemas/content/content-resource-product.ts
|
|
273
|
+
function getContentResourceProductSchema(mysqlTable) {
|
|
274
|
+
return mysqlTable("contentResourceProduct", {
|
|
275
|
+
productId: varchar4("productId", {
|
|
276
|
+
length: 255
|
|
246
277
|
}).notNull(),
|
|
247
|
-
|
|
248
|
-
length:
|
|
249
|
-
}),
|
|
278
|
+
resourceId: varchar4("resourceId", {
|
|
279
|
+
length: 255
|
|
280
|
+
}).notNull(),
|
|
281
|
+
position: double("position").notNull().default(0),
|
|
282
|
+
metadata: json3("metadata").$type().default({}),
|
|
250
283
|
createdAt: timestamp4("createdAt", {
|
|
251
284
|
mode: "date",
|
|
252
285
|
fsp: 3
|
|
253
|
-
}).default(
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
}).
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
length: 191
|
|
269
|
-
}),
|
|
270
|
-
couponId: varchar4("couponId", {
|
|
271
|
-
length: 191
|
|
272
|
-
}),
|
|
273
|
-
productId: varchar4("productId", {
|
|
274
|
-
length: 191
|
|
275
|
-
}).notNull(),
|
|
276
|
-
merchantChargeId: varchar4("merchantChargeId", {
|
|
277
|
-
length: 191
|
|
278
|
-
}),
|
|
279
|
-
upgradedFromId: varchar4("upgradedFromId", {
|
|
280
|
-
length: 191
|
|
281
|
-
}),
|
|
282
|
-
status: varchar4("status", {
|
|
283
|
-
length: 191
|
|
284
|
-
}).default("Valid").notNull(),
|
|
285
|
-
bulkCouponId: varchar4("bulkCouponId", {
|
|
286
|
-
length: 191
|
|
287
|
-
}),
|
|
288
|
-
merchantSessionId: varchar4("merchantSessionId", {
|
|
289
|
-
length: 191
|
|
290
|
-
}),
|
|
291
|
-
redeemedBulkCouponId: varchar4("redeemedBulkCouponId", {
|
|
292
|
-
length: 191
|
|
286
|
+
}).default(sql3`CURRENT_TIMESTAMP(3)`),
|
|
287
|
+
updatedAt: timestamp4("updatedAt", {
|
|
288
|
+
mode: "date",
|
|
289
|
+
fsp: 3
|
|
290
|
+
}).default(sql3`CURRENT_TIMESTAMP(3)`),
|
|
291
|
+
deletedAt: timestamp4("deletedAt", {
|
|
292
|
+
mode: "date",
|
|
293
|
+
fsp: 3
|
|
294
|
+
})
|
|
295
|
+
}, (crr) => ({
|
|
296
|
+
pk: primaryKey3({
|
|
297
|
+
columns: [
|
|
298
|
+
crr.productId,
|
|
299
|
+
crr.resourceId
|
|
300
|
+
]
|
|
293
301
|
}),
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
purchaseId: primaryKey4({
|
|
298
|
-
columns: [
|
|
299
|
-
table.id
|
|
300
|
-
],
|
|
301
|
-
name: "Purchase_id"
|
|
302
|
-
}),
|
|
303
|
-
purchaseUpgradedFromIdKey: unique("Purchase_upgradedFromId_key").on(table.upgradedFromId)
|
|
304
|
-
};
|
|
305
|
-
});
|
|
302
|
+
contentResourceIdIdx: index2("contentResourceId_idx").on(crr.productId),
|
|
303
|
+
resourceIdIdx: index2("resourceId_idx").on(crr.resourceId)
|
|
304
|
+
}));
|
|
306
305
|
}
|
|
307
|
-
__name(
|
|
308
|
-
function
|
|
309
|
-
const
|
|
310
|
-
const
|
|
311
|
-
const
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
const coupons = getCouponSchema(mysqlTable);
|
|
315
|
-
return relations4(purchases, ({ many, one }) => ({
|
|
316
|
-
user: one(users, {
|
|
317
|
-
fields: [
|
|
318
|
-
purchases.userId
|
|
319
|
-
],
|
|
320
|
-
references: [
|
|
321
|
-
users.id
|
|
322
|
-
],
|
|
323
|
-
relationName: "user"
|
|
324
|
-
}),
|
|
325
|
-
product: one(products, {
|
|
306
|
+
__name(getContentResourceProductSchema, "getContentResourceProductSchema");
|
|
307
|
+
function getContentResourceProductRelationsSchema(mysqlTable) {
|
|
308
|
+
const contentResource = getContentResourceSchema(mysqlTable);
|
|
309
|
+
const contentResourceProduct = getContentResourceProductSchema(mysqlTable);
|
|
310
|
+
const product = getProductSchema(mysqlTable);
|
|
311
|
+
return relations4(contentResourceProduct, ({ one }) => ({
|
|
312
|
+
product: one(product, {
|
|
326
313
|
fields: [
|
|
327
|
-
|
|
314
|
+
contentResourceProduct.productId
|
|
328
315
|
],
|
|
329
316
|
references: [
|
|
330
|
-
|
|
317
|
+
product.id
|
|
331
318
|
],
|
|
332
319
|
relationName: "product"
|
|
333
320
|
}),
|
|
334
|
-
|
|
321
|
+
resource: one(contentResource, {
|
|
335
322
|
fields: [
|
|
336
|
-
|
|
323
|
+
contentResourceProduct.resourceId
|
|
337
324
|
],
|
|
338
325
|
references: [
|
|
339
|
-
|
|
326
|
+
contentResource.id
|
|
340
327
|
],
|
|
341
|
-
relationName: "
|
|
328
|
+
relationName: "resource"
|
|
329
|
+
})
|
|
330
|
+
}));
|
|
331
|
+
}
|
|
332
|
+
__name(getContentResourceProductRelationsSchema, "getContentResourceProductRelationsSchema");
|
|
333
|
+
|
|
334
|
+
// src/lib/mysql/schemas/content/content-resource-resource.ts
|
|
335
|
+
import { relations as relations5, sql as sql4 } from "drizzle-orm";
|
|
336
|
+
import { double as double2, index as index3, json as json4, primaryKey as primaryKey4, timestamp as timestamp5, varchar as varchar5 } from "drizzle-orm/mysql-core";
|
|
337
|
+
function getContentResourceResourceSchema(mysqlTable) {
|
|
338
|
+
return mysqlTable("contentResourceResource", {
|
|
339
|
+
resourceOfId: varchar5("resourceOfId", {
|
|
340
|
+
length: 255
|
|
341
|
+
}).notNull(),
|
|
342
|
+
resourceId: varchar5("resourceId", {
|
|
343
|
+
length: 255
|
|
344
|
+
}).notNull(),
|
|
345
|
+
position: double2("position").notNull().default(0),
|
|
346
|
+
metadata: json4("metadata").$type().default({}),
|
|
347
|
+
createdAt: timestamp5("createdAt", {
|
|
348
|
+
mode: "date",
|
|
349
|
+
fsp: 3
|
|
350
|
+
}).default(sql4`CURRENT_TIMESTAMP(3)`),
|
|
351
|
+
updatedAt: timestamp5("updatedAt", {
|
|
352
|
+
mode: "date",
|
|
353
|
+
fsp: 3
|
|
354
|
+
}).default(sql4`CURRENT_TIMESTAMP(3)`),
|
|
355
|
+
deletedAt: timestamp5("deletedAt", {
|
|
356
|
+
mode: "date",
|
|
357
|
+
fsp: 3
|
|
358
|
+
})
|
|
359
|
+
}, (crr) => ({
|
|
360
|
+
pk: primaryKey4({
|
|
361
|
+
columns: [
|
|
362
|
+
crr.resourceOfId,
|
|
363
|
+
crr.resourceId
|
|
364
|
+
]
|
|
342
365
|
}),
|
|
343
|
-
|
|
366
|
+
contentResourceIdIdx: index3("contentResourceId_idx").on(crr.resourceOfId),
|
|
367
|
+
resourceIdIdx: index3("resourceId_idx").on(crr.resourceId)
|
|
368
|
+
}));
|
|
369
|
+
}
|
|
370
|
+
__name(getContentResourceResourceSchema, "getContentResourceResourceSchema");
|
|
371
|
+
function getContentResourceResourceRelationsSchema(mysqlTable) {
|
|
372
|
+
const contentResource = getContentResourceSchema(mysqlTable);
|
|
373
|
+
const contentResourceResource = getContentResourceResourceSchema(mysqlTable);
|
|
374
|
+
return relations5(contentResourceResource, ({ one }) => ({
|
|
375
|
+
resourceOf: one(contentResource, {
|
|
344
376
|
fields: [
|
|
345
|
-
|
|
377
|
+
contentResourceResource.resourceOfId
|
|
346
378
|
],
|
|
347
379
|
references: [
|
|
348
|
-
|
|
380
|
+
contentResource.id
|
|
349
381
|
],
|
|
350
|
-
relationName: "
|
|
382
|
+
relationName: "resourceOf"
|
|
351
383
|
}),
|
|
352
|
-
|
|
384
|
+
resource: one(contentResource, {
|
|
353
385
|
fields: [
|
|
354
|
-
|
|
386
|
+
contentResourceResource.resourceId
|
|
355
387
|
],
|
|
356
388
|
references: [
|
|
357
|
-
|
|
389
|
+
contentResource.id
|
|
358
390
|
],
|
|
359
|
-
relationName: "
|
|
391
|
+
relationName: "resource"
|
|
360
392
|
})
|
|
361
393
|
}));
|
|
362
394
|
}
|
|
363
|
-
__name(
|
|
395
|
+
__name(getContentResourceResourceRelationsSchema, "getContentResourceResourceRelationsSchema");
|
|
364
396
|
|
|
365
|
-
// src/lib/mysql/schemas/
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
return mysqlTable("communicationPreference", {
|
|
370
|
-
id: varchar5("id", {
|
|
397
|
+
// src/lib/mysql/schemas/content/content-resource.ts
|
|
398
|
+
function getContentResourceSchema(mysqlTable) {
|
|
399
|
+
return mysqlTable("contentResource", {
|
|
400
|
+
id: varchar6("id", {
|
|
371
401
|
length: 255
|
|
372
402
|
}).notNull().primaryKey(),
|
|
373
|
-
|
|
374
|
-
length: 255
|
|
375
|
-
}).notNull(),
|
|
376
|
-
channelId: varchar5("channelId", {
|
|
403
|
+
type: varchar6("type", {
|
|
377
404
|
length: 255
|
|
378
405
|
}).notNull(),
|
|
379
|
-
|
|
380
|
-
"low",
|
|
381
|
-
"medium",
|
|
382
|
-
"high"
|
|
383
|
-
]).notNull().default("medium"),
|
|
384
|
-
preferenceTypeId: varchar5("preferenceTypeId", {
|
|
406
|
+
createdById: varchar6("createdById", {
|
|
385
407
|
length: 255
|
|
386
408
|
}).notNull(),
|
|
387
|
-
|
|
388
|
-
createdAt:
|
|
389
|
-
mode: "date",
|
|
390
|
-
fsp: 3
|
|
391
|
-
}).defaultNow(),
|
|
392
|
-
optInAt: timestamp5("optInAt", {
|
|
393
|
-
mode: "date",
|
|
394
|
-
fsp: 3
|
|
395
|
-
}),
|
|
396
|
-
optOutAt: timestamp5("optOutAt", {
|
|
409
|
+
fields: json5("fields").$type().default({}),
|
|
410
|
+
createdAt: timestamp6("createdAt", {
|
|
397
411
|
mode: "date",
|
|
398
412
|
fsp: 3
|
|
399
|
-
}),
|
|
400
|
-
updatedAt:
|
|
413
|
+
}).default(sql5`CURRENT_TIMESTAMP(3)`),
|
|
414
|
+
updatedAt: timestamp6("updatedAt", {
|
|
401
415
|
mode: "date",
|
|
402
416
|
fsp: 3
|
|
403
|
-
}).
|
|
404
|
-
deletedAt:
|
|
417
|
+
}).default(sql5`CURRENT_TIMESTAMP(3)`),
|
|
418
|
+
deletedAt: timestamp6("deletedAt", {
|
|
405
419
|
mode: "date",
|
|
406
420
|
fsp: 3
|
|
407
421
|
})
|
|
408
|
-
}, (
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
422
|
+
}, (cm) => ({
|
|
423
|
+
typeIdx: index4("type_idx").on(cm.type),
|
|
424
|
+
createdByIdx: index4("createdById_idx").on(cm.createdById),
|
|
425
|
+
createdAtIdx: index4("createdAt_idx").on(cm.createdAt)
|
|
412
426
|
}));
|
|
413
427
|
}
|
|
414
|
-
__name(
|
|
415
|
-
function
|
|
416
|
-
const
|
|
428
|
+
__name(getContentResourceSchema, "getContentResourceSchema");
|
|
429
|
+
function getContentResourceRelationsSchema(mysqlTable) {
|
|
430
|
+
const contentResource = getContentResourceSchema(mysqlTable);
|
|
417
431
|
const users = getUsersSchema(mysqlTable);
|
|
418
|
-
const
|
|
419
|
-
const
|
|
420
|
-
return
|
|
421
|
-
|
|
432
|
+
const contentResourceResource = getContentResourceResourceSchema(mysqlTable);
|
|
433
|
+
const contentResourceProduct = getContentResourceProductSchema(mysqlTable);
|
|
434
|
+
return relations6(contentResource, ({ one, many }) => ({
|
|
435
|
+
createdBy: one(users, {
|
|
422
436
|
fields: [
|
|
423
|
-
|
|
437
|
+
contentResource.createdById
|
|
424
438
|
],
|
|
425
439
|
references: [
|
|
426
440
|
users.id
|
|
427
441
|
],
|
|
428
442
|
relationName: "user"
|
|
429
443
|
}),
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
communicationPreferences.channelId
|
|
433
|
-
],
|
|
434
|
-
references: [
|
|
435
|
-
communicationChannel.id
|
|
436
|
-
],
|
|
437
|
-
relationName: "channel"
|
|
444
|
+
resources: many(contentResourceResource, {
|
|
445
|
+
relationName: "resourceOf"
|
|
438
446
|
}),
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
communicationPreferenceTypes.id
|
|
445
|
-
],
|
|
446
|
-
relationName: "preferenceType"
|
|
447
|
+
resourceOf: many(contentResourceResource, {
|
|
448
|
+
relationName: "resource"
|
|
449
|
+
}),
|
|
450
|
+
resourceProducts: many(contentResourceProduct, {
|
|
451
|
+
relationName: "resource"
|
|
447
452
|
})
|
|
448
453
|
}));
|
|
449
454
|
}
|
|
450
|
-
__name(
|
|
455
|
+
__name(getContentResourceRelationsSchema, "getContentResourceRelationsSchema");
|
|
451
456
|
|
|
452
457
|
// src/lib/mysql/schemas/content/content-contributions.ts
|
|
453
|
-
import { relations as relations6 } from "drizzle-orm";
|
|
454
|
-
import { boolean as boolean2, index as index3, timestamp as timestamp6, varchar as varchar6 } from "drizzle-orm/mysql-core";
|
|
455
458
|
function getContentContributionsSchema(mysqlTable) {
|
|
456
459
|
return mysqlTable("contentContribution", {
|
|
457
|
-
id:
|
|
460
|
+
id: varchar7("id", {
|
|
458
461
|
length: 255
|
|
459
462
|
}).notNull().primaryKey(),
|
|
460
|
-
userId:
|
|
463
|
+
userId: varchar7("userId", {
|
|
461
464
|
length: 255
|
|
462
465
|
}).notNull(),
|
|
463
|
-
contentId:
|
|
466
|
+
contentId: varchar7("contentId", {
|
|
464
467
|
length: 255
|
|
465
468
|
}).notNull(),
|
|
466
|
-
contributionTypeId:
|
|
469
|
+
contributionTypeId: varchar7("contributionTypeId", {
|
|
467
470
|
length: 255
|
|
468
471
|
}).notNull(),
|
|
469
472
|
active: boolean2("active").notNull().default(true),
|
|
470
|
-
createdAt:
|
|
473
|
+
createdAt: timestamp7("createdAt", {
|
|
471
474
|
mode: "date",
|
|
472
475
|
fsp: 3
|
|
473
476
|
}).defaultNow(),
|
|
474
|
-
updatedAt:
|
|
477
|
+
updatedAt: timestamp7("updatedAt", {
|
|
475
478
|
mode: "date",
|
|
476
479
|
fsp: 3
|
|
477
480
|
}).defaultNow(),
|
|
478
|
-
deletedAt:
|
|
481
|
+
deletedAt: timestamp7("deletedAt", {
|
|
479
482
|
mode: "date",
|
|
480
483
|
fsp: 3
|
|
481
484
|
})
|
|
482
485
|
}, (cc) => ({
|
|
483
|
-
userIdIdx:
|
|
484
|
-
contentIdIdx:
|
|
485
|
-
contributionTypeIdIdx:
|
|
486
|
+
userIdIdx: index5("userId_idx").on(cc.userId),
|
|
487
|
+
contentIdIdx: index5("contentId_idx").on(cc.contentId),
|
|
488
|
+
contributionTypeIdIdx: index5("contributionTypeId_idx").on(cc.contributionTypeId)
|
|
486
489
|
}));
|
|
487
490
|
}
|
|
488
491
|
__name(getContentContributionsSchema, "getContentContributionsSchema");
|
|
@@ -491,7 +494,7 @@ function getContentContributionRelationsSchema(mysqlTable) {
|
|
|
491
494
|
const users = getUsersSchema(mysqlTable);
|
|
492
495
|
const contentResource = getContentResourceSchema(mysqlTable);
|
|
493
496
|
const contributionTypes = getContributionTypesSchema(mysqlTable);
|
|
494
|
-
return
|
|
497
|
+
return relations7(contentContributions, ({ one }) => ({
|
|
495
498
|
user: one(users, {
|
|
496
499
|
fields: [
|
|
497
500
|
contentContributions.userId
|
|
@@ -524,20 +527,20 @@ function getContentContributionRelationsSchema(mysqlTable) {
|
|
|
524
527
|
__name(getContentContributionRelationsSchema, "getContentContributionRelationsSchema");
|
|
525
528
|
|
|
526
529
|
// src/lib/mysql/schemas/auth/accounts.ts
|
|
527
|
-
import { relations as
|
|
528
|
-
import { index as
|
|
530
|
+
import { relations as relations8 } from "drizzle-orm";
|
|
531
|
+
import { index as index6, int as int3, primaryKey as primaryKey5, text, varchar as varchar8 } from "drizzle-orm/mysql-core";
|
|
529
532
|
function getAccountsSchema(mysqlTable) {
|
|
530
533
|
return mysqlTable("account", {
|
|
531
|
-
userId:
|
|
534
|
+
userId: varchar8("userId", {
|
|
532
535
|
length: 255
|
|
533
536
|
}).notNull(),
|
|
534
|
-
type:
|
|
537
|
+
type: varchar8("type", {
|
|
535
538
|
length: 255
|
|
536
539
|
}).$type().notNull(),
|
|
537
|
-
provider:
|
|
540
|
+
provider: varchar8("provider", {
|
|
538
541
|
length: 255
|
|
539
542
|
}).notNull(),
|
|
540
|
-
providerAccountId:
|
|
543
|
+
providerAccountId: varchar8("providerAccountId", {
|
|
541
544
|
length: 255
|
|
542
545
|
}).notNull(),
|
|
543
546
|
refresh_token: text("refresh_token"),
|
|
@@ -545,14 +548,14 @@ function getAccountsSchema(mysqlTable) {
|
|
|
545
548
|
oauth_token: text("oauth_token"),
|
|
546
549
|
oauth_token_secret: text("oauth_token_secret"),
|
|
547
550
|
expires_at: int3("expires_at"),
|
|
548
|
-
token_type:
|
|
551
|
+
token_type: varchar8("token_type", {
|
|
549
552
|
length: 255
|
|
550
553
|
}),
|
|
551
|
-
scope:
|
|
554
|
+
scope: varchar8("scope", {
|
|
552
555
|
length: 255
|
|
553
556
|
}),
|
|
554
557
|
id_token: text("id_token"),
|
|
555
|
-
session_state:
|
|
558
|
+
session_state: varchar8("session_state", {
|
|
556
559
|
length: 255
|
|
557
560
|
}),
|
|
558
561
|
refresh_token_expires_in: int3("refresh_token_expires_in")
|
|
@@ -563,14 +566,14 @@ function getAccountsSchema(mysqlTable) {
|
|
|
563
566
|
account.providerAccountId
|
|
564
567
|
]
|
|
565
568
|
}),
|
|
566
|
-
userIdIdx:
|
|
569
|
+
userIdIdx: index6("userId_idx").on(account.userId)
|
|
567
570
|
}));
|
|
568
571
|
}
|
|
569
572
|
__name(getAccountsSchema, "getAccountsSchema");
|
|
570
573
|
function getAccountsRelationsSchema(mysqlTable) {
|
|
571
574
|
const accounts = getAccountsSchema(mysqlTable);
|
|
572
575
|
const users = getUsersSchema(mysqlTable);
|
|
573
|
-
return
|
|
576
|
+
return relations8(accounts, ({ one }) => ({
|
|
574
577
|
user: one(users, {
|
|
575
578
|
fields: [
|
|
576
579
|
accounts.userId
|
|
@@ -585,26 +588,26 @@ function getAccountsRelationsSchema(mysqlTable) {
|
|
|
585
588
|
__name(getAccountsRelationsSchema, "getAccountsRelationsSchema");
|
|
586
589
|
|
|
587
590
|
// src/lib/mysql/schemas/auth/user-permissions.ts
|
|
588
|
-
import { relations as
|
|
589
|
-
import { boolean as boolean3, index as
|
|
591
|
+
import { relations as relations9 } from "drizzle-orm";
|
|
592
|
+
import { boolean as boolean3, index as index7, primaryKey as primaryKey6, timestamp as timestamp8, varchar as varchar9 } from "drizzle-orm/mysql-core";
|
|
590
593
|
function getUserPermissionsSchema(mysqlTable) {
|
|
591
594
|
return mysqlTable("userPermission", {
|
|
592
|
-
userId:
|
|
595
|
+
userId: varchar9("userId", {
|
|
593
596
|
length: 255
|
|
594
597
|
}).notNull(),
|
|
595
|
-
permissionId:
|
|
598
|
+
permissionId: varchar9("permissionId", {
|
|
596
599
|
length: 255
|
|
597
600
|
}).notNull(),
|
|
598
601
|
active: boolean3("active").notNull().default(true),
|
|
599
|
-
createdAt:
|
|
602
|
+
createdAt: timestamp8("createdAt", {
|
|
600
603
|
mode: "date",
|
|
601
604
|
fsp: 3
|
|
602
605
|
}).defaultNow(),
|
|
603
|
-
updatedAt:
|
|
606
|
+
updatedAt: timestamp8("updatedAt", {
|
|
604
607
|
mode: "date",
|
|
605
608
|
fsp: 3
|
|
606
609
|
}).defaultNow(),
|
|
607
|
-
deletedAt:
|
|
610
|
+
deletedAt: timestamp8("deletedAt", {
|
|
608
611
|
mode: "date",
|
|
609
612
|
fsp: 3
|
|
610
613
|
})
|
|
@@ -615,8 +618,8 @@ function getUserPermissionsSchema(mysqlTable) {
|
|
|
615
618
|
up.permissionId
|
|
616
619
|
]
|
|
617
620
|
}),
|
|
618
|
-
userIdIdx:
|
|
619
|
-
permissionIdIdx:
|
|
621
|
+
userIdIdx: index7("userId_idx").on(up.userId),
|
|
622
|
+
permissionIdIdx: index7("permissionId_idx").on(up.permissionId)
|
|
620
623
|
}));
|
|
621
624
|
}
|
|
622
625
|
__name(getUserPermissionsSchema, "getUserPermissionsSchema");
|
|
@@ -624,7 +627,7 @@ function getUserPermissionsRelationsSchema(mysqlTable) {
|
|
|
624
627
|
const userPermissions = getUserPermissionsSchema(mysqlTable);
|
|
625
628
|
const users = getUsersSchema(mysqlTable);
|
|
626
629
|
const permissions = getPermissionsSchema(mysqlTable);
|
|
627
|
-
return
|
|
630
|
+
return relations9(userPermissions, ({ one }) => ({
|
|
628
631
|
user: one(users, {
|
|
629
632
|
fields: [
|
|
630
633
|
userPermissions.userId
|
|
@@ -648,43 +651,43 @@ function getUserPermissionsRelationsSchema(mysqlTable) {
|
|
|
648
651
|
__name(getUserPermissionsRelationsSchema, "getUserPermissionsRelationsSchema");
|
|
649
652
|
|
|
650
653
|
// src/lib/mysql/schemas/auth/user-roles.ts
|
|
651
|
-
import { relations as
|
|
652
|
-
import { boolean as boolean5, index as
|
|
654
|
+
import { relations as relations11 } from "drizzle-orm";
|
|
655
|
+
import { boolean as boolean5, index as index9, primaryKey as primaryKey7, timestamp as timestamp10, varchar as varchar11 } from "drizzle-orm/mysql-core";
|
|
653
656
|
|
|
654
657
|
// src/lib/mysql/schemas/auth/roles.ts
|
|
655
|
-
import { relations as
|
|
656
|
-
import { boolean as boolean4, index as
|
|
658
|
+
import { relations as relations10 } from "drizzle-orm";
|
|
659
|
+
import { boolean as boolean4, index as index8, text as text2, timestamp as timestamp9, varchar as varchar10 } from "drizzle-orm/mysql-core";
|
|
657
660
|
function getRolesSchema(mysqlTable) {
|
|
658
661
|
return mysqlTable("role", {
|
|
659
|
-
id:
|
|
662
|
+
id: varchar10("id", {
|
|
660
663
|
length: 255
|
|
661
664
|
}).notNull().primaryKey(),
|
|
662
|
-
name:
|
|
665
|
+
name: varchar10("name", {
|
|
663
666
|
length: 255
|
|
664
667
|
}).notNull().unique(),
|
|
665
668
|
description: text2("description"),
|
|
666
669
|
active: boolean4("active").notNull().default(true),
|
|
667
|
-
createdAt:
|
|
670
|
+
createdAt: timestamp9("createdAt", {
|
|
668
671
|
mode: "date",
|
|
669
672
|
fsp: 3
|
|
670
673
|
}).defaultNow(),
|
|
671
|
-
updatedAt:
|
|
674
|
+
updatedAt: timestamp9("updatedAt", {
|
|
672
675
|
mode: "date",
|
|
673
676
|
fsp: 3
|
|
674
677
|
}).defaultNow(),
|
|
675
|
-
deletedAt:
|
|
678
|
+
deletedAt: timestamp9("deletedAt", {
|
|
676
679
|
mode: "date",
|
|
677
680
|
fsp: 3
|
|
678
681
|
})
|
|
679
682
|
}, (role) => ({
|
|
680
|
-
nameIdx:
|
|
683
|
+
nameIdx: index8("name_idx").on(role.name)
|
|
681
684
|
}));
|
|
682
685
|
}
|
|
683
686
|
__name(getRolesSchema, "getRolesSchema");
|
|
684
687
|
function getRolesRelationsSchema(mysqlTable) {
|
|
685
688
|
const roles = getRolesSchema(mysqlTable);
|
|
686
689
|
const userRoles = getUserRolesSchema(mysqlTable);
|
|
687
|
-
return
|
|
690
|
+
return relations10(roles, ({ many }) => ({
|
|
688
691
|
userRoles: many(userRoles, {
|
|
689
692
|
relationName: "role"
|
|
690
693
|
})
|
|
@@ -695,22 +698,22 @@ __name(getRolesRelationsSchema, "getRolesRelationsSchema");
|
|
|
695
698
|
// src/lib/mysql/schemas/auth/user-roles.ts
|
|
696
699
|
function getUserRolesSchema(mysqlTable) {
|
|
697
700
|
return mysqlTable("userRole", {
|
|
698
|
-
userId:
|
|
701
|
+
userId: varchar11("userId", {
|
|
699
702
|
length: 255
|
|
700
703
|
}).notNull(),
|
|
701
|
-
roleId:
|
|
704
|
+
roleId: varchar11("roleId", {
|
|
702
705
|
length: 255
|
|
703
706
|
}).notNull(),
|
|
704
707
|
active: boolean5("active").notNull().default(true),
|
|
705
|
-
createdAt:
|
|
708
|
+
createdAt: timestamp10("createdAt", {
|
|
706
709
|
mode: "date",
|
|
707
710
|
fsp: 3
|
|
708
711
|
}).defaultNow(),
|
|
709
|
-
updatedAt:
|
|
712
|
+
updatedAt: timestamp10("updatedAt", {
|
|
710
713
|
mode: "date",
|
|
711
714
|
fsp: 3
|
|
712
715
|
}).defaultNow(),
|
|
713
|
-
deletedAt:
|
|
716
|
+
deletedAt: timestamp10("deletedAt", {
|
|
714
717
|
mode: "date",
|
|
715
718
|
fsp: 3
|
|
716
719
|
})
|
|
@@ -721,8 +724,8 @@ function getUserRolesSchema(mysqlTable) {
|
|
|
721
724
|
ur.roleId
|
|
722
725
|
]
|
|
723
726
|
}),
|
|
724
|
-
userIdIdx:
|
|
725
|
-
roleIdIdx:
|
|
727
|
+
userIdIdx: index9("userId_idx").on(ur.userId),
|
|
728
|
+
roleIdIdx: index9("roleId_idx").on(ur.roleId)
|
|
726
729
|
}));
|
|
727
730
|
}
|
|
728
731
|
__name(getUserRolesSchema, "getUserRolesSchema");
|
|
@@ -730,7 +733,7 @@ function getUserRolesRelationsSchema(mysqlTable) {
|
|
|
730
733
|
const userRoles = getUserRolesSchema(mysqlTable);
|
|
731
734
|
const users = getUsersSchema(mysqlTable);
|
|
732
735
|
const roles = getRolesSchema(mysqlTable);
|
|
733
|
-
return
|
|
736
|
+
return relations11(userRoles, ({ one }) => ({
|
|
734
737
|
user: one(users, {
|
|
735
738
|
fields: [
|
|
736
739
|
userRoles.userId
|
|
@@ -756,34 +759,34 @@ __name(getUserRolesRelationsSchema, "getUserRolesRelationsSchema");
|
|
|
756
759
|
// src/lib/mysql/schemas/auth/users.ts
|
|
757
760
|
function getUsersSchema(mysqlTable) {
|
|
758
761
|
return mysqlTable("user", {
|
|
759
|
-
id:
|
|
762
|
+
id: varchar12("id", {
|
|
760
763
|
length: 255
|
|
761
764
|
}).notNull().primaryKey(),
|
|
762
|
-
name:
|
|
765
|
+
name: varchar12("name", {
|
|
763
766
|
length: 255
|
|
764
767
|
}),
|
|
765
768
|
role: mysqlEnum2("role", [
|
|
766
769
|
"user",
|
|
767
770
|
"admin"
|
|
768
771
|
]).default("user"),
|
|
769
|
-
email:
|
|
772
|
+
email: varchar12("email", {
|
|
770
773
|
length: 255
|
|
771
774
|
}).notNull().unique(),
|
|
772
|
-
emailVerified:
|
|
775
|
+
emailVerified: timestamp11("emailVerified", {
|
|
773
776
|
mode: "date",
|
|
774
777
|
fsp: 3
|
|
775
778
|
}),
|
|
776
|
-
image:
|
|
779
|
+
image: varchar12("image", {
|
|
777
780
|
length: 255
|
|
778
781
|
}),
|
|
779
|
-
createdAt:
|
|
782
|
+
createdAt: timestamp11("createdAt", {
|
|
780
783
|
mode: "date",
|
|
781
784
|
fsp: 3
|
|
782
|
-
}).default(
|
|
785
|
+
}).default(sql6`CURRENT_TIMESTAMP(3)`)
|
|
783
786
|
}, (user) => ({
|
|
784
|
-
emailIdx:
|
|
785
|
-
roleIdx:
|
|
786
|
-
createdAtIdx:
|
|
787
|
+
emailIdx: index10("email_idx").on(user.email),
|
|
788
|
+
roleIdx: index10("role_idx").on(user.role),
|
|
789
|
+
createdAtIdx: index10("created_at_idx").on(user.createdAt)
|
|
787
790
|
}));
|
|
788
791
|
}
|
|
789
792
|
__name(getUsersSchema, "getUsersSchema");
|
|
@@ -796,7 +799,7 @@ function getUsersRelationsSchema(mysqlTable) {
|
|
|
796
799
|
const contentContributions = getContentContributionsSchema(mysqlTable);
|
|
797
800
|
const contentResource = getContentResourceSchema(mysqlTable);
|
|
798
801
|
const purchases = getPurchaseSchema(mysqlTable);
|
|
799
|
-
return
|
|
802
|
+
return relations12(users, ({ many }) => ({
|
|
800
803
|
accounts: many(accounts, {
|
|
801
804
|
relationName: "user"
|
|
802
805
|
}),
|
|
@@ -822,128 +825,202 @@ function getUsersRelationsSchema(mysqlTable) {
|
|
|
822
825
|
}
|
|
823
826
|
__name(getUsersRelationsSchema, "getUsersRelationsSchema");
|
|
824
827
|
|
|
825
|
-
// src/lib/mysql/schemas/
|
|
826
|
-
function
|
|
827
|
-
return mysqlTable("
|
|
828
|
-
id:
|
|
829
|
-
length:
|
|
830
|
-
}).notNull().primaryKey(),
|
|
831
|
-
type: varchar12("type", {
|
|
832
|
-
length: 255
|
|
833
|
-
}).notNull(),
|
|
834
|
-
createdById: varchar12("createdById", {
|
|
835
|
-
length: 255
|
|
828
|
+
// src/lib/mysql/schemas/commerce/purchase.ts
|
|
829
|
+
function getPurchaseSchema(mysqlTable) {
|
|
830
|
+
return mysqlTable("purchases", {
|
|
831
|
+
id: varchar13("id", {
|
|
832
|
+
length: 191
|
|
836
833
|
}).notNull(),
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
}).default(sql6`CURRENT_TIMESTAMP(3)`),
|
|
842
|
-
updatedAt: timestamp11("updatedAt", {
|
|
843
|
-
mode: "date",
|
|
844
|
-
fsp: 3
|
|
845
|
-
}).default(sql6`CURRENT_TIMESTAMP(3)`),
|
|
846
|
-
deletedAt: timestamp11("deletedAt", {
|
|
834
|
+
userId: varchar13("userId", {
|
|
835
|
+
length: 191
|
|
836
|
+
}),
|
|
837
|
+
createdAt: timestamp12("createdAt", {
|
|
847
838
|
mode: "date",
|
|
848
839
|
fsp: 3
|
|
849
|
-
})
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
840
|
+
}).default(sql7`CURRENT_TIMESTAMP(3)`).notNull(),
|
|
841
|
+
totalAmount: decimal2("totalAmount", {
|
|
842
|
+
precision: 65,
|
|
843
|
+
scale: 30
|
|
844
|
+
}).notNull(),
|
|
845
|
+
ipAddress: varchar13("ip_address", {
|
|
846
|
+
length: 191
|
|
847
|
+
}),
|
|
848
|
+
city: varchar13("city", {
|
|
849
|
+
length: 191
|
|
850
|
+
}),
|
|
851
|
+
state: varchar13("state", {
|
|
852
|
+
length: 191
|
|
853
|
+
}),
|
|
854
|
+
country: varchar13("country", {
|
|
855
|
+
length: 191
|
|
856
|
+
}),
|
|
857
|
+
couponId: varchar13("couponId", {
|
|
858
|
+
length: 191
|
|
859
|
+
}),
|
|
860
|
+
productId: varchar13("productId", {
|
|
861
|
+
length: 191
|
|
862
|
+
}).notNull(),
|
|
863
|
+
merchantChargeId: varchar13("merchantChargeId", {
|
|
864
|
+
length: 191
|
|
865
|
+
}),
|
|
866
|
+
upgradedFromId: varchar13("upgradedFromId", {
|
|
867
|
+
length: 191
|
|
868
|
+
}),
|
|
869
|
+
status: varchar13("status", {
|
|
870
|
+
length: 191
|
|
871
|
+
}).default("Valid").notNull(),
|
|
872
|
+
bulkCouponId: varchar13("bulkCouponId", {
|
|
873
|
+
length: 191
|
|
874
|
+
}),
|
|
875
|
+
merchantSessionId: varchar13("merchantSessionId", {
|
|
876
|
+
length: 191
|
|
877
|
+
}),
|
|
878
|
+
redeemedBulkCouponId: varchar13("redeemedBulkCouponId", {
|
|
879
|
+
length: 191
|
|
880
|
+
}),
|
|
881
|
+
fields: json6("fields").$type().default({})
|
|
882
|
+
}, (table) => {
|
|
883
|
+
return {
|
|
884
|
+
purchaseId: primaryKey8({
|
|
885
|
+
columns: [
|
|
886
|
+
table.id
|
|
887
|
+
],
|
|
888
|
+
name: "Purchase_id"
|
|
889
|
+
}),
|
|
890
|
+
purchaseUpgradedFromIdKey: unique("Purchase_upgradedFromId_key").on(table.upgradedFromId)
|
|
891
|
+
};
|
|
892
|
+
});
|
|
855
893
|
}
|
|
856
|
-
__name(
|
|
857
|
-
function
|
|
858
|
-
const
|
|
894
|
+
__name(getPurchaseSchema, "getPurchaseSchema");
|
|
895
|
+
function getPurchaseRelationsSchema(mysqlTable) {
|
|
896
|
+
const purchases = getPurchaseSchema(mysqlTable);
|
|
859
897
|
const users = getUsersSchema(mysqlTable);
|
|
860
|
-
const
|
|
861
|
-
const
|
|
862
|
-
|
|
863
|
-
|
|
898
|
+
const products = getProductSchema(mysqlTable);
|
|
899
|
+
const merchantCharges = getMerchantChargeSchema(mysqlTable);
|
|
900
|
+
const merchantSessions = getMerchantSessionSchema(mysqlTable);
|
|
901
|
+
const coupons = getCouponSchema(mysqlTable);
|
|
902
|
+
return relations13(purchases, ({ many, one }) => ({
|
|
903
|
+
redeemedBulkCoupon: one(coupons, {
|
|
864
904
|
fields: [
|
|
865
|
-
|
|
905
|
+
purchases.redeemedBulkCouponId
|
|
906
|
+
],
|
|
907
|
+
references: [
|
|
908
|
+
coupons.id
|
|
909
|
+
],
|
|
910
|
+
relationName: "redeemedBulkCoupon"
|
|
911
|
+
}),
|
|
912
|
+
user: one(users, {
|
|
913
|
+
fields: [
|
|
914
|
+
purchases.userId
|
|
866
915
|
],
|
|
867
916
|
references: [
|
|
868
917
|
users.id
|
|
869
918
|
],
|
|
870
919
|
relationName: "user"
|
|
871
920
|
}),
|
|
872
|
-
|
|
873
|
-
|
|
921
|
+
product: one(products, {
|
|
922
|
+
fields: [
|
|
923
|
+
purchases.productId
|
|
924
|
+
],
|
|
925
|
+
references: [
|
|
926
|
+
products.id
|
|
927
|
+
],
|
|
928
|
+
relationName: "product"
|
|
874
929
|
}),
|
|
875
|
-
|
|
876
|
-
|
|
930
|
+
bulkCoupon: one(coupons, {
|
|
931
|
+
fields: [
|
|
932
|
+
purchases.bulkCouponId
|
|
933
|
+
],
|
|
934
|
+
references: [
|
|
935
|
+
coupons.id
|
|
936
|
+
],
|
|
937
|
+
relationName: "bulkCoupon"
|
|
877
938
|
}),
|
|
878
|
-
|
|
879
|
-
|
|
939
|
+
merchantCharge: one(merchantCharges, {
|
|
940
|
+
fields: [
|
|
941
|
+
purchases.merchantChargeId
|
|
942
|
+
],
|
|
943
|
+
references: [
|
|
944
|
+
merchantCharges.id
|
|
945
|
+
],
|
|
946
|
+
relationName: "merchantCharge"
|
|
947
|
+
}),
|
|
948
|
+
merchantSession: one(merchantSessions, {
|
|
949
|
+
fields: [
|
|
950
|
+
purchases.merchantSessionId
|
|
951
|
+
],
|
|
952
|
+
references: [
|
|
953
|
+
merchantSessions.id
|
|
954
|
+
],
|
|
955
|
+
relationName: "merchantSession"
|
|
880
956
|
})
|
|
881
957
|
}));
|
|
882
958
|
}
|
|
883
|
-
__name(
|
|
959
|
+
__name(getPurchaseRelationsSchema, "getPurchaseRelationsSchema");
|
|
884
960
|
|
|
885
|
-
// src/lib/mysql/schemas/
|
|
886
|
-
function
|
|
887
|
-
return mysqlTable("
|
|
888
|
-
|
|
889
|
-
length:
|
|
890
|
-
}).notNull(),
|
|
891
|
-
resourceId: varchar13("resourceId", {
|
|
892
|
-
length: 255
|
|
961
|
+
// src/lib/mysql/schemas/commerce/coupon.ts
|
|
962
|
+
function getCouponSchema(mysqlTable) {
|
|
963
|
+
return mysqlTable("coupons", {
|
|
964
|
+
id: varchar14("id", {
|
|
965
|
+
length: 191
|
|
893
966
|
}).notNull(),
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
fsp: 3
|
|
899
|
-
}).default(sql7`CURRENT_TIMESTAMP(3)`),
|
|
900
|
-
updatedAt: timestamp12("updatedAt", {
|
|
967
|
+
code: varchar14("code", {
|
|
968
|
+
length: 191
|
|
969
|
+
}),
|
|
970
|
+
createdAt: timestamp13("createdAt", {
|
|
901
971
|
mode: "date",
|
|
902
972
|
fsp: 3
|
|
903
|
-
}).default(
|
|
904
|
-
|
|
973
|
+
}).default(sql8`CURRENT_TIMESTAMP(3)`).notNull(),
|
|
974
|
+
expires: timestamp13("expires", {
|
|
905
975
|
mode: "date",
|
|
906
976
|
fsp: 3
|
|
907
|
-
})
|
|
908
|
-
}, (crr) => ({
|
|
909
|
-
pk: primaryKey8({
|
|
910
|
-
columns: [
|
|
911
|
-
crr.resourceOfId,
|
|
912
|
-
crr.resourceId
|
|
913
|
-
]
|
|
914
977
|
}),
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
function getContentResourceResourceRelationsSchema(mysqlTable) {
|
|
921
|
-
const contentResource = getContentResourceSchema(mysqlTable);
|
|
922
|
-
const contentResourceResource = getContentResourceResourceSchema(mysqlTable);
|
|
923
|
-
return relations13(contentResourceResource, ({ one }) => ({
|
|
924
|
-
resourceOf: one(contentResource, {
|
|
925
|
-
fields: [
|
|
926
|
-
contentResourceResource.resourceOfId
|
|
927
|
-
],
|
|
928
|
-
references: [
|
|
929
|
-
contentResource.id
|
|
930
|
-
],
|
|
931
|
-
relationName: "resourceOf"
|
|
978
|
+
fields: json7("fields").$type().default({}),
|
|
979
|
+
maxUses: int4("maxUses").default(-1).notNull(),
|
|
980
|
+
default: boolean6("default").default(false).notNull(),
|
|
981
|
+
merchantCouponId: varchar14("merchantCouponId", {
|
|
982
|
+
length: 191
|
|
932
983
|
}),
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
984
|
+
status: int4("status").default(0).notNull(),
|
|
985
|
+
usedCount: int4("usedCount").default(0).notNull(),
|
|
986
|
+
percentageDiscount: decimal3("percentageDiscount", {
|
|
987
|
+
precision: 3,
|
|
988
|
+
scale: 2
|
|
989
|
+
}).notNull(),
|
|
990
|
+
restrictedToProductId: varchar14("restrictedToProductId", {
|
|
991
|
+
length: 191
|
|
992
|
+
}),
|
|
993
|
+
bulkPurchaseId: varchar14("bulkPurchaseId", {
|
|
994
|
+
length: 191
|
|
995
|
+
})
|
|
996
|
+
}, (table) => {
|
|
997
|
+
return {
|
|
998
|
+
couponId: primaryKey9({
|
|
999
|
+
columns: [
|
|
1000
|
+
table.id
|
|
1001
|
+
],
|
|
1002
|
+
name: "Coupon_id"
|
|
1003
|
+
}),
|
|
1004
|
+
couponBulkPurchaseIdKey: unique2("Coupon_bulkPurchaseId_key").on(table.bulkPurchaseId),
|
|
1005
|
+
couponCodeKey: unique2("Coupon_code_key").on(table.code)
|
|
1006
|
+
};
|
|
1007
|
+
});
|
|
1008
|
+
}
|
|
1009
|
+
__name(getCouponSchema, "getCouponSchema");
|
|
1010
|
+
function getCouponRelationsSchema(mysqlTable) {
|
|
1011
|
+
const purchase = getPurchaseSchema(mysqlTable);
|
|
1012
|
+
const coupon = getCouponSchema(mysqlTable);
|
|
1013
|
+
return relations14(coupon, ({ many }) => ({
|
|
1014
|
+
bulkCouponPurchases: many(purchase, {
|
|
1015
|
+
relationName: "redeemedBulkCoupon"
|
|
941
1016
|
})
|
|
942
1017
|
}));
|
|
943
1018
|
}
|
|
944
|
-
__name(
|
|
1019
|
+
__name(getCouponRelationsSchema, "getCouponRelationsSchema");
|
|
945
1020
|
|
|
946
1021
|
export {
|
|
1022
|
+
getCouponSchema,
|
|
1023
|
+
getCouponRelationsSchema,
|
|
947
1024
|
getContentResourceResourceSchema,
|
|
948
1025
|
getContentResourceResourceRelationsSchema,
|
|
949
1026
|
getContentResourceSchema,
|
|
@@ -971,4 +1048,4 @@ export {
|
|
|
971
1048
|
getAccountsSchema,
|
|
972
1049
|
getAccountsRelationsSchema
|
|
973
1050
|
};
|
|
974
|
-
//# sourceMappingURL=chunk-
|
|
1051
|
+
//# sourceMappingURL=chunk-3RJVKNXB.js.map
|