Report this

What is the reason for this report?

Running Django migrations on App Platform dev database

Posted on September 4, 2025

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?

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Start building today

From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.