I'm trying to figure out why my migrations appear to run twice when unit testing. I do have multiple dbs with custom routers to route to different databases.
I've tried debugging and tracing the routers to see if that's where the issue lies, but I don't know enough about the migration process to know what to look for.
...I'm surprised it even works given that the database is already migrated once -- shouldn't the 2nd migrations fail?
I'm not expecting an answer -- I think there's not enough information.
But where should I dig?
Rich
$ ./manage-coverage test --noinput -v 2
nosetests --logging-level=INFO --progressive-advisories --with-timer --timer-top-n=10 --with-prowl-report --with-timed-setup-report --with-id --id-file=/opt/gitlab-runner/NCiG8AGt/1/redacted-automation/reddash/djproj/.noseids -v --verbosity=2
Using --with-id and --verbosity=2 or higher with nose-progressive causes visualization errors. Remove one or the other to avoid a mess.
Creating test database for alias 'default' ('reddash_cicd_3')...
Operations to perform:
Synchronize unmigrated apps: api, bugzilla, celery, django_db_constraints, django_extensions, django_filters, django_nose, drf_yasg, humanize, messages, redauto, polymorphic, rest_framework, saml2, staticfiles, timezone_field
Apply all migrations: accounts, admin, auth, contenttypes, dashboards, django_celery_beat, django_celery_results, reversion, sessions, tracking
Synchronizing apps without migrations:
Creating tables...
Running deferred SQL...
Running migrations:
Applying contenttypes.0001_initial... OK
Applying contenttypes.0002_remove_content_type_name... OK
Applying auth.0001_initial... OK
Applying auth.0002_alter_permission_name_max_length... OK
Applying auth.0003_alter_user_email_max_length... OK
Applying auth.0004_alter_user_username_opts... OK
Applying auth.0005_alter_user_last_login_null... OK
Applying auth.0006_require_contenttypes_0002... OK
Applying auth.0007_alter_validators_add_error_messages... OK
Applying accounts.0001_initial... OK
Applying tracking.0001_initial... OK
Applying accounts.0002_auto_20160929_2021... OK
Applying accounts.0003_auto_20190225_2216... OK
Applying accounts.0004_token... OK
Applying accounts.0005_auto_20190306_1804... OK
Applying tracking.0002_apirequestlog_department... OK
Applying accounts.0006_dedupe_20190422_1447... OK
Applying accounts.0007_auto_20190422_1459... OK
Applying accounts.0008_auto_20190730_2235... OK
Applying accounts.0009_auto_20190802_1750... OK
Applying accounts.0010_auto_20190906_0024... OK
Applying accounts.0011_user_is_redauto... OK
Applying admin.0001_initial... OK
Applying admin.0002_logentry_remove_auto_add... OK
Applying auth.0008_alter_user_username_max_length... OK
Applying dashboards.0001_initial... OK
[...]
Applying dashboards.0110_auto_20191118_1742... OK
Applying django_celery_beat.0001_initial... OK
Applying django_celery_beat.0002_auto_20161118_0346... OK
Applying django_celery_beat.0003_auto_20161209_0049... OK
Applying django_celery_beat.0004_auto_20170221_0000... OK
Applying django_celery_beat.0005_add_solarschedule_events_choices... OK
Applying django_celery_beat.0006_auto_20180210_1226... OK
Applying django_celery_results.0001_initial... OK
Applying reversion.0001_squashed_0004_auto_20160611_1202... OK
Applying sessions.0001_initial... OK
Applying tracking.0003_auto_20190822_1229... OK
Applying tracking.0004_auto_20191030_2030... OK
Applying tracking.0005_auto_20191030_2030... OK
Applying tracking.0006_remove_apirequestlog_server_name... OK
Applying tracking.0007_auto_20191030_2038... OK
Creating test database for alias 'bugzilla' (':memory:')...
Operations to perform:
Synchronize unmigrated apps: api, bugzilla, celery, django_db_constraints, django_extensions, django_filters, django_nose, drf_yasg, humanize, messages, redauto, polymorphic, rest_framework, saml2, staticfiles, timezone_field
Apply all migrations: accounts, admin, auth, contenttypes, dashboards, django_celery_beat, django_celery_results, reversion, sessions, tracking
Synchronizing apps without migrations:
Creating tables...
Creating table bugs
Creating table bug_fix_by_map
Creating table products
Creating table phases
Creating table versions
Running deferred SQL...
Running migrations:
Applying contenttypes.0001_initial... OK
Applying contenttypes.0002_remove_content_type_name... OK
Applying auth.0001_initial... OK
Applying auth.0002_alter_permission_name_max_length... OK
Applying auth.0003_alter_user_email_max_length... OK
Applying auth.0004_alter_user_username_opts... OK
Applying auth.0005_alter_user_last_login_null... OK
Applying auth.0006_require_contenttypes_0002... OK
Applying auth.0007_alter_validators_add_error_messages... OK
Applying accounts.0001_initial... OK
Applying tracking.0001_initial... OK
Applying accounts.0002_auto_20160929_2021... OK
Applying accounts.0003_auto_20190225_2216... OK
Applying accounts.0004_token... OK
Applying accounts.0005_auto_20190306_1804... OK
Applying tracking.0002_apirequestlog_department... OK
Applying accounts.0006_dedupe_20190422_1447... OK
Applying accounts.0007_auto_20190422_1459... OK
Applying accounts.0008_auto_20190730_2235... OK
Applying accounts.0009_auto_20190802_1750... OK
Applying accounts.0010_auto_20190906_0024... OK
Applying accounts.0011_user_is_redauto... OK
Applying admin.0001_initial... OK
Applying admin.0002_logentry_remove_auto_add... OK
Applying auth.0008_alter_user_username_max_length... OK
Applying dashboards.0001_initial... OK
[...]
Applying dashboards.0110_auto_20191118_1742... OK
Applying django_celery_beat.0001_initial... OK
Applying django_celery_beat.0002_auto_20161118_0346... OK
Applying django_celery_beat.0003_auto_20161209_0049... OK
Applying django_celery_beat.0004_auto_20170221_0000... OK
Applying django_celery_beat.0005_add_solarschedule_events_choices... OK
Applying django_celery_beat.0006_auto_20180210_1226... OK
Applying django_celery_results.0001_initial... OK
Applying reversion.0001_squashed_0004_auto_20160611_1202... OK
Applying sessions.0001_initial... OK
Applying tracking.0003_auto_20190822_1229... OK
Applying tracking.0004_auto_20191030_2030... OK
Applying tracking.0005_auto_20191030_2030... OK
Applying tracking.0006_remove_apirequestlog_server_name... OK
Applying tracking.0007_auto_20191030_2038...
#1 test_user ... ok (0.0581s)
[...]