Bin
2025-12-17 21f0498f62ada55651f4d232327e15fc47f498b1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# Generated by Django 3.1.13 on 2021-09-13 07:39
import logging
 
from django.db import migrations
from core.utils.common import trigram_migration_operations
 
logger = logging.getLogger(__name__)
 
 
def forwards(apps, schema_editor):
    if not schema_editor.connection.vendor.startswith('postgres'):
        logger.info('Database vendor: {}'.format(schema_editor.connection.vendor))
        logger.info('Skipping migration without attempting to CREATE INDEX')
        return
 
    schema_editor.execute('create index concurrently tasks_annotations_result_idx on task_completion using gin (upper(cast(result as text)) gin_trgm_ops);')
 
 
def backwards(apps, schema_editor):
    if not schema_editor.connection.vendor.startswith('postgres'):
        logger.info('Database vendor: {}'.format(schema_editor.connection.vendor))
        logger.info('Skipping migration without attempting to DROP INDEX')
        return
 
    schema_editor.execute('drop index tasks_annotations_result_idx;')
 
 
class Migration(migrations.Migration):
    atomic = False
 
    dependencies = [('tasks', '0008_auto_20210903_1332')]
 
    operations = trigram_migration_operations(migrations.RunPython(forwards, backwards))