From 6eaadeef438a2f048cd1c9d2126d7a2c1d161849 Mon Sep 17 00:00:00 2001 From: lizerk Date: Thu, 12 Mar 2026 00:54:58 +0300 Subject: [PATCH] =?UTF-8?q?=D1=84=D0=B8=D0=BA=D1=81=20=D0=BC=D0=B8=D0=B3?= =?UTF-8?q?=D1=80=D0=B0=D1=86=D0=B8=D0=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...0014_migrate_comments_to_communications.py | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/backend/documents/migrations/0014_migrate_comments_to_communications.py b/backend/documents/migrations/0014_migrate_comments_to_communications.py index 43caa81e..4fc9aa24 100644 --- a/backend/documents/migrations/0014_migrate_comments_to_communications.py +++ b/backend/documents/migrations/0014_migrate_comments_to_communications.py @@ -15,9 +15,9 @@ def migrate_comments_forward(apps, schema_editor): SELECT DISTINCT 'comments', 'Комментарии: ' || substr(d.title, 1, 50), - NULL, - 1, - '{"allow_replies": true, "allow_reactions": true, "allow_attachments": true, "allow_editing": true}', + NULL::bigint, + TRUE, + '{"allow_replies": true, "allow_reactions": true, "allow_attachments": true, "allow_editing": true}'::jsonb, (SELECT id FROM django_content_type WHERE app_label='documents' AND model='document'), dc.document_id FROM documents_documentcomment dc @@ -44,11 +44,11 @@ def migrate_comments_forward(apps, schema_editor): dc.author_id, dc.text, dc.created_at, - 0, 0, 0, + FALSE, FALSE, FALSE, dc.is_edited, CASE WHEN dc.is_edited THEN dc.updated_at ELSE NULL END, - 0, 0, 0, - json_object( + FALSE, FALSE, FALSE, + jsonb_build_object( 'legacy_comment_id', dc.id, 'legacy_model', 'documents.DocumentComment' ) @@ -82,13 +82,13 @@ def migrate_comments_forward(apps, schema_editor): dc.author_id, dc.text, dc.created_at, - 0, 0, 0, + FALSE, FALSE, FALSE, dc.is_edited, CASE WHEN dc.is_edited THEN dc.updated_at ELSE NULL END, - 0, 0, 0, + FALSE, FALSE, FALSE, parent_msg.id, parent_msg.id, - json_object( + jsonb_build_object( 'legacy_comment_id', dc.id, 'legacy_model', 'documents.DocumentComment' ) @@ -100,7 +100,7 @@ def migrate_comments_forward(apps, schema_editor): ) JOIN communications_message parent_msg ON ( parent_msg.chat_id = cc.id - AND json_extract(parent_msg.system_metadata, '$.legacy_comment_id') = dc.parent_id + AND (parent_msg.system_metadata->>'legacy_comment_id')::bigint = dc.parent_id ) WHERE dc.parent_id IS NOT NULL AND NOT EXISTS (