Add PostgreSQL database layer with Kysely and migrations
- Add database.ts with connection pool, Kysely query builder, and migration runner - Create migrations for users and sessions tables (0001, 0002) - Implement PostgresAuthStore to replace InMemoryAuthStore - Wire up database service in services/index.ts 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
21
express/migrations/0001_users.sql
Normal file
21
express/migrations/0001_users.sql
Normal file
@@ -0,0 +1,21 @@
|
||||
-- 0001_users.sql
|
||||
-- Create users table for authentication
|
||||
|
||||
CREATE TABLE users (
|
||||
id UUID PRIMARY KEY,
|
||||
email TEXT UNIQUE NOT NULL,
|
||||
password_hash TEXT NOT NULL,
|
||||
display_name TEXT,
|
||||
status TEXT NOT NULL DEFAULT 'pending',
|
||||
roles TEXT[] NOT NULL DEFAULT '{}',
|
||||
permissions TEXT[] NOT NULL DEFAULT '{}',
|
||||
email_verified BOOLEAN NOT NULL DEFAULT FALSE,
|
||||
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
||||
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
|
||||
);
|
||||
|
||||
-- Index for email lookups (login)
|
||||
CREATE INDEX users_email_idx ON users (LOWER(email));
|
||||
|
||||
-- Index for status filtering
|
||||
CREATE INDEX users_status_idx ON users (status);
|
||||
Reference in New Issue
Block a user