-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SIMSBIOHUB-665: Habitat Features Database Schema #1483
Draft
NickPhura
wants to merge
7
commits into
dev
Choose a base branch
from
SIMSBIOHUB-665
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
38be4eb
- Initial habitat features database schemas.
NickPhura 5c17785
Update enums in api/app
NickPhura f24166f
Merge remote-tracking branch 'origin/dev' into SIMSBIOHUB-665
NickPhura 01b3a80
Updates
NickPhura c23477b
insert habitat features with migration
mauberti-bc 82dd117
add join table linking habitat features and allowed measurements
mauberti-bc ebea5e7
Merge branch 'dev' into SIMSBIOHUB-665
NickPhura File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { z } from 'zod'; | ||
|
||
/** | ||
* Alert Severity Data Type. | ||
* | ||
* @description Data type for `alert_severity`. | ||
*/ | ||
export const AlertSeverity = z.enum(['info', 'warning', 'error', 'success']); | ||
|
||
export type AlertSeverity = z.infer<typeof AlertSeverity>; |
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,31 @@ | ||
import { z } from 'zod'; | ||
|
||
/** | ||
* Quantitative Unit Data Type. | ||
* | ||
* @description Data type for `quantitative_unit`. | ||
*/ | ||
export const QuantitativeUnit = z.enum([ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same comment as above |
||
'millimeter', | ||
'centimeter', | ||
'meter', | ||
'milligram', | ||
'gram', | ||
'kilogram', | ||
'percent', | ||
'celsius', | ||
'ppt', | ||
'SCF', | ||
'degrees', | ||
'pH', | ||
'seconds', | ||
'meters squared', | ||
'count', | ||
'GHz', | ||
'Hz', | ||
'amps', | ||
'volts', | ||
'megapixels' | ||
]); | ||
|
||
export type QuantitativeUnit = z.infer<typeof QuantitativeUnit>; |
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
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
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
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
27 changes: 27 additions & 0 deletions
27
database/src/migrations/20250206000001_rename_environment_unit_enum.ts
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,27 @@ | ||
import { Knex } from 'knex'; | ||
|
||
/** | ||
* Rename the `environment_unit` enum to `quantitative_unit`. | ||
* | ||
* Originally created in migration `20240417000000_obsevation_environment_tables.ts` when only the environment tables | ||
* used it. But, it really contains generic units that can be used in other tables as well. | ||
* | ||
* @export | ||
* @param {Knex} knex | ||
* @return {*} {Promise<void>} | ||
*/ | ||
export async function up(knex: Knex): Promise<void> { | ||
await knex.raw(` | ||
---------------------------------------------------------------------------------------- | ||
-- Rename the environment_unit enum to quantitative_unit | ||
---------------------------------------------------------------------------------------- | ||
|
||
SET SEARCH_PATH=biohub; | ||
|
||
ALTER TYPE environment_unit RENAME TO quantitative_unit; | ||
`); | ||
} | ||
|
||
export async function down(knex: Knex): Promise<void> { | ||
await knex.raw(``); | ||
} |
42 changes: 42 additions & 0 deletions
42
database/src/migrations/20250206000002_update_environments.ts
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,42 @@ | ||
import { Knex } from 'knex'; | ||
|
||
/** | ||
* Updates to environment tables: | ||
* - Add missing foreign key constraint for environment_qualitative_option table. | ||
* - Add indexes on 'name' column in environment_qualitative and environment_quantitative tables to improve search | ||
* performance. | ||
* | ||
* @export | ||
* @param {Knex} knex | ||
* @return {*} {Promise<void>} | ||
*/ | ||
export async function up(knex: Knex): Promise<void> { | ||
await knex.raw(`--sql | ||
---------------------------------------------------------------------------------------- | ||
-- Add missing foreign key | ||
---------------------------------------------------------------------------------------- | ||
|
||
SET SEARCH_PATH=biohub, public; | ||
|
||
-- Add foreign key constraint | ||
ALTER TABLE environment_qualitative_option | ||
ADD CONSTRAINT environment_qualitative_option_fk1 | ||
FOREIGN KEY (environment_qualitative_id) | ||
REFERENCES environment_qualitative(environment_qualitative_id); | ||
|
||
-- Add indexes for foreign keys | ||
CREATE INDEX environment_qualitative_option_idx1 ON environment_qualitative_option(environment_qualitative_id); | ||
|
||
---------------------------------------------------------------------------------------- | ||
-- Add indexes to improve search performance | ||
---------------------------------------------------------------------------------------- | ||
|
||
CREATE INDEX environment_qualitative_idx1 ON environment_qualitative(name); | ||
|
||
CREATE INDEX environment_quantitative_idx1 ON environment_quantitative(name); | ||
`); | ||
} | ||
|
||
export async function down(knex: Knex): Promise<void> { | ||
await knex.raw(``); | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
question: Should we export the actual enum instead of the type? Would this be more useful?
Then at least downstream we would be able to reference it