Disabling Migrations While Testing

If you have a large Django 1.7+ project with a lot of migrations running test even with --keepdb can be slow just because the new migration framework has to order the migrations even if there is nothing to do.

After a few attempts I have found something which works pretty well for me. In your testing setting you can include the following:

class DisableMigrations(object):

    def __contains__(self, item):
        return True

    def __getitem__(self, item):
        return "notmigrations"

MIGRATION_MODULES = DisableMigrations()

I have found related suggestions on the Django mailing list. Both ideas are presented on Stackoverflow.

Update: Thanks NotSqrt for linking me to original Gist I found when I was searching but wasn't able to easily find again :).

By Albert O'Connor . Published on Jan. 6, 2016.
Subscribe to the feed or head back to the list of posts.



Glad I could help !

The initial Gist 15 months ago: https://gist.github.com/NotSqrt/5f3c76cd15e40ef62d09

Posted 8 months, 3 weeks ago

Comments closed either explicitly or because the post is older than 30 days.