From a03c1d831b166a2a946d5e1158fe6691359b29a3 Mon Sep 17 00:00:00 2001 From: Diogo Matos Chaves Date: Sun, 3 Mar 2024 13:46:55 -0300 Subject: [PATCH] Delete referencing null objects --- database/model/migrations/0093_auto_20240227_1753.py | 7 +++++++ database/model/migrations/0094_auto_20240227_1808.py | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/database/model/migrations/0093_auto_20240227_1753.py b/database/model/migrations/0093_auto_20240227_1753.py index b1cfb7c..4bfc185 100644 --- a/database/model/migrations/0093_auto_20240227_1753.py +++ b/database/model/migrations/0093_auto_20240227_1753.py @@ -4,6 +4,12 @@ import django.db.models.deletion +def delete_referecing_null(apps, _): + Position = apps.get_model('model', 'Position') + + Position.objects.filter(pipeline__id=None).delete() + + class Migration(migrations.Migration): dependencies = [ @@ -11,6 +17,7 @@ class Migration(migrations.Migration): ] operations = [ + migrations.RunPython(delete_referecing_null), migrations.RemoveField( model_name='position', name='exchange', diff --git a/database/model/migrations/0094_auto_20240227_1808.py b/database/model/migrations/0094_auto_20240227_1808.py index a3dca83..7a0f6a4 100644 --- a/database/model/migrations/0094_auto_20240227_1808.py +++ b/database/model/migrations/0094_auto_20240227_1808.py @@ -4,6 +4,12 @@ import django.db.models.deletion +def delete_referecing_null(apps, _): + Trade = apps.get_model('model', 'Trade') + + Trade.objects.filter(pipeline__id=None).delete() + + class Migration(migrations.Migration): dependencies = [ @@ -11,6 +17,7 @@ class Migration(migrations.Migration): ] operations = [ + migrations.RunPython(delete_referecing_null), migrations.RemoveField( model_name='trade', name='exchange',