Files
zulip/pgroonga/migrations/0002_html_escape_subject.py
Anders Kaseorg 6e4c3e41dc python: Normalize quotes with Black.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-12 13:11:19 -08:00

29 lines
821 B
Python

from django.db import connection, migrations
from django.db.backends.postgresql.schema import DatabaseSchemaEditor
from django.db.migrations.state import StateApps
from psycopg2.sql import SQL
from zerver.lib.migrate import do_batch_update
def rebuild_pgroonga_index(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None:
with connection.cursor() as cursor:
do_batch_update(
cursor,
"zerver_message",
[SQL("search_pgroonga = escape_html(subject) || ' ' || rendered_content")],
batch_size=10000,
)
class Migration(migrations.Migration):
atomic = False
dependencies = [
("pgroonga", "0001_enable"),
]
operations = [
migrations.RunPython(rebuild_pgroonga_index, reverse_code=migrations.RunPython.noop),
]