From 41de13b1ffeb44c5a91fcd6eb4742fa93a40128c Mon Sep 17 00:00:00 2001 From: Toan Hoang Minh Date: Fri, 31 Jul 2026 11:48:55 +0700 Subject: [PATCH] feat: add User Prisma model + migration --- .../20260731044659_add_user/migration.sql | 13 +++++++++++++ prisma/schema.prisma | 18 ++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 prisma/migrations/20260731044659_add_user/migration.sql diff --git a/prisma/migrations/20260731044659_add_user/migration.sql b/prisma/migrations/20260731044659_add_user/migration.sql new file mode 100644 index 0000000..d9b0395 --- /dev/null +++ b/prisma/migrations/20260731044659_add_user/migration.sql @@ -0,0 +1,13 @@ +-- CreateTable +CREATE TABLE "users" ( + "id" UUID NOT NULL, + "email" TEXT NOT NULL, + "password_hash" TEXT NOT NULL, + "name" TEXT NOT NULL, + "created_at" TIMESTAMPTZ(6) NOT NULL DEFAULT CURRENT_TIMESTAMP, + + CONSTRAINT "users_pkey" PRIMARY KEY ("id") +); + +-- CreateIndex +CREATE UNIQUE INDEX "users_email_key" ON "users"("email"); diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 8352f54..eb3c65e 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -38,3 +38,21 @@ model Request { @@map("requests") } + +// Minimal internal auth accounts — NOT company SSO (deliberately ruled out, +// see CLAUDE.md / auth decision notes). A handful of trusted IT staff +// accounts, created by hand via scripts/create-user.ts, no self-registration. +// Auth.js v5 Credentials provider + JWT session strategy is used, so this is +// intentionally just a plain user table — no `Account`/`Session`/ +// `VerificationToken` models, those exist for OAuth account linking / DB +// session strategy, neither of which applies here. No `role` field either: +// permission model is flat for now (any logged-in user can do anything). +model User { + id String @id @default(uuid()) @db.Uuid + email String @unique + passwordHash String @map("password_hash") + name String + createdAt DateTime @default(now()) @map("created_at") @db.Timestamptz(6) + + @@map("users") +}