Skip to content

Commit

Permalink
Merge pull request #1 from maqi1520/psql
Browse files Browse the repository at this point in the history
chore(psql): use psql
  • Loading branch information
maqi1520 authored Jul 5, 2021
2 parents c862ff3 + e430048 commit 0914754
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 15 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,5 @@ yarn-error.log*
# vercel
.vercel
.env

*.sql
Original file line number Diff line number Diff line change
@@ -1,51 +1,55 @@
-- CreateTable
CREATE TABLE "User" (
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
"id" SERIAL NOT NULL,
"name" TEXT,
"password" TEXT NOT NULL,
"email" TEXT NOT NULL
"email" TEXT NOT NULL,

PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "Post" (
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
"id" SERIAL NOT NULL,
"title" TEXT NOT NULL,
"content" TEXT NOT NULL,
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"likes" INTEGER DEFAULT 0,
"hits" INTEGER NOT NULL DEFAULT 0,
"summary" TEXT,
"slug" TEXT,
"userId" INTEGER NOT NULL,
"published" INTEGER NOT NULL DEFAULT 0,
FOREIGN KEY ("userId") REFERENCES "User" ("id") ON DELETE CASCADE ON UPDATE CASCADE

PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "Category" (
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
"id" SERIAL NOT NULL,
"name" TEXT NOT NULL,
"createdAt" DATETIME DEFAULT CURRENT_TIMESTAMP
"createdAt" TIMESTAMP(3) DEFAULT CURRENT_TIMESTAMP,

PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "Project" (
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
"id" SERIAL NOT NULL,
"title" TEXT NOT NULL,
"description" TEXT NOT NULL,
"repoUrl" TEXT,
"appUrl" TEXT,
"order" INTEGER DEFAULT -1,
"userId" INTEGER NOT NULL,
FOREIGN KEY ("userId") REFERENCES "User" ("id") ON DELETE CASCADE ON UPDATE CASCADE

PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "_CategoryToPost" (
"A" INTEGER NOT NULL,
"B" INTEGER NOT NULL,
FOREIGN KEY ("A") REFERENCES "Category" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
FOREIGN KEY ("B") REFERENCES "Post" ("id") ON DELETE CASCADE ON UPDATE CASCADE
"B" INTEGER NOT NULL
);

-- CreateIndex
Expand All @@ -62,3 +66,15 @@ CREATE UNIQUE INDEX "_CategoryToPost_AB_unique" ON "_CategoryToPost"("A", "B");

-- CreateIndex
CREATE INDEX "_CategoryToPost_B_index" ON "_CategoryToPost"("B");

-- AddForeignKey
ALTER TABLE "Post" ADD FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "Project" ADD FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "_CategoryToPost" ADD FOREIGN KEY ("A") REFERENCES "Category"("id") ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "_CategoryToPost" ADD FOREIGN KEY ("B") REFERENCES "Post"("id") ON DELETE CASCADE ON UPDATE CASCADE;
2 changes: 1 addition & 1 deletion prisma/migrations/migration_lock.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Please do not edit this file manually
# It should be added in your version-control system (i.e. Git)
provider = "sqlite"
provider = "postgresql"
4 changes: 2 additions & 2 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ generator client {
}

datasource db {
provider = "sqlite"
url = "file:./dev.db"
provider = "postgresql"
url = env("DATABASE_URL")
}

model User{
Expand Down

1 comment on commit 0914754

@vercel
Copy link

@vercel vercel bot commented on 0914754 Jul 5, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.