42 lines
1.3 KiB
SQL
42 lines
1.3 KiB
SQL
-- CreateTable
|
|
CREATE TABLE "Profile" (
|
|
"id" TEXT NOT NULL,
|
|
"name" TEXT NOT NULL,
|
|
"email" TEXT NOT NULL,
|
|
"alamat" TEXT NOT NULL,
|
|
"jenisKelamin" TEXT NOT NULL,
|
|
"active" BOOLEAN NOT NULL DEFAULT true,
|
|
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
"updatedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
"userId" TEXT,
|
|
"imagesId" TEXT,
|
|
|
|
CONSTRAINT "Profile_pkey" PRIMARY KEY ("id")
|
|
);
|
|
|
|
-- CreateTable
|
|
CREATE TABLE "Images" (
|
|
"id" TEXT NOT NULL,
|
|
"url" TEXT NOT NULL,
|
|
"active" BOOLEAN NOT NULL DEFAULT true,
|
|
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
"updatedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
|
|
CONSTRAINT "Images_pkey" PRIMARY KEY ("id")
|
|
);
|
|
|
|
-- CreateIndex
|
|
CREATE UNIQUE INDEX "Profile_email_key" ON "Profile"("email");
|
|
|
|
-- CreateIndex
|
|
CREATE UNIQUE INDEX "Profile_userId_key" ON "Profile"("userId");
|
|
|
|
-- CreateIndex
|
|
CREATE UNIQUE INDEX "Profile_imagesId_key" ON "Profile"("imagesId");
|
|
|
|
-- AddForeignKey
|
|
ALTER TABLE "Profile" ADD CONSTRAINT "Profile_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
|
|
|
-- AddForeignKey
|
|
ALTER TABLE "Profile" ADD CONSTRAINT "Profile_imagesId_fkey" FOREIGN KEY ("imagesId") REFERENCES "Images"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|