django.db.utils.ProgrammingError: permission denied for table django_migrations
のエラーの対処に苦戦したので書いておこうと思います。
このエラーが出たときpostgresqlのdjango移行を実行中に、接続ファイルで使用されているpostgresqlのユーザーに対して権限設定がなされてないことが原因みたいです。なのでpostgresqlのユーザーに権限を持たせようと思います。
コマンドからpsql -U postgres
でpostgresにログインします。
>psql -U postgres
ユーザ postgres のパスワード:
psql (12.1)
"help"でヘルプを表示します。
postgres=#
次に使用したいデーターベースにログインします。(database nameは使用したいデータベースを入れてください。)
postgres=# ¥c database name
データベース"database name"にユーザ"postgres"として接続しました。
database name=#
そして権限を持たせるために3つのコードを入力します。(usernameは使用しようとしているユーザ名に書き換えてください。)
GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public to username;
GRANT ALL PRIVILEGES ON ALL SEQUENCES IN SCHEMA public to username;
GRANT ALL PRIVILEGES ON ALL FUNCTIONS IN SCHEMA public to username;
これでpostgresqlのユーザーに対して権限を持たせることができました。