-- Migration: 018_audit_log -- Create audit_log table for tracking security-relevant events (login, register, etc.) CREATE TABLE IF NOT EXISTS audit_log ( id SERIAL PRIMARY KEY, user_id INTEGER, event_type VARCHAR(50) NOT NULL, ip_address VARCHAR(45), user_agent TEXT, details JSONB, created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW() ); CREATE INDEX idx_audit_log_user_id ON audit_log(user_id); CREATE INDEX idx_audit_log_event_type ON audit_log(event_type); CREATE INDEX idx_audit_log_created_at ON audit_log(created_at);