add login feature
This commit is contained in:
29
server/prisma/migrations/0_init/migration.sql
Normal file
29
server/prisma/migrations/0_init/migration.sql
Normal 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();
|
||||
3
server/prisma/migrations/migration_lock.toml
Normal file
3
server/prisma/migrations/migration_lock.toml
Normal 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"
|
||||
Reference in New Issue
Block a user