-
Notifications
You must be signed in to change notification settings - Fork 46
/
Copy path0036_search_op_add_ch.py
39 lines (33 loc) · 1.47 KB
/
0036_search_op_add_ch.py
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
34
35
36
37
38
39
# Generated by Django 4.1.5 on 2023-06-21 13:46
from django.db import migrations
from osrd_infra.migrations import run_sql_create_infra_search_table
class Migration(migrations.Migration):
dependencies = [
("osrd_infra", "0035_trainschedule_scheduled_points"),
]
operations = [
migrations.RunSQL(
sql="""
DROP TRIGGER IF EXISTS osrd_search_operationalpoint__ins_trig ON osrd_infra_operationalpointmodel;
DROP TRIGGER IF EXISTS osrd_search_operationalpoint__upd_trig ON osrd_infra_operationalpointmodel;
DROP TABLE IF EXISTS osrd_search_operationalpoint;
""",
reverse_sql="",
),
run_sql_create_infra_search_table(
name="osrd_search_operationalpoint",
source_table="osrd_infra_operationalpointmodel",
search_columns={
"name": "{source}.data#>>'{{extensions,identifier,name}}'",
},
extra_columns={
"infra_id": ("{source}.infra_id", "INT"),
"obj_id": ("{source}.obj_id", "VARCHAR(255)"),
"uic": ("({source}.data#>'{{extensions,identifier,uic}}')::integer", "INT"),
"ch": ("{source}.data->'extensions'->'sncf'->>'ch'", "TEXT"),
"trigram": ("{source}.data#>>'{{extensions,sncf,trigram}}'", "VARCHAR(3)"),
},
triggers=True,
phony_model_name="OsrdSearchOperationalPoint",
),
]