diff --git a/db/migrations/versions/~2024_11_13_1349-71ec50f94e6f_add_ggis_scheme_reference_number.py b/db/migrations/versions/~2024_11_13_1349-71ec50f94e6f_add_ggis_scheme_reference_number.py new file mode 100644 index 00000000..442f0170 --- /dev/null +++ b/db/migrations/versions/~2024_11_13_1349-71ec50f94e6f_add_ggis_scheme_reference_number.py @@ -0,0 +1,38 @@ +"""Add ggis_scheme_reference_number + +Revision ID: 71ec50f94e6f +Revises: de8d7954ffda +Create Date: 2024-11-13 13:49:03.498795 + +""" + +import sqlalchemy as sa +from alembic import op + +# revision identifiers, used by Alembic. +revision = "71ec50f94e6f" +down_revision = "de8d7954ffda" +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + with op.batch_alter_table("fund", schema=None) as batch_op: + batch_op.add_column(sa.Column("ggis_scheme_reference_number", sa.String(length=255), nullable=True)) + + with op.batch_alter_table("round", schema=None) as batch_op: + batch_op.alter_column("reference_contact_page_over_email", existing_type=sa.BOOLEAN(), nullable=False) + + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + with op.batch_alter_table("round", schema=None) as batch_op: + batch_op.alter_column("reference_contact_page_over_email", existing_type=sa.BOOLEAN(), nullable=True) + + with op.batch_alter_table("fund", schema=None) as batch_op: + batch_op.drop_column("ggis_scheme_reference_number") + + # ### end Alembic commands ### diff --git a/db/models/fund.py b/db/models/fund.py index 1c8124ce..f2d24dea 100644 --- a/db/models/fund.py +++ b/db/models/fund.py @@ -41,3 +41,4 @@ class Fund(BaseModel): owner_organisation_shortname = Column("owner_organisation_shortname", db.String(), nullable=False, unique=False) owner_organisation_logo_uri = Column("owner_organisation_logo_uri", db.Text(), nullable=True, unique=False) funding_type = Column("funding_type", SQLAEnum(FundingType, name="fundingtype"), nullable=False, unique=False) + ggis_scheme_reference_number = Column("ggis_scheme_reference_number", db.String(255), nullable=True, unique=False) diff --git a/tests/conftest.py b/tests/conftest.py index 69ebb0b8..63cd8d06 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -35,6 +35,7 @@ def seed_dynamic_data(request, app, clear_test_data, _db): "id": fund_id, "short_name": "FUND", "funding_type": "COMPETITIVE", + "ggis_scheme_reference_number": "", "rounds": [ { "id": round_id_1, @@ -123,6 +124,7 @@ def seed_dynamic_data(request, app, clear_test_data, _db): "owner_organisation_shortname": "TON", "owner_organisation_logo_uri": "...", "funding_type": fund["funding_type"] or FundingType.COMPETITIVE, + "ggis_scheme_reference_number": fund["ggis_scheme_reference_number"] or "", } insert_fund_data(fund_config) rounds = [] @@ -202,6 +204,7 @@ def mock_get_fund_round(mocker): title_json={"en": "Fund 1"}, description_json={"en": "description text"}, funding_type=FundingType.COMPETITIVE, + ggis_scheme_reference_number="G2-SCH-0000092414", ) round_config = { "id": uuid4(), diff --git a/tests/test_data/test_fab_round_config.py b/tests/test_data/test_fab_round_config.py index b2b4ad90..d4ae85d8 100644 --- a/tests/test_data/test_fab_round_config.py +++ b/tests/test_data/test_fab_round_config.py @@ -24,6 +24,7 @@ "name_json": {"en": "Test"}, "title_json": {"en": "Test Fund"}, "description_json": {"en": "test"}, + "ggis_scheme_reference_number": "", }, "round_config": { "id": "1a2d6043-689b-4472-a09c-fd8fcfd20151", diff --git a/tests/test_data_fund_round.py b/tests/test_data_fund_round.py index 51406859..f135b6aa 100644 --- a/tests/test_data_fund_round.py +++ b/tests/test_data_fund_round.py @@ -14,6 +14,8 @@ def test_get_fund_by_id(seed_dynamic_data): f = get_fund_by_id(seed_dynamic_data["funds"][0]["id"]) assert f.name_json["en"] == "Unit Test Fund 1" assert f.short_name == "FND1" + assert hasattr(f, "ggis_scheme_reference_number") + assert f.ggis_scheme_reference_number is None def test_get_fund_by_short_name(seed_dynamic_data):