Files
digicraft-be/prisma/migrations/20260102231739_add_user_model_and_relations/migration.sql
Fahri Can Seçer 80dcf4d04a
Some checks failed
Deploy Backend / deploy (push) Has been cancelled
main
2026-02-05 01:29:22 +03:00

43 lines
1.7 KiB
SQL

-- CreateTable
CREATE TABLE "User" (
"id" TEXT NOT NULL PRIMARY KEY,
"email" TEXT NOT NULL,
"passwordHash" TEXT NOT NULL,
"role" TEXT NOT NULL DEFAULT 'USER',
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP
);
-- RedefineTables
PRAGMA foreign_keys=OFF;
CREATE TABLE "new_BrandProfile" (
"id" TEXT NOT NULL PRIMARY KEY,
"name" TEXT NOT NULL,
"referencePaths" TEXT NOT NULL,
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
"userId" TEXT,
CONSTRAINT "BrandProfile_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User" ("id") ON DELETE SET NULL ON UPDATE CASCADE
);
INSERT INTO "new_BrandProfile" ("createdAt", "id", "name", "referencePaths") SELECT "createdAt", "id", "name", "referencePaths" FROM "BrandProfile";
DROP TABLE "BrandProfile";
ALTER TABLE "new_BrandProfile" RENAME TO "BrandProfile";
CREATE UNIQUE INDEX "BrandProfile_name_key" ON "BrandProfile"("name");
CREATE TABLE "new_Project" (
"id" TEXT NOT NULL PRIMARY KEY,
"niche" TEXT NOT NULL,
"productType" TEXT NOT NULL,
"creativity" TEXT NOT NULL,
"status" TEXT NOT NULL DEFAULT 'draft',
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" DATETIME NOT NULL,
"userId" TEXT,
CONSTRAINT "Project_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User" ("id") ON DELETE SET NULL ON UPDATE CASCADE
);
INSERT INTO "new_Project" ("createdAt", "creativity", "id", "niche", "productType", "status", "updatedAt") SELECT "createdAt", "creativity", "id", "niche", "productType", "status", "updatedAt" FROM "Project";
DROP TABLE "Project";
ALTER TABLE "new_Project" RENAME TO "Project";
PRAGMA foreign_key_check;
PRAGMA foreign_keys=ON;
-- CreateIndex
CREATE UNIQUE INDEX "User_email_key" ON "User"("email");