"""Apply worker's narrow table grant after migrations have created attachments.""" import os import psycopg2 conn = psycopg2.connect(os.environ["DATABASE_URL"], sslmode="verify-full", sslrootcert=os.getenv("DB_CA_FILE", "/run/tls/service-ca.crt")) try: with conn: with conn.cursor() as cur: cur.execute("GRANT SELECT, INSERT, UPDATE, DELETE ON TABLE attachments TO messenger_worker") finally: conn.close()