add login feature

This commit is contained in:
2025-10-22 06:55:28 -04:00
parent f2cf309d97
commit 28d0443f44
22 changed files with 287 additions and 1136 deletions

View File

@@ -0,0 +1,29 @@
-- 1. Enable necessary extensions
CREATE EXTENSION IF NOT EXISTS "pgcrypto";
CREATE EXTENSION IF NOT EXISTS "citext";
-- 2. Define the Users table
CREATE TABLE "public"."Users" (
"id" UUID PRIMARY KEY DEFAULT gen_random_uuid(),
"username" CITEXT UNIQUE NOT NULL,
"email" CITEXT UNIQUE NOT NULL,
"hashed_password" TEXT NOT NULL,
"created_at" TIMESTAMPTZ NOT NULL DEFAULT NOW(),
"updated_at" TIMESTAMPTZ NOT NULL DEFAULT NOW()
);
-- 3. Create the function to update the timestamp
CREATE OR REPLACE FUNCTION update_updated_at_column()
RETURNS TRIGGER AS $$
BEGIN
NEW.updated_at = NOW();
RETURN NEW;
END;
$$ language 'plpgsql';
-- 4. Create the trigger and attach it to the Users table
CREATE TRIGGER update_users_updated_at
BEFORE UPDATE ON "public"."Users"
FOR EACH ROW
EXECUTE FUNCTION update_updated_at_column();

View File

@@ -0,0 +1,3 @@
# Please do not edit this file manually
# It should be added in your version-control system (i.e. Git)
provider = "postgresql"

View File

@@ -0,0 +1,18 @@
generator client {
provider = "prisma-client-js"
output = "../generated/prisma"
}
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
model Users {
id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid
username String @unique @db.Citext
email String @unique @db.Citext
hashed_password String
created_at DateTime @default(now()) @db.Timestamptz(6)
updated_at DateTime @default(now()) @db.Timestamptz(6)
}