From 2f30e566b9b26d4c3777bca1155b32c2aee2c293 Mon Sep 17 00:00:00 2001 From: Robyn Marowitz Date: Tue, 1 Oct 2024 16:07:30 -0600 Subject: [PATCH 1/6] add fields to tables file --- usaon_benefit_tool/models/tables.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/usaon_benefit_tool/models/tables.py b/usaon_benefit_tool/models/tables.py index d42f8a90..faaf2951 100644 --- a/usaon_benefit_tool/models/tables.py +++ b/usaon_benefit_tool/models/tables.py @@ -412,6 +412,12 @@ class Link(BaseModel): ), nullable=False, ) + performance_rating_rationale = Column(String(8192), nullable=True) + critically_rating_rationale = Column(String(8192), nullable=True) + gaps = Column(String(8192), nullable=True) + variable_or_attribute = Column(String(512), nullable=True) + + source_assessment_node = relationship( AssessmentNode, From b9701ed2757e91cebd8a8d5db58f0513af4e6ac2 Mon Sep 17 00:00:00 2001 From: Robyn Marowitz Date: Tue, 1 Oct 2024 16:22:39 -0600 Subject: [PATCH 2/6] Fix spacing --- usaon_benefit_tool/models/tables.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/usaon_benefit_tool/models/tables.py b/usaon_benefit_tool/models/tables.py index faaf2951..7f7f92ef 100644 --- a/usaon_benefit_tool/models/tables.py +++ b/usaon_benefit_tool/models/tables.py @@ -417,8 +417,6 @@ class Link(BaseModel): gaps = Column(String(8192), nullable=True) variable_or_attribute = Column(String(512), nullable=True) - - source_assessment_node = relationship( AssessmentNode, foreign_keys=[source_assessment_node_id], From e87778c3dc1df7379f20ceb557a7ef3b41324f06 Mon Sep 17 00:00:00 2001 From: Robyn Marowitz Date: Wed, 2 Oct 2024 10:26:36 -0600 Subject: [PATCH 3/6] Update names for last 2 fields --- usaon_benefit_tool/models/tables.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/usaon_benefit_tool/models/tables.py b/usaon_benefit_tool/models/tables.py index 7f7f92ef..5709780b 100644 --- a/usaon_benefit_tool/models/tables.py +++ b/usaon_benefit_tool/models/tables.py @@ -414,8 +414,8 @@ class Link(BaseModel): ) performance_rating_rationale = Column(String(8192), nullable=True) critically_rating_rationale = Column(String(8192), nullable=True) - gaps = Column(String(8192), nullable=True) - variable_or_attribute = Column(String(512), nullable=True) + gaps_description = Column(String(8192), nullable=True) + attribute_description = Column(String(512), nullable=True) source_assessment_node = relationship( AssessmentNode, From fa9fa64c72ee4f55836ada05aaac39d784d99368 Mon Sep 17 00:00:00 2001 From: Robyn Marowitz Date: Wed, 2 Oct 2024 10:26:48 -0600 Subject: [PATCH 4/6] DB migration (v2.2.0) --- deploy/post/v2.2.0 | 24 +++++++++++++ .../925ed377e31b_add_new_link_fields.py | 36 +++++++++++++++++++ 2 files changed, 60 insertions(+) create mode 100755 deploy/post/v2.2.0 create mode 100644 migrations/versions/925ed377e31b_add_new_link_fields.py diff --git a/deploy/post/v2.2.0 b/deploy/post/v2.2.0 new file mode 100755 index 00000000..4005cc78 --- /dev/null +++ b/deploy/post/v2.2.0 @@ -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 [ "925ed377e31b (head)" = "${current}" ]; then + echo "Data migration successful. On expected revision ${current}." +else + echo "Data migration failed. On unexpected revision ${current}." +fi diff --git a/migrations/versions/925ed377e31b_add_new_link_fields.py b/migrations/versions/925ed377e31b_add_new_link_fields.py new file mode 100644 index 00000000..b0804410 --- /dev/null +++ b/migrations/versions/925ed377e31b_add_new_link_fields.py @@ -0,0 +1,36 @@ +"""Add new link fields + +Revision ID: 925ed377e31b +Revises: fafa3da67d5e +Create Date: 2024-10-02 16:17:16.949764 + +""" +from typing import Sequence, Union + +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision: str = '925ed377e31b' +down_revision: Union[str, None] = 'fafa3da67d5e' +branch_labels: Union[str, Sequence[str], None] = None +depends_on: Union[str, Sequence[str], None] = None + + +def upgrade() -> None: + # ### commands auto generated by Alembic - please adjust! ### + op.add_column('link', sa.Column('performance_rating_rationale', sa.String(length=8192), nullable=True)) + op.add_column('link', sa.Column('critically_rating_rationale', sa.String(length=8192), nullable=True)) + op.add_column('link', sa.Column('gaps_description', sa.String(length=8192), nullable=True)) + op.add_column('link', sa.Column('attribute_description', sa.String(length=512), nullable=True)) + # ### end Alembic commands ### + + +def downgrade() -> None: + # ### commands auto generated by Alembic - please adjust! ### + op.drop_column('link', 'attribute_description') + op.drop_column('link', 'gaps_description') + op.drop_column('link', 'critically_rating_rationale') + op.drop_column('link', 'performance_rating_rationale') + # ### end Alembic commands ### From 38615f61be0cb856d0cc59b113aca25ec0f9de7a Mon Sep 17 00:00:00 2001 From: Robyn Marowitz Date: Wed, 2 Oct 2024 10:34:51 -0600 Subject: [PATCH 5/6] resolve lint errors --- .../925ed377e31b_add_new_link_fields.py | 50 +++++++++++++++---- 1 file changed, 39 insertions(+), 11 deletions(-) diff --git a/migrations/versions/925ed377e31b_add_new_link_fields.py b/migrations/versions/925ed377e31b_add_new_link_fields.py index b0804410..4203bfc9 100644 --- a/migrations/versions/925ed377e31b_add_new_link_fields.py +++ b/migrations/versions/925ed377e31b_add_new_link_fields.py @@ -1,29 +1,57 @@ -"""Add new link fields +"""Add new link fields. Revision ID: 925ed377e31b Revises: fafa3da67d5e Create Date: 2024-10-02 16:17:16.949764 """ -from typing import Sequence, Union -from alembic import op -import sqlalchemy as sa +from collections.abc import Sequence +import sqlalchemy as sa +from alembic import op # revision identifiers, used by Alembic. revision: str = '925ed377e31b' -down_revision: Union[str, None] = 'fafa3da67d5e' -branch_labels: Union[str, Sequence[str], None] = None -depends_on: Union[str, Sequence[str], None] = None +down_revision: str | None = 'fafa3da67d5e' +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('link', sa.Column('performance_rating_rationale', sa.String(length=8192), nullable=True)) - op.add_column('link', sa.Column('critically_rating_rationale', sa.String(length=8192), nullable=True)) - op.add_column('link', sa.Column('gaps_description', sa.String(length=8192), nullable=True)) - op.add_column('link', sa.Column('attribute_description', sa.String(length=512), nullable=True)) + op.add_column( + 'link', + sa.Column( + 'performance_rating_rationale', + sa.String(length=8192), + nullable=True, + ), + ) + op.add_column( + 'link', + sa.Column( + 'critically_rating_rationale', + sa.String(length=8192), + nullable=True, + ), + ) + op.add_column( + 'link', + sa.Column( + 'gaps_description', + sa.String(length=8192), + nullable=True, + ), + ) + op.add_column( + 'link', + sa.Column( + 'attribute_description', + sa.String(length=512), + nullable=True, + ), + ) # ### end Alembic commands ### From e0b7f9d96e3ad8d194ade1e3f82de771f7e902cd Mon Sep 17 00:00:00 2001 From: Robyn Marowitz Date: Wed, 2 Oct 2024 10:39:47 -0600 Subject: [PATCH 6/6] Update changelog --- CHANGELOG.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f696c8e3..c7fc9b4f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,11 +1,12 @@ ## v2.2.0 (2024-10-01) -* Allow nodes of same type to link -* Reverse color bar +* Allow nodes of same type to link. +* Reverse color bar. +* Add new link fields (db migration 925ed377e31b). ## v2.1.0 (2024-09-26) -* Increase length of description columns to 4096 chars. +* Increase length of description columns to 4096 chars (db migration fafa3da67d5e). ## v2.0.2 (2024-06-07)