diff --git a/sql/db_migrations/migrations/000014_add_more_fields_to_md.down.sql b/sql/db_migrations/migrations/000014_add_more_fields_to_md.down.sql index 89b30d5..5468243 100644 --- a/sql/db_migrations/migrations/000014_add_more_fields_to_md.down.sql +++ b/sql/db_migrations/migrations/000014_add_more_fields_to_md.down.sql @@ -1,3 +1,3 @@ ALTER TABLE mesoscaleDiscussionV2 DROP probabilityOfWatchIssuance; ALTER TABLE mesoscaleDiscussionV2 DROP expires; -ALTER TABLE mesoscaleDiscussionV2 DROP valid; +ALTER TABLE mesoscaleDiscussionV2 DROP effective; diff --git a/sql/db_migrations/migrations/000014_add_more_fields_to_md.up.sql b/sql/db_migrations/migrations/000014_add_more_fields_to_md.up.sql index 51ae589..db324fb 100644 --- a/sql/db_migrations/migrations/000014_add_more_fields_to_md.up.sql +++ b/sql/db_migrations/migrations/000014_add_more_fields_to_md.up.sql @@ -1,3 +1,3 @@ ALTER TABLE mesoscaleDiscussionV2 ADD probabilityOfWatchIssuance INT; ALTER TABLE mesoscaleDiscussionV2 ADD expires TIMESTAMP WITH TIME ZONE; -ALTER TABLE mesoscaleDiscussionV2 ADD valid TIMESTAMP WITH TIME ZONE; +ALTER TABLE mesoscaleDiscussionV2 ADD effective TIMESTAMP WITH TIME ZONE; diff --git a/sql/mesoscale_discussion_v2_table.go b/sql/mesoscale_discussion_v2_table.go index 52face6..491ae7b 100644 --- a/sql/mesoscale_discussion_v2_table.go +++ b/sql/mesoscale_discussion_v2_table.go @@ -34,7 +34,7 @@ func NewPostgresMesoscaleDiscussionV2Table(db *sql.DB) PostgresMesoscaleDiscussi func (p *PostgresMesoscaleDiscussionV2Table) Insert(md data_structures.MesoscaleDiscussionV2) error { //language=SQL statement, err := p.db.Prepare(` - INSERT INTO mesoscaleDiscussionV2 (id, number, year, geometry, rawText, probabilityOfWatchIssuance, valid, expires) + INSERT INTO mesoscaleDiscussionV2 (id, number, year, geometry, rawText, probabilityOfWatchIssuance, effective, expires) VALUES ( $1, $2, @@ -69,7 +69,7 @@ func (p *PostgresMesoscaleDiscussionV2Table) Insert(md data_structures.Mesoscale } func (p *PostgresMesoscaleDiscussionV2Table) Select(year, mdNumber int) (*data_structures.MesoscaleDiscussionV2, error) { - statement, err := p.db.Prepare(`SELECT id, number, year, geometry::JSONB, rawText FROM mesoscaleDiscussionV2 WHERE year = $1 AND mdNumber = $2`) + statement, err := p.db.Prepare(`SELECT id, number, year, geometry::JSONB, rawText, probabilityOfWatchIssuance, effective, expires FROM mesoscaleDiscussionV2 WHERE year = $1 AND mdNumber = $2`) if err != nil { return nil, err } @@ -84,6 +84,9 @@ func (p *PostgresMesoscaleDiscussionV2Table) Select(year, mdNumber int) (*data_s &md.Year, &marshalledGeometry, &md.RawText, + &md.ProbabilityOfWatchIssuance, + &md.Effective, + &md.Expires, ) if err != nil { return nil, err @@ -100,7 +103,7 @@ func (p *PostgresMesoscaleDiscussionV2Table) Select(year, mdNumber int) (*data_s } func (p *PostgresMesoscaleDiscussionV2Table) SelectById(id string) (*data_structures.MesoscaleDiscussionV2, error) { - statement, err := p.db.Prepare(`SELECT id, number, year, geometry::JSONB, rawText FROM mesoscaleDiscussionV2 WHERE id = $1`) + statement, err := p.db.Prepare(`SELECT id, number, year, geometry::JSONB, rawText, probabilityOfWatchIssuance, effective, expires FROM mesoscaleDiscussionV2 WHERE id = $1`) if err != nil { return nil, err } @@ -115,6 +118,9 @@ func (p *PostgresMesoscaleDiscussionV2Table) SelectById(id string) (*data_struct &md.Year, &marshalledGeometry, &md.RawText, + &md.ProbabilityOfWatchIssuance, + &md.Effective, + &md.Expires, ) if err != nil { return nil, err