Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update schema #76

Merged
merged 2 commits into from
Jan 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading