Skip to content
This repository has been archived by the owner on Oct 3, 2023. It is now read-only.

Commit

Permalink
feat(db): add User model
Browse files Browse the repository at this point in the history
  • Loading branch information
GGORG0 committed Jun 29, 2022
1 parent 84a8be0 commit 35787b2
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 0 deletions.
16 changes: 16 additions & 0 deletions prisma/migrations/20220628110828_users/migration.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
-- CreateTable
CREATE TABLE "User" (
"uuid" UUID NOT NULL,
"usernname" VARCHAR(16) NOT NULL,
"created" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"passwordHash" TEXT NOT NULL,
"email" TEXT NOT NULL,

CONSTRAINT "User_pkey" PRIMARY KEY ("uuid")
);

-- CreateIndex
CREATE UNIQUE INDEX "User_usernname_key" ON "User"("usernname");

-- CreateIndex
CREATE UNIQUE INDEX "User_email_key" ON "User"("email");
17 changes: 17 additions & 0 deletions prisma/migrations/20220628113656_user_typo/migration.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/*
Warnings:
- You are about to drop the column `usernname` on the `User` table. All the data in the column will be lost.
- A unique constraint covering the columns `[username]` on the table `User` will be added. If there are existing duplicate values, this will fail.
- Added the required column `username` to the `User` table without a default value. This is not possible if the table is not empty.
*/
-- DropIndex
DROP INDEX "User_usernname_key";

-- AlterTable
ALTER TABLE "User" DROP COLUMN "usernname",
ADD COLUMN "username" VARCHAR(16) NOT NULL;

-- CreateIndex
CREATE UNIQUE INDEX "User_username_key" ON "User"("username");
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/*
Warnings:
- Added the required column `passwordSalt` to the `User` table without a default value. This is not possible if the table is not empty.
*/
-- AlterTable
ALTER TABLE "User" ADD COLUMN "passwordSalt" CHAR(12) NOT NULL;
9 changes: 9 additions & 0 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,12 @@ model Image {
size Int
hash String @db.Char(64)
}

model User {
uuid String @id @db.Uuid @default(uuid())
username String @unique @db.VarChar(16)
created DateTime @default(now())
passwordHash String
passwordSalt String @db.Char(12)
email String @unique
}

0 comments on commit 35787b2

Please sign in to comment.