-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #341 from nsidc/SBA-update
Sba update
- Loading branch information
Showing
9 changed files
with
240 additions
and
508 deletions.
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,24 @@ | ||
#!/bin/bash | ||
|
||
set -euo pipefail | ||
|
||
# HACK: Garrison doesn't see these variables that were exported in main deploy | ||
# script, which is unintuitive. NOTE that sourcing VERSION.env is not | ||
# compatible with integration, but this script doesn't receive the environment | ||
# as a parameter. Garrison needs some extra thought here. | ||
source /etc/profile.d/envvars.sh | ||
source VERSION.env | ||
|
||
# TODO: figure out better way | ||
echo "Waiting 10 seconds for the new stack to come up..." | ||
sleep 10 | ||
|
||
docker compose run --rm usaon-benefit-tool alembic upgrade head | ||
|
||
# confirm the expected migration was applied | ||
current=$(docker compose run --rm usaon-benefit-tool alembic current 2>/dev/null) | ||
if [ "ce8e6e308e5c (head)" = "${current}" ]; then | ||
echo "Data migration successful. On expected revision ${current}." | ||
else | ||
echo "Data migration failed. On unexpected revision ${current}." | ||
fi |
53 changes: 53 additions & 0 deletions
53
migrations/versions/b9357b81d2b0_add_new_sba_related_fields.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,53 @@ | ||
"""Add new SBA related fields. | ||
Revision ID: b9357b81d2b0 | ||
Revises: ea1181510e10 | ||
Create Date: 2024-10-14 22:37:03.652801 | ||
""" | ||
|
||
from collections.abc import Sequence | ||
|
||
import sqlalchemy as sa | ||
from alembic import op | ||
|
||
# revision identifiers, used by Alembic. | ||
revision: str = 'b9357b81d2b0' | ||
down_revision: str | None = 'ea1181510e10' | ||
branch_labels: str | Sequence[str] | None = None | ||
depends_on: str | Sequence[str] | None = None | ||
|
||
|
||
def upgrade() -> None: | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.add_column( | ||
'node_subtype_societal_benefit_area', | ||
sa.Column('name', sa.String(length=512), nullable=True), | ||
) | ||
op.add_column( | ||
'node_subtype_societal_benefit_area', | ||
sa.Column('short_name', sa.String(length=256), nullable=True), | ||
) | ||
op.add_column( | ||
'node_subtype_societal_benefit_area', | ||
sa.Column('description', sa.String(), nullable=True), | ||
) | ||
op.add_column( | ||
'node_subtype_societal_benefit_area', | ||
sa.Column('framework_name', sa.String(length=256), nullable=True), | ||
) | ||
op.add_column( | ||
'node_subtype_societal_benefit_area', | ||
sa.Column('framework_url', sa.String(length=512), nullable=True), | ||
) | ||
# ### end Alembic commands ### | ||
|
||
|
||
def downgrade() -> None: | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.drop_column('node_subtype_societal_benefit_area', 'framework_url') | ||
op.drop_column('node_subtype_societal_benefit_area', 'framework_name') | ||
op.drop_column('node_subtype_societal_benefit_area', 'description') | ||
op.drop_column('node_subtype_societal_benefit_area', 'short_name') | ||
op.drop_column('node_subtype_societal_benefit_area', 'name') | ||
# ### end Alembic commands ### |
74 changes: 74 additions & 0 deletions
74
migrations/versions/ce8e6e308e5c_remove_prefilled_sba_reference_tables.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,74 @@ | ||
"""remove prefilled sba reference tables. | ||
Revision ID: ce8e6e308e5c | ||
Revises: d46c4d798847 | ||
Create Date: 2024-10-15 23:03:00.302098 | ||
""" | ||
|
||
from collections.abc import Sequence | ||
|
||
import sqlalchemy as sa | ||
from alembic import op | ||
|
||
# revision identifiers, used by Alembic. | ||
revision: str = 'ce8e6e308e5c' | ||
down_revision: str | None = 'd46c4d798847' | ||
branch_labels: str | Sequence[str] | None = None | ||
depends_on: str | Sequence[str] | None = None | ||
|
||
|
||
def upgrade() -> None: | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.drop_table('societal_benefit_key_objective') | ||
op.drop_table('societal_benefit_subarea') | ||
op.drop_table('societal_benefit_area') | ||
# ### end Alembic commands ### | ||
|
||
|
||
def downgrade() -> None: | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.create_table( | ||
'societal_benefit_area', | ||
sa.Column('id', sa.VARCHAR(length=256), autoincrement=False, nullable=False), | ||
sa.PrimaryKeyConstraint('id', name='pk_societal_benefit_area'), | ||
postgresql_ignore_search_path=False, | ||
) | ||
op.create_table( | ||
'societal_benefit_subarea', | ||
sa.Column('id', sa.VARCHAR(length=256), autoincrement=False, nullable=False), | ||
sa.Column( | ||
'societal_benefit_area_id', | ||
sa.VARCHAR(length=256), | ||
autoincrement=False, | ||
nullable=False, | ||
), | ||
sa.ForeignKeyConstraint( | ||
['societal_benefit_area_id'], | ||
['societal_benefit_area.id'], | ||
name='fk_societal_benefit_subarea_societal_benefit_area_id_so_0d93', | ||
), | ||
sa.PrimaryKeyConstraint('id', name='pk_societal_benefit_subarea'), | ||
postgresql_ignore_search_path=False, | ||
) | ||
op.create_table( | ||
'societal_benefit_key_objective', | ||
sa.Column('id', sa.VARCHAR(length=256), autoincrement=False, nullable=False), | ||
sa.Column( | ||
'societal_benefit_subarea_id', | ||
sa.VARCHAR(length=256), | ||
autoincrement=False, | ||
nullable=False, | ||
), | ||
sa.ForeignKeyConstraint( | ||
['societal_benefit_subarea_id'], | ||
['societal_benefit_subarea.id'], | ||
name='fk_societal_benefit_key_objective_societal_benefit_suba_8857', | ||
), | ||
sa.PrimaryKeyConstraint( | ||
'id', | ||
'societal_benefit_subarea_id', | ||
name='pk_societal_benefit_key_objective', | ||
), | ||
) | ||
# ### end Alembic commands ### |
80 changes: 80 additions & 0 deletions
80
migrations/versions/d46c4d798847_remove_sba_foreign_key_relationship.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,80 @@ | ||
"""Remove SBA foreign key relationship. | ||
Revision ID: d46c4d798847 | ||
Revises: b9357b81d2b0 | ||
Create Date: 2024-10-15 22:10:15.917116 | ||
""" | ||
|
||
from collections.abc import Sequence | ||
|
||
import sqlalchemy as sa | ||
from alembic import op | ||
|
||
# revision identifiers, used by Alembic. | ||
revision: str = 'd46c4d798847' | ||
down_revision: str | None = 'b9357b81d2b0' | ||
branch_labels: str | Sequence[str] | None = None | ||
depends_on: str | Sequence[str] | None = None | ||
|
||
|
||
def upgrade() -> None: | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.drop_constraint( | ||
'uq_node_subtype_societal_benefit_area_societal_benefit_area_id', | ||
'node_subtype_societal_benefit_area', | ||
type_='unique', | ||
) | ||
op.drop_constraint( | ||
'fk_node_subtype_societal_benefit_area_societal_benefit__adfa', | ||
'node_subtype_societal_benefit_area', | ||
type_='foreignkey', | ||
) | ||
op.drop_column('node_subtype_societal_benefit_area', 'description') | ||
op.drop_column('node_subtype_societal_benefit_area', 'short_name') | ||
op.drop_column('node_subtype_societal_benefit_area', 'name') | ||
op.drop_column('node_subtype_societal_benefit_area', 'societal_benefit_area_id') | ||
# ### end Alembic commands ### | ||
|
||
|
||
def downgrade() -> None: | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.add_column( | ||
'node_subtype_societal_benefit_area', | ||
sa.Column( | ||
'societal_benefit_area_id', | ||
sa.VARCHAR(), | ||
autoincrement=False, | ||
nullable=False, | ||
), | ||
) | ||
op.add_column( | ||
'node_subtype_societal_benefit_area', | ||
sa.Column('name', sa.VARCHAR(length=512), autoincrement=False, nullable=True), | ||
) | ||
op.add_column( | ||
'node_subtype_societal_benefit_area', | ||
sa.Column( | ||
'short_name', | ||
sa.VARCHAR(length=256), | ||
autoincrement=False, | ||
nullable=True, | ||
), | ||
) | ||
op.add_column( | ||
'node_subtype_societal_benefit_area', | ||
sa.Column('description', sa.VARCHAR(), autoincrement=False, nullable=True), | ||
) | ||
op.create_foreign_key( | ||
'fk_node_subtype_societal_benefit_area_societal_benefit__adfa', | ||
'node_subtype_societal_benefit_area', | ||
'societal_benefit_area', | ||
['societal_benefit_area_id'], | ||
['id'], | ||
) | ||
op.create_unique_constraint( | ||
'uq_node_subtype_societal_benefit_area_societal_benefit_area_id', | ||
'node_subtype_societal_benefit_area', | ||
['societal_benefit_area_id'], | ||
) | ||
# ### end Alembic commands ### |
Oops, something went wrong.