-- Run as PostgreSQL superuser (postgres) against database archi
-- Fixes "permission denied for schema public" on PostgreSQL 15+

\c archi

GRANT USAGE, CREATE ON SCHEMA public TO archi;
GRANT ALL PRIVILEGES ON DATABASE archi TO archi;
ALTER DATABASE archi OWNER TO archi;
ALTER SCHEMA public OWNER TO archi;

ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT ALL ON TABLES TO archi;
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT ALL ON SEQUENCES TO archi;
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT ALL ON TYPES TO archi;
