-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Modify Skill app: changes on skill_type model (#63)
- Loading branch information
1 parent
d719a53
commit 7d53df2
Showing
4 changed files
with
75 additions
and
10 deletions.
There are no files selected for viewing
40 changes: 40 additions & 0 deletions
40
skills/migrations/0005_remove_skill_skill_type_skill_skill_type.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,40 @@ | ||
# Generated by Django 4.2.11 on 2025-02-27 21:51 | ||
|
||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
from skills.models import Skill | ||
|
||
def move_skill_type_fk(apps, schema_editor): # pragma: no cover | ||
for skill in apps.get_model('skills', 'Skill').objects.all(): | ||
skill.skill_class = skill.skill_type.all().first() | ||
skill.save() | ||
|
||
def move_skill_type_m2m(apps, schema_editor): # pragma: no cover | ||
for skill in apps.get_model('skills', 'Skill').objects.all(): | ||
skill.skill_type.add(skill.skill_class) | ||
skill.save() | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('skills', '0004_alter_skill_skill_type_and_more'), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name='skill', | ||
name='skill_class', | ||
field=models.ForeignKey(blank=True, help_text='ID of the another skill that this skill is a subtype of.', null=True, on_delete=django.db.models.deletion.SET_NULL, to='skills.skill', verbose_name='Skill type'), | ||
), | ||
migrations.RunPython(move_skill_type_fk, move_skill_type_m2m), | ||
migrations.RemoveField( | ||
model_name='skill', | ||
name='skill_type', | ||
), | ||
migrations.RenameField( | ||
model_name='skill', | ||
old_name='skill_class', | ||
new_name='skill_type', | ||
), | ||
] |
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