Skip to content

Instantly share code, notes, and snippets.

@alvinchow86
alvinchow86 / migration_manifest.py
Created May 15, 2017 22:54
django-tips-blog-migration-manifest
def handle(self, *app_labels, **options):
# Generate a migrations manifest with latest migration on each app
super(Command, self).handle(*app_labels, **options)
loader = MigrationLoader(None, ignore_no_migrations=True)
apps = sorted(loader.migrated_apps)
graph = loader.graph
with open('latest_migrations.manifest', 'w') as f:
for app_name in apps:
@alvinchow86
alvinchow86 / migration_state_operations.py
Last active May 15, 2017 22:35
django-blog-post-migration-state-operations
class Migration(migrations.Migration):
state_operations = [ORIGINAL_MIGRATIONS]
operations = migrations.SeparateDatabaseAndState(state_operations=state_operations)
import pytest
class TestOne(object):
@pytest.fixture(autouse=True)
def setup(self):
5 / 0
self.foo = 'foo'
def test_one(self):