-
Notifications
You must be signed in to change notification settings - Fork 8
SUBMIT-768 Track_phases table fixes #806
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
Draft
dinesh-aot
wants to merge
6
commits into
bcgov:develop
Choose a base branch
from
dinesh-aot:SUBMIT-768
base: develop
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
6 commits
Select commit
Hold shift + click to select a range
88d4909
demo env setup related changes
dinesh-aot 7cac90e
Merge branch 'develop' of https://github.com/dinesh-aot/EPIC.submit i…
dinesh-aot 2bf0f87
Merge branch 'develop' of https://github.com/dinesh-aot/EPIC.submit i…
dinesh-aot 81283ab
Merge branch 'develop' of https://github.com/dinesh-aot/EPIC.submit i…
dinesh-aot 8cf1a82
Merge branch 'develop' of https://github.com/dinesh-aot/EPIC.submit i…
dinesh-aot 20064cd
changes to track_works and phases table
dinesh-aot 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 hidden or 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
66 changes: 66 additions & 0 deletions
66
submit-api/migrations/versions/f1d8ab8c2d30_adding_display_name_for_phase_name.py
This file contains hidden or 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,66 @@ | ||
| """adding display_name for phase name | ||
|
|
||
| Revision ID: f1d8ab8c2d30 | ||
| Revises: e27054af162b | ||
| Create Date: 2026-02-26 15:12:55.957537 | ||
|
|
||
| """ | ||
| from alembic import op | ||
| import sqlalchemy as sa | ||
|
|
||
|
|
||
| # revision identifiers, used by Alembic. | ||
| revision = 'f1d8ab8c2d30' | ||
| down_revision = 'e27054af162b' | ||
| branch_labels = None | ||
| depends_on = None | ||
|
|
||
|
|
||
| def upgrade(): | ||
| # ### commands auto generated by Alembic - please adjust! ### | ||
| # Drop unnecessary indexes from small tables | ||
| with op.batch_alter_table('package_types', schema=None) as batch_op: | ||
| batch_op.drop_index('idx_package_types_name') | ||
| batch_op.drop_index('idx_package_types_phase_id') | ||
|
|
||
| # Drop old index and create optimized indexes for packages table | ||
| with op.batch_alter_table('packages', schema=None) as batch_op: | ||
| batch_op.drop_index('idx_packages_account_project_work_id') | ||
|
|
||
| # Create new indexes for packages | ||
| op.create_index('idx_packages_account_project_id', 'packages', ['account_project_id']) | ||
| op.create_index( | ||
|
Collaborator
Author
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. Created this as partial index as there is a chance that this field can contain NULL values in case of Management Plan, which will break the index. |
||
| 'idx_packages_account_project_work_id', | ||
| 'packages', | ||
| ['account_project_work_id'], | ||
| postgresql_where=sa.text('account_project_work_id IS NOT NULL') | ||
| ) | ||
|
|
||
| # Add display_name and ea_act_name columns to track_phases | ||
| with op.batch_alter_table('track_phases', schema=None) as batch_op: | ||
| batch_op.add_column(sa.Column('display_name', sa.String(length=255), nullable=True, comment='Submit-specific phase name override; defaults to name field if not set')) | ||
| batch_op.add_column(sa.Column('ea_act_name', sa.String(length=255), nullable=True, comment='Environmental Assessment Act name')) | ||
|
|
||
| # ### end Alembic commands ### | ||
|
|
||
|
|
||
| def downgrade(): | ||
| # ### commands auto generated by Alembic - please adjust! ### | ||
| # Drop display_name and ea_act_name columns from track_phases | ||
| with op.batch_alter_table('track_phases', schema=None) as batch_op: | ||
| batch_op.drop_column('ea_act_name') | ||
| batch_op.drop_column('display_name') | ||
|
|
||
| # Drop new optimized indexes | ||
| op.drop_index('idx_packages_account_project_work_id', table_name='packages') | ||
| op.drop_index('idx_packages_account_project_id', table_name='packages') | ||
|
|
||
| # Restore old indexes | ||
| with op.batch_alter_table('packages', schema=None) as batch_op: | ||
| batch_op.create_index('idx_packages_account_project_work_id', ['account_project_work_id'], unique=False) | ||
|
|
||
| with op.batch_alter_table('package_types', schema=None) as batch_op: | ||
| batch_op.create_index('idx_package_types_phase_id', ['phase_id'], unique=False) | ||
| batch_op.create_index('idx_package_types_name', ['name'], unique=False) | ||
|
|
||
| # ### end Alembic commands ### | ||
This file contains hidden or 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,33 @@ | ||
| """Environmental Assessment Act enum.""" | ||
| from enum import Enum | ||
|
|
||
|
|
||
| class EAActName(str, Enum): | ||
| """Environmental Assessment Act names.""" | ||
|
|
||
| EA_ACT_1996 = "EA Act (1996)" | ||
| EA_ACT_2002 = "EA Act (2002)" | ||
| EA_ACT_2018 = "EA Act (2018)" | ||
| OTHER = "Other" | ||
|
|
||
| @classmethod | ||
| def get_by_id(cls, ea_act_id: int): | ||
| """Get EA Act name by ID.""" | ||
| mapping = { | ||
| 1: cls.EA_ACT_1996, | ||
| 2: cls.EA_ACT_2002, | ||
| 3: cls.EA_ACT_2018, | ||
| 4: cls.OTHER, | ||
| } | ||
| return mapping.get(ea_act_id) | ||
|
|
||
| @classmethod | ||
| def get_id_by_name(cls, name: str): | ||
| """Get EA Act ID by name.""" | ||
| mapping = { | ||
| cls.EA_ACT_1996.value: 1, | ||
| cls.EA_ACT_2002.value: 2, | ||
| cls.EA_ACT_2018.value: 3, | ||
| cls.OTHER.value: 4, | ||
| } | ||
| return mapping.get(name) |
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.
I didn't feel like this index would be useful considering the size possible data in this table.