-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
158 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,155 @@ | ||
-- CreateEnum | ||
CREATE TYPE "Level" AS ENUM ('Admin', 'User'); | ||
|
||
-- CreateTable | ||
CREATE TABLE "nextauth_accounts" ( | ||
"id" TEXT NOT NULL, | ||
"user_id" TEXT NOT NULL, | ||
"type" TEXT NOT NULL, | ||
"provider" TEXT NOT NULL, | ||
"provider_account_id" TEXT NOT NULL, | ||
"refresh_token" TEXT, | ||
"refresh_token_expires_in" INTEGER, | ||
"access_token" TEXT, | ||
"expires_at" INTEGER, | ||
"token_type" TEXT, | ||
"scope" TEXT, | ||
"id_token" TEXT, | ||
"session_state" TEXT, | ||
|
||
CONSTRAINT "nextauth_accounts_pkey" PRIMARY KEY ("id") | ||
); | ||
|
||
-- CreateTable | ||
CREATE TABLE "nextauth_sessions" ( | ||
"id" TEXT NOT NULL, | ||
"session_token" TEXT NOT NULL, | ||
"user_id" TEXT NOT NULL, | ||
"expires" TIMESTAMP(3) NOT NULL, | ||
|
||
CONSTRAINT "nextauth_sessions_pkey" PRIMARY KEY ("id") | ||
); | ||
|
||
-- CreateTable | ||
CREATE TABLE "nextauth_users" ( | ||
"id" TEXT NOT NULL, | ||
"name" TEXT, | ||
"email" TEXT, | ||
"email_verified" TIMESTAMP(3), | ||
"image" TEXT, | ||
"level" "Level" NOT NULL DEFAULT 'User', | ||
|
||
CONSTRAINT "nextauth_users_pkey" PRIMARY KEY ("id") | ||
); | ||
|
||
-- CreateTable | ||
CREATE TABLE "nextauth_verificationtokens" ( | ||
"identifier" TEXT NOT NULL, | ||
"token" TEXT NOT NULL, | ||
"expires" TIMESTAMP(3) NOT NULL | ||
); | ||
|
||
-- CreateTable | ||
CREATE TABLE "tabs" ( | ||
"id" TEXT NOT NULL, | ||
"title" TEXT NOT NULL, | ||
"order" INTEGER, | ||
"owner_id" TEXT NOT NULL, | ||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
|
||
CONSTRAINT "tabs_pkey" PRIMARY KEY ("id") | ||
); | ||
|
||
-- CreateTable | ||
CREATE TABLE "articles" ( | ||
"id" TEXT NOT NULL, | ||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
"content" JSONB[], | ||
"owner_id" TEXT NOT NULL, | ||
"tab_id" TEXT NOT NULL, | ||
|
||
CONSTRAINT "articles_pkey" PRIMARY KEY ("id") | ||
); | ||
|
||
-- CreateTable | ||
CREATE TABLE "printers" ( | ||
"id" TEXT NOT NULL, | ||
"name" TEXT NOT NULL, | ||
"ip" TEXT NOT NULL, | ||
"port" TEXT NOT NULL, | ||
"owner_id" TEXT NOT NULL, | ||
|
||
CONSTRAINT "printers_pkey" PRIMARY KEY ("id") | ||
); | ||
|
||
-- CreateTable | ||
CREATE TABLE "Share" ( | ||
"id" TEXT NOT NULL, | ||
"isShareActive" BOOLEAN NOT NULL DEFAULT true, | ||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
"expiredAt" TIMESTAMP(3), | ||
"author_id" TEXT NOT NULL, | ||
"article_id" TEXT NOT NULL, | ||
|
||
CONSTRAINT "Share_pkey" PRIMARY KEY ("id") | ||
); | ||
|
||
-- CreateTable | ||
CREATE TABLE "logs" ( | ||
"id" TEXT NOT NULL, | ||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
"message" TEXT NOT NULL, | ||
"level" TEXT NOT NULL, | ||
"meta" TEXT NOT NULL, | ||
"ip" TEXT NOT NULL, | ||
|
||
CONSTRAINT "logs_pkey" PRIMARY KEY ("id") | ||
); | ||
|
||
-- CreateIndex | ||
CREATE UNIQUE INDEX "nextauth_accounts_provider_provider_account_id_key" ON "nextauth_accounts"("provider", "provider_account_id"); | ||
|
||
-- CreateIndex | ||
CREATE UNIQUE INDEX "nextauth_sessions_session_token_key" ON "nextauth_sessions"("session_token"); | ||
|
||
-- CreateIndex | ||
CREATE UNIQUE INDEX "nextauth_users_email_key" ON "nextauth_users"("email"); | ||
|
||
-- CreateIndex | ||
CREATE UNIQUE INDEX "nextauth_verificationtokens_token_key" ON "nextauth_verificationtokens"("token"); | ||
|
||
-- CreateIndex | ||
CREATE UNIQUE INDEX "nextauth_verificationtokens_identifier_token_key" ON "nextauth_verificationtokens"("identifier", "token"); | ||
|
||
-- CreateIndex | ||
CREATE UNIQUE INDEX "articles_tab_id_key" ON "articles"("tab_id"); | ||
|
||
-- CreateIndex | ||
CREATE UNIQUE INDEX "printers_owner_id_key" ON "printers"("owner_id"); | ||
|
||
-- CreateIndex | ||
CREATE UNIQUE INDEX "Share_article_id_key" ON "Share"("article_id"); | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "nextauth_accounts" ADD CONSTRAINT "nextauth_accounts_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "nextauth_users"("id") ON DELETE CASCADE ON UPDATE CASCADE; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "nextauth_sessions" ADD CONSTRAINT "nextauth_sessions_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "nextauth_users"("id") ON DELETE CASCADE ON UPDATE CASCADE; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "tabs" ADD CONSTRAINT "tabs_owner_id_fkey" FOREIGN KEY ("owner_id") REFERENCES "nextauth_users"("id") ON DELETE CASCADE ON UPDATE CASCADE; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "articles" ADD CONSTRAINT "articles_owner_id_fkey" FOREIGN KEY ("owner_id") REFERENCES "nextauth_users"("id") ON DELETE CASCADE ON UPDATE CASCADE; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "articles" ADD CONSTRAINT "articles_tab_id_fkey" FOREIGN KEY ("tab_id") REFERENCES "tabs"("id") ON DELETE CASCADE ON UPDATE CASCADE; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "printers" ADD CONSTRAINT "printers_owner_id_fkey" FOREIGN KEY ("owner_id") REFERENCES "nextauth_users"("id") ON DELETE CASCADE ON UPDATE CASCADE; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "Share" ADD CONSTRAINT "Share_author_id_fkey" FOREIGN KEY ("author_id") REFERENCES "nextauth_users"("id") ON DELETE CASCADE ON UPDATE CASCADE; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "Share" ADD CONSTRAINT "Share_article_id_fkey" FOREIGN KEY ("article_id") REFERENCES "articles"("id") ON DELETE CASCADE ON UPDATE CASCADE; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Please do not edit this file manually | ||
# It should be added in your version-control system (i.e. Git) | ||
provider = "postgresql" |