fix: db migration

This commit is contained in:
Andras Bacsai 2022-09-22 09:02:39 +02:00
parent 011ea9659e
commit 550150d685
3 changed files with 12 additions and 23 deletions

View File

@ -1,22 +0,0 @@
-- CreateTable
CREATE TABLE "Certificate" (
"id" TEXT NOT NULL PRIMARY KEY,
"key" TEXT NOT NULL,
"cert" TEXT NOT NULL,
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" DATETIME NOT NULL
);
-- CreateTable
CREATE TABLE "_CertificateToTeam" (
"A" TEXT NOT NULL,
"B" TEXT NOT NULL,
CONSTRAINT "_CertificateToTeam_A_fkey" FOREIGN KEY ("A") REFERENCES "Certificate" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT "_CertificateToTeam_B_fkey" FOREIGN KEY ("B") REFERENCES "Team" ("id") ON DELETE CASCADE ON UPDATE CASCADE
);
-- CreateIndex
CREATE UNIQUE INDEX "_CertificateToTeam_AB_unique" ON "_CertificateToTeam"("A", "B");
-- CreateIndex
CREATE INDEX "_CertificateToTeam_B_index" ON "_CertificateToTeam"("B");

View File

@ -0,0 +1,10 @@
-- CreateTable
CREATE TABLE "Certificate" (
"id" TEXT NOT NULL PRIMARY KEY,
"key" TEXT NOT NULL,
"cert" TEXT NOT NULL,
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" DATETIME NOT NULL,
"teamId" TEXT,
CONSTRAINT "Certificate_teamId_fkey" FOREIGN KEY ("teamId") REFERENCES "Team" ("id") ON DELETE SET NULL ON UPDATE CASCADE
);

View File

@ -12,9 +12,10 @@ model Certificate {
id String @id @default(cuid())
key String
cert String
team Team[]
team Team? @relation(fields: [teamId], references: [id])
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
teamId String?
}
model Setting {