-- Reset password for viewer_readonly user
-- Run this script as a PostgreSQL superuser (e.g., postgres user)
-- This will set the password to match what's in your .env file: punimtag_password

-- Reset the password
ALTER USER viewer_readonly WITH PASSWORD 'punimtag_password';

-- Verify permissions are still correct
GRANT CONNECT ON DATABASE punimtag TO viewer_readonly;
GRANT USAGE ON SCHEMA public TO viewer_readonly;
GRANT SELECT ON ALL TABLES IN SCHEMA public TO viewer_readonly;

-- Grant on future tables
ALTER DEFAULT PRIVILEGES IN SCHEMA public 
GRANT SELECT ON TABLES TO viewer_readonly;

-- Display success message
\echo 'Password for viewer_readonly has been reset to: punimtag_password'
\echo 'This should now match your .env file'

