Skip to content
Snippets Groups Projects
Verified Commit 01310922 authored by Ernesto Rico Schmidt's avatar Ernesto Rico Schmidt
Browse files

fix: improve migration of existing tags

parent 7ef26937
No related branches found
No related tags found
No related merge requests found
Pipeline #5840 passed
# Generated by Django 4.2.2 on 2023-09-06 02:31 # Generated by Django 4.2.2 on 2023-09-06 02:31
import json
from django.db import migrations, models from django.db import migrations, models
def split_old_tags(apps, _):
Note = apps.get_model("program", "Note")
for note in Note.objects.exclude(old_tags=""):
note.tags = json.dumps([tag.strip() for tag in note.old_tags.split(",")])
note.save()
class Migration(migrations.Migration): class Migration(migrations.Migration):
dependencies = [ dependencies = [
("program", "0072_timeslot_language_timeslot_topic"), ("program", "0072_timeslot_language_timeslot_topic"),
] ]
operations = [ operations = [
migrations.AlterField( migrations.RenameField(
model_name="note", model_name="note",
name="tags", new_name="old_tags",
old_name="tags",
),
migrations.AddField(
field=models.JSONField(blank=True), field=models.JSONField(blank=True),
model_name="note",
name="tags",
), ),
migrations.RunPython(code=split_old_tags),
migrations.RemoveField(
model_name="note",
name="old_tags",
)
] ]
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment