-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: remove Taxonomy.required, squash taxonomy migrations (#33438)
* feat: remove Taxonomy.required, make allow_multiple True by default * chore: squash migrations * fix: more robust migration Co-authored-by: Jillian <[email protected]> * chore: version bump, use squashed migration --------- Co-authored-by: Jillian <[email protected]>
- Loading branch information
1 parent
565b34e
commit d6e21a1
Showing
12 changed files
with
126 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
openedx/core/djangoapps/content_tagging/migrations/0001_squashed.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# Generated by Django 3.2.21 on 2023-10-09 23:12 | ||
|
||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
replaces = [ | ||
('content_tagging', '0001_initial'), | ||
('content_tagging', '0002_system_defined_taxonomies'), | ||
('content_tagging', '0003_system_defined_fixture'), | ||
('content_tagging', '0004_system_defined_org'), | ||
('content_tagging', '0005_auto_20230830_1517'), | ||
('content_tagging', '0006_simplify_models'), | ||
] | ||
|
||
initial = True | ||
|
||
dependencies = [ | ||
("oel_tagging", "0001_squashed"), | ||
('organizations', '0003_historicalorganizationcourse'), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='ContentObjectTag', | ||
fields=[ | ||
], | ||
options={ | ||
'proxy': True, | ||
'indexes': [], | ||
'constraints': [], | ||
}, | ||
bases=('oel_tagging.objecttag',), | ||
), | ||
migrations.CreateModel( | ||
name='TaxonomyOrg', | ||
fields=[ | ||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('rel_type', models.CharField(choices=[('OWN', 'owner')], default='OWN', max_length=3)), | ||
('org', models.ForeignKey(default=None, help_text='Organization that is related to this taxonomy.If None, then this taxonomy is related to all organizations.', null=True, on_delete=django.db.models.deletion.CASCADE, to='organizations.organization')), | ||
('taxonomy', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='oel_tagging.taxonomy')), | ||
], | ||
), | ||
migrations.AddIndex( | ||
model_name='taxonomyorg', | ||
index=models.Index(fields=['taxonomy', 'rel_type'], name='content_tag_taxonom_b04dd1_idx'), | ||
), | ||
migrations.AddIndex( | ||
model_name='taxonomyorg', | ||
index=models.Index(fields=['taxonomy', 'rel_type', 'org'], name='content_tag_taxonom_70d60b_idx'), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
openedx/core/djangoapps/content_tagging/migrations/0007_system_defined_org_2.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
from django.db import migrations | ||
|
||
|
||
def mark_language_taxonomy_as_all_orgs(apps, _schema_editor): | ||
""" | ||
Associates the system defined taxonomy Language (id=-1) to all orgs. | ||
""" | ||
TaxonomyOrg = apps.get_model("content_tagging", "TaxonomyOrg") | ||
TaxonomyOrg.objects.update_or_create(taxonomy_id=-1, defaults={"org": None}) | ||
|
||
|
||
def revert_mark_language_taxonomy_as_all_orgs(apps, _schema_editor): | ||
""" | ||
Deletes association of system defined taxonomy Language (id=-1) to all orgs. | ||
""" | ||
TaxonomyOrg = apps.get_model("content_tagging", "TaxonomyOrg") | ||
TaxonomyOrg.objects.get(taxonomy_id=-1, org=None).delete() | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
('content_tagging', '0001_squashed'), | ||
("oel_tagging", "0012_language_taxonomy"), | ||
] | ||
|
||
operations = [ | ||
migrations.RunPython(mark_language_taxonomy_as_all_orgs, revert_mark_language_taxonomy_as_all_orgs), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters