diff --git a/express/framework/migrations/2026-01-01_03-user-credentials.sql b/express/framework/migrations/2026-01-01_03-user-credentials.sql new file mode 100644 index 0000000..ca3acc7 --- /dev/null +++ b/express/framework/migrations/2026-01-01_03-user-credentials.sql @@ -0,0 +1,17 @@ +-- 0003_user_credentials.sql +-- Create user_credentials table for password storage (extensible for other auth methods) + +CREATE TABLE user_credentials ( + id UUID PRIMARY KEY, + user_id UUID NOT NULL REFERENCES users(id), + credential_type TEXT NOT NULL DEFAULT 'password', + password_hash TEXT, + created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(), + updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW() +); + +-- Each user can have at most one credential per type +CREATE UNIQUE INDEX user_credentials_user_type_idx ON user_credentials (user_id, credential_type); + +-- Index for user lookups +CREATE INDEX user_credentials_user_id_idx ON user_credentials (user_id);