-- Make email field optional in accounts table
-- Only username is required, other fields are optional

ALTER TABLE accounts
    ALTER COLUMN email DROP NOT NULL;

-- Drop UNIQUE constraint on email since it can be NULL now
ALTER TABLE accounts
    DROP CONSTRAINT IF EXISTS accounts_email_key;

-- Create partial unique index on email (only for non-NULL values)
CREATE UNIQUE INDEX idx_accounts_email_unique ON accounts(email) WHERE email IS NOT NULL;
