Skip to content
This repository has been archived by the owner on May 10, 2024. It is now read-only.

Commit

Permalink
switch to postgres
Browse files Browse the repository at this point in the history
  • Loading branch information
flybayer committed Feb 26, 2022
1 parent 97c3043 commit ba9c5e5
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 49 deletions.
Empty file removed db/migrations/.keep
Empty file.
47 changes: 0 additions & 47 deletions db/migrations/20220226153118_initial_migration/migration.sql

This file was deleted.

57 changes: 57 additions & 0 deletions db/migrations/20220226153201_init/migration.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
-- 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 E'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")
);

-- 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");

-- 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;
2 changes: 1 addition & 1 deletion db/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"
2 changes: 1 addition & 1 deletion db/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// learn more about it in the docs: https://pris.ly/d/prisma-schema

datasource db {
provider = "sqlite"
provider = "postgres"
url = env("DATABASE_URL")
}

Expand Down

0 comments on commit ba9c5e5

Please sign in to comment.