gohorsejobs/backend/migrations/038_create_password_reset_tokens.sql
2026-02-15 16:03:40 +00:00

17 lines
730 B
SQL

-- Migration: Create password_reset_tokens table
-- Description: Stores tokens for password reset flow
CREATE TABLE IF NOT EXISTS password_reset_tokens (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
user_id VARCHAR(36) NOT NULL REFERENCES core_users(id) ON DELETE CASCADE,
token VARCHAR(64) NOT NULL UNIQUE,
expires_at TIMESTAMP NOT NULL,
used BOOLEAN DEFAULT false,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
CREATE INDEX idx_reset_tokens_token ON password_reset_tokens(token);
CREATE INDEX idx_reset_tokens_user ON password_reset_tokens(user_id);
COMMENT ON TABLE password_reset_tokens IS 'Stores password reset tokens for authentication';