multiple usernames

This commit is contained in:
Gsk54
2022-12-20 17:37:59 +01:00
parent 3b02341275
commit 57d4172580
47 changed files with 928 additions and 245 deletions

View File

@@ -1,10 +0,0 @@
-- CreateTable
CREATE TABLE "auth" (
"uuid" UUID NOT NULL,
"username" TEXT NOT NULL,
"password" TEXT NOT NULL,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMP(3) NOT NULL,
CONSTRAINT "auth_pkey" PRIMARY KEY ("uuid")
);

View File

@@ -0,0 +1,26 @@
-- CreateEnum
CREATE TYPE "Type" AS ENUM ('EMAIL', 'PHONE');
-- CreateTable
CREATE TABLE "auth" (
"uuid" UUID NOT NULL,
"password" TEXT NOT NULL,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMP(3) NOT NULL,
CONSTRAINT "auth_pkey" PRIMARY KEY ("uuid")
);
-- CreateTable
CREATE TABLE "username" (
"username" TEXT NOT NULL,
"uuid" UUID NOT NULL,
"type" "Type" NOT NULL DEFAULT 'EMAIL',
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMP(3) NOT NULL,
CONSTRAINT "username_pkey" PRIMARY KEY ("username")
);
-- CreateIndex
CREATE UNIQUE INDEX "username_uuid_type_key" ON "username"("uuid", "type");

View File

@@ -12,10 +12,25 @@ datasource db {
model Auth {
uuid String @id @db.Uuid
username String
password String
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
@@map("auth")
}
model Username {
username String @id
uuid String @db.Uuid
type Type @default(EMAIL) // type is needed in case of username update
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
@@unique([uuid, type])
@@map("username")
}
enum Type {
EMAIL
PHONE
}