Skip to content

Commit 219c5c5

Browse files
committed
fix: prevent migration ordering inconsistencies
1 parent 811126d commit 219c5c5

5 files changed

Lines changed: 113 additions & 11 deletions

File tree

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Generated by Django 5.2.10 on 2026-01-25 21:52
2+
3+
import django.db.models.deletion
4+
from django.db import migrations, models
5+
from django.db.migrations.operations.special import SeparateDatabaseAndState
6+
7+
8+
class Migration(migrations.Migration):
9+
10+
dependencies = [
11+
('contentstore', '0014_remove_componentlink_downstream_is_modified_and_more'),
12+
('oel_authoring', '0001_initial'),
13+
]
14+
15+
operations = [
16+
SeparateDatabaseAndState(
17+
database_operations=[],
18+
state_operations=[
19+
migrations.AlterField(
20+
model_name='componentlink',
21+
name='upstream_block',
22+
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='links', to='oel_authoring.component'),
23+
),
24+
migrations.AlterField(
25+
model_name='containerlink',
26+
name='upstream_container',
27+
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='links', to='oel_authoring.container'),
28+
),
29+
]
30+
),
31+
]
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Generated by Django 5.2.10 on 2026-01-25 21:52
2+
3+
import django.db.models.deletion
4+
from django.db import migrations, models
5+
from django.db.migrations.operations.special import SeparateDatabaseAndState
6+
7+
8+
class Migration(migrations.Migration):
9+
10+
dependencies = [
11+
('modulestore_migrator', '0006_alter_modulestoreblocksource_forwarded_and_more'),
12+
('oel_authoring', '0001_initial'),
13+
]
14+
15+
operations = [
16+
SeparateDatabaseAndState(
17+
database_operations=[],
18+
state_operations=[
19+
migrations.AlterField(
20+
model_name='modulestoreblockmigration',
21+
name='change_log_record',
22+
field=models.OneToOneField(null=True, on_delete=django.db.models.deletion.SET_NULL, to='oel_authoring.draftchangelogrecord'),
23+
),
24+
migrations.AlterField(
25+
model_name='modulestoreblockmigration',
26+
name='target',
27+
field=models.ForeignKey(blank=True, help_text='The target entity of this block migration, set to null if it fails to migrate', null=True, on_delete=django.db.models.deletion.CASCADE, to='oel_authoring.publishableentity'),
28+
),
29+
migrations.AlterField(
30+
model_name='modulestoremigration',
31+
name='change_log',
32+
field=models.ForeignKey(help_text='Changelog entry in the target learning package which records this migration', null=True, on_delete=django.db.models.deletion.SET_NULL, to='oel_authoring.draftchangelog'),
33+
),
34+
migrations.AlterField(
35+
model_name='modulestoremigration',
36+
name='target',
37+
field=models.ForeignKey(help_text='Content will be imported into this library', on_delete=django.db.models.deletion.CASCADE, to='oel_authoring.learningpackage'),
38+
),
39+
migrations.AlterField(
40+
model_name='modulestoremigration',
41+
name='target_collection',
42+
field=models.ForeignKey(blank=True, help_text='Optional - Collection (within the target library) into which imported content will be grouped', null=True, on_delete=django.db.models.deletion.SET_NULL, to='oel_authoring.collection'),
43+
),
44+
]
45+
),
46+
]

cms/envs/common.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
from datetime import timedelta
4646

4747
from django.utils.translation import gettext_lazy as _
48-
from openedx_learning.api.django import learning_core_apps_to_install
48+
from openedx_learning.api.django import openedx_learning_apps_to_install
4949

5050
from openedx.envs.common import * # pylint: disable=wildcard-import
5151

@@ -898,8 +898,7 @@ def make_lms_template_path(settings):
898898

899899
'openedx_events',
900900

901-
# Learning Core Apps, used by v2 content libraries (content_libraries app)
902-
*learning_core_apps_to_install(),
901+
*openedx_learning_apps_to_install(),
903902
]
904903

905904
### Apps only installed in some instances

lms/envs/common.py

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
PROVISIONING_PENDING_ENTERPRISE_CUSTOMER_ADMIN_ROLE,
6161
DEFAULT_ENTERPRISE_ENROLLMENT_INTENTIONS_ROLE,
6262
)
63-
from openedx_learning.api.django import learning_core_apps_to_install
63+
from openedx_learning.api.django import openedx_learning_apps_to_install
6464

6565
from openedx.core.lib.derived import Derived
6666
from openedx.envs.common import * # pylint: disable=wildcard-import
@@ -2020,8 +2020,12 @@
20202020

20212021
'openedx_events',
20222022

2023-
# Learning Core Apps, used by v2 content libraries (content_libraries app)
2024-
*learning_core_apps_to_install(),
2023+
# These go together as a unit.
2024+
*openedx_learning_apps_to_install(),
2025+
'cms.djangoapps.contentstore',
2026+
'cms.djangoapps.modulestore_migrator',
2027+
'openedx.core.djangoapps.content.search',
2028+
'openedx.core.djangoapps.content_staging',
20252029
]
20262030

20272031
# Add LMS specific optional apps
@@ -2875,9 +2879,25 @@
28752879

28762880
from edx_django_utils.plugins import get_plugin_apps, add_plugins # pylint: disable=wrong-import-position,wrong-import-order
28772881
from openedx.core.djangoapps.plugins.constants import ProjectType, SettingsType # pylint: disable=wrong-import-position
2882+
2883+
for app in INSTALLED_APPS:
2884+
if 'content_libraries' in app:
2885+
print("Found it before plugin application!")
2886+
28782887
INSTALLED_APPS.extend(get_plugin_apps(ProjectType.LMS))
2888+
2889+
for app in INSTALLED_APPS:
2890+
if 'content_libraries' in app:
2891+
print("Found it after extension!")
2892+
2893+
28792894
add_plugins(__name__, ProjectType.LMS, SettingsType.COMMON)
28802895

2896+
for app in INSTALLED_APPS:
2897+
if 'content_libraries' in app:
2898+
print("Found it after plugin application!")
2899+
2900+
28812901
PROCTORED_EXAM_VIEWABLE_PAST_DUE = False
28822902

28832903
######################### rate limit for yt_video_metadata api ##############

openedx/core/djangoapps/content_libraries/migrations/0012_alter_contentlibrary_learning_package.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,25 @@
22

33
import django.db.models.deletion
44
from django.db import migrations, models
5+
from django.db.migrations.operations.special import SeparateDatabaseAndState
56

67

78
class Migration(migrations.Migration):
89

910
dependencies = [
1011
('content_libraries', '0011_remove_contentlibrary_bundle_uuid_and_more'),
11-
('oel_authoring', '0002_rename_tables_to_oel_authoring'),
12+
('oel_authoring', '0001_initial'),
1213
]
1314

1415
operations = [
15-
migrations.AlterField(
16-
model_name='contentlibrary',
17-
name='learning_package',
18-
field=models.OneToOneField(default=None, null=True, on_delete=django.db.models.deletion.RESTRICT, to='oel_authoring.learningpackage'),
16+
SeparateDatabaseAndState(
17+
database_operations=[],
18+
state_operations=[
19+
migrations.AlterField(
20+
model_name='contentlibrary',
21+
name='learning_package',
22+
field=models.OneToOneField(default=None, null=True, on_delete=django.db.models.deletion.RESTRICT, to='oel_authoring.learningpackage'),
23+
),
24+
]
1925
),
2026
]

0 commit comments

Comments
 (0)