class DisableMigrations(object): | |
def __contains__(self, item): | |
return True | |
def __getitem__(self, item): | |
return "notmigrations" | |
MIGRATION_MODULES = DisableMigrations() |
This comment has been minimized.
This comment has been minimized.
danxshap
commented
Dec 15, 2014
Thank you for this! |
This comment has been minimized.
This comment has been minimized.
rikva
commented
Dec 17, 2014
Perfect. Thanks! |
This comment has been minimized.
This comment has been minimized.
chrisbarmonde
commented
Jan 15, 2015
You are a patron saint of testing. |
This comment has been minimized.
This comment has been minimized.
runekaagaard
commented
Jan 23, 2015
One word: Ahhhhhhhhh |
This comment has been minimized.
This comment has been minimized.
jordij
commented
Feb 4, 2015
boss! |
This comment has been minimized.
This comment has been minimized.
maximiliano
commented
Feb 19, 2015
Worked better for me, thanks! |
This comment has been minimized.
This comment has been minimized.
LegoStormtroopr
commented
Mar 1, 2015
+1 love it. |
This comment has been minimized.
This comment has been minimized.
LeMeteore
commented
Mar 4, 2015
Thanks a lot, +10000 |
This comment has been minimized.
This comment has been minimized.
troygrosfield
commented
Apr 19, 2015
Just so everyone can support the publicly release app by @henriquebastos that includes this snippet: Should rename the app to "headache reliever". Thanks guys! |
This comment has been minimized.
This comment has been minimized.
mannysz
commented
May 7, 2015
Is there a way to use it with django-nose? |
This comment has been minimized.
This comment has been minimized.
Glad I could help |
This comment has been minimized.
This comment has been minimized.
adrienemery
commented
Jul 22, 2015
Has anyone used this with django-nose? |
This comment has been minimized.
This comment has been minimized.
flaugher
commented
Sep 20, 2015
Could someone please explain exactly how you use this snippet when running your tests? Thank you. |
This comment has been minimized.
This comment has been minimized.
chrisv2
commented
Jan 23, 2016
@flaugher: create a settings_test.py next to your regular settings.py:
Then run your tests with settings_test instead of regular settings:
|
This comment has been minimized.
This comment has been minimized.
nicholasserra
commented
Feb 18, 2016
Thanks! |
This comment has been minimized.
This comment has been minimized.
jamescw
commented
Feb 25, 2016
This is a great tool, but I use the hstore field on some models and the recommend way to install the hstore extension is via a migration: https://docs.djangoproject.com/es/1.9/ref/contrib/postgres/fields/#hstorefield Any idea how I can run only one migration or run some custom SQL to install the extension? |
This comment has been minimized.
This comment has been minimized.
roblinton
commented
Mar 1, 2016
Based on the same source as this app, I use something like this in my settings:
|
This comment has been minimized.
This comment has been minimized.
Remiz
commented
Aug 3, 2016
Not sure if someone else has the issue, but when I tried this snipped on my project that contains Cartridge, during the table creation it complains that one of the ManyToMany table already exists... Does anyone else had an issue with that? |
This comment has been minimized.
This comment has been minimized.
raprasad
commented
Aug 12, 2016
Thanks. Used this snippet with another scenario where there was need to re-create "unmanaged" database tables during tests: https://gist.github.com/raprasad/f292f94657728de45d1614a741928308 |
This comment has been minimized.
This comment has been minimized.
cjw296
commented
Oct 7, 2016
So, how do you use this pattern when you want to test migrations as part of your test suite? |
This comment has been minimized.
This comment has been minimized.
renzon
commented
Jun 7, 2017
For those who use pytest-django, it already supports commands to define db behaviour on tests: http://pytest-django.readthedocs.io/en/latest/database.html You can have a stage env with a different pytest.ini where you test migrations. |
This comment has been minimized.
This comment has been minimized.
tclancy
commented
Oct 27, 2017
Looks like you need to alter this slightly on Django 1.11:
|
This comment has been minimized.
This comment has been minimized.
Jelle28
commented
Jul 26, 2018
•
Thanks, it still works |
This comment has been minimized.
rchrd2 commentedDec 11, 2014
This worked for me, and it is more simple than other solutions I came accross.