From 05db2ccb180086cb6ff69f99a3711fc101eb5f78 Mon Sep 17 00:00:00 2001 From: Ian Eaves Date: Tue, 12 Sep 2023 11:03:11 -0500 Subject: [PATCH] migration (#638) --- .../0017_invalid_source_lineage_state.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 grai-server/app/lineage/migrations/0017_invalid_source_lineage_state.py diff --git a/grai-server/app/lineage/migrations/0017_invalid_source_lineage_state.py b/grai-server/app/lineage/migrations/0017_invalid_source_lineage_state.py new file mode 100644 index 000000000..cae3876ae --- /dev/null +++ b/grai-server/app/lineage/migrations/0017_invalid_source_lineage_state.py @@ -0,0 +1,18 @@ +# Generated by Django 4.2.5 on 2023-09-12 15:32 + +from django.db import migrations +from lineage.models import Source + + +def forwards(apps, schema_editor): + for source in Source.objects.iterator(chunk_size=1000): + source.nodes.remove(*source.nodes.filter(workspace__id__ne=source.workspace)) + source.edges.remove(*source.edges.filter(workspace__id__ne=source.workspace)) + + +class Migration(migrations.Migration): + dependencies = [ + ("lineage", "0016_alter_edge_metadata_alter_node_metadata"), + ] + + operations = [migrations.RunPython(forwards)]