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();