This commit is contained in:
lizerk 2026-03-12 00:59:39 +03:00
parent 66c243879f
commit 77551b5240
3 changed files with 24 additions and 6 deletions

View File

@ -10,7 +10,8 @@ def migrate_comments_forward(apps, schema_editor):
schema_editor.execute("""
INSERT INTO communications_chat (
type, name, created_by_id, can_reply, flags,
context_content_type_id, context_object_id
context_content_type_id, context_object_id,
created_at, is_main, is_blocked, include_all_users, extra_data
)
SELECT DISTINCT
'comments',
@ -19,7 +20,12 @@ def migrate_comments_forward(apps, schema_editor):
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
dc.document_id,
NOW(),
FALSE,
FALSE,
FALSE,
'{}'::jsonb
FROM documents_documentcomment dc
JOIN documents_document d ON d.id = dc.document_id
WHERE NOT EXISTS (

View File

@ -10,7 +10,8 @@ def migrate_comments_forward(apps, schema_editor):
schema_editor.execute("""
INSERT INTO communications_chat (
type, name, created_by_id, can_reply, flags,
context_content_type_id, context_object_id
context_content_type_id, context_object_id,
created_at, is_main, is_blocked, include_all_users, extra_data
)
SELECT DISTINCT
'comments',
@ -19,7 +20,12 @@ def migrate_comments_forward(apps, schema_editor):
TRUE,
'{"allow_replies": true, "allow_reactions": true, "allow_attachments": true, "allow_editing": true}'::jsonb,
(SELECT id FROM django_content_type WHERE app_label='feed' AND model='post'),
c.post_id
c.post_id,
NOW(),
FALSE,
FALSE,
FALSE,
'{}'::jsonb
FROM feed_comment c
JOIN feed_post p ON p.id = c.post_id
WHERE NOT EXISTS (

View File

@ -10,7 +10,8 @@ def migrate_comments_forward(apps, schema_editor):
schema_editor.execute("""
INSERT INTO communications_chat (
type, name, created_by_id, can_reply, flags,
context_content_type_id, context_object_id
context_content_type_id, context_object_id,
created_at, is_main, is_blocked, include_all_users, extra_data
)
SELECT DISTINCT
'comments',
@ -19,7 +20,12 @@ def migrate_comments_forward(apps, schema_editor):
TRUE,
'{"allow_replies": true, "allow_reactions": true, "allow_attachments": true, "allow_editing": true}'::jsonb,
(SELECT id FROM django_content_type WHERE app_label='requests_app' AND model='request'),
rc.request_id
rc.request_id,
NOW(),
FALSE,
FALSE,
FALSE,
'{}'::jsonb
FROM requests_app_requestcomment rc
WHERE NOT EXISTS (
SELECT 1 FROM communications_chat cc