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.
Thank you for this! |
This comment has been minimized.
This comment has been minimized.
Perfect. Thanks! |
This comment has been minimized.
This comment has been minimized.
You are a patron saint of testing. |
This comment has been minimized.
This comment has been minimized.
One word: Ahhhhhhhhh |
This comment has been minimized.
This comment has been minimized.
boss! |
This comment has been minimized.
This comment has been minimized.
Worked better for me, thanks! |
This comment has been minimized.
This comment has been minimized.
+1 love it. |
This comment has been minimized.
This comment has been minimized.
Thanks a lot, +10000 |
This comment has been minimized.
This comment has been minimized.
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.
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.
Has anyone used this with django-nose? |
This comment has been minimized.
This comment has been minimized.
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.
@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.
Thanks! |
This comment has been minimized.
This comment has been minimized.
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.
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.
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.
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.
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.
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.
Looks like you need to alter this slightly on Django 1.11:
|
This comment has been minimized.
This comment has been minimized.
Thanks, it still works |
This comment has been minimized.
This comment has been minimized.
Hello, Thanks |
This comment has been minimized.
This comment has been minimized.
If your Django version is >= 1.9
|
This comment has been minimized.
This worked for me, and it is more simple than other solutions I came accross.