|
| 1 | +# Generated by Django 4.1.5 on 2023-06-21 13:46 |
| 2 | + |
| 3 | +from django.db import migrations |
| 4 | + |
| 5 | +from osrd_infra.migrations import run_sql_create_infra_search_table |
| 6 | + |
| 7 | + |
| 8 | +class Migration(migrations.Migration): |
| 9 | + |
| 10 | + dependencies = [ |
| 11 | + ("osrd_infra", "0035_trainschedule_scheduled_points"), |
| 12 | + ] |
| 13 | + |
| 14 | + operations = [ |
| 15 | + migrations.RunSQL( |
| 16 | + sql=""" |
| 17 | + DROP TRIGGER IF EXISTS osrd_search_operationalpoint__ins_trig ON osrd_infra_operationalpointmodel; |
| 18 | + DROP TRIGGER IF EXISTS osrd_search_operationalpoint__upd_trig ON osrd_infra_operationalpointmodel; |
| 19 | + DROP TABLE IF EXISTS osrd_search_operationalpoint; |
| 20 | + """, |
| 21 | + reverse_sql="", |
| 22 | + ), |
| 23 | + run_sql_create_infra_search_table( |
| 24 | + name="osrd_search_operationalpoint", |
| 25 | + source_table="osrd_infra_operationalpointmodel", |
| 26 | + search_columns={ |
| 27 | + "name": "{source}.data#>>'{{extensions,identifier,name}}'", |
| 28 | + }, |
| 29 | + extra_columns={ |
| 30 | + "infra_id": ("{source}.infra_id", "INT"), |
| 31 | + "obj_id": ("{source}.obj_id", "VARCHAR(255)"), |
| 32 | + "uic": ("({source}.data#>'{{extensions,identifier,uic}}')::integer", "INT"), |
| 33 | + "ch": ("{source}.data->'extensions'->'sncf'->>'ch'", "TEXT"), |
| 34 | + "trigram": ("{source}.data#>>'{{extensions,sncf,trigram}}'", "VARCHAR(3)"), |
| 35 | + }, |
| 36 | + triggers=True, |
| 37 | + phony_model_name="OsrdSearchOperationalPoint", |
| 38 | + ), |
| 39 | + ] |
0 commit comments