From f09866ab33e4b20c181010e2b568bdc2d71ade87 Mon Sep 17 00:00:00 2001 From: Tom Dooner Date: Tue, 23 Aug 2016 20:04:04 -0700 Subject: [PATCH 1/2] Don't load data fixtures when migrating automatically These are pretty good for development, but they were also run in production which is not good for data quality. They can still be run with: python manage.py loaddata disclosure/fixtures/*.json --- disclosure/migrations/0001_initial.py | 27 ------------------- .../migrations/0002_auto_20160502_0351.py | 4 +-- 2 files changed, 2 insertions(+), 29 deletions(-) delete mode 100644 disclosure/migrations/0001_initial.py diff --git a/disclosure/migrations/0001_initial.py b/disclosure/migrations/0001_initial.py deleted file mode 100644 index 836b4ac3..00000000 --- a/disclosure/migrations/0001_initial.py +++ /dev/null @@ -1,27 +0,0 @@ -# -*- coding: utf-8 -*- -import os.path as op - -from django.conf import settings -from django.core.management import call_command -from django.db import migrations - - -def load_ballot_data(apps, schema_editor): - fixtures = ( - ('locality', op.join(settings.FIXTURES_DIR, '2016_05_02_locality.json')), - ('ballot', op.join(settings.FIXTURES_DIR, '2016_05_02_ballot.json')),) - - for app, path in fixtures: - call_command('loaddata', path, app=app) - - -class Migration(migrations.Migration): - - dependencies = [ - ('ballot', '0002_auto_20160304_2151'), - ('locality', '0002_locality_true_model_id'), - ] - - operations = [ - migrations.RunPython(load_ballot_data), - ] diff --git a/disclosure/migrations/0002_auto_20160502_0351.py b/disclosure/migrations/0002_auto_20160502_0351.py index d1441541..ba7263d8 100644 --- a/disclosure/migrations/0002_auto_20160502_0351.py +++ b/disclosure/migrations/0002_auto_20160502_0351.py @@ -12,8 +12,8 @@ def load_ballot_data(apps, schema_editor): fixtures = ( ('ballot', op.join(settings.FIXTURES_DIR, '2016_05_01_ballot.json')),) - for app, path in fixtures: - call_command('loaddata', path, app=app) + # for app, path in fixtures: + # call_command('loaddata', path, app=app) class Migration(migrations.Migration): From 61d3f87c31ee635659cb712a7f0ad4ab55df02c8 Mon Sep 17 00:00:00 2001 From: Tom Dooner Date: Tue, 23 Aug 2016 20:15:38 -0700 Subject: [PATCH 2/2] Remove migration which loads fixtures See f09866ab for context; I accidentally commented-out a migration instead of removing it entirely. --- .../migrations/0002_auto_20160502_0351.py | 27 ------------------- 1 file changed, 27 deletions(-) delete mode 100644 disclosure/migrations/0002_auto_20160502_0351.py diff --git a/disclosure/migrations/0002_auto_20160502_0351.py b/disclosure/migrations/0002_auto_20160502_0351.py deleted file mode 100644 index ba7263d8..00000000 --- a/disclosure/migrations/0002_auto_20160502_0351.py +++ /dev/null @@ -1,27 +0,0 @@ -# -*- coding: utf-8 -*- -from __future__ import unicode_literals - -import os.path as op - -from django.conf import settings -from django.core.management import call_command -from django.db import migrations - - -def load_ballot_data(apps, schema_editor): - fixtures = ( - ('ballot', op.join(settings.FIXTURES_DIR, '2016_05_01_ballot.json')),) - - # for app, path in fixtures: - # call_command('loaddata', path, app=app) - - -class Migration(migrations.Migration): - - dependencies = [ - ('disclosure', '0001_initial'), - ] - - operations = [ - migrations.RunPython(load_ballot_data), - ]