You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
113 lines
3.1 KiB
113 lines
3.1 KiB
2 years ago
|
-- CreateTable
|
||
|
CREATE TABLE "User" (
|
||
|
"id" SERIAL NOT NULL,
|
||
|
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||
|
"updatedAt" TIMESTAMP(3) NOT NULL,
|
||
|
"name" TEXT,
|
||
|
"email" TEXT NOT NULL,
|
||
|
"hashedPassword" TEXT,
|
||
|
"role" TEXT NOT NULL DEFAULT 'USER',
|
||
|
|
||
|
CONSTRAINT "User_pkey" PRIMARY KEY ("id")
|
||
|
);
|
||
|
|
||
|
-- CreateTable
|
||
|
CREATE TABLE "Session" (
|
||
|
"id" SERIAL NOT NULL,
|
||
|
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||
|
"updatedAt" TIMESTAMP(3) NOT NULL,
|
||
|
"expiresAt" TIMESTAMP(3),
|
||
|
"handle" TEXT NOT NULL,
|
||
|
"hashedSessionToken" TEXT,
|
||
|
"antiCSRFToken" TEXT,
|
||
|
"publicData" TEXT,
|
||
|
"privateData" TEXT,
|
||
|
"userId" INTEGER,
|
||
|
|
||
|
CONSTRAINT "Session_pkey" PRIMARY KEY ("id")
|
||
|
);
|
||
|
|
||
|
-- CreateTable
|
||
|
CREATE TABLE "Token" (
|
||
|
"id" SERIAL NOT NULL,
|
||
|
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||
|
"updatedAt" TIMESTAMP(3) NOT NULL,
|
||
|
"hashedToken" TEXT NOT NULL,
|
||
|
"type" TEXT NOT NULL,
|
||
|
"expiresAt" TIMESTAMP(3) NOT NULL,
|
||
|
"sentTo" TEXT NOT NULL,
|
||
|
"userId" INTEGER NOT NULL,
|
||
|
|
||
|
CONSTRAINT "Token_pkey" PRIMARY KEY ("id")
|
||
|
);
|
||
|
|
||
|
-- CreateTable
|
||
|
CREATE TABLE "SearchRequest" (
|
||
|
"id" SERIAL NOT NULL,
|
||
|
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||
|
"updatedAt" TIMESTAMP(3) NOT NULL,
|
||
|
"text" TEXT NOT NULL,
|
||
|
"count" INTEGER NOT NULL DEFAULT 0,
|
||
|
|
||
|
CONSTRAINT "SearchRequest_pkey" PRIMARY KEY ("id")
|
||
|
);
|
||
|
|
||
|
-- CreateTable
|
||
|
CREATE TABLE "Webpage" (
|
||
|
"id" SERIAL NOT NULL,
|
||
|
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||
|
"updatedAt" TIMESTAMP(3) NOT NULL,
|
||
|
"path" TEXT NOT NULL,
|
||
|
|
||
|
CONSTRAINT "Webpage_pkey" PRIMARY KEY ("id")
|
||
|
);
|
||
|
|
||
|
-- CreateTable
|
||
|
CREATE TABLE "Domain" (
|
||
|
"id" SERIAL NOT NULL,
|
||
|
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||
|
"updatedAt" TIMESTAMP(3) NOT NULL,
|
||
|
"address" TEXT NOT NULL,
|
||
2 years ago
|
"lastParse" TIMESTAMP(3),
|
||
2 years ago
|
|
||
|
CONSTRAINT "Domain_pkey" PRIMARY KEY ("id")
|
||
|
);
|
||
|
|
||
2 years ago
|
-- CreateTable
|
||
|
CREATE TABLE "NftDomain" (
|
||
|
"id" SERIAL NOT NULL,
|
||
|
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||
|
"updatedAt" TIMESTAMP(3) NOT NULL,
|
||
|
"address" TEXT NOT NULL,
|
||
|
"available" BOOLEAN NOT NULL,
|
||
|
|
||
|
CONSTRAINT "NftDomain_pkey" PRIMARY KEY ("id")
|
||
|
);
|
||
|
|
||
2 years ago
|
-- CreateIndex
|
||
|
CREATE UNIQUE INDEX "User_email_key" ON "User"("email");
|
||
|
|
||
|
-- CreateIndex
|
||
|
CREATE UNIQUE INDEX "Session_handle_key" ON "Session"("handle");
|
||
|
|
||
|
-- CreateIndex
|
||
|
CREATE UNIQUE INDEX "Token_hashedToken_type_key" ON "Token"("hashedToken", "type");
|
||
|
|
||
|
-- CreateIndex
|
||
|
CREATE UNIQUE INDEX "SearchRequest_text_key" ON "SearchRequest"("text");
|
||
|
|
||
|
-- CreateIndex
|
||
|
CREATE UNIQUE INDEX "Webpage_path_key" ON "Webpage"("path");
|
||
|
|
||
|
-- CreateIndex
|
||
|
CREATE UNIQUE INDEX "Domain_address_key" ON "Domain"("address");
|
||
|
|
||
2 years ago
|
-- CreateIndex
|
||
|
CREATE UNIQUE INDEX "NftDomain_address_key" ON "NftDomain"("address");
|
||
|
|
||
2 years ago
|
-- AddForeignKey
|
||
|
ALTER TABLE "Session" ADD CONSTRAINT "Session_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||
|
|
||
|
-- AddForeignKey
|
||
|
ALTER TABLE "Token" ADD CONSTRAINT "Token_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|