From 39b899643b247c7d46665b9a15ed3233fcbe165d Mon Sep 17 00:00:00 2001 From: Mathieu Agopian Date: Tue, 6 Oct 2026 16:20:01 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8(migration)=20export=20management=20co?= =?UTF-8?q?mmand=20also=20exports=20mentions?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Export mentions of users in documents, and whether they've already been notified by email Signed-off-by: Mathieu Agopian --- .../management/commands/export_migration.py | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/backend/core/management/commands/export_migration.py b/src/backend/core/management/commands/export_migration.py index efd0f3444..52abdc762 100644 --- a/src/backend/core/management/commands/export_migration.py +++ b/src/backend/core/management/commands/export_migration.py @@ -49,6 +49,13 @@ try: except ImportError: _HAS_RECONCILIATION = False +try: + from core.models import Mention + + _HAS_MENTION = True +except ImportError: + _HAS_MENTION = False + try: from zoneinfo import ZoneInfo as _ZoneInfo except ImportError: @@ -105,6 +112,8 @@ class Command(BaseCommand): self._export_threads(stream) self._export_comments(stream) self._export_reactions(stream) + if _HAS_MENTION: + self._export_mentions(stream) def _progress(self, label, count, done=False): """Overwrite the current stderr line with an incrementing count.""" @@ -279,3 +288,14 @@ class Command(BaseCommand): count += 1 self._progress("reaction users", count) self._progress("reaction users", count, done=True) + + def _export_mentions(self, stream): + """Export all concrete Mention fields.""" + self.stderr.write("Exporting mentions...") + count = 0 + for mention in Mention.objects.order_by("created_at").values().iterator(): + pk = mention.pop("id") + _write(stream, "core.mention", pk, mention) + count += 1 + self._progress("mentions", count) + self._progress("mentions", count, done=True)