By Jack Morgan
Kia ora!
I’ve been unable to run Django migrations on an App Platform dev database, as it throws the error permission denied for schema public
.
I’ve looked at the following posts, but still no luck.
When connecting to the deployed Django resource and running python manage.py migrate
in the console, or creating a job instance to run the same command, I get the following errors:
Sep 04 05:02:42
Operations to perform:
Sep 04 05:02:42
Apply all migrations: account, admin, auth, contenttypes, mfa, sessions, sites, socialaccount, users
Sep 04 05:02:42
Running migrations:
Sep 04 05:02:42
Traceback (most recent call last):
Sep 04 05:02:42
File "/usr/local/lib/python3.12/site-packages/django/db/backends/utils.py", line 103, in _execute
Sep 04 05:02:42
return self.cursor.execute(sql)
Sep 04 05:02:42
^^^^^^^^^^^^^^^^^^^^^^^^
Sep 04 05:02:42
File "/usr/local/lib/python3.12/site-packages/psycopg/cursor.py", line 97, in execute
Sep 04 05:02:42
raise ex.with_traceback(None)
Sep 04 05:02:42
psycopg.errors.InsufficientPrivilege: permission denied for schema public
Sep 04 05:02:42
LINE 1: CREATE TABLE "django_migrations" ("id" bigint NOT NULL PRIMA...
Sep 04 05:02:42
^
Sep 04 05:02:42
Sep 04 05:02:42
The above exception was the direct cause of the following exception:
Sep 04 05:02:42
Sep 04 05:02:42
Traceback (most recent call last):
Sep 04 05:02:42
File "/usr/local/lib/python3.12/site-packages/django/db/migrations/recorder.py", line 78, in ensure_schema
Sep 04 05:02:42
editor.create_model(self.Migration)
Sep 04 05:02:42
File "/usr/local/lib/python3.12/site-packages/django/db/backends/base/schema.py", line 512, in create_model
Sep 04 05:02:42
self.execute(sql, params or None)
Sep 04 05:02:42
File "/usr/local/lib/python3.12/site-packages/django/db/backends/postgresql/schema.py", line 45, in execute
Sep 04 05:02:42
return super().execute(sql, params)
Sep 04 05:02:42
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Sep 04 05:02:42
File "/usr/local/lib/python3.12/site-packages/django/db/backends/base/schema.py", line 204, in execute
Sep 04 05:02:42
cursor.execute(sql, params)
Sep 04 05:02:42
File "/usr/local/lib/python3.12/site-packages/sentry_sdk/utils.py", line 1816, in runner
Sep 04 05:02:42
return sentry_patched_function(*args, **kwargs)
Sep 04 05:02:42
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Sep 04 05:02:42
File "/usr/local/lib/python3.12/site-packages/sentry_sdk/integrations/django/__init__.py", line 652, in execute
From my understanding and local testing, Django should only modify the public
schema in the db
database. Anything I’ve missed?
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Hi there,
I think that you should not be using the db
database, instead you should just use the default postgres
database itself that the database user has access to.
How are you defining your database details exactly?
Let me know how it goes.
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.