Skip to content

Commit

Permalink
Added migration script for nd_fact table.
Browse files Browse the repository at this point in the history
  • Loading branch information
guignonv committed Feb 8, 2022
1 parent e5cfe8a commit e91dc32
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions chado/migrations/V1.3.3.010__add_environmental_fact_table.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
-- Adds a new "nd_fact" table to store environmental data.
CREATE TABLE nd_fact(
nd_fact_id BIGSERIAL PRIMARY KEY NOT NULL,
nd_geolocation_id BIGINT NOT NULL REFERENCES nd_geolocation (nd_geolocation_id) ON DELETE CASCADE INITIALLY DEFERRED,
type_id BIGINT NOT NULL REFERENCES cvterm (cvterm_id) ON DELETE CASCADE INITIALLY DEFERRED,
timecaptured TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
value TEXT NULL,
CONSTRAINT nd_fact_c1 UNIQUE (nd_geolocation_id, type_id, timecaptured)
);
CREATE INDEX nd_fact_idx1 ON nd_fact (nd_geolocation_id);
CREATE INDEX nd_fact_idx2 ON nd_fact (timecaptured);

COMMENT ON TABLE nd_fact IS 'The fact table contains facts (temparture, weather condition,...) at a given time for a given geolocation.';
COMMENT ON COLUMN nd_fact.value IS 'The value can be NULL if the type_id is self-explicit. For instance, if the type_id term is "sunny day", there is no need for a value.';

0 comments on commit e91dc32

Please sign in to comment.