From bb5c43a4e7b73adfd1c919d2a1bc48f080961605 Mon Sep 17 00:00:00 2001 From: Ryan Westfall Date: Mon, 19 Oct 2026 01:08:54 -0700 Subject: [PATCH] Make chat_backend migrations a single chain (#77) ## Summary - Closes #76. - `0034_waitlistentry` and `0034_customuser_use_conversation_context` both depended on `0033_agentrun_agentstep`, so the graph had two leaves. - Waitlist is now `0035_waitlistentry` and depends on `0034_customuser_use_conversation_context`. One leaf: `0035_waitlistentry`. ## Deploy note If `django_migrations` already has a row named `0034_waitlistentry`, rename it before migrate: ```sql UPDATE django_migrations SET name = '0035_waitlistentry' WHERE app = 'chat_backend' AND name = '0034_waitlistentry'; ``` Then run migrate. A database that never applied `0034_waitlistentry` can migrate as usual. ## Test plan - [x] `chat_backend.tests.test_migration_graph` asserts a single leaf and the new parent. - [x] `chat_backend.tests.test_public_marketing` still passes. - [ ] On a database that already applied both 0034 siblings, run the rename SQL, then `migrate`, and confirm no `InconsistentMigrationHistory`. Reviewed-on: https://git.aimloperations.com/ai_ml_operations/chat_backend/pulls/77 --- ...0034_waitlistentry.py => 0035_waitlistentry.py} | 2 +- llm_be/chat_backend/tests/test_migration_graph.py | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) rename llm_be/chat_backend/migrations/{0034_waitlistentry.py => 0035_waitlistentry.py} (93%) create mode 100644 llm_be/chat_backend/tests/test_migration_graph.py diff --git a/llm_be/chat_backend/migrations/0034_waitlistentry.py b/llm_be/chat_backend/migrations/0035_waitlistentry.py similarity index 93% rename from llm_be/chat_backend/migrations/0034_waitlistentry.py rename to llm_be/chat_backend/migrations/0035_waitlistentry.py index 5505357..3be9cab 100644 --- a/llm_be/chat_backend/migrations/0034_waitlistentry.py +++ b/llm_be/chat_backend/migrations/0035_waitlistentry.py @@ -7,7 +7,7 @@ from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ - ("chat_backend", "0033_agentrun_agentstep"), + ("chat_backend", "0034_customuser_use_conversation_context"), ] operations = [ diff --git a/llm_be/chat_backend/tests/test_migration_graph.py b/llm_be/chat_backend/tests/test_migration_graph.py new file mode 100644 index 0000000..5b9092c --- /dev/null +++ b/llm_be/chat_backend/tests/test_migration_graph.py @@ -0,0 +1,14 @@ +from django.db import connection +from django.db.migrations.loader import MigrationLoader +from django.test import TestCase + + +class MigrationGraphTests(TestCase): + def test_chat_backend_has_a_single_leaf(self): + loader = MigrationLoader(connection, ignore_no_migrations=True) + leaves = [name for app, name in loader.graph.leaf_nodes() if app == "chat_backend"] + self.assertEqual(leaves, ["0035_waitlistentry"]) + + node = loader.graph.nodes[("chat_backend", "0035_waitlistentry")] + parents = [name for app, name in node.dependencies if app == "chat_backend"] + self.assertEqual(parents, ["0034_customuser_use_conversation_context"])