Skip to content
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
wants to merge 6 commits into
base: dev
Choose a base branch
from

Conversation

NickPhura
Copy link
Collaborator

@NickPhura NickPhura commented Feb 7, 2025

Links to Jira Tickets

https://apps.nrs.gov.bc.ca/int/jira/browse/SIMSBIOHUB-665

Description of Changes

Initial Habitat Features database schema.

Bonus:

  • Added a missing foreign key between environment_qualitative and environment_qualitative_option
  • Added index on the name column in environment_qualitative and environment_quantitative
  • Renamed database enum environment_unit to quantitative_unit
  • Added a folder for database types/units
    • Added file for database enum quantitative_unit
      • Updated references in api, and related type in app
    • Added file for database enum alert_severity
      • Updated references in api
      • Updated related tests

Testing Notes

Database migrations run as expected.
Has appropriate constraints, indexes, etc.

TODO

Table survey_habitat_feature

  • count?
  • survey_sample_period_id?
  • survey_observation_id?

If we do add survey_sample_period_id and survey_observation_id, should we restrict it to only one of them, since having both would be redundant?

Copy link

codecov bot commented Feb 7, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 47.58%. Comparing base (ce549a6) to head (82dd117).
Report is 7 commits behind head on dev.

Additional details and impacted files
@@            Coverage Diff             @@
##              dev    #1483      +/-   ##
==========================================
- Coverage   47.74%   47.58%   -0.16%     
==========================================
  Files         935      928       -7     
  Lines       25844    24188    -1656     
  Branches     3978     3609     -369     
==========================================
- Hits        12340    11511     -829     
+ Misses      12848    12043     -805     
+ Partials      656      634      -22     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

- Fix/update environment table foreign keys/indexes.
- Rename environment_unit database enum.
- Update api/app references to database enums.
*
* @description Data type for `alert_severity`.
*/
export const AlertSeverity = z.enum(['info', 'warning', 'error', 'success']);
Copy link
Collaborator

@MacQSL MacQSL Feb 14, 2025

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

export enum AlertSeverity {
    info = 'info',
    warning = 'warning',
    ...
}

export const AlertSeverityUnit = z.nativeEnum(AlertSeverity)

@mauberti-bc mauberti-bc added the Ready For Review PR is ready for review label Feb 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Ready For Review PR is ready for review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants