Django, psql & “permission denied” on migrate
Posted on October 16, 2018 (Last modified on July 11, 2024) • 1 min read • 65 wordsI got this error:
psycopg2.ProgrammingError: permission denied for relation django_migrations
… when I wanted to do a “python manage.py 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>
# ...