aboutsummaryrefslogtreecommitdiffstats
path: root/db/schema_0009-update_alerts_problem_state_queries.sql
blob: fc5de927aaaae3024e934e796a2382b04f811e6f (plain)
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
begin;

    UPDATE alert_type set item_where = 'nearby.problem_id = problem.id and problem.state in 
    (''confirmed'', ''investigating'', ''planned'', ''in progress'', 
     ''fixed'', ''fixed - council'', ''fixed - user'', ''closed'')' WHERE ref = 'postcode_local_problems';
    UPDATE alert_type set item_where = 'problem.state in 
        (''confirmed'', ''investigating'', ''planned'', ''in progress'', 
         ''fixed'', ''fixed - council'', ''fixed - user'', ''closed'' )' WHERE ref = 'new_problems';
    UPDATE alert_type set item_where = 'problem.state in (''fixed'', ''fixed - user'', ''fixed - council'')' WHERE ref = 'new_fixed_problems';
    UPDATE alert_type set item_where = 'nearby.problem_id = problem.id and problem.state in 
    (''confirmed'', ''investigating'', ''planned'', ''in progress'', 
     ''fixed'', ''fixed - council'', ''fixed - user'', ''closed'')' WHERE ref = 'local_problems';
    UPDATE alert_type set item_where = 'problem.state in 
    (''confirmed'', ''investigating'', ''planned'', ''in progress'', 
      ''fixed'', ''fixed - council'', ''fixed - user'', ''closed'') and 
    (council like ''%''||?||''%'' or council is null) and 
    areas like ''%,''||?||'',%''' WHERE ref = 'council_problems';
    UPDATE alert_type set item_where = 'problem.state in 
    (''confirmed'', ''investigating'', ''planned'', ''in progress'', 
     ''fixed'', ''fixed - council'', ''fixed - user'', ''closed'') and 
    (council like ''%''||?||''%'' or council is null) and 
    areas like ''%,''||?||'',%''' WHERE ref = 'ward_problems';
    UPDATE alert_type set item_where = 'problem.state in 
    (''confirmed'', ''investigating'', ''planned'', ''in progress'', 
     ''fixed'', ''fixed - council'', ''fixed - user'', ''closed'') and 
    areas like ''%,''||?||'',%''' WHERE ref = 'area_problems';

commit;