-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of github.com:earth-metabolome-initiative/emi-mon…
…orepo
- Loading branch information
Showing
12 changed files
with
103 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
web/backend/migrations/2024-02-09-143242_create_item_real_quantities_table/down.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
-- This file should undo anything in `up.sql` |
19 changes: 19 additions & 0 deletions
19
web/backend/migrations/2024-02-09-143242_create_item_real_quantities_table/up.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
-- SQL defining the item_real_quantities table. | ||
-- Each item, being a physical object, has a weight. This table defines the weights of items. | ||
-- The weight of an item may change over time, and be measured using different scales and by | ||
-- different people. | ||
CREATE TABLE item_real_quantities ( | ||
id SERIAL PRIMARY KEY, | ||
item_id INTEGER REFERENCES items(id), | ||
weight DECIMAL(10, 2) NOT NULL, | ||
unit_id INTEGER REFERENCES units(id), | ||
sensor_id INTEGER REFERENCES items(id), | ||
measured_at TIMESTAMPTZ NOT NULL DEFAULT now(), | ||
measured_by INTEGER REFERENCES users(id), | ||
created_at TIMESTAMPTZ NOT NULL DEFAULT now(), | ||
updated_at TIMESTAMPTZ NOT NULL DEFAULT now(), | ||
created_by INTEGER NOT NULL REFERENCES users(id), | ||
updated_by INTEGER NOT NULL REFERENCES users(id), | ||
FOREIGN KEY (item_id, unit_id) REFERENCES items(item_id, unit_id), | ||
FOREIGN KEY (unit_id) REFERENCES real_units(id) | ||
); |
1 change: 1 addition & 0 deletions
1
web/backend/migrations/2024-02-09-144314_create_item_discrete_quantities_table/down.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
-- This file should undo anything in `up.sql` |
22 changes: 22 additions & 0 deletions
22
web/backend/migrations/2024-02-09-144314_create_item_discrete_quantities_table/up.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
-- SQL defining the item_quantities table. | ||
-- Some items may be counted discretely, as opposed to a weight in grams. | ||
-- This table defines the discrete quantities of items that we have in stock. | ||
-- The quantity of an item may change over time, so multiple quantity entries | ||
-- may be inserted for the same item. | ||
-- While these quantities are discrete, in order to facilitate the semantics of | ||
-- the system, we will still allow for the user to specify the counter unit for | ||
-- the item. For example, a counter unit may be a box, a tube, or a vial. | ||
CREATE TABLE item_discrete_quantities ( | ||
id SERIAL PRIMARY KEY, | ||
item_id INTEGER REFERENCES items(id), | ||
quantity INTEGER NOT NULL, | ||
unit_id INTEGER REFERENCES weight_units(id), | ||
measured_at TIMESTAMPTZ NOT NULL DEFAULT now(), | ||
measured_by INTEGER REFERENCES users(id), | ||
created_at TIMESTAMPTZ NOT NULL DEFAULT now(), | ||
updated_at TIMESTAMPTZ NOT NULL DEFAULT now(), | ||
created_by INTEGER NOT NULL REFERENCES users(id), | ||
updated_by INTEGER NOT NULL REFERENCES users(id), | ||
FOREIGN KEY (item_id, unit_id) REFERENCES item_units(item_id, unit_id), | ||
FOREIGN KEY (unit_id) REFERENCES discrete_units(id) | ||
); |
1 change: 1 addition & 0 deletions
1
web/backend/migrations/2024-02-09-155933_create_discrete_units_table/down.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
-- This file should undo anything in `up.sql` |
7 changes: 7 additions & 0 deletions
7
web/backend/migrations/2024-02-09-155933_create_discrete_units_table/up.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
-- SQL describing the discrete_units table. | ||
-- The discrete_units table is used as the finite set of units that can be used to measure | ||
-- the discrete quantities of items. For example, a box, a tube, or a vial. | ||
CREATE TABLE discrete_units ( | ||
id INTEGER PRIMARY KEY, | ||
FOREIGN KEY (id) REFERENCES units(id) | ||
); |
1 change: 1 addition & 0 deletions
1
web/backend/migrations/2024-02-09-160358_create_real_units_table/down.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
-- This file should undo anything in `up.sql` |
7 changes: 7 additions & 0 deletions
7
web/backend/migrations/2024-02-09-160358_create_real_units_table/up.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
-- SQL describing the real_units table. | ||
-- The real_units table is used as the finite set of units that can be used to measure | ||
-- the real quantities of items. For example, a box, a tube, or a vial. | ||
CREATE TABLE real_units ( | ||
id INTEGER PRIMARY KEY, | ||
FOREIGN KEY (id) REFERENCES units(id) | ||
); |