-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Issue #2491] Modify the Agency table schema to include a link to a t…
…op-level agency (#2517) Summary Fixes #2491 Time to review: 15 mins Changes proposed New schema fields DB Migration In the opportunity table, add a new property called top_level_agency_name that pulls from agency record relationship it already has to get the top-level agency name. Something like: Context for reviewers We want to add a foreign key in the agency table to the (same) agency table called top_level_agency_id as well as a corresponding relationship. This field will be populated by a separate process and used in setting up the agency name in the API Additional information After seed is complete: https://github.com/user-attachments/assets/a861d717-06ba-4731-a88f-679945ba0ae7
- Loading branch information
1 parent
1fa4cef
commit 26eeecf
Showing
6 changed files
with
65 additions
and
2 deletions.
There are no files selected for viewing
42 changes: 42 additions & 0 deletions
42
api/src/db/migrations/versions/2024_10_17_add_top_level_agency_field.py
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 @@ | ||
"""Add top level agency field | ||
Revision ID: 39f7f941fc6c | ||
Revises: 558ad9563e9a | ||
Create Date: 2024-10-17 20:08:55.193636 | ||
""" | ||
|
||
import sqlalchemy as sa | ||
from alembic import op | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = "39f7f941fc6c" | ||
down_revision = "558ad9563e9a" | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade(): | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.add_column( | ||
"agency", sa.Column("top_level_agency_id", sa.BigInteger(), nullable=True), schema="api" | ||
) | ||
op.create_foreign_key( | ||
op.f("agency_top_level_agency_id_agency_fkey"), | ||
"agency", | ||
"agency", | ||
["top_level_agency_id"], | ||
["agency_id"], | ||
source_schema="api", | ||
referent_schema="api", | ||
) | ||
# ### end Alembic commands ### | ||
|
||
|
||
def downgrade(): | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.drop_constraint( | ||
op.f("agency_top_level_agency_id_agency_fkey"), "agency", schema="api", type_="foreignkey" | ||
) | ||
op.drop_column("agency", "top_level_agency_id", schema="api") | ||
# ### end Alembic commands ### |
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.