run postgres query for rows that changes is null for them and there is value for changes_text

This commit is contained in:
GreatBahram 2024-06-12 06:49:52 +02:00
parent d412b2b16a
commit bec21f98ec

View file

@ -125,7 +125,13 @@ class Command(BaseCommand):
def postgres():
with connection.cursor() as cursor:
cursor.execute(
'UPDATE auditlog_logentry SET changes="changes_text"::jsonb'
"""
UPDATE auditlog_logentry
SET changes="changes_text"::jsonb
WHERE changes_text IS NOT NULL
AND changes_text <> ''
AND changes IS NULL
"""
)
return cursor.cursor.rowcount