Skip to content

Commit

Permalink
Merge pull request #76 from richard483/fix-1
Browse files Browse the repository at this point in the history
update schema
  • Loading branch information
richard483 authored Jan 28, 2024
2 parents 8d95e11 + 584e26e commit b6fd03e
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 266 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "backend-8tech",
"version": "4.2.7",
"version": "4.2.8",
"description": "",
"author": "8tech",
"private": true,
Expand Down
41 changes: 19 additions & 22 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,24 @@ datasource db {
}

model User {
id String @id @default(uuid())
email String @unique
username String @unique
firstName String
lastName String
password String?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
roles Role[] @default([USER])
description String?
previousWorkplaceId String[]
previousWorkplaceCount Int?
ratings Rating[]
cv String?
companyId String?
portfolio String[] @map("portfolio")
profilePicture String?
hasGoogleAccount Boolean @default(false)
company Company? @relation(fields: [companyId], references: [id], onDelete: Cascade)
contract Contract[]
id String @id @default(uuid())
email String @unique
username String @unique
firstName String
lastName String
password String?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
roles Role[] @default([USER])
description String?
ratings Rating[]
cv String?
companyId String?
portfolio String[] @map("portfolio")
profilePicture String?
hasGoogleAccount Boolean @default(false)
company Company? @relation(fields: [companyId], references: [id], onDelete: Cascade)
contract Contract[]
}

model JobVacancy {
Expand All @@ -42,9 +40,8 @@ model JobVacancy {
description String
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
// company Id is optional for current development purposes
company Company? @relation(fields: [companyId], references: [id], onDelete: Cascade)
companyId String?
companyId String
contracts Contract[]
}

Expand Down
235 changes: 11 additions & 224 deletions prisma/seed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,29 +53,6 @@ async function users() {
password: hashPassword('User123_'),
roles: ['USER'],
description: 'default richard description that being created by seed.ts',
previousWorkplaceId: [
await prisma.company
.findFirst({
where: {
name: 'Nijisanji Anycolor',
},
})
.then((company) => company.id),
await prisma.company
.findFirst({
where: {
name: 'Hololive',
},
})
.then((company) => company.id),
await prisma.company
.findFirst({
where: {
name: 'Djarum',
},
})
.then((company) => company.id),
],
},
});
const defaultUser = await prisma.user.upsert({
Expand All @@ -89,29 +66,6 @@ async function users() {
password: hashPassword('User123_'),
roles: ['USER'],
description: 'default user description that being created by seed.ts',
previousWorkplaceId: [
await prisma.company
.findFirst({
where: {
name: 'Nijisanji Anycolor',
},
})
.then((company) => company.id),
await prisma.company
.findFirst({
where: {
name: 'Hololive',
},
})
.then((company) => company.id),
await prisma.company
.findFirst({
where: {
name: 'Djarum',
},
})
.then((company) => company.id),
],
},
});
const notADefaultUser = await prisma.user.upsert({
Expand All @@ -125,15 +79,6 @@ async function users() {
password: hashPassword('User123_'),
roles: ['USER'],
description: 'notADefault user description that being created by seed.ts',
previousWorkplaceId: [
await prisma.company
.findFirst({
where: {
name: 'Nijisanji Anycolor',
},
})
.then((company) => company.id),
],
},
});
const mariaMarionetteUser = await prisma.user.upsert({
Expand All @@ -148,22 +93,6 @@ async function users() {
roles: ['USER'],
description:
'mariaMarionette user description that being created by seed.ts',
previousWorkplaceId: [
await prisma.company
.findFirst({
where: {
name: 'Nijisanji Anycolor',
},
})
.then((company) => company.id),
await prisma.company
.findFirst({
where: {
name: 'Djarum',
},
})
.then((company) => company.id),
],
},
});
const mikaUser = await prisma.user.upsert({
Expand All @@ -177,29 +106,6 @@ async function users() {
password: hashPassword('User123_'),
roles: ['USER'],
description: 'mika user description that being created by seed.ts',
previousWorkplaceId: [
await prisma.company
.findFirst({
where: {
name: 'Nijisanji Anycolor',
},
})
.then((company) => company.id),
await prisma.company
.findFirst({
where: {
name: 'Hololive',
},
})
.then((company) => company.id),
await prisma.company
.findFirst({
where: {
name: 'Djarum',
},
})
.then((company) => company.id),
],
},
});
const sonnyUser = await prisma.user.upsert({
Expand All @@ -213,22 +119,6 @@ async function users() {
password: hashPassword('User123_'),
roles: ['USER'],
description: 'sonny user description that being created by seed.ts',
previousWorkplaceId: [
await prisma.company
.findFirst({
where: {
name: 'Nijisanji Anycolor',
},
})
.then((company) => company.id),
await prisma.company
.findFirst({
where: {
name: 'Hololive',
},
})
.then((company) => company.id),
],
},
});
const ennaUser = await prisma.user.upsert({
Expand All @@ -242,29 +132,6 @@ async function users() {
password: hashPassword('User123_'),
roles: ['USER'],
description: 'enna user description that being created by seed.ts',
previousWorkplaceId: [
await prisma.company
.findFirst({
where: {
name: 'Nijisanji Anycolor',
},
})
.then((company) => company.id),
await prisma.company
.findFirst({
where: {
name: 'Hololive',
},
})
.then((company) => company.id),
await prisma.company
.findFirst({
where: {
name: 'Djarum',
},
})
.then((company) => company.id),
],
},
});
const satoruUser = await prisma.user.upsert({
Expand All @@ -278,29 +145,6 @@ async function users() {
password: hashPassword('User123_'),
roles: ['USER'],
description: 'satoru user description that being created by seed.ts',
previousWorkplaceId: [
await prisma.company
.findFirst({
where: {
name: 'Nijisanji Anycolor',
},
})
.then((company) => company.id),
await prisma.company
.findFirst({
where: {
name: 'Hololive',
},
})
.then((company) => company.id),
await prisma.company
.findFirst({
where: {
name: 'Djarum',
},
})
.then((company) => company.id),
],
},
});
const eyePatchUser = await prisma.user.upsert({
Expand All @@ -314,29 +158,6 @@ async function users() {
password: hashPassword('User123_'),
roles: ['USER'],
description: 'eyePatch user description that being created by seed.ts',
previousWorkplaceId: [
await prisma.company
.findFirst({
where: {
name: 'Nijisanji Anycolor',
},
})
.then((company) => company.id),
await prisma.company
.findFirst({
where: {
name: 'Hololive',
},
})
.then((company) => company.id),
await prisma.company
.findFirst({
where: {
name: 'Djarum',
},
})
.then((company) => company.id),
],
},
});
const ricatUser = await prisma.user.upsert({
Expand All @@ -350,56 +171,22 @@ async function users() {
password: hashPassword('User123_'),
roles: ['USER'],
description: 'ricat user description that being created by seed.ts',
previousWorkplaceId: [
await prisma.company
.findFirst({
where: {
name: 'Nijisanji Anycolor',
},
})
.then((company) => company.id),
await prisma.company
.findFirst({
where: {
name: 'Hololive',
},
})
.then((company) => company.id),
await prisma.company
.findFirst({
where: {
name: 'Djarum',
},
})
.then((company) => company.id),
],
},
});

console.log('Created recruiter user: ', recruiter);
console.log(
await [
admin,
defaultUser,
notADefaultUser,
mariaMarionetteUser,
mikaUser,
sonnyUser,
ennaUser,
satoruUser,
eyePatchUser,
ricatUser,
richardWilliam,
].map(async (user) => {
await prisma.user.update({
where: {
id: user.id,
},
data: {
previousWorkplaceCount: user.previousWorkplaceId.length,
},
});
}),
admin,
defaultUser,
notADefaultUser,
mariaMarionetteUser,
mikaUser,
sonnyUser,
ennaUser,
satoruUser,
eyePatchUser,
ricatUser,
richardWilliam,
);
}

Expand Down
1 change: 0 additions & 1 deletion src/users/interface/user.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ export interface IUser {
updatedAt: Date;
roles: string[] | Role[];
description: string;
previousWorkplaceId?: any;
ratings?: any;
companyId?: string;
portfolio: string[];
Expand Down
Loading

0 comments on commit b6fd03e

Please sign in to comment.