mirror of
https://github.com/stonith404/pingvin-share.git
synced 2024-11-05 23:40:12 +01:00
76 lines
2.3 KiB
SQL
76 lines
2.3 KiB
SQL
-- CreateTable
|
|
CREATE TABLE "User" (
|
|
"id" TEXT NOT NULL,
|
|
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
"updatedAt" TIMESTAMP(3) NOT NULL,
|
|
"email" TEXT NOT NULL,
|
|
"password" TEXT NOT NULL,
|
|
"firstName" TEXT,
|
|
"lastName" TEXT,
|
|
|
|
CONSTRAINT "User_pkey" PRIMARY KEY ("id")
|
|
);
|
|
|
|
-- CreateTable
|
|
CREATE TABLE "RefreshToken" (
|
|
"token" TEXT NOT NULL,
|
|
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
"expiresAt" TIMESTAMP(3) NOT NULL DEFAULT NOW() + interval '3 months',
|
|
"userId" TEXT NOT NULL,
|
|
|
|
CONSTRAINT "RefreshToken_pkey" PRIMARY KEY ("token")
|
|
);
|
|
|
|
-- CreateTable
|
|
CREATE TABLE "Share" (
|
|
"id" TEXT NOT NULL,
|
|
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
"uploadLocked" BOOLEAN NOT NULL DEFAULT false,
|
|
"isZipReady" BOOLEAN NOT NULL DEFAULT false,
|
|
"views" INTEGER NOT NULL DEFAULT 0,
|
|
"expiration" TIMESTAMP(3) NOT NULL,
|
|
"creatorId" TEXT NOT NULL,
|
|
|
|
CONSTRAINT "Share_pkey" PRIMARY KEY ("id")
|
|
);
|
|
|
|
-- CreateTable
|
|
CREATE TABLE "File" (
|
|
"id" TEXT NOT NULL,
|
|
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
"name" TEXT NOT NULL,
|
|
"size" TEXT NOT NULL,
|
|
"shareId" TEXT NOT NULL,
|
|
|
|
CONSTRAINT "File_pkey" PRIMARY KEY ("id")
|
|
);
|
|
|
|
-- CreateTable
|
|
CREATE TABLE "ShareSecurity" (
|
|
"id" TEXT NOT NULL,
|
|
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
"password" TEXT,
|
|
"maxViews" INTEGER,
|
|
"shareId" TEXT,
|
|
|
|
CONSTRAINT "ShareSecurity_pkey" PRIMARY KEY ("id")
|
|
);
|
|
|
|
-- CreateIndex
|
|
CREATE UNIQUE INDEX "User_email_key" ON "User"("email");
|
|
|
|
-- CreateIndex
|
|
CREATE UNIQUE INDEX "ShareSecurity_shareId_key" ON "ShareSecurity"("shareId");
|
|
|
|
-- AddForeignKey
|
|
ALTER TABLE "RefreshToken" ADD CONSTRAINT "RefreshToken_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
|
|
|
-- AddForeignKey
|
|
ALTER TABLE "Share" ADD CONSTRAINT "Share_creatorId_fkey" FOREIGN KEY ("creatorId") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
|
|
|
-- AddForeignKey
|
|
ALTER TABLE "File" ADD CONSTRAINT "File_shareId_fkey" FOREIGN KEY ("shareId") REFERENCES "Share"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
|
|
|
-- AddForeignKey
|
|
ALTER TABLE "ShareSecurity" ADD CONSTRAINT "ShareSecurity_shareId_fkey" FOREIGN KEY ("shareId") REFERENCES "Share"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|