diff --git a/prisma/migrations/20241021191938_somfadf/migration.sql b/prisma/migrations/20241021191938_somfadf/migration.sql new file mode 100644 index 00000000..21f638de --- /dev/null +++ b/prisma/migrations/20241021191938_somfadf/migration.sql @@ -0,0 +1,18 @@ +-- CreateEnum +CREATE TYPE "ProjectStack" AS ENUM ('GO', 'PYTHON', 'MERN', 'NEXTJS', 'AI_GPT_APIS', 'SPRINGBOOT', 'OTHERS'); + +-- DropForeignKey +ALTER TABLE "Experience" DROP CONSTRAINT "Experience_userId_fkey"; + +-- DropForeignKey +ALTER TABLE "Project" DROP CONSTRAINT "Project_userId_fkey"; + +-- AlterTable +ALTER TABLE "Project" ADD COLUMN "projectThumbnail" TEXT, +ADD COLUMN "stack" "ProjectStack" NOT NULL DEFAULT 'OTHERS'; + +-- AddForeignKey +ALTER TABLE "Experience" ADD CONSTRAINT "Experience_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "Project" ADD CONSTRAINT "Project_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; diff --git a/prisma/seed.ts b/prisma/seed.ts index 27d6685a..5aa0b4a8 100644 --- a/prisma/seed.ts +++ b/prisma/seed.ts @@ -13,7 +13,7 @@ const prisma = new PrismaClient(); const users = [ { id: '1', name: 'Jack', email: 'user@gmail.com' }, - { id: '2', name: 'Admin', email: 'admin@gmail.com', role: Role.ADMIN , onBoard : true }, + { id: '2', name: 'Admin', email: 'admin@gmail.com', role: Role.ADMIN, onBoard: true }, { id: '3', name: 'Hr', email: 'hr@gmail.com', role: Role.HR }, ]; @@ -63,6 +63,7 @@ let jobs = [ minSalary: null, maxSalary: null, isVerifiedJob: false, + }, { id: '3', @@ -86,6 +87,7 @@ let jobs = [ minSalary: 90000, maxSalary: 120000, isVerifiedJob: true, + deleted: true }, { id: '4', @@ -134,6 +136,7 @@ let jobs = [ minSalary: 110000, maxSalary: 150000, isVerifiedJob: true, + deleted: true }, { id: '6', @@ -159,6 +162,7 @@ let jobs = [ minSalary: 80000, maxSalary: 100000, isVerifiedJob: false, + }, { id: '7', @@ -183,6 +187,8 @@ let jobs = [ minSalary: 70000, maxSalary: 90000, isVerifiedJob: false, + delted: true + }, { id: '8', @@ -207,6 +213,8 @@ let jobs = [ minSalary: null, maxSalary: null, isVerifiedJob: true, + deleted: true + }, { id: '9', @@ -229,6 +237,7 @@ let jobs = [ minSalary: 100000, maxSalary: 130000, isVerifiedJob: true, + }, { id: '10', @@ -253,6 +262,7 @@ let jobs = [ minSalary: 75000, maxSalary: 95000, isVerifiedJob: false, + }, { id: '11', @@ -274,6 +284,7 @@ let jobs = [ minSalary: 25000, maxSalary: 50000, isVerifiedJob: true, + }, { id: '12', @@ -298,6 +309,7 @@ let jobs = [ minSalary: null, maxSalary: null, isVerifiedJob: true, + delted: false }, ]; diff --git a/src/actions/job.action.ts b/src/actions/job.action.ts index 4948a62a..fb1120fb 100644 --- a/src/actions/job.action.ts +++ b/src/actions/job.action.ts @@ -135,6 +135,7 @@ export const getAllJobs = withSession< ? { ...filterQueries } : { isVerifiedJob: true, + deleted: false, ...filterQueries, expired: false, }), @@ -195,6 +196,7 @@ export const getRecommendedJobs = withServerActionAsyncCatcher< id: { not: id }, isVerifiedJob: true, expired: false, + deleted: false, }, orderBy: { postedAt: 'desc', @@ -227,6 +229,7 @@ export const getRecommendedJobs = withServerActionAsyncCatcher< where: { id: { not: id }, expired: false, + deleted: false, }, orderBy: { postedAt: 'desc', @@ -273,7 +276,7 @@ export const getJobById = withServerActionAsyncCatcher< const result = JobByIdSchema.parse(data); const { id } = result; const job = await prisma.job.findFirst({ - where: { id, expired: false }, + where: { id, expired: false, deleted: false }, select: { id: true, title: true, @@ -308,8 +311,12 @@ export const getJobById = withServerActionAsyncCatcher< export const getCityFilters = async () => { const response = await prisma.job.findMany({ - select: { + where: { + isVerifiedJob: true, expired: false, + deleted: false, + }, + select: { city: true, }, }); @@ -324,6 +331,7 @@ export const getRecentJobs = async () => { const recentJobs = await prisma.job.findMany({ where: { isVerifiedJob: true, + deleted: false, expired: false, }, orderBy: {