Skip to content

Commit 077ae44

Browse files
authored
Merge pull request #326 from akrherz/taf_domain
260305
2 parents 9c9d379 + c87ea3f commit 077ae44

34 files changed

+4067
-3794
lines changed

.sqlfluff

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
[sqlfluff]
2-
dialect = "postgres"
2+
dialect = postgres
33
large_file_skip_byte_limit = 0
4+
exclude_rules = RF04, LT05
5+
ignore = data/*, upgrade/*

.sqlfluffignore

Lines changed: 0 additions & 1 deletion
This file was deleted.

init/afos.sql

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
1-
21
-- Boilerplate IEM schema_manager_version, the version gets incremented each
32
-- time we make an upgrade script
4-
CREATE TABLE iem_schema_manager_version(
3+
CREATE TABLE iem_schema_manager_version (
54
version int,
6-
updated timestamptz);
7-
INSERT into iem_schema_manager_version values (10, now());
5+
updated timestamptz
6+
);
7+
INSERT INTO iem_schema_manager_version VALUES (10, now());
88

9-
CREATE TABLE products(
9+
CREATE TABLE products (
1010
data text,
11-
pil char(6) not null,
11+
pil char(6) NOT NULL,
1212
entered timestamptz,
1313
source char(4),
1414
wmo char(6),
1515
bbb varchar(3)
16-
) PARTITION by RANGE (entered);
17-
ALTER TABLE products OWNER to mesonet;
18-
GRANT ALL on products to ldm;
19-
GRANT SELECT on products to nobody;
16+
) PARTITION BY RANGE (entered);
17+
ALTER TABLE products OWNER TO mesonet;
18+
GRANT ALL ON products TO ldm;
19+
GRANT SELECT ON products TO nobody;
2020

2121

22-
do
22+
DO
2323
$do$
2424
declare
2525
year int;

init/asos.sql

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,9 @@ $do$;
240240
CREATE TABLE taf (
241241
id serial UNIQUE,
242242
station char(4),
243-
valid timestamptz, -- noqa
243+
valid timestamptz,
244+
issue timestamptz,
245+
expire timestamptz,
244246
product_id varchar(35),
245247
is_amendment boolean
246248
);

init/asos1min.sql

Lines changed: 83 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -1,95 +1,104 @@
11
CREATE EXTENSION postgis;
22

33
-- bandaid
4-
insert into spatial_ref_sys select 9311, 'EPSG', 9311, srtext, proj4text from spatial_ref_sys where srid = 2163;
4+
INSERT INTO spatial_ref_sys
5+
SELECT
6+
9311 AS srid,
7+
'EPSG' AS auth_name,
8+
9311 AS auth_srid,
9+
srtext,
10+
proj4text
11+
FROM spatial_ref_sys
12+
WHERE srid = 2163;
513

614
-- Boilerplate IEM schema_manager_version, the version gets incremented each
715
-- time we make an upgrade script
8-
CREATE TABLE iem_schema_manager_version(
9-
version int,
10-
updated timestamptz);
11-
INSERT into iem_schema_manager_version values (1, now());
16+
CREATE TABLE iem_schema_manager_version (
17+
version int,
18+
updated timestamptz
19+
);
20+
INSERT INTO iem_schema_manager_version VALUES (1, now());
1221

1322

1423
---
1524
--- Quasi synced from mesosite database
1625
---
17-
CREATE TABLE stations(
18-
id varchar(64),
19-
synop int,
20-
name varchar(64),
21-
state char(2),
22-
country char(2),
23-
elevation real,
24-
network varchar(20),
25-
online boolean,
26-
params varchar(300),
27-
county varchar(50),
28-
plot_name varchar(64),
29-
climate_site varchar(6),
30-
remote_id int,
31-
nwn_id int,
32-
spri smallint,
33-
wfo varchar(3),
34-
archive_begin date,
35-
archive_end date,
36-
modified timestamp with time zone,
37-
tzname varchar(32),
38-
iemid SERIAL,
39-
metasite boolean,
40-
sigstage_low real,
41-
sigstage_action real,
42-
sigstage_bankfull real,
43-
sigstage_flood real,
44-
sigstage_moderate real,
45-
sigstage_major real,
46-
sigstage_record real,
47-
ugc_county char(6),
48-
ugc_zone char(6),
49-
ncdc81 varchar(11),
26+
CREATE TABLE stations (
27+
id varchar(64),
28+
synop int,
29+
name varchar(64),
30+
state char(2),
31+
country char(2),
32+
elevation real,
33+
network varchar(20),
34+
online boolean,
35+
params varchar(300),
36+
county varchar(50),
37+
plot_name varchar(64),
38+
climate_site varchar(6),
39+
remote_id int,
40+
nwn_id int,
41+
spri smallint,
42+
wfo varchar(3),
43+
archive_begin date,
44+
archive_end date,
45+
modified timestamp with time zone,
46+
tzname varchar(32),
47+
iemid serial,
48+
metasite boolean,
49+
sigstage_low real,
50+
sigstage_action real,
51+
sigstage_bankfull real,
52+
sigstage_flood real,
53+
sigstage_moderate real,
54+
sigstage_major real,
55+
sigstage_record real,
56+
ugc_county char(6),
57+
ugc_zone char(6),
58+
ncdc81 varchar(11),
5059
ncei91 varchar(11),
51-
temp24_hour smallint,
52-
precip24_hour smallint,
53-
wigos varchar(64)
60+
temp24_hour smallint,
61+
precip24_hour smallint,
62+
wigos varchar(64)
5463
);
55-
ALTER TABLE stations OWNER to mesonet;
56-
CREATE UNIQUE index stations_idx on stations(id, network);
57-
create UNIQUE index stations_iemid_idx on stations(iemid);
58-
SELECT AddGeometryColumn('stations', 'geom', 4326, 'POINT', 2);
59-
GRANT SELECT on stations to nobody;
60-
grant all on stations_iemid_seq to nobody;
61-
GRANT ALL on stations to mesonet,ldm;
62-
GRANT ALL on stations_iemid_seq to mesonet,ldm;
64+
ALTER TABLE stations OWNER TO mesonet;
65+
CREATE UNIQUE INDEX stations_idx ON stations (id, network);
66+
CREATE UNIQUE INDEX stations_iemid_idx ON stations (iemid);
67+
SELECT addgeometrycolumn('stations', 'geom', 4326, 'POINT', 2);
68+
GRANT SELECT ON stations TO nobody;
69+
GRANT ALL ON stations_iemid_seq TO nobody;
70+
GRANT ALL ON stations TO mesonet, ldm;
71+
GRANT ALL ON stations_iemid_seq TO mesonet, ldm;
6372

6473
---
6574
--- One Minute ASOS data
6675
---
67-
CREATE TABLE alldata_1minute(
68-
station varchar(4),
69-
valid timestamptz,
70-
vis1_coeff real,
71-
vis1_nd char(1),
72-
vis2_coeff real,
73-
vis2_nd char(1),
74-
vis3_coeff real,
75-
vis3_nd char(1),
76-
drct smallint,
77-
sknt smallint,
78-
gust_drct smallint,
79-
gust_sknt smallint,
80-
ptype char(2),
81-
precip real,
82-
pres1 real,
83-
pres2 real,
84-
pres3 real,
85-
tmpf smallint,
86-
dwpf smallint
87-
) PARTITION by range(valid);
88-
ALTER TABLE alldata_1minute OWNER to mesonet;
89-
GRANT ALL on alldata_1minute to ldm;
90-
GRANT SELECT on alldata_1minute to nobody;
76+
CREATE TABLE alldata_1minute (
77+
station varchar(4),
78+
valid timestamptz,
79+
vis1_coeff real,
80+
vis1_nd char(1),
81+
vis2_coeff real,
82+
vis2_nd char(1),
83+
vis3_coeff real,
84+
vis3_nd char(1),
85+
drct smallint,
86+
sknt smallint,
87+
gust_drct smallint,
88+
gust_sknt smallint,
89+
ptype char(2),
90+
precip real,
91+
pres1 real,
92+
pres2 real,
93+
pres3 real,
94+
tmpf smallint,
95+
dwpf smallint
96+
) PARTITION BY RANGE (valid);
97+
ALTER TABLE alldata_1minute OWNER TO mesonet;
98+
GRANT ALL ON alldata_1minute TO ldm;
99+
GRANT SELECT ON alldata_1minute TO nobody;
91100

92-
do
101+
DO
93102
$do$
94103
declare
95104
year int;

init/awos.sql

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
21
-- Boilerplate IEM schema_manager_version, the version gets incremented each
32
-- time we make an upgrade script
4-
CREATE TABLE iem_schema_manager_version(
3+
CREATE TABLE iem_schema_manager_version (
54
version int,
6-
updated timestamptz);
7-
INSERT into iem_schema_manager_version values (0, now());
5+
updated timestamptz
6+
);
7+
INSERT INTO iem_schema_manager_version VALUES (0, now());
88

99
---
1010
--- Main table that all children inherit from
1111
---
12-
CREATE TABLE alldata(
12+
CREATE TABLE alldata (
1313
station varchar(5),
1414
valid timestamptz,
1515
tmpf smallint,
@@ -27,12 +27,12 @@ CREATE TABLE alldata(
2727
vsby real,
2828
alti real,
2929
qc varchar(5)
30-
) PARTITION by range(valid);
31-
ALTER TABLE alldata OWNER to mesonet;
32-
GRANT ALL on alldata to ldm;
33-
GRANT SELECT on alldata to nobody;
30+
) PARTITION BY RANGE (valid);
31+
ALTER TABLE alldata OWNER TO mesonet;
32+
GRANT ALL ON alldata TO ldm;
33+
GRANT SELECT ON alldata TO nobody;
3434

35-
do
35+
DO
3636
$do$
3737
declare
3838
year int;

0 commit comments

Comments
 (0)