A note on fixing PostgreSQL permission issue with Django migrations

After upgrading the Postgres database in one of my application’s test environment, the Django server code stopped working because the permission required to do database migration is missing.

I didn’t investigate the exact change in the defaults. But as a quickfix, we just need to grant the permission to the owner user on the default “public” schema, like this:

postgres=# \c your_data_base
emblem=# GRANT ALL ON SCHEMA public TO your_user_name;

A full list of commands I often use for setting up a test database:

CREATE DATABASE mydb;
CREATE USER myuser WITH ENCRYPTED PASSWORD 'mypass';
GRANT ALL PRIVILEGES ON DATABASE mydb TO myuser;
\c mydb;
GRANT ALL ON SCHEMA public TO myuser;

Published by