-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Moved the feed data for the lookup tables from csv file into src/conf… (
#67) …ig file. Added custom tests for alembic migration --------- Co-authored-by: Nargis Sultani <[email protected]>
- Loading branch information
1 parent
ee4d59c
commit 9004692
Showing
19 changed files
with
334 additions
and
255 deletions.
There are no files selected for viewing
Empty file.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
28 changes: 0 additions & 28 deletions
28
db_revisions/versions/26a742d97ad9_feed_federal_regulator_table.py
This file was deleted.
Oops, something went wrong.
39 changes: 39 additions & 0 deletions
39
db_revisions/versions/26a742d97ad9_seed_federal_regulator_table.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,39 @@ | ||
"""Seed Federal Regulator table | ||
Revision ID: 26a742d97ad9 | ||
Revises: 7b6ff51002b5 | ||
Create Date: 2023-12-14 01:23:17.872728 | ||
""" | ||
from typing import Sequence, Union | ||
from alembic import op | ||
from utils import get_table_by_name | ||
|
||
|
||
# revision identifiers, used by Alembic. | ||
revision: str = "26a742d97ad9" | ||
down_revision: Union[str, None] = "7b6ff51002b5" | ||
branch_labels: Union[str, Sequence[str], None] = None | ||
depends_on: Union[str, Sequence[str], None] = None | ||
|
||
|
||
def upgrade() -> None: | ||
seed_data = [ | ||
{"id": "FCA", "name": "Farm Credit Administration"}, | ||
{"id": "FDIC", "name": "Federal Deposit Insurance Corporation"}, | ||
{"id": "FHFA", "name": "Federal Housing Finance Agency"}, | ||
{"id": "FRS", "name": "Federal Reserve System"}, | ||
{"id": "NCUA", "name": "National Credit Union Administration"}, | ||
{"id": "OCC", "name": "Office of the Comptroller of the Currency"}, | ||
{"id": "OTS", "name": "Office of Thrift Supervision (only valid until July 21, 2011)"}, | ||
] | ||
|
||
table = get_table_by_name("federal_regulator") | ||
|
||
op.bulk_insert(table, seed_data) | ||
|
||
|
||
def downgrade() -> None: | ||
table = get_table_by_name("federal_regulator") | ||
|
||
op.execute(table.delete()) |
28 changes: 0 additions & 28 deletions
28
db_revisions/versions/7b6ff51002b5_feed_address_state_table.py
This file was deleted.
Oops, something went wrong.
89 changes: 89 additions & 0 deletions
89
db_revisions/versions/7b6ff51002b5_seed_address_state_table.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,89 @@ | ||
"""Seed Address State table | ||
Revision ID: 7b6ff51002b5 | ||
Revises: 045aa502e050 | ||
Create Date: 2023-12-14 01:21:48.325752 | ||
""" | ||
from typing import Sequence, Union | ||
from alembic import op | ||
from utils import get_table_by_name | ||
|
||
|
||
# revision identifiers, used by Alembic. | ||
revision: str = "7b6ff51002b5" | ||
down_revision: Union[str, None] = "045aa502e050" | ||
branch_labels: Union[str, Sequence[str], None] = None | ||
depends_on: Union[str, Sequence[str], None] = None | ||
|
||
|
||
def upgrade() -> None: | ||
seed_data = [ | ||
{"code": "AL", "name": "Alabama"}, | ||
{"code": "AK", "name": "Alaska"}, | ||
{"code": "AZ", "name": "Arizona"}, | ||
{"code": "AR", "name": "Arkansas"}, | ||
{"code": "CA", "name": "California"}, | ||
{"code": "CO", "name": "Colorado"}, | ||
{"code": "CT", "name": "Connecticut"}, | ||
{"code": "DE", "name": "Delaware"}, | ||
{"code": "FL", "name": "Florida"}, | ||
{"code": "GA", "name": "Georgia"}, | ||
{"code": "HI", "name": "Hawaii"}, | ||
{"code": "ID", "name": "Idaho"}, | ||
{"code": "IL", "name": "Illinois"}, | ||
{"code": "IN", "name": "Indiana"}, | ||
{"code": "IA", "name": "Iowa"}, | ||
{"code": "KS", "name": "Kansas"}, | ||
{"code": "KY", "name": "Kentucky"}, | ||
{"code": "LA", "name": "Louisiana"}, | ||
{"code": "ME", "name": "Maine"}, | ||
{"code": "MD", "name": "Maryland"}, | ||
{"code": "MA", "name": "Massachusetts"}, | ||
{"code": "MI", "name": "Michigan"}, | ||
{"code": "MN", "name": "Minnesota"}, | ||
{"code": "MS", "name": "Mississippi"}, | ||
{"code": "MO", "name": "Missouri"}, | ||
{"code": "MT", "name": "Montana"}, | ||
{"code": "NE", "name": "Nebraska"}, | ||
{"code": "NV", "name": "Nevada"}, | ||
{"code": "NH", "name": "New Hampshire"}, | ||
{"code": "NJ", "name": "New Jersey"}, | ||
{"code": "NM", "name": "New Mexico"}, | ||
{"code": "NY", "name": "New York"}, | ||
{"code": "NC", "name": "North Carolina"}, | ||
{"code": "ND", "name": "North Dakota"}, | ||
{"code": "OH", "name": "Ohio"}, | ||
{"code": "OK", "name": "Oklahoma"}, | ||
{"code": "OR", "name": "Oregon"}, | ||
{"code": "PA", "name": "Pennsylvania"}, | ||
{"code": "RI", "name": "Rhode Island"}, | ||
{"code": "SC", "name": "South Carolina"}, | ||
{"code": "SD", "name": "South Dakota"}, | ||
{"code": "TN", "name": "Tennessee"}, | ||
{"code": "TX", "name": "Texas"}, | ||
{"code": "UT", "name": "Utah"}, | ||
{"code": "VT", "name": "Vermont"}, | ||
{"code": "VA", "name": "Virginia"}, | ||
{"code": "WA", "name": "Washington"}, | ||
{"code": "WV", "name": "West Virginia"}, | ||
{"code": "WI", "name": "Wisconsin"}, | ||
{"code": "WY", "name": "Wyoming"}, | ||
{"code": "DC", "name": "District of Columbia"}, | ||
{"code": "AS", "name": "American Samoa"}, | ||
{"code": "GU", "name": "Guam"}, | ||
{"code": "MP", "name": "Northern Mariana Islands"}, | ||
{"code": "PR", "name": "Puerto Rico"}, | ||
{"code": "UM", "name": "United States Minor Outlying Islands"}, | ||
{"code": "VI", "name": "Virgin Islands, U.S."}, | ||
] | ||
|
||
table = get_table_by_name("address_state") | ||
|
||
op.bulk_insert(table, seed_data) | ||
|
||
|
||
def downgrade() -> None: | ||
table = get_table_by_name("address_state") | ||
|
||
op.execute(table.delete()) |
27 changes: 0 additions & 27 deletions
27
db_revisions/versions/a41281b1e109_feed_sbl_institution_type_table.py
This file was deleted.
Oops, something went wrong.
44 changes: 44 additions & 0 deletions
44
db_revisions/versions/a41281b1e109_seed_sbl_institution_type_table.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,44 @@ | ||
"""Seed SBL Institution Type table | ||
Revision ID: a41281b1e109 | ||
Revises: f4ff7d1aa6df | ||
Create Date: 2023-12-14 01:24:00.120073 | ||
""" | ||
from typing import Sequence, Union | ||
from alembic import op | ||
from utils import get_table_by_name | ||
|
||
# revision identifiers, used by Alembic. | ||
revision: str = "a41281b1e109" | ||
down_revision: Union[str, None] = "f4ff7d1aa6df" | ||
branch_labels: Union[str, Sequence[str], None] = None | ||
depends_on: Union[str, Sequence[str], None] = None | ||
|
||
|
||
def upgrade() -> None: | ||
seed_data = [ | ||
{"id": "1", "name": "Bank or savings association."}, | ||
{"id": "2", "name": "Minority depository institution."}, | ||
{"id": "3", "name": "Credit union."}, | ||
{"id": "4", "name": "Nondepository institution."}, | ||
{"id": "5", "name": "Community development financial institution (CDFI)."}, | ||
{"id": "6", "name": "Other nonprofit financial institution."}, | ||
{"id": "7", "name": "Farm Credit System institution."}, | ||
{"id": "8", "name": "Government lender."}, | ||
{"id": "9", "name": "Commercial finance company."}, | ||
{"id": "10", "name": "Equipment finance company."}, | ||
{"id": "11", "name": "Industrial loan company."}, | ||
{"id": "12", "name": "Online lender."}, | ||
{"id": "13", "name": "Other"}, | ||
] | ||
|
||
table = get_table_by_name("sbl_institution_type") | ||
|
||
op.bulk_insert(table, seed_data) | ||
|
||
|
||
def downgrade() -> None: | ||
table = get_table_by_name("sbl_institution_type") | ||
|
||
op.execute(table.delete()) |
Oops, something went wrong.