-- Quick permission grant script
-- 
-- WORKING METHOD (tested and confirmed):
--   PGPASSWORD=punimtag_password psql -h localhost -U punimtag -d punimtag -f grant_permissions_now.sql
--
-- Alternative methods:
--   1. Using postgres user: PGPASSWORD=postgres_password psql -h localhost -U postgres -d punimtag -f grant_permissions_now.sql
--   2. Using sudo: sudo -u postgres psql -d punimtag -f grant_permissions_now.sql
--   3. Manual connection: psql -U punimtag -d punimtag (then paste the GRANT commands below)

\c punimtag

GRANT CONNECT ON DATABASE punimtag TO viewer_readonly;
GRANT USAGE ON SCHEMA public TO viewer_readonly;
GRANT SELECT ON TABLE photos TO viewer_readonly;
GRANT SELECT ON TABLE people TO viewer_readonly;
GRANT SELECT ON TABLE faces TO viewer_readonly;
GRANT SELECT ON TABLE person_encodings TO viewer_readonly;
GRANT SELECT ON TABLE tags TO viewer_readonly;
GRANT SELECT ON TABLE phototaglinkage TO viewer_readonly;
GRANT SELECT ON TABLE photo_favorites TO viewer_readonly;
GRANT USAGE, SELECT ON ALL SEQUENCES IN SCHEMA public TO viewer_readonly;

\echo '✅ Permissions granted!'

