I want to write a new migration file to change old bad data to the better one. For example, the old model was like this:
from django.db import models
class Person(models.Model):
fullname = models.CharField(max_length=250, null=True)
information = models.CharField(max_length=350, null=True)
and the value of fullname is sth like:
first_name:George;last_name:Adam Pince Green
which first_name and last_name are always in the same order. The value of information is like:
id_code:0021678913;born_in:Canada;birth_year:1975
or
birth_year:1990;born_in:Portugal;id_code:0219206431
which are not ordered. now I need to write a migration file that split this fullname and information values to the new model like:
from django.db import models
class Person(models.Model):
first_name = models.CharField(max_length=30, null=True)
last_name = models.CharField(max_length=50, null=True)
id_code = models.CharField(max_length=10, null=True)
born_in = models.CharField(max_length=30, null=True)
birth_year = models.PositiveSmallIntegerField(null=True)