-- Migration V008: Add EULA acceptance tracking to users table
-- Created: 2025-10-04
-- Description: Adds eulaAcceptedAt and eulaVersion fields to track when users accept legal agreements

-- Add EULA acceptance timestamp
ALTER TABLE users
ADD COLUMN eula_accepted_at TIMESTAMP WITHOUT TIME ZONE NULL;

-- Add EULA version tracking (e.g., "1.0", "2024-10-04")
ALTER TABLE users
ADD COLUMN eula_version VARCHAR(20) NULL;

-- Add comment for documentation
COMMENT ON COLUMN users.eula_accepted_at IS 'Timestamp when user accepted the EULA';
COMMENT ON COLUMN users.eula_version IS 'Version of EULA that was accepted (e.g., "1.0", "2024-10-04")';

-- Create index for quickly finding users who haven't accepted EULA
CREATE INDEX idx_users_eula_acceptance ON users(eula_accepted_at) WHERE eula_accepted_at IS NULL;

COMMENT ON INDEX idx_users_eula_acceptance IS 'Find users who have not yet accepted the EULA (partial index)';
