Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Issue #3264] Remove attachment type from opportunity attachment schema #3806

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions api/src/api/opportunities_v1/opportunity_schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
ApplicantType,
FundingCategory,
FundingInstrument,
OpportunityAttachmentType,
OpportunityCategory,
OpportunityStatus,
)
Expand Down Expand Up @@ -323,13 +322,6 @@ class OpportunityAttachmentV1Schema(FileResponseSchema):
"example": "The full announcement NOFO",
}
)
opportunity_attachment_type = fields.Enum(
OpportunityAttachmentType,
metadata={
"description": "The type of attachment",
"example": OpportunityAttachmentType.NOTICE_OF_FUNDING_OPPORTUNITY,
},
)


class OpportunityWithAttachmentsV1Schema(OpportunityV1Schema):
Expand Down
5 changes: 0 additions & 5 deletions api/src/constants/lookup_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,6 @@ class ExtractType(StrEnum):
OPPORTUNITIES_CSV = "opportunities_csv"


class OpportunityAttachmentType(StrEnum):
NOTICE_OF_FUNDING_OPPORTUNITY = "notice_of_funding_opportunity"
OTHER = "other"


class ExternalUserType(StrEnum):
LOGIN_GOV = "login_gov"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import src.data_migration.transformation.transform_constants as transform_constants
import src.data_migration.transformation.transform_util as transform_util
from src.adapters.aws import S3Config
from src.constants.lookup_constants import OpportunityAttachmentType
from src.data_migration.transformation.subtask.abstract_transform_subtask import (
AbstractTransformSubTask,
)
Expand Down Expand Up @@ -187,8 +186,6 @@ def transform_opportunity_attachment(
target_attachment = OpportunityAttachment(
attachment_id=source_attachment.syn_att_id,
opportunity_id=source_attachment.opportunity_id,
# TODO - we'll eventually remove attachment type, for now just arbitrarily set the value
opportunity_attachment_type=OpportunityAttachmentType.OTHER,
# Note we calculate the file location here, but haven't yet done anything
# with s3, the calling function, will handle writing the file to s3.
file_location=file_location,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
"""Remove opportunity attachment type

Revision ID: f99f1a5aee8b
Revises: 43b179a7c92e
Create Date: 2025-02-07 20:01:38.893554

"""

import sqlalchemy as sa
from alembic import op
from sqlalchemy.dialects import postgresql

# revision identifiers, used by Alembic.
revision = "f99f1a5aee8b"
down_revision = "43b179a7c92e"
branch_labels = None
depends_on = None


def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_table("lk_opportunity_attachment_type", schema="api")
op.drop_index(
"opportunity_attachment_opportunity_attachment_type_id_idx",
table_name="opportunity_attachment",
schema="api",
)
op.drop_constraint(
"opportunity_attachment_opportunity_attachment_type_id_l_e60d",
"opportunity_attachment",
schema="api",
type_="foreignkey",
)
op.drop_column("opportunity_attachment", "opportunity_attachment_type_id", schema="api")
# ### end Alembic commands ###


def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.add_column(
"opportunity_attachment",
sa.Column(
"opportunity_attachment_type_id", sa.INTEGER(), autoincrement=False, nullable=False
),
schema="api",
)
op.create_foreign_key(
"opportunity_attachment_opportunity_attachment_type_id_l_e60d",
"opportunity_attachment",
"lk_opportunity_attachment_type",
["opportunity_attachment_type_id"],
["opportunity_attachment_type_id"],
source_schema="api",
referent_schema="api",
)
op.create_index(
"opportunity_attachment_opportunity_attachment_type_id_idx",
"opportunity_attachment",
["opportunity_attachment_type_id"],
unique=False,
schema="api",
)
op.create_table(
"lk_opportunity_attachment_type",
sa.Column(
"opportunity_attachment_type_id", sa.INTEGER(), autoincrement=True, nullable=False
),
sa.Column("description", sa.TEXT(), autoincrement=False, nullable=False),
sa.Column(
"created_at",
postgresql.TIMESTAMP(timezone=True),
server_default=sa.text("now()"),
autoincrement=False,
nullable=False,
),
sa.Column(
"updated_at",
postgresql.TIMESTAMP(timezone=True),
server_default=sa.text("now()"),
autoincrement=False,
nullable=False,
),
sa.PrimaryKeyConstraint(
"opportunity_attachment_type_id", name="lk_opportunity_attachment_type_pkey"
),
schema="api",
)
# ### end Alembic commands ###
23 changes: 0 additions & 23 deletions api/src/db/models/lookup_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
FundingCategory,
FundingInstrument,
JobStatus,
OpportunityAttachmentType,
OpportunityCategory,
OpportunityStatus,
)
Expand All @@ -25,13 +24,6 @@
]
)

OPPORTUNITY_ATTACHMENT_TYPE_CONFIG = LookupConfig(
[
LookupStr(OpportunityAttachmentType.NOTICE_OF_FUNDING_OPPORTUNITY, 1),
LookupStr(OpportunityAttachmentType.OTHER, 2),
]
)

OPPORTUNITY_CATEGORY_CONFIG = LookupConfig(
[
LookupStr(OpportunityCategory.DISCRETIONARY, 1),
Expand Down Expand Up @@ -234,21 +226,6 @@ def from_lookup(cls, lookup: Lookup) -> "LkAgencySubmissionNotificationSetting":
)


@LookupRegistry.register_lookup(OPPORTUNITY_ATTACHMENT_TYPE_CONFIG)
class LkOpportunityAttachmentType(LookupTable, TimestampMixin):
__tablename__ = "lk_opportunity_attachment_type"

opportunity_attachment_type_id: Mapped[int] = mapped_column(primary_key=True)
description: Mapped[str]

@classmethod
def from_lookup(cls, lookup: Lookup) -> "LkOpportunityAttachmentType":
return LkOpportunityAttachmentType(
opportunity_attachment_type_id=lookup.lookup_val,
description=lookup.get_description(),
)


@LookupRegistry.register_lookup(EXTERNAL_USER_TYPE_CONFIG)
class LkExternalUserType(LookupTable, TimestampMixin):
__tablename__ = "lk_external_user_type"
Expand Down
8 changes: 0 additions & 8 deletions api/src/db/models/opportunity_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
ApplicantType,
FundingCategory,
FundingInstrument,
OpportunityAttachmentType,
OpportunityCategory,
OpportunityStatus,
)
Expand All @@ -20,7 +19,6 @@
LkApplicantType,
LkFundingCategory,
LkFundingInstrument,
LkOpportunityAttachmentType,
LkOpportunityCategory,
LkOpportunityStatus,
)
Expand Down Expand Up @@ -435,12 +433,6 @@ class OpportunityAttachment(ApiSchemaTable, TimestampMixin):
BigInteger, ForeignKey(Opportunity.opportunity_id), index=True
)
opportunity: Mapped[Opportunity] = relationship(Opportunity)
opportunity_attachment_type: Mapped[OpportunityAttachmentType] = mapped_column(
"opportunity_attachment_type_id",
LookupColumn(LkOpportunityAttachmentType),
ForeignKey(LkOpportunityAttachmentType.opportunity_attachment_type_id),
index=True,
)

file_location: Mapped[str]
mime_type: Mapped[str]
Expand Down
2 changes: 0 additions & 2 deletions api/tests/src/db/models/factories.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
ExtractType,
FundingCategory,
FundingInstrument,
OpportunityAttachmentType,
OpportunityCategory,
OpportunityCategoryLegacy,
OpportunityStatus,
Expand Down Expand Up @@ -773,7 +772,6 @@ class Meta:
file_name = factory.Faker("file_name")
file_description = factory.Faker("sentence")
file_size_bytes = factory.Faker("random_int", min=1000, max=10000000)
opportunity_attachment_type = factory.fuzzy.FuzzyChoice(OpportunityAttachmentType)

created_at = factory.Faker("date_time_between", start_date="-1y", end_date="now")
updated_at = factory.LazyAttribute(
Expand Down
Loading