Is it possible to run Django migrations on a Cloud SQL replica without being the owner of the table?

I'm using Google Cloud SQL for PostgreSQL as an external primary replica, with data being replicated continuously from a self-managed PostgreSQL source using Database Migration Service (DMS) in CDC mode.

I connected a Django project to this replica and tried to run a migration that renames a column and adds a new one:

uv run python manage.py migrate

However, I get the following error:

django.db.utils.ProgrammingError: must be owner of table camera_manager_invoice

This makes sense, since in PostgreSQL, ALTER TABLE requires table ownership. But in this case, the replica was created by DMS, so the actual table owner is the replication source — and not the current user.


🔍 The Problem:

I'm trying to apply schema changes via Django migrations on a Cloud SQL replica that I do not own. The replication is working fine for data (CDC), but I need to apply structural changes on the replica independently.


✅ What I Tried:

  • Changing the connected user: still not the owner, so same error.
  • Running sqlmigrate to get the SQL and applying manually: same result — permission denied.
  • Attempted to change ownership of the table via ALTER TABLE ... OWNER TO ...: failed due to not being superuser.
  • Tried running migration with --fake, but this skips execution and doesn't change the schema.

❓ My Question:

Is there any way to apply schema changes via Django migrations (or manually) on a Cloud SQL replica, without being the table owner?

I'm open to alternatives, best practices, or official GCP recommendations for this situation.


Вернуться на верх