Importing base schema
This commit is contained in:
parent
7e74d672ba
commit
b045ded9cd
16 changed files with 170 additions and 0 deletions
5
datastore/migrations/00004_AddStrain_down.sql
Normal file
5
datastore/migrations/00004_AddStrain_down.sql
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
-- bactdb
|
||||||
|
-- Matthew R Dillon
|
||||||
|
|
||||||
|
DROP TABLE strains;
|
||||||
|
|
20
datastore/migrations/00004_AddStrain_up.sql
Normal file
20
datastore/migrations/00004_AddStrain_up.sql
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
-- bactdb
|
||||||
|
-- Matthew R Dillon
|
||||||
|
|
||||||
|
CREATE TABLE strains (
|
||||||
|
id BIGSERIAL NOT NULL,
|
||||||
|
species_id BIGINT,
|
||||||
|
strain_name CHARACTER VARYING(100),
|
||||||
|
strain_type CHARACTER VARYING(100),
|
||||||
|
etymology CHARACTER VARYING(500),
|
||||||
|
accession_banks CHARACTER VARYING(100),
|
||||||
|
genbank_embl_ddb CHARACTER VARYING(100),
|
||||||
|
|
||||||
|
created_at TIMESTAMP WITH TIME ZONE,
|
||||||
|
updated_at TIMESTAMP WITH TIME ZONE,
|
||||||
|
deleted_at TIMESTAMP WITH TIME ZONE,
|
||||||
|
|
||||||
|
CONSTRAINT strain_pkey PRIMARY KEY (id),
|
||||||
|
FOREIGN KEY (species_id) REFERENCES species(id)
|
||||||
|
);
|
||||||
|
|
5
datastore/migrations/00005_AddObservationTypes_down.sql
Normal file
5
datastore/migrations/00005_AddObservationTypes_down.sql
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
-- bactdb
|
||||||
|
-- Matthew R Dillon
|
||||||
|
|
||||||
|
DROP TABLE observation_types;
|
||||||
|
|
14
datastore/migrations/00005_AddObservationTypes_up.sql
Normal file
14
datastore/migrations/00005_AddObservationTypes_up.sql
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
-- bactdb
|
||||||
|
-- Matthew R Dillon
|
||||||
|
|
||||||
|
CREATE TABLE observation_types (
|
||||||
|
id BIGSERIAL NOT NULL,
|
||||||
|
observation_type_name CHARACTER VARYING(100),
|
||||||
|
|
||||||
|
created_at TIMESTAMP WITH TIME ZONE,
|
||||||
|
updated_at TIMESTAMP WITH TIME ZONE,
|
||||||
|
deleted_at TIMESTAMP WITH TIME ZONE,
|
||||||
|
|
||||||
|
CONSTRAINT observation_types_pkey PRIMARY KEY (id)
|
||||||
|
);
|
||||||
|
|
5
datastore/migrations/00006_AddObservations_down.sql
Normal file
5
datastore/migrations/00006_AddObservations_down.sql
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
-- bactdb
|
||||||
|
-- Matthew R Dillon
|
||||||
|
|
||||||
|
DROP TABLE observations;
|
||||||
|
|
16
datastore/migrations/00006_AddObservations_up.sql
Normal file
16
datastore/migrations/00006_AddObservations_up.sql
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
-- bactdb
|
||||||
|
-- Matthew R Dillon
|
||||||
|
|
||||||
|
CREATE TABLE observations (
|
||||||
|
id BIGSERIAL NOT NULL,
|
||||||
|
observation_name CHARACTER VARYING(100),
|
||||||
|
observation_type_id BIGINT,
|
||||||
|
|
||||||
|
created_at TIMESTAMP WITH TIME ZONE,
|
||||||
|
updated_at TIMESTAMP WITH TIME ZONE,
|
||||||
|
deleted_at TIMESTAMP WITH TIME ZONE,
|
||||||
|
|
||||||
|
CONSTRAINT observations_pkey PRIMARY KEY (id),
|
||||||
|
FOREIGN KEY (observation_type_id) REFERENCES observation_types(id)
|
||||||
|
);
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
-- bactdb
|
||||||
|
-- Matthew R Dillon
|
||||||
|
|
||||||
|
DROP TABLE strainsobservations;
|
||||||
|
|
17
datastore/migrations/00007_AddStrainsObservations_up.sql
Normal file
17
datastore/migrations/00007_AddStrainsObservations_up.sql
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
-- bactdb
|
||||||
|
-- Matthew R Dillon
|
||||||
|
|
||||||
|
CREATE TABLE strainsobservations (
|
||||||
|
id BIGSERIAL NOT NULL,
|
||||||
|
strain_id BIGINT NOT NULL,
|
||||||
|
observations_id BIGINT NOT NULL,
|
||||||
|
|
||||||
|
created_at TIMESTAMP WITH TIME ZONE,
|
||||||
|
updated_at TIMESTAMP WITH TIME ZONE,
|
||||||
|
deleted_at TIMESTAMP WITH TIME ZONE,
|
||||||
|
|
||||||
|
CONSTRAINT strainsobservations_pkey PRIMARY KEY (id),
|
||||||
|
FOREIGN KEY (strain_id) REFERENCES strains(id),
|
||||||
|
FOREIGN KEY (observations_id) REFERENCES observations(id)
|
||||||
|
);
|
||||||
|
|
5
datastore/migrations/00008_AddText_Measurements_down.sql
Normal file
5
datastore/migrations/00008_AddText_Measurements_down.sql
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
-- bactdb
|
||||||
|
-- Matthew R Dillon
|
||||||
|
|
||||||
|
DROP TABLE text_measurements;
|
||||||
|
|
14
datastore/migrations/00008_AddText_Measurements_up.sql
Normal file
14
datastore/migrations/00008_AddText_Measurements_up.sql
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
-- bactdb
|
||||||
|
-- Matthew R Dillon
|
||||||
|
|
||||||
|
CREATE TABLE text_measurements (
|
||||||
|
id BIGSERIAL NOT NULL,
|
||||||
|
text_measurement_name CHARACTER VARYING(100),
|
||||||
|
|
||||||
|
created_at TIMESTAMP WITH TIME ZONE,
|
||||||
|
updated_at TIMESTAMP WITH TIME ZONE,
|
||||||
|
deleted_at TIMESTAMP WITH TIME ZONE,
|
||||||
|
|
||||||
|
CONSTRAINT text_measurements_pkey PRIMARY KEY (id)
|
||||||
|
);
|
||||||
|
|
5
datastore/migrations/00009_AddUnit_Types_down.sql
Normal file
5
datastore/migrations/00009_AddUnit_Types_down.sql
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
-- bactdb
|
||||||
|
-- Matthew R Dillon
|
||||||
|
|
||||||
|
DROP TABLE unit_types;
|
||||||
|
|
15
datastore/migrations/00009_AddUnit_Types_up.sql
Normal file
15
datastore/migrations/00009_AddUnit_Types_up.sql
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
-- bactdb
|
||||||
|
-- Matthew R Dillon
|
||||||
|
|
||||||
|
CREATE TABLE unit_types (
|
||||||
|
id BIGSERIAL NOT NULL,
|
||||||
|
name CHARACTER VARYING(100),
|
||||||
|
symbol CHARACTER VARYING(10),
|
||||||
|
|
||||||
|
created_at TIMESTAMP WITH TIME ZONE,
|
||||||
|
updated_at TIMESTAMP WITH TIME ZONE,
|
||||||
|
deleted_at TIMESTAMP WITH TIME ZONE,
|
||||||
|
|
||||||
|
CONSTRAINT unit_types_pkey PRIMARY KEY (id)
|
||||||
|
);
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
-- bactdb
|
||||||
|
-- Matthew R Dillon
|
||||||
|
|
||||||
|
DROP TABLE numerical_measurements;
|
||||||
|
|
17
datastore/migrations/00010_AddNumerical_Measurements_up.sql
Normal file
17
datastore/migrations/00010_AddNumerical_Measurements_up.sql
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
-- bactdb
|
||||||
|
-- Matthew R Dillon
|
||||||
|
|
||||||
|
CREATE TABLE numerical_measurements (
|
||||||
|
id BIGSERIAL NOT NULL,
|
||||||
|
measurement_value NUMERIC(6, 4) NOT NULL,
|
||||||
|
confidence_interval NUMERIC(6,4) NULL,
|
||||||
|
unit_type_id BIGINT,
|
||||||
|
|
||||||
|
created_at TIMESTAMP WITH TIME ZONE,
|
||||||
|
updated_at TIMESTAMP WITH TIME ZONE,
|
||||||
|
deleted_at TIMESTAMP WITH TIME ZONE,
|
||||||
|
|
||||||
|
CONSTRAINT numerical_measurements_pkey PRIMARY KEY (id),
|
||||||
|
FOREIGN KEY (unit_type_id) REFERENCES unit_types(id)
|
||||||
|
);
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
-- bactdb
|
||||||
|
-- Matthew R Dillon
|
||||||
|
|
||||||
|
DROP TABLE strainsobsmeasurements;
|
||||||
|
|
17
datastore/migrations/00011_AddStrainObsMeasurements_up.sql
Normal file
17
datastore/migrations/00011_AddStrainObsMeasurements_up.sql
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
-- bactdb
|
||||||
|
-- Matthew R Dillon
|
||||||
|
|
||||||
|
CREATE TABLE strainsobsmeasurements (
|
||||||
|
id BIGSERIAL NOT NULL,
|
||||||
|
strainsobservations_id BIGINT,
|
||||||
|
measurement_table CHARACTER VARYING(15),
|
||||||
|
measurement_id BIGINT,
|
||||||
|
|
||||||
|
created_at TIMESTAMP WITH TIME ZONE,
|
||||||
|
updated_at TIMESTAMP WITH TIME ZONE,
|
||||||
|
deleted_at TIMESTAMP WITH TIME ZONE,
|
||||||
|
|
||||||
|
CONSTRAINT strainsobsmeasurements_pkey PRIMARY KEY (id),
|
||||||
|
FOREIGN KEY (strainsobservations_id) REFERENCES strainsobservations(id)
|
||||||
|
);
|
||||||
|
|
Reference in a new issue