Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 47 additions & 1 deletion init/other.sql
Original file line number Diff line number Diff line change
@@ -1,9 +1,55 @@
CREATE EXTENSION postgis;

-- Boilerplate IEM schema_manager_version, the version gets incremented each
-- time we make an upgrade script
CREATE TABLE iem_schema_manager_version(
version int,
updated timestamptz);
INSERT into iem_schema_manager_version values (15, now());
INSERT into iem_schema_manager_version values (16, now());

CREATE TABLE stations(
id varchar(64),
synop int,
name varchar(64),
state char(2),
country char(2),
elevation real,
network varchar(20),
online boolean,
params varchar(300),
county varchar(50),
plot_name varchar(64),
climate_site varchar(6),
remote_id int,
nwn_id int,
spri smallint,
wfo varchar(3),
archive_begin date,
archive_end date,
modified timestamp with time zone,
tzname varchar(32),
iemid SERIAL,
metasite boolean,
sigstage_low real,
sigstage_action real,
sigstage_bankfull real,
sigstage_flood real,
sigstage_moderate real,
sigstage_major real,
sigstage_record real,
ugc_county char(6),
ugc_zone char(6),
ncdc81 varchar(11),
ncei91 varchar(11),
temp24_hour smallint,
precip24_hour smallint,
wigos varchar(64),
geom geometry(POINT, 4326)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The geom column is present here, but missing in the upgrade scripts (upgrade/other/16.sql and upgrade/rwis/8.sql). Ensure that the upgrade scripts also include this column to maintain consistency across the database schema.

Comment on lines +10 to +47
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This stations table definition is duplicated in init/rwis.sql, upgrade/other/16.sql, and upgrade/rwis/8.sql. Consider creating a common SQL file or function to define the table and referencing it from these files to avoid duplication and potential inconsistencies. This will improve maintainability.

);
alter table stations owner to mesonet;
grant select on stations to ldm,nobody;
CREATE UNIQUE index stations_idx on stations(id, network);
create UNIQUE index stations_iemid_idx on stations(iemid);

-- Purple Air Data
create table purpleair(
Expand Down
48 changes: 47 additions & 1 deletion init/rwis.sql
Original file line number Diff line number Diff line change
@@ -1,9 +1,55 @@
CREATE EXTENSION postgis;
-- Boilerplate IEM schema_manager_version, the version gets incremented each
-- time we make an upgrade script
CREATE TABLE iem_schema_manager_version(
version int,
updated timestamptz);
INSERT into iem_schema_manager_version values (8, now());
INSERT into iem_schema_manager_version values (9, now());

CREATE TABLE stations(
id varchar(64),
synop int,
name varchar(64),
state char(2),
country char(2),
elevation real,
network varchar(20),
online boolean,
params varchar(300),
county varchar(50),
plot_name varchar(64),
climate_site varchar(6),
remote_id int,
nwn_id int,
spri smallint,
wfo varchar(3),
archive_begin date,
archive_end date,
modified timestamp with time zone,
tzname varchar(32),
iemid SERIAL,
metasite boolean,
sigstage_low real,
sigstage_action real,
sigstage_bankfull real,
sigstage_flood real,
sigstage_moderate real,
sigstage_major real,
sigstage_record real,
ugc_county char(6),
ugc_zone char(6),
ncdc81 varchar(11),
ncei91 varchar(11),
temp24_hour smallint,
precip24_hour smallint,
wigos varchar(64),
geom geometry(POINT, 4326)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The geom column is present here, but missing in the upgrade scripts (upgrade/other/16.sql and upgrade/rwis/8.sql). Ensure that the upgrade scripts also include this column to maintain consistency across the database schema.

Comment on lines +9 to +46
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This stations table definition is duplicated in init/other.sql, upgrade/other/16.sql, and upgrade/rwis/8.sql. Consider creating a common SQL file or function to define the table and referencing it from these files to avoid duplication and potential inconsistencies. This will improve maintainability.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please suggest how to do this

);
alter table stations owner to mesonet;
grant select on stations to ldm,nobody;
CREATE UNIQUE index stations_idx on stations(id, network);
create UNIQUE index stations_iemid_idx on stations(iemid);


CREATE TABLE sensors(
station varchar(5),
Expand Down
45 changes: 45 additions & 0 deletions upgrade/other/16.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
CREATE EXTENSION postgis;
-- need stations table
CREATE TABLE stations(
id varchar(64),
synop int,
name varchar(64),
state char(2),
country char(2),
elevation real,
network varchar(20),
online boolean,
params varchar(300),
county varchar(50),
plot_name varchar(64),
climate_site varchar(6),
remote_id int,
nwn_id int,
spri smallint,
wfo varchar(3),
archive_begin date,
archive_end date,
modified timestamp with time zone,
tzname varchar(32),
iemid SERIAL,
metasite boolean,
sigstage_low real,
sigstage_action real,
sigstage_bankfull real,
sigstage_flood real,
sigstage_moderate real,
sigstage_major real,
sigstage_record real,
ugc_county char(6),
ugc_zone char(6),
ncdc81 varchar(11),
ncei91 varchar(11),
temp24_hour smallint,
precip24_hour smallint,
wigos varchar(64),
geom geometry(POINT, 4326)
);
alter table stations owner to mesonet;
grant select on stations to ldm,nobody;
CREATE UNIQUE index stations_idx on stations(id, network);
create UNIQUE index stations_iemid_idx on stations(iemid);
45 changes: 45 additions & 0 deletions upgrade/rwis/9.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
CREATE EXTENSION postgis;
-- need stations table
CREATE TABLE stations(
id varchar(64),
synop int,
name varchar(64),
state char(2),
country char(2),
elevation real,
network varchar(20),
online boolean,
params varchar(300),
county varchar(50),
plot_name varchar(64),
climate_site varchar(6),
remote_id int,
nwn_id int,
spri smallint,
wfo varchar(3),
archive_begin date,
archive_end date,
modified timestamp with time zone,
tzname varchar(32),
iemid SERIAL,
metasite boolean,
sigstage_low real,
sigstage_action real,
sigstage_bankfull real,
sigstage_flood real,
sigstage_moderate real,
sigstage_major real,
sigstage_record real,
ugc_county char(6),
ugc_zone char(6),
ncdc81 varchar(11),
ncei91 varchar(11),
temp24_hour smallint,
precip24_hour smallint,
wigos varchar(64),
geom geometry(POINT, 4326)
);
alter table stations owner to mesonet;
grant select on stations to ldm,nobody;
CREATE UNIQUE index stations_idx on stations(id, network);
create UNIQUE index stations_iemid_idx on stations(iemid);
Loading