Skip to content

Commit 048c560

Browse files
kdmccormickclaude
andcommitted
feat!: ComponentVersionMedia.key -> ComponentVersionMedia.path
BREAKING CHANGE: Renamed ComponentVersionMedia.key -> ComponentVersionMedia.path BREAKING CHANGE: In create_component_version_media(...) and look_up_component_version_media(...), renamed param key -> path. Part of: #322 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 3f23389 commit 048c560

2 files changed

Lines changed: 66 additions & 0 deletions

File tree

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
from django.db import migrations, models
2+
3+
import openedx_django_lib.fields
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
('openedx_content', '0017_rename_learningpackage_db_column_key_to_package_ref'),
10+
]
11+
12+
operations = [
13+
migrations.RemoveConstraint(
14+
model_name='componentversionmedia',
15+
name='oel_cvcontent_uniq_cv_key',
16+
),
17+
migrations.RenameField(
18+
model_name='componentversionmedia',
19+
old_name='key',
20+
new_name='path',
21+
),
22+
migrations.AddConstraint(
23+
model_name='componentversionmedia',
24+
constraint=models.UniqueConstraint(
25+
fields=['component_version', 'path'],
26+
name='oel_cvcontent_uniq_cv_key',
27+
),
28+
),
29+
]
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
from django.db import migrations
2+
3+
import openedx_django_lib.fields
4+
5+
6+
class Migration(migrations.Migration):
7+
"""
8+
Rename the underlying DB column for ComponentVersionMedia.path from
9+
'_key' to 'path'. Uses SeparateDatabaseAndState with RunSQL for
10+
SQLite/MySQL compatibility. The table is named
11+
'openedx_content_componentversionmedia' (Django default).
12+
"""
13+
14+
dependencies = [
15+
('openedx_content', '0018_rename_componentversionmedia_key_to_path'),
16+
]
17+
18+
operations = [
19+
migrations.SeparateDatabaseAndState(
20+
state_operations=[
21+
migrations.AlterField(
22+
model_name='componentversionmedia',
23+
name='path',
24+
field=openedx_django_lib.fields.MultiCollationCharField(
25+
db_collations={'mysql': 'utf8mb4_bin', 'sqlite': 'BINARY'},
26+
max_length=500,
27+
),
28+
),
29+
],
30+
database_operations=[
31+
migrations.RunSQL(
32+
sql='ALTER TABLE openedx_content_componentversionmedia RENAME COLUMN _key TO path',
33+
reverse_sql='ALTER TABLE openedx_content_componentversionmedia RENAME COLUMN path TO _key',
34+
),
35+
],
36+
),
37+
]

0 commit comments

Comments
 (0)