0

Django using django-tenant-schemas My project requires runtime tenant creation (postgres schema creation), but due to long django migration history, migrations of a new schema take > 10 minutes which is far too long.

So a method is required which skips the migrations, but brings the DB in the correct state.

Reading What should I use instead of syncdb in Django 1.9? and https://docs.djangoproject.com/en/2.0/ref/django-admin/#cmdoption-migrate-run-syncdb

... it seems following could be a solution:

python manage.py migrate auth
# performs migrations for auth and contenttypes contrib apps
python manage.py migrate --run-syncdb
# creates the rest of the database

But what are the consequences of this? Does it mean backwards migrations will not be possible for new schemas? (OK in this project as new schema doesn't have history anyway)

Does it also mean future migrations cannot be applied since there is no correct migration history? That would obviously be a no-go.

FYI version info:

Django==1.11.7
django-tenant-schemas==1.8.0
Davy
  • 1,720
  • 1
  • 19
  • 42

1 Answers1

0

If you are not having any data migrations

using python manage.py migrate --run-syncdb and faking the migration application should be fine python manage.py migrate --fake

Additional functionality that can help you lower number of migrations is to squash migrations into single one

iklinac
  • 14,944
  • 4
  • 28
  • 30
  • The docs say "Creates tables for apps without migrations". Doesn't that imply it won't create tables for apps that have migrations? – Cerin Aug 12 '23 at 04:56
  • No, following precedes migration system and does not take migrations in consideration ( syncdb ), so running it creates all tables for all models – iklinac Aug 31 '23 at 16:58