Separate framework and app migrations
Also add a new develop command: clear-db.
This commit is contained in:
26
express/framework/migrations/2026-01-01_02-sessions.sql
Normal file
26
express/framework/migrations/2026-01-01_02-sessions.sql
Normal file
@@ -0,0 +1,26 @@
|
||||
-- 0002_sessions.sql
|
||||
-- Create sessions table for auth tokens
|
||||
|
||||
CREATE TABLE sessions (
|
||||
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
||||
token_hash TEXT UNIQUE NOT NULL,
|
||||
user_id UUID NOT NULL REFERENCES users(id),
|
||||
user_email_id UUID REFERENCES user_emails(id),
|
||||
token_type TEXT NOT NULL,
|
||||
auth_method TEXT NOT NULL,
|
||||
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
||||
expires_at TIMESTAMPTZ NOT NULL,
|
||||
revoked_at TIMESTAMPTZ,
|
||||
ip_address INET,
|
||||
user_agent TEXT,
|
||||
is_used BOOLEAN DEFAULT FALSE
|
||||
);
|
||||
|
||||
-- Index for user session lookups (logout all, etc.)
|
||||
CREATE INDEX sessions_user_id_idx ON sessions (user_id);
|
||||
|
||||
-- Index for expiration cleanup
|
||||
CREATE INDEX sessions_expires_at_idx ON sessions (expires_at);
|
||||
|
||||
-- Index for token type filtering
|
||||
CREATE INDEX sessions_token_type_idx ON sessions (token_type);
|
||||
Reference in New Issue
Block a user