-- +goose Up -- +goose StatementBegin CREATE TABLE user_sessions ( id UUID PRIMARY KEY DEFAULT gen_random_uuid (), user_id UUID REFERENCES users (id) NOT NULL, session_type VARCHAR(32) NOT NULL DEFAULT 'user', -- e.g. 'user', 'admin' issued_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW (), expires_at TIMESTAMP WITH TIME ZONE, last_active TIMESTAMP WITH TIME ZONE, ip_address VARCHAR(45), -- supports IPv4/IPv6 user_agent TEXT, access_token_id UUID, refresh_token_id UUID, device_info JSONB, -- optional: structured info (browser, OS, etc.) is_active BOOLEAN NOT NULL DEFAULT TRUE, revoked_at TIMESTAMP WITH TIME ZONE ); CREATE INDEX IF NOT EXISTS idx_user_sessions_user_id ON user_sessions (user_id); -- +goose StatementEnd -- +goose Down -- +goose StatementBegin DROP TABLE IF EXISTS user_sessions; -- +goose StatementEnd