aboutsummaryrefslogtreecommitdiffstats
path: root/src/resource_inventory/migrations/0012_manual_20200218_1536.py
diff options
context:
space:
mode:
authorParker Berberian <pberberian@iol.unh.edu>2020-02-27 16:26:47 -0500
committerParker Berberian <pberberian@iol.unh.edu>2020-02-27 16:26:47 -0500
commit4940cda1806aa13591485b996264ddc887202d35 (patch)
tree5e36f2fff3dc99fa26cbe11a8f8ca205e59947cc /src/resource_inventory/migrations/0012_manual_20200218_1536.py
parentd73588dfe1066f85bb83df0e3c0881ff42c25e04 (diff)
Improve Data Migration
Improved migration files so that they preserve data Change-Id: I53283fd3fd207ed3f9773beea7b1ce2062b5bd9f Signed-off-by: Parker Berberian <pberberian@iol.unh.edu>
Diffstat (limited to 'src/resource_inventory/migrations/0012_manual_20200218_1536.py')
-rw-r--r--src/resource_inventory/migrations/0012_manual_20200218_1536.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/resource_inventory/migrations/0012_manual_20200218_1536.py b/src/resource_inventory/migrations/0012_manual_20200218_1536.py
new file mode 100644
index 0000000..378bdc3
--- /dev/null
+++ b/src/resource_inventory/migrations/0012_manual_20200218_1536.py
@@ -0,0 +1,25 @@
+# Generated by Django 2.2 on 2020-02-18 15:36
+
+from django.conf import settings
+from django.db import migrations
+
+
+def clear_networks(apps, schema_editor):
+ Network = apps.get_model('resource_inventory', 'Network')
+ Vlan = apps.get_model('resource_inventory', 'Vlan')
+ for vlan in Vlan.objects.all():
+ vlan.delete()
+ for net in Network.objects.all():
+ net.delete()
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ migrations.swappable_dependency(settings.AUTH_USER_MODEL),
+ ('resource_inventory', '0012_auto_20200103_1850'),
+ ]
+
+ operations = [
+ migrations.RunPython(clear_networks)
+ ]