Skip to content

Commit b32c583

Browse files
committed
🗃️(backend) fix storage_location for existing files stored on AWS
The `storage_location` field was introduced in a previous release with a default value of `SCW_S3` for new files. However, existing files are stored on AWS S3. This commit updates the migration to correctly set `storage_location` to `AWS_S3` for those existing records.
1 parent 56d03dd commit b32c583

File tree

4 files changed

+64
-0
lines changed

4 files changed

+64
-0
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,13 @@ Versioning](https://semver.org/spec/v2.0.0.html).
88

99
## [Unreleased]
1010

11+
### Fixed
12+
13+
- Fix storage location field for existing files stored on AWS S3:
14+
- markdown images
15+
- deposited files
16+
- clasroom documents
17+
1118
## [5.8.0] - 2025-06-06
1219

1320
### Added
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Generated by Django 5.0.9 on 2025-06-11 17:34
2+
3+
from django.db import migrations
4+
5+
6+
def set_storage_location_to_aws(apps, schema_editor):
7+
"""Update the storage_location field for existing classroom documents."""
8+
ClassroomDocument = apps.get_model("bbb", "ClassroomDocument")
9+
ClassroomDocument.objects.all().update(storage_location="AWS_S3")
10+
11+
12+
class Migration(migrations.Migration):
13+
dependencies = [
14+
("bbb", "0024_classroomdocument_storage_location"),
15+
]
16+
17+
operations = [
18+
migrations.RunPython(set_storage_location_to_aws, migrations.RunPython.noop),
19+
]
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Generated by Django 5.0.9 on 2025-06-11 17:27
2+
3+
from django.db import migrations
4+
5+
6+
def set_storage_location_to_aws(apps, schema_editor):
7+
"""Update the storage_location field for existing deposited files."""
8+
DepositedFile = apps.get_model("deposit", "DepositedFile")
9+
DepositedFile.objects.all().update(storage_location="AWS_S3")
10+
11+
12+
class Migration(migrations.Migration):
13+
dependencies = [
14+
("deposit", "0006_depositedfile_storage_location"),
15+
]
16+
17+
operations = [
18+
migrations.RunPython(set_storage_location_to_aws, migrations.RunPython.noop),
19+
]
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Generated by Django 5.0.9 on 2025-06-11 17:37
2+
3+
from django.db import migrations
4+
5+
6+
def set_storage_location_to_aws(apps, schema_editor):
7+
"""Update the storage_location field for existing markdown images."""
8+
MarkdownImage = apps.get_model("markdown", "MarkdownImage")
9+
MarkdownImage.objects.all().update(storage_location="AWS_S3")
10+
11+
12+
class Migration(migrations.Migration):
13+
dependencies = [
14+
("markdown", "0007_markdownimage_storage_location"),
15+
]
16+
17+
operations = [
18+
migrations.RunPython(set_storage_location_to_aws, migrations.RunPython.noop),
19+
]

0 commit comments

Comments
 (0)