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