comparison schema/tap_tests_data.sql @ 3302:ec6163c6687d

'Historicise' gauges on import Gauge data sets will be updated or a new version will be inserted depending on temporal validity and a timestamp marking the last update in the RIS-Index of a data set. The trigger on date_info is removed because the value is actually an attribut coming from the RIS-Index. Gauge measurements and predictions are associated to the version with matching temporal validity. Bottlenecks are always associated to the actual version of the gauge, although this might change as soon as bottlenecks are 'historicised', too.
author Tom Gottfried <tom@intevation.de>
date Thu, 16 May 2019 18:41:43 +0200
parents a2127495093e
children 02951a62e8c6
comparison
equal deleted inserted replaced
3301:6514b943654e 3302:ec6163c6687d
35 INSERT INTO users.list_users VALUES ( 35 INSERT INTO users.list_users VALUES (
36 'sys_admin', 'test_sys_admin1', 'sys_admin1$', 'AT', NULL, 'zzz'); 36 'sys_admin', 'test_sys_admin1', 'sys_admin1$', 'AT', NULL, 'zzz');
37 37
38 INSERT INTO limiting_factors VALUES ('depth'), ('width'); 38 INSERT INTO limiting_factors VALUES ('depth'), ('width');
39 39
40 INSERT INTO waterway.gauges ( 40 WITH
41 location, objname, geom, zero_point, source_organization) 41 gs AS (
42 INSERT INTO waterway.gauges (
43 location,
44 validity,
45 objname,
46 geom,
47 zero_point,
48 date_info,
49 source_organization,
50 lastupdate)
42 VALUES ( 51 VALUES (
43 ('AT', 'XXX', '00001', 'G0001', 1)::isrs, 52 ('AT', 'XXX', '00001', 'G0001', 1)::isrs,
53 tstzrange(current_timestamp - '1 day'::interval, current_timestamp),
44 'testgauge', 54 'testgauge',
45 ST_geomfromtext('POINT(0 0)', 4326), 55 ST_geomfromtext('POINT(0 0)', 4326),
46 0, 56 0,
47 'testorganization' 57 current_timestamp,
48 ); 58 'testorganization',
49 59 current_timestamp)
50 INSERT INTO waterway.bottlenecks ( 60 RETURNING location, validity),
51 bottleneck_id, fk_g_fid, stretch, area, rb, lb, responsible_country, 61 bns AS (
52 revisiting_time, limiting, source_organization, staging_done)
53 VALUES ( 62 VALUES (
54 'testbottleneck1', 63 'testbottleneck1',
55 ('AT', 'XXX', '00001', 'G0001', 1)::isrs,
56 isrsrange(('AT', 'XXX', '00001', '00000', 0)::isrs, 64 isrsrange(('AT', 'XXX', '00001', '00000', 0)::isrs,
57 ('AT', 'XXX', '00001', '00000', 2)::isrs), 65 ('AT', 'XXX', '00001', '00000', 2)::isrs),
58 ST_geomfromtext('MULTIPOLYGON(((0 0, 0 1, 1 1, 1 0, 0 0)))', 4326), 66 ST_geomfromtext('MULTIPOLYGON(((0 0, 0 1, 1 1, 1 0, 0 0)))', 4326),
59 'AT', 'AT', 'AT', 67 'AT', 'AT', 'AT',
60 1, 'depth', 'testorganization', false 68 1, 'depth', 'testorganization', false
61 ), ( 69 ), (
62 'testbottleneck2', 70 'testbottleneck2',
63 ('AT', 'XXX', '00001', 'G0001', 1)::isrs,
64 isrsrange(('AT', 'XXX', '00001', '00000', 0)::isrs, 71 isrsrange(('AT', 'XXX', '00001', '00000', 0)::isrs,
65 ('AT', 'XXX', '00001', '00000', 2)::isrs), 72 ('AT', 'XXX', '00001', '00000', 2)::isrs),
66 ST_geomfromtext('MULTIPOLYGON(((0 0, 0 1, 1 1, 1 0, 0 0)))', 4326), 73 ST_geomfromtext('MULTIPOLYGON(((0 0, 0 1, 1 1, 1 0, 0 0)))', 4326),
67 'AT', 'AT', 'AT', 74 'AT', 'AT', 'AT',
68 1, 'depth', 'testorganization', true 75 1, 'depth', 'testorganization', true
69 ); 76 ))
77 INSERT INTO waterway.bottlenecks (
78 gauge_location, gauge_validity,
79 bottleneck_id, stretch, area, rb, lb, responsible_country,
80 revisiting_time, limiting, source_organization, staging_done)
81 SELECT * FROM gs, bns;
70 82
71 INSERT INTO waterway.distance_marks_virtual VALUES ( 83 INSERT INTO waterway.distance_marks_virtual VALUES (
72 ('AT', 'XXX', '00001', '00000', 0)::isrs, 84 ('AT', 'XXX', '00001', '00000', 0)::isrs,
73 ST_SetSRID('POINT(0 0)'::geometry, 4326), 85 ST_SetSRID('POINT(0 0)'::geometry, 4326),
74 'someENC' 86 'someENC'