From 35787b2f10418cd9dfc54036f1c4602ef3c99543 Mon Sep 17 00:00:00 2001 From: GGORG Date: Wed, 29 Jun 2022 14:29:15 +0200 Subject: [PATCH] feat(db): add User model --- .../20220628110828_users/migration.sql | 16 ++++++++++++++++ .../20220628113656_user_typo/migration.sql | 17 +++++++++++++++++ .../migration.sql | 8 ++++++++ prisma/schema.prisma | 9 +++++++++ 4 files changed, 50 insertions(+) create mode 100644 prisma/migrations/20220628110828_users/migration.sql create mode 100644 prisma/migrations/20220628113656_user_typo/migration.sql create mode 100644 prisma/migrations/20220628170804_user_password_salt/migration.sql diff --git a/prisma/migrations/20220628110828_users/migration.sql b/prisma/migrations/20220628110828_users/migration.sql new file mode 100644 index 0000000..29623a1 --- /dev/null +++ b/prisma/migrations/20220628110828_users/migration.sql @@ -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"); diff --git a/prisma/migrations/20220628113656_user_typo/migration.sql b/prisma/migrations/20220628113656_user_typo/migration.sql new file mode 100644 index 0000000..affbee7 --- /dev/null +++ b/prisma/migrations/20220628113656_user_typo/migration.sql @@ -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"); diff --git a/prisma/migrations/20220628170804_user_password_salt/migration.sql b/prisma/migrations/20220628170804_user_password_salt/migration.sql new file mode 100644 index 0000000..3727e71 --- /dev/null +++ b/prisma/migrations/20220628170804_user_password_salt/migration.sql @@ -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; diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 0db43be..628f7ef 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -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 +} \ No newline at end of file