Skip to content

Commit 3ba7840

Browse files
Remove attachment type from opportunity attachment schema
1 parent 13bd68e commit 3ba7840

File tree

7 files changed

+88
-42
lines changed

7 files changed

+88
-42
lines changed

api/src/api/opportunities_v1/opportunity_schemas.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
ApplicantType,
1717
FundingCategory,
1818
FundingInstrument,
19-
OpportunityAttachmentType,
2019
OpportunityCategory,
2120
OpportunityStatus,
2221
)

api/src/constants/lookup_constants.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -123,11 +123,6 @@ class ExtractType(StrEnum):
123123
OPPORTUNITIES_CSV = "opportunities_csv"
124124

125125

126-
class OpportunityAttachmentType(StrEnum):
127-
NOTICE_OF_FUNDING_OPPORTUNITY = "notice_of_funding_opportunity"
128-
OTHER = "other"
129-
130-
131126
class ExternalUserType(StrEnum):
132127
LOGIN_GOV = "login_gov"
133128

api/src/data_migration/transformation/subtask/transform_opportunity_attachment.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import src.data_migration.transformation.transform_constants as transform_constants
55
import src.data_migration.transformation.transform_util as transform_util
66
from src.adapters.aws import S3Config
7-
from src.constants.lookup_constants import OpportunityAttachmentType
87
from src.data_migration.transformation.subtask.abstract_transform_subtask import (
98
AbstractTransformSubTask,
109
)
@@ -187,8 +186,6 @@ def transform_opportunity_attachment(
187186
target_attachment = OpportunityAttachment(
188187
attachment_id=source_attachment.syn_att_id,
189188
opportunity_id=source_attachment.opportunity_id,
190-
# TODO - we'll eventually remove attachment type, for now just arbitrarily set the value
191-
opportunity_attachment_type=OpportunityAttachmentType.OTHER,
192189
# Note we calculate the file location here, but haven't yet done anything
193190
# with s3, the calling function, will handle writing the file to s3.
194191
file_location=file_location,
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
"""Remove opportunity attachment type
2+
3+
Revision ID: f99f1a5aee8b
4+
Revises: 43b179a7c92e
5+
Create Date: 2025-02-07 20:01:38.893554
6+
7+
"""
8+
9+
import sqlalchemy as sa
10+
from alembic import op
11+
from sqlalchemy.dialects import postgresql
12+
13+
# revision identifiers, used by Alembic.
14+
revision = "f99f1a5aee8b"
15+
down_revision = "43b179a7c92e"
16+
branch_labels = None
17+
depends_on = None
18+
19+
20+
def upgrade():
21+
# ### commands auto generated by Alembic - please adjust! ###
22+
op.drop_table("lk_opportunity_attachment_type", schema="api")
23+
op.drop_index(
24+
"opportunity_attachment_opportunity_attachment_type_id_idx",
25+
table_name="opportunity_attachment",
26+
schema="api",
27+
)
28+
op.drop_constraint(
29+
"opportunity_attachment_opportunity_attachment_type_id_l_e60d",
30+
"opportunity_attachment",
31+
schema="api",
32+
type_="foreignkey",
33+
)
34+
op.drop_column("opportunity_attachment", "opportunity_attachment_type_id", schema="api")
35+
# ### end Alembic commands ###
36+
37+
38+
def downgrade():
39+
# ### commands auto generated by Alembic - please adjust! ###
40+
op.add_column(
41+
"opportunity_attachment",
42+
sa.Column(
43+
"opportunity_attachment_type_id", sa.INTEGER(), autoincrement=False, nullable=False
44+
),
45+
schema="api",
46+
)
47+
op.create_foreign_key(
48+
"opportunity_attachment_opportunity_attachment_type_id_l_e60d",
49+
"opportunity_attachment",
50+
"lk_opportunity_attachment_type",
51+
["opportunity_attachment_type_id"],
52+
["opportunity_attachment_type_id"],
53+
source_schema="api",
54+
referent_schema="api",
55+
)
56+
op.create_index(
57+
"opportunity_attachment_opportunity_attachment_type_id_idx",
58+
"opportunity_attachment",
59+
["opportunity_attachment_type_id"],
60+
unique=False,
61+
schema="api",
62+
)
63+
op.create_table(
64+
"lk_opportunity_attachment_type",
65+
sa.Column(
66+
"opportunity_attachment_type_id", sa.INTEGER(), autoincrement=True, nullable=False
67+
),
68+
sa.Column("description", sa.TEXT(), autoincrement=False, nullable=False),
69+
sa.Column(
70+
"created_at",
71+
postgresql.TIMESTAMP(timezone=True),
72+
server_default=sa.text("now()"),
73+
autoincrement=False,
74+
nullable=False,
75+
),
76+
sa.Column(
77+
"updated_at",
78+
postgresql.TIMESTAMP(timezone=True),
79+
server_default=sa.text("now()"),
80+
autoincrement=False,
81+
nullable=False,
82+
),
83+
sa.PrimaryKeyConstraint(
84+
"opportunity_attachment_type_id", name="lk_opportunity_attachment_type_pkey"
85+
),
86+
schema="api",
87+
)
88+
# ### end Alembic commands ###

api/src/db/models/lookup_models.py

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
FundingCategory,
1010
FundingInstrument,
1111
JobStatus,
12-
OpportunityAttachmentType,
1312
OpportunityCategory,
1413
OpportunityStatus,
1514
)
@@ -25,13 +24,6 @@
2524
]
2625
)
2726

28-
OPPORTUNITY_ATTACHMENT_TYPE_CONFIG = LookupConfig(
29-
[
30-
LookupStr(OpportunityAttachmentType.NOTICE_OF_FUNDING_OPPORTUNITY, 1),
31-
LookupStr(OpportunityAttachmentType.OTHER, 2),
32-
]
33-
)
34-
3527
OPPORTUNITY_CATEGORY_CONFIG = LookupConfig(
3628
[
3729
LookupStr(OpportunityCategory.DISCRETIONARY, 1),
@@ -234,21 +226,6 @@ def from_lookup(cls, lookup: Lookup) -> "LkAgencySubmissionNotificationSetting":
234226
)
235227

236228

237-
@LookupRegistry.register_lookup(OPPORTUNITY_ATTACHMENT_TYPE_CONFIG)
238-
class LkOpportunityAttachmentType(LookupTable, TimestampMixin):
239-
__tablename__ = "lk_opportunity_attachment_type"
240-
241-
opportunity_attachment_type_id: Mapped[int] = mapped_column(primary_key=True)
242-
description: Mapped[str]
243-
244-
@classmethod
245-
def from_lookup(cls, lookup: Lookup) -> "LkOpportunityAttachmentType":
246-
return LkOpportunityAttachmentType(
247-
opportunity_attachment_type_id=lookup.lookup_val,
248-
description=lookup.get_description(),
249-
)
250-
251-
252229
@LookupRegistry.register_lookup(EXTERNAL_USER_TYPE_CONFIG)
253230
class LkExternalUserType(LookupTable, TimestampMixin):
254231
__tablename__ = "lk_external_user_type"

api/src/db/models/opportunity_models.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
ApplicantType,
1111
FundingCategory,
1212
FundingInstrument,
13-
OpportunityAttachmentType,
1413
OpportunityCategory,
1514
OpportunityStatus,
1615
)
@@ -20,7 +19,6 @@
2019
LkApplicantType,
2120
LkFundingCategory,
2221
LkFundingInstrument,
23-
LkOpportunityAttachmentType,
2422
LkOpportunityCategory,
2523
LkOpportunityStatus,
2624
)
@@ -435,12 +433,6 @@ class OpportunityAttachment(ApiSchemaTable, TimestampMixin):
435433
BigInteger, ForeignKey(Opportunity.opportunity_id), index=True
436434
)
437435
opportunity: Mapped[Opportunity] = relationship(Opportunity)
438-
opportunity_attachment_type: Mapped[OpportunityAttachmentType] = mapped_column(
439-
"opportunity_attachment_type_id",
440-
LookupColumn(LkOpportunityAttachmentType),
441-
ForeignKey(LkOpportunityAttachmentType.opportunity_attachment_type_id),
442-
index=True,
443-
)
444436

445437
file_location: Mapped[str]
446438
mime_type: Mapped[str]

api/tests/src/db/models/factories.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
ExtractType,
3535
FundingCategory,
3636
FundingInstrument,
37-
OpportunityAttachmentType,
3837
OpportunityCategory,
3938
OpportunityCategoryLegacy,
4039
OpportunityStatus,
@@ -773,7 +772,6 @@ class Meta:
773772
file_name = factory.Faker("file_name")
774773
file_description = factory.Faker("sentence")
775774
file_size_bytes = factory.Faker("random_int", min=1000, max=10000000)
776-
opportunity_attachment_type = factory.fuzzy.FuzzyChoice(OpportunityAttachmentType)
777775

778776
created_at = factory.Faker("date_time_between", start_date="-1y", end_date="now")
779777
updated_at = factory.LazyAttribute(

0 commit comments

Comments
 (0)