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