#23745: Migrations migrate is slow
-------------------------------------+-------------------------------------
     Reporter:  claudep              |                    Owner:  nobody
         Type:                       |                   Status:  closed
  Cleanup/optimization               |
    Component:  Migrations           |                  Version:  master
     Severity:  Release blocker      |               Resolution:  fixed
     Keywords:                       |             Triage Stage:  Ready for
                                     |  checkin
    Has patch:  1                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------

Comment (by sirex):

 Here is my suggestion:


 {{{
 #!python
 if settings.TESTS_MIGRATE:
     call_command(
         'migrate',
         verbosity=max(verbosity - 1, 0),
         interactive=False,
         database=self.connection.alias,
         test_database=True,
         test_flush=True,
     )
 else:
     from django.apps import apps
     from django.core.management.commands.migrate import Command as
 MigrateCommand
     command = MigrateCommand()
     command.verbosity = 0
     command.interactive = False
     command.load_initial_data = False
     app_labels = [app.label for app in apps.get_app_configs()]
     created_models = command.sync_apps(self.connection, app_labels)
 }}}

 This is just a quick and dirty modification of
 `django/db/backends/creation.py:create_test_db`, but the idea is to add
 option for not running migrations in tests.

 With this modification, my tests became instant fast again.

--
Ticket URL: <https://code.djangoproject.com/ticket/23745#comment:16>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/065.5f37be3e1ef9a6ae465abca4abccab9f%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to