Skip to content

Commit 6e64968

Browse files
committed
feat: Add storage_path field to Attachment model for S3 file paths
1 parent fa1bb5c commit 6e64968

File tree

3 files changed

+33
-0
lines changed

3 files changed

+33
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
"""Add storage_path to Attachment model
2+
3+
Revision ID: 2025_02_23_storage_path
4+
Revises: 2025_02_23_gin_idx
5+
Create Date: 2025-02-23 11:00:00.000000
6+
7+
"""
8+
from alembic import op
9+
import sqlalchemy as sa
10+
11+
# revision identifiers, used by Alembic.
12+
revision = '2025_02_23_storage_path'
13+
down_revision = '2025_02_23_gin_idx'
14+
branch_labels = None
15+
depends_on = None
16+
17+
18+
def upgrade() -> None:
19+
# Add storage_path column
20+
op.add_column('attachment', sa.Column('storage_path', sa.String(length=1024), nullable=False))
21+
22+
23+
def downgrade() -> None:
24+
# Remove storage_path column
25+
op.drop_column('attachment', 'storage_path')

backend/app/tests/api/routes/test_attachments.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ def test_create_attachment(
2525
data = {
2626
"file_name": "test.pdf",
2727
"mime_type": "application/pdf",
28+
"storage_path": "patients/attachments/test.pdf",
2829
"description": "Test attachment",
2930
"patient_id": str(patient.id)
3031
}
@@ -56,6 +57,7 @@ def test_read_attachment(
5657
attachment = Attachment(
5758
file_name="test.pdf",
5859
mime_type="application/pdf",
60+
storage_path="patients/attachments/test.pdf",
5961
description="Test attachment",
6062
patient_id=patient.id
6163
)
@@ -89,11 +91,13 @@ def test_read_attachments(
8991
attachment1 = Attachment(
9092
file_name="test1.pdf",
9193
mime_type="application/pdf",
94+
storage_path="patients/attachments/test1.pdf",
9295
patient_id=patient.id
9396
)
9497
attachment2 = Attachment(
9598
file_name="test2.pdf",
9699
mime_type="application/pdf",
100+
storage_path="patients/attachments/test2.pdf",
97101
patient_id=patient.id
98102
)
99103
db.add(attachment1)
@@ -126,6 +130,7 @@ def test_update_attachment(
126130
attachment = Attachment(
127131
file_name="test.pdf",
128132
mime_type="application/pdf",
133+
storage_path="patients/attachments/test.pdf",
129134
patient_id=patient.id
130135
)
131136
db.add(attachment)
@@ -160,6 +165,7 @@ def test_delete_attachment(
160165
attachment = Attachment(
161166
file_name="test.pdf",
162167
mime_type="application/pdf",
168+
storage_path="patients/attachments/test.pdf",
163169
patient_id=patient.id
164170
)
165171
db.add(attachment)

backend/app/tests/api/routes/test_patients.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,11 +210,13 @@ def test_read_patients_attachment_filter(
210210
attachment1 = Attachment(
211211
file_name="test1.bam",
212212
mime_type="application/x-bam",
213+
storage_path="patients/attachments/test1.bam",
213214
patient_id=patient1.id
214215
)
215216
attachment2 = Attachment(
216217
file_name="test.cram",
217218
mime_type="application/x-cram",
219+
storage_path="patients/attachments/test.cram",
218220
patient_id=patient2.id
219221
)
220222
db.add(attachment1)

0 commit comments

Comments
 (0)