Django, psql & “permission denied” on migrate

0 minute read

I got this error:

psycopg2.ProgrammingError: permission denied for relation django_migrations

… when I wanted to do a “python migrate”. This post had the solution. In short: You have to change the owner of the tables to the one specified in the Django configuration.

This is how my script looks:

#!/usr/bin/env bash
echo "ALTER TABLE public.django_admin_log OWNER TO <new_owner>;" | psql -U <current_owner> <database>
# ...