aboutsummaryrefslogtreecommitdiffstats
path: root/rrs/migrations
diff options
context:
space:
mode:
Diffstat (limited to 'rrs/migrations')
-rw-r--r--rrs/migrations/0012_reup_layerbranch_field.py19
-rw-r--r--rrs/migrations/0013_reup_layerbranch_populate.py29
-rw-r--r--rrs/migrations/0014_reup_layerbranch_nonnull.py19
-rw-r--r--rrs/migrations/0015_rmh_layerbranch_populate.py29
-rw-r--r--rrs/migrations/0016_rmh_layerbranch_nonnull.py19
5 files changed, 115 insertions, 0 deletions
diff --git a/rrs/migrations/0012_reup_layerbranch_field.py b/rrs/migrations/0012_reup_layerbranch_field.py
new file mode 100644
index 0000000000..18aebbd33d
--- /dev/null
+++ b/rrs/migrations/0012_reup_layerbranch_field.py
@@ -0,0 +1,19 @@
+# -*- coding: utf-8 -*-
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('rrs', '0011_release_name_unique'),
+ ]
+
+ operations = [
+ migrations.AddField(
+ model_name='recipeupstreamhistory',
+ name='layerbranch',
+ field=models.ForeignKey(null=True, to='layerindex.LayerBranch'),
+ ),
+ ]
diff --git a/rrs/migrations/0013_reup_layerbranch_populate.py b/rrs/migrations/0013_reup_layerbranch_populate.py
new file mode 100644
index 0000000000..f5e88a76c4
--- /dev/null
+++ b/rrs/migrations/0013_reup_layerbranch_populate.py
@@ -0,0 +1,29 @@
+# -*- coding: utf-8 -*-
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+import settings
+
+
+def populate_layerbranch(apps, schema_editor):
+ RecipeUpstreamHistory = apps.get_model('rrs', 'RecipeUpstreamHistory')
+ LayerBranch = apps.get_model('layerindex', 'LayerBranch')
+ if not settings.CORE_LAYER_NAME:
+ raise Exception('Please set CORE_LAYER_NAME in settings.py')
+ core_layerbranch = LayerBranch.objects.filter(layer__name=settings.CORE_LAYER_NAME).first()
+ if not core_layerbranch:
+ raise Exception('Unable to find core layer "%s" specified in CORE_LAYER_NAME in settings.py' % settings.CORE_LAYER_NAME)
+ for row in RecipeUpstreamHistory.objects.all():
+ row.layerbranch = core_layerbranch
+ row.save()
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('rrs', '0012_reup_layerbranch_field'),
+ ]
+
+ operations = [
+ migrations.RunPython(populate_layerbranch, reverse_code=migrations.RunPython.noop),
+ ]
diff --git a/rrs/migrations/0014_reup_layerbranch_nonnull.py b/rrs/migrations/0014_reup_layerbranch_nonnull.py
new file mode 100644
index 0000000000..1ee6ee9e81
--- /dev/null
+++ b/rrs/migrations/0014_reup_layerbranch_nonnull.py
@@ -0,0 +1,19 @@
+# -*- coding: utf-8 -*-
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('rrs', '0013_reup_layerbranch_populate'),
+ ]
+
+ operations = [
+ migrations.AlterField(
+ model_name='recipeupstreamhistory',
+ name='layerbranch',
+ field=models.ForeignKey(to='layerindex.LayerBranch'),
+ ),
+ ]
diff --git a/rrs/migrations/0015_rmh_layerbranch_populate.py b/rrs/migrations/0015_rmh_layerbranch_populate.py
new file mode 100644
index 0000000000..5c3d5e3335
--- /dev/null
+++ b/rrs/migrations/0015_rmh_layerbranch_populate.py
@@ -0,0 +1,29 @@
+# -*- coding: utf-8 -*-
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+import settings
+
+
+def populate_rmh_layerbranch(apps, schema_editor):
+ RecipeMaintainerHistory = apps.get_model('rrs', 'RecipeMaintainerHistory')
+ LayerBranch = apps.get_model('layerindex', 'LayerBranch')
+ if not settings.CORE_LAYER_NAME:
+ raise Exception('Please set CORE_LAYER_NAME in settings.py')
+ core_layerbranch = LayerBranch.objects.filter(layer__name=settings.CORE_LAYER_NAME).first()
+ if not core_layerbranch:
+ raise Exception('Unable to find core layer "%s" specified in CORE_LAYER_NAME in settings.py - please set up the layerindex application first' % settings.CORE_LAYER_NAME)
+ for row in RecipeMaintainerHistory.objects.all():
+ row.layerbranch = core_layerbranch
+ row.save()
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('rrs', '0014_reup_layerbranch_nonnull'),
+ ]
+
+ operations = [
+ migrations.RunPython(populate_rmh_layerbranch, reverse_code=migrations.RunPython.noop),
+ ]
diff --git a/rrs/migrations/0016_rmh_layerbranch_nonnull.py b/rrs/migrations/0016_rmh_layerbranch_nonnull.py
new file mode 100644
index 0000000000..5c192fd571
--- /dev/null
+++ b/rrs/migrations/0016_rmh_layerbranch_nonnull.py
@@ -0,0 +1,19 @@
+# -*- coding: utf-8 -*-
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('rrs', '0015_rmh_layerbranch_populate'),
+ ]
+
+ operations = [
+ migrations.AlterField(
+ model_name='recipemaintainerhistory',
+ name='layerbranch',
+ field=models.ForeignKey(to='layerindex.LayerBranch'),
+ ),
+ ]