careerty-prism 1.0.30 → 1.0.31
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/others/seeder.ts
CHANGED
|
@@ -3,6 +3,30 @@ const prisma = new PrismaClient()
|
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
|
|
6
|
+
function generateRandomString(length: number) {
|
|
7
|
+
const chars =
|
|
8
|
+
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
|
9
|
+
let randomString = "";
|
|
10
|
+
for (let i = 0; i < length; i++) {
|
|
11
|
+
randomString += chars[Math.floor(Math.random() * chars.length)];
|
|
12
|
+
}
|
|
13
|
+
return randomString;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
function toPermalink(text: string) {
|
|
18
|
+
|
|
19
|
+
let permalinkText = text
|
|
20
|
+
.toLowerCase()
|
|
21
|
+
.replace(/[^a-z0-9]+/g, "-")
|
|
22
|
+
.replace(/^-+/, "")
|
|
23
|
+
.replace(/-+$/, "");
|
|
24
|
+
|
|
25
|
+
let randomString = generateRandomString(5);
|
|
26
|
+
permalinkText += '-' + randomString;
|
|
27
|
+
return permalinkText;
|
|
28
|
+
}
|
|
29
|
+
|
|
6
30
|
|
|
7
31
|
async function getDefaultDocTemplte(tx: any, type: string) {
|
|
8
32
|
|
|
@@ -234,6 +258,90 @@ async function plans(tx: any) {
|
|
|
234
258
|
}
|
|
235
259
|
|
|
236
260
|
|
|
261
|
+
async function mentorshipCategory(tx: any) {
|
|
262
|
+
|
|
263
|
+
var categories = [
|
|
264
|
+
{
|
|
265
|
+
category: {
|
|
266
|
+
name: 'Graphic Design'
|
|
267
|
+
},
|
|
268
|
+
translation: [
|
|
269
|
+
{
|
|
270
|
+
key: 'name',
|
|
271
|
+
value: 'Graphic Design',
|
|
272
|
+
lang: "en"
|
|
273
|
+
},
|
|
274
|
+
{
|
|
275
|
+
key: 'name',
|
|
276
|
+
value: 'Graphic Design',
|
|
277
|
+
lang: "ar"
|
|
278
|
+
},
|
|
279
|
+
{
|
|
280
|
+
key: 'description',
|
|
281
|
+
value: 'Graphic Design',
|
|
282
|
+
lang: "en"
|
|
283
|
+
},
|
|
284
|
+
{
|
|
285
|
+
key: 'description',
|
|
286
|
+
value: 'Graphic Design',
|
|
287
|
+
lang: "ar"
|
|
288
|
+
}
|
|
289
|
+
]
|
|
290
|
+
},
|
|
291
|
+
{
|
|
292
|
+
category: {
|
|
293
|
+
name: 'Backend Development'
|
|
294
|
+
},
|
|
295
|
+
translation: [
|
|
296
|
+
{
|
|
297
|
+
key: 'name',
|
|
298
|
+
value: 'Backend Development',
|
|
299
|
+
lang: "en"
|
|
300
|
+
},
|
|
301
|
+
{
|
|
302
|
+
key: 'name',
|
|
303
|
+
value: 'Backend Development',
|
|
304
|
+
lang: "ar"
|
|
305
|
+
},
|
|
306
|
+
{
|
|
307
|
+
key: 'description',
|
|
308
|
+
value: 'Backend Development',
|
|
309
|
+
lang: "en"
|
|
310
|
+
},
|
|
311
|
+
{
|
|
312
|
+
key: 'description',
|
|
313
|
+
value: 'Backend Development',
|
|
314
|
+
lang: "ar"
|
|
315
|
+
}
|
|
316
|
+
]
|
|
317
|
+
},
|
|
318
|
+
];
|
|
319
|
+
|
|
320
|
+
for (const category of categories) {
|
|
321
|
+
var savedCategory = await tx.mnCategory.create({
|
|
322
|
+
data: {
|
|
323
|
+
name: category.category.name,
|
|
324
|
+
status: true,
|
|
325
|
+
description:'',
|
|
326
|
+
icon:'icon',
|
|
327
|
+
permalink: toPermalink(category.category.name)
|
|
328
|
+
}
|
|
329
|
+
});
|
|
330
|
+
|
|
331
|
+
for (const categoryTranslation of category.translation) {
|
|
332
|
+
await tx.mnCategoryTranslation.create({
|
|
333
|
+
data: {
|
|
334
|
+
key: categoryTranslation.key,
|
|
335
|
+
value: categoryTranslation.value,
|
|
336
|
+
lang: categoryTranslation.lang,
|
|
337
|
+
categoryId: savedCategory.id
|
|
338
|
+
}
|
|
339
|
+
})
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
|
|
237
345
|
async function mnPrograms() {
|
|
238
346
|
|
|
239
347
|
}
|
|
@@ -243,9 +351,10 @@ async function mentors() {
|
|
|
243
351
|
|
|
244
352
|
}
|
|
245
353
|
|
|
246
|
-
async function skillRepo(tx: any) {
|
|
247
354
|
|
|
248
355
|
|
|
356
|
+
async function skillRepo(tx: any) {
|
|
357
|
+
|
|
249
358
|
var skills = [
|
|
250
359
|
{
|
|
251
360
|
skill: {
|
|
@@ -842,6 +951,7 @@ async function main() {
|
|
|
842
951
|
await prisma.$transaction(async (tx) => {
|
|
843
952
|
await plansPerks(tx);
|
|
844
953
|
await plans(tx);
|
|
954
|
+
await mentorshipCategory(tx)
|
|
845
955
|
await skillRepo(tx);
|
|
846
956
|
await colorRepo(tx);
|
|
847
957
|
await fontsRepo(tx);
|
package/package.json
CHANGED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Warnings:
|
|
3
|
+
|
|
4
|
+
- You are about to alter the column `status` on the `mentor` table. The data in that column could be lost. The data in that column will be cast from `Int` to `TinyInt`.
|
|
5
|
+
|
|
6
|
+
*/
|
|
7
|
+
-- AlterTable
|
|
8
|
+
ALTER TABLE `mentor` MODIFY `status` BOOLEAN NOT NULL DEFAULT false;
|
|
9
|
+
|
|
10
|
+
-- CreateTable
|
|
11
|
+
CREATE TABLE `UserFavoriteMentor` (
|
|
12
|
+
`id` INTEGER NOT NULL AUTO_INCREMENT,
|
|
13
|
+
`userId` INTEGER NOT NULL,
|
|
14
|
+
`mentorId` INTEGER NOT NULL,
|
|
15
|
+
|
|
16
|
+
UNIQUE INDEX `UserFavoriteMentor_userId_key`(`userId`),
|
|
17
|
+
UNIQUE INDEX `UserFavoriteMentor_mentorId_key`(`mentorId`),
|
|
18
|
+
PRIMARY KEY (`id`)
|
|
19
|
+
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
|
20
|
+
|
|
21
|
+
-- AddForeignKey
|
|
22
|
+
ALTER TABLE `UserFavoriteMentor` ADD CONSTRAINT `UserFavoriteMentor_mentorId_fkey` FOREIGN KEY (`mentorId`) REFERENCES `Mentor`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
|
23
|
+
|
|
24
|
+
-- AddForeignKey
|
|
25
|
+
ALTER TABLE `UserFavoriteMentor` ADD CONSTRAINT `UserFavoriteMentor_userId_fkey` FOREIGN KEY (`userId`) REFERENCES `User`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
package/prisma/schema.prisma
CHANGED
|
@@ -116,6 +116,8 @@ model User {
|
|
|
116
116
|
Referral Referral? @relation(fields: [referralId], references: [id])
|
|
117
117
|
UserAvailablity UserAvailablity[]
|
|
118
118
|
AiCvChat AiCvChat[]
|
|
119
|
+
|
|
120
|
+
UserFavoriteMentor UserFavoriteMentor[]
|
|
119
121
|
}
|
|
120
122
|
|
|
121
123
|
model UserMeta {
|
|
@@ -151,6 +153,16 @@ model UserAvailablitySlot {
|
|
|
151
153
|
UserAvailablity UserAvailablity @relation(fields: [userAvailablityId], references: [id])
|
|
152
154
|
}
|
|
153
155
|
|
|
156
|
+
model UserFavoriteMentor {
|
|
157
|
+
id Int @id @default(autoincrement())
|
|
158
|
+
userId Int @unique
|
|
159
|
+
mentorId Int @unique
|
|
160
|
+
Mentor Mentor @relation(fields: [mentorId], references: [id])
|
|
161
|
+
User User @relation(fields: [userId], references: [id])
|
|
162
|
+
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
|
|
154
166
|
model Referral {
|
|
155
167
|
id Int @id @default(autoincrement())
|
|
156
168
|
userId Int @unique
|
|
@@ -548,6 +560,8 @@ model Mentor {
|
|
|
548
560
|
MnProgramRequest MnProgramRequest[]
|
|
549
561
|
MentorAvailablity MentorAvailablity[]
|
|
550
562
|
// MnProgramMeet MnProgramMeet[]
|
|
563
|
+
|
|
564
|
+
UserFavoriteMentor UserFavoriteMentor[]
|
|
551
565
|
}
|
|
552
566
|
|
|
553
567
|
model MentorAvailablity {
|