Skip to content

Commit

Permalink
Sync constants with db enums code100x#289 (code100x#299)
Browse files Browse the repository at this point in the history
* sync-db

* contants-db-sync

* keys-fix

* key

---------

Co-authored-by: Aakash  Singh <[email protected]>
  • Loading branch information
aakash2330 and Aakash Singh authored Sep 4, 2024
1 parent a3c7c9c commit bf2055e
Show file tree
Hide file tree
Showing 9 changed files with 138 additions and 135 deletions.
50 changes: 50 additions & 0 deletions prisma/migrations/20240901095201_/migration.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
-- CreateEnum
CREATE TYPE "Currency" AS ENUM ('INR', 'USD');

-- CreateEnum
CREATE TYPE "WorkMode" AS ENUM ('remote', 'hybrid', 'office');

-- CreateEnum
CREATE TYPE "Role" AS ENUM ('USER', 'ADMIN');

-- CreateEnum
CREATE TYPE "Location" AS ENUM ('BANGLORE', 'DELHI', 'MUMBAI', 'PUNE', 'CHENNAI', 'HYDERABAD', 'KOLKATA', 'AHMEDABAD', 'JAIPUR', 'SURAT');

-- CreateTable
CREATE TABLE "User" (
"id" TEXT NOT NULL,
"name" TEXT NOT NULL,
"email" TEXT NOT NULL,
"password" TEXT NOT NULL,
"avatar" TEXT,
"isVerified" BOOLEAN NOT NULL DEFAULT false,
"role" "Role" NOT NULL DEFAULT 'USER',

CONSTRAINT "User_pkey" PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "Job" (
"id" TEXT NOT NULL,
"userId" TEXT NOT NULL,
"title" TEXT NOT NULL,
"description" TEXT,
"company_name" TEXT NOT NULL,
"work_mode" "WorkMode" NOT NULL,
"currency" "Currency" NOT NULL DEFAULT 'INR',
"location" "Location" NOT NULL,
"has_salary_range" BOOLEAN NOT NULL DEFAULT false,
"minSalary" INTEGER,
"maxSalary" INTEGER,
"is_verified_job" BOOLEAN NOT NULL DEFAULT false,
"postedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMP(3) NOT NULL,

CONSTRAINT "Job_pkey" PRIMARY KEY ("id")
);

-- CreateIndex
CREATE UNIQUE INDEX "User_email_key" ON "User"("email");

-- AddForeignKey
ALTER TABLE "Job" ADD CONSTRAINT "Job_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
15 changes: 15 additions & 0 deletions prisma/migrations/20240902211016_/migration.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/*
Warnings:
- Changed the type of `location` on the `Job` table. No cast exists, the column would be dropped and recreated, which cannot be done if there is data, since the column is required.
*/
-- CreateEnum
CREATE TYPE "JobLocations" AS ENUM ('BANGLORE', 'DELHI', 'MUMBAI', 'PUNE', 'CHENNAI', 'HYDERABAD', 'KOLKATA', 'AHMEDABAD', 'JAIPUR', 'SURAT');

-- AlterTable
ALTER TABLE "Job" DROP COLUMN "location",
ADD COLUMN "location" "JobLocations" NOT NULL;

-- DropEnum
DROP TYPE "Location";
3 changes: 3 additions & 0 deletions prisma/migrations/migration_lock.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Please do not edit this file manually
# It should be added in your version-control system (i.e. Git)
provider = "postgresql"
40 changes: 27 additions & 13 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -7,34 +7,35 @@ datasource db {
url = env("DATABASE_URL")
}

model User{
model User {
id String @id @default(cuid())
name String
email String @unique
password String
password String
avatar String?
isVerified Boolean @default(false)
role Role @default(USER)
jobs Job[]
}

model Job {
id String @id @default(cuid())
model Job {
id String @id @default(cuid())
userId String
title String
description String?
companyName String @map("company_name")
workMode WorkMode @map("work_mode")
currency Currency @default(INR)
location String
hasSalaryRange Boolean @default(false) @map("has_salary_range")
companyName String @map("company_name")
workMode WorkMode @map("work_mode")
currency Currency @default(INR)
location JobLocations
hasSalaryRange Boolean @default(false) @map("has_salary_range")
minSalary Int?
maxSalary Int?
isVerifiedJob Boolean @default(false) @map("is_verified_job")
postedAt DateTime @default(now())
updatedAt DateTime @updatedAt
user User @relation(fields: [userId], references: [id])
isVerifiedJob Boolean @default(false) @map("is_verified_job")
postedAt DateTime @default(now())
updatedAt DateTime @updatedAt
user User @relation(fields: [userId], references: [id])
}

enum Currency {
INR
USD
Expand All @@ -50,3 +51,16 @@ enum Role {
USER
ADMIN
}

enum JobLocations {
BANGLORE
DELHI
MUMBAI
PUNE
CHENNAI
HYDERABAD
KOLKATA
AHMEDABAD
JAIPUR
SURAT
}
Loading

0 comments on commit bf2055e

Please sign in to comment.