···11+-- CreateTable: profiles (absorbs user_profiles)
22+CREATE TABLE "profiles" (
33+ "id" TEXT NOT NULL,
44+ "userId" TEXT NOT NULL,
55+ "name" TEXT NOT NULL,
66+ "fullName" TEXT,
77+ "headline" TEXT,
88+ "encryptedPhone" TEXT,
99+ "encryptedAddress" TEXT,
1010+ "encryptedPostalCode" TEXT,
1111+ "city" TEXT,
1212+ "country" TEXT,
1313+ "website" TEXT,
1414+ "linkedInUrl" TEXT,
1515+ "summary" TEXT,
1616+ "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
1717+ "updatedAt" TIMESTAMP(3) NOT NULL,
1818+1919+ CONSTRAINT "profiles_pkey" PRIMARY KEY ("id")
2020+);
2121+2222+-- Migrate existing user_profiles into profiles
2323+INSERT INTO "profiles" ("id", "userId", "name", "fullName", "headline", "encryptedPhone", "encryptedAddress", "encryptedPostalCode", "city", "country", "website", "linkedInUrl", "summary", "createdAt", "updatedAt")
2424+SELECT "id", "userId", 'Default', "fullName", "headline", "encryptedPhone", "encryptedAddress", "encryptedPostalCode", "city", "country", "website", "linkedInUrl", "summary", "createdAt", "updatedAt"
2525+FROM "user_profiles";
2626+2727+-- Create profiles for users who don't have one yet
2828+INSERT INTO "profiles" ("id", "userId", "name", "createdAt", "updatedAt")
2929+SELECT gen_random_uuid()::text, u."id", 'Default', NOW(), NOW()
3030+FROM "users" u
3131+WHERE NOT EXISTS (SELECT 1 FROM "profiles" p WHERE p."userId" = u."id");
3232+3333+-- Add profileId column to educations (nullable initially)
3434+ALTER TABLE "educations" ADD COLUMN "profileId" TEXT;
3535+3636+-- Populate profileId from userId
3737+UPDATE "educations" e
3838+SET "profileId" = (SELECT p."id" FROM "profiles" p WHERE p."userId" = e."userId" LIMIT 1);
3939+4040+-- Make profileId NOT NULL and add FK
4141+ALTER TABLE "educations" ALTER COLUMN "profileId" SET NOT NULL;
4242+ALTER TABLE "educations" ADD CONSTRAINT "educations_profileId_fkey" FOREIGN KEY ("profileId") REFERENCES "profiles"("id") ON DELETE CASCADE ON UPDATE CASCADE;
4343+4444+-- Drop old userId FK and column from educations
4545+ALTER TABLE "educations" DROP CONSTRAINT "educations_userId_fkey";
4646+ALTER TABLE "educations" DROP COLUMN "userId";
4747+4848+-- Add profileId column to user_job_experiences (nullable initially)
4949+ALTER TABLE "user_job_experiences" ADD COLUMN "profileId" TEXT;
5050+5151+-- Populate profileId from userId
5252+UPDATE "user_job_experiences" uje
5353+SET "profileId" = (SELECT p."id" FROM "profiles" p WHERE p."userId" = uje."userId" LIMIT 1);
5454+5555+-- Make profileId NOT NULL and add FK
5656+ALTER TABLE "user_job_experiences" ALTER COLUMN "profileId" SET NOT NULL;
5757+ALTER TABLE "user_job_experiences" ADD CONSTRAINT "user_job_experiences_profileId_fkey" FOREIGN KEY ("profileId") REFERENCES "profiles"("id") ON DELETE CASCADE ON UPDATE CASCADE;
5858+5959+-- Drop old userId FK and column from user_job_experiences
6060+ALTER TABLE "user_job_experiences" DROP CONSTRAINT "user_job_experiences_userId_fkey";
6161+ALTER TABLE "user_job_experiences" DROP COLUMN "userId";
6262+6363+-- Add profileId column to cvs (nullable initially)
6464+ALTER TABLE "cvs" ADD COLUMN "profileId" TEXT;
6565+6666+-- Populate profileId from userId
6767+UPDATE "cvs" c
6868+SET "profileId" = (SELECT p."id" FROM "profiles" p WHERE p."userId" = c."userId" LIMIT 1);
6969+7070+-- Make profileId NOT NULL and add FK
7171+ALTER TABLE "cvs" ALTER COLUMN "profileId" SET NOT NULL;
7272+ALTER TABLE "cvs" ADD CONSTRAINT "cvs_profileId_fkey" FOREIGN KEY ("profileId") REFERENCES "profiles"("id") ON DELETE CASCADE ON UPDATE CASCADE;
7373+7474+-- Drop old userId FK and column from cvs
7575+ALTER TABLE "cvs" DROP CONSTRAINT "cvs_userId_fkey";
7676+ALTER TABLE "cvs" DROP COLUMN "userId";
7777+7878+-- Add profileId column to user_files (nullable initially)
7979+ALTER TABLE "user_files" ADD COLUMN "profileId" TEXT;
8080+8181+-- Populate profileId from userId
8282+UPDATE "user_files" uf
8383+SET "profileId" = (SELECT p."id" FROM "profiles" p WHERE p."userId" = uf."userId" LIMIT 1);
8484+8585+-- Make profileId NOT NULL and add FK
8686+ALTER TABLE "user_files" ALTER COLUMN "profileId" SET NOT NULL;
8787+ALTER TABLE "user_files" ADD CONSTRAINT "user_files_profileId_fkey" FOREIGN KEY ("profileId") REFERENCES "profiles"("id") ON DELETE CASCADE ON UPDATE CASCADE;
8888+8989+-- Drop old userId FK and column from user_files
9090+ALTER TABLE "user_files" DROP CONSTRAINT "user_files_userId_fkey";
9191+ALTER TABLE "user_files" DROP COLUMN "userId";
9292+9393+-- Add profileId column to applications (nullable initially)
9494+ALTER TABLE "applications" ADD COLUMN "profileId" TEXT;
9595+9696+-- Populate profileId from userId
9797+UPDATE "applications" a
9898+SET "profileId" = (SELECT p."id" FROM "profiles" p WHERE p."userId" = a."userId" LIMIT 1);
9999+100100+-- Make profileId NOT NULL and add FK
101101+ALTER TABLE "applications" ALTER COLUMN "profileId" SET NOT NULL;
102102+ALTER TABLE "applications" ADD CONSTRAINT "applications_profileId_fkey" FOREIGN KEY ("profileId") REFERENCES "profiles"("id") ON DELETE CASCADE ON UPDATE CASCADE;
103103+104104+-- Note: applications keeps userId (for @@unique([userId, vacancyId]) constraint)
105105+106106+-- Add FK from profiles to users
107107+ALTER TABLE "profiles" ADD CONSTRAINT "profiles_userId_fkey" FOREIGN KEY ("userId") REFERENCES "users"("id") ON DELETE CASCADE ON UPDATE CASCADE;
108108+109109+-- Drop old user_profiles table
110110+DROP TABLE "user_profiles";
···11// This is your Prisma schema file,
22// learn more about it in the docs: https://pris.ly/d/prisma-schema
3344+// output: pnpm hoists .prisma/client to the workspace root but prisma generate
55+// writes to the pnpm store by default. Explicit output ensures types land where
66+// TypeScript actually resolves them (relative to this prisma/ directory).
47generator client {
55- provider = "prisma-client-js"
88+ provider = "prisma-client-js"
99+ output = "../../../node_modules/.prisma/client"
610 enableTracing = false
77- binaryTargets = ["native", "darwin-arm64", "linux-musl-arm64-openssl-3.0.x"]
1111+ binaryTargets = ["native", "darwin-arm64", "debian-openssl-3.0.x"]
812}
9131014datasource db {