Disabling Migrations While Testing

January, 06 2016

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 :).


Tweet comments, corrections, or high fives to @amjoconn