-- Migration: Create password_resets table -- Description: Password reset tokens CREATE TABLE IF NOT EXISTS password_resets ( id SERIAL PRIMARY KEY, user_id UUID NOT NULL, token VARCHAR(255) UNIQUE NOT NULL, expires_at TIMESTAMP NOT NULL, used BOOLEAN DEFAULT false, created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, -- Foreign key FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE ); -- Indexes CREATE INDEX idx_password_resets_token ON password_resets(token); CREATE INDEX idx_password_resets_user ON password_resets(user_id); CREATE INDEX idx_password_resets_expires ON password_resets(expires_at); -- Comments COMMENT ON TABLE password_resets IS 'Password reset tokens with expiration'; COMMENT ON COLUMN password_resets.token IS 'Unique reset token sent to user'; COMMENT ON COLUMN password_resets.used IS 'Whether token has been used';