Skip to content

Commit f5b6b4b

Browse files
kdmccormickclaude
andcommitted
fix(squash): squash media migrations into single migration
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 64a1cb2 commit f5b6b4b

3 files changed

Lines changed: 56 additions & 66 deletions

File tree

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
"""
2+
Rename ComponentVersionMedia.key -> ComponentVersionMedia.path.
3+
4+
The field previously had db_column='_key'; this migration also renames the
5+
underlying DB column to match the new field name.
6+
"""
7+
from django.db import migrations, models
8+
9+
import openedx_django_lib.fields
10+
11+
12+
class Migration(migrations.Migration):
13+
14+
dependencies = [
15+
('openedx_content', '0011_rename_entity_key_and_package_key_to_refs'),
16+
]
17+
18+
operations = [
19+
migrations.RemoveConstraint(
20+
model_name='componentversionmedia',
21+
name='oel_cvcontent_uniq_cv_key',
22+
),
23+
migrations.RenameField(
24+
model_name='componentversionmedia',
25+
old_name='key',
26+
new_name='path',
27+
),
28+
# RenameField only changes the Django field name; the DB column is still
29+
# '_key' (set via db_column). Use SeparateDatabaseAndState to rename the
30+
# actual column and drop the db_column override from state.
31+
migrations.SeparateDatabaseAndState(
32+
state_operations=[
33+
migrations.AlterField(
34+
model_name='componentversionmedia',
35+
name='path',
36+
field=openedx_django_lib.fields.MultiCollationCharField(
37+
db_collations={'mysql': 'utf8mb4_bin', 'sqlite': 'BINARY'},
38+
max_length=500,
39+
),
40+
),
41+
],
42+
database_operations=[
43+
migrations.RunSQL(
44+
sql='ALTER TABLE openedx_content_componentversionmedia RENAME COLUMN _key TO path',
45+
reverse_sql='ALTER TABLE openedx_content_componentversionmedia RENAME COLUMN path TO _key',
46+
),
47+
],
48+
),
49+
migrations.AddConstraint(
50+
model_name='componentversionmedia',
51+
constraint=models.UniqueConstraint(
52+
fields=['component_version', 'path'],
53+
name='oel_cvcontent_uniq_cv_key',
54+
),
55+
),
56+
]

src/openedx_content/migrations/0018_rename_componentversionmedia_key_to_path.py

Lines changed: 0 additions & 29 deletions
This file was deleted.

src/openedx_content/migrations/0019_rename_componentversionmedia_db_column_key_to_path.py

Lines changed: 0 additions & 37 deletions
This file was deleted.

0 commit comments

Comments
 (0)