bernardopires / django-tenant-schemas

Tenant support for Django using PostgreSQL schemas.
https://django-tenant-schemas.readthedocs.org/en/latest/
MIT License
1.46k stars 424 forks source link

Adding a new app to shared apps on existing database: relations not found #502

Open jeroenbrouwer opened 7 years ago

jeroenbrouwer commented 7 years ago

I have experienced some troubles adding the apps django_q and rest_framework.auth to SHARED_APPS when running an existing database with a public schema set up and some shared schemas. The command migrate_schemas runs fine but somehow I am getting errors like:

django.db.utils.ProgrammingError: relation "authtoken_token" does not exist LINE 1: ...oken"."user_id", "authtoken_token"."created" FROM "authtoken...

My current solution is to recreate the database and loading the data again which solves the errors and works, however, this is not a viable or preferred option when running in production. Any clues on how to overcome this issue?

Thanks!

devxpy commented 6 years ago

Same issue here.

tmog commented 6 years ago

This is likely because you have moved the apps from TENANT_APPS to SHARED_APPS after having run the initial migration. You should be able to fix this by manually deleting the migration in django_migrations as mentioned in #276

mauroeparis commented 5 years ago

how can i do that without having a consistency issue with django migrations?

I kept getting InconsistentMigrationHistory until i dropped the table and got an django.db.utils.ProgrammingError: relation "{{ app }}" already exists, i faked everything and still got the django.db.utils.ProgrammingError: relation "authtoken_token" does not exist error