mirror of https://github.com/interlegis/sapl.git
Marcio Mazza
7 years ago
8 changed files with 84 additions and 53 deletions
@ -0,0 +1,46 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# Generated by Django 1.9.13 on 2018-01-31 12:14 |
|||
from __future__ import unicode_literals |
|||
|
|||
from django.db import migrations, models |
|||
|
|||
from sapl.utils import LISTA_DE_UFS |
|||
|
|||
|
|||
def migrate_municipio_e_uf_como_charfields(apps, schema_editor): |
|||
Parlamentar = apps.get_model('parlamentares', 'Parlamentar') |
|||
for parlamentar in Parlamentar.objects.all(): |
|||
municipio = parlamentar.municipio_residencia_old |
|||
if municipio: |
|||
parlamentar.municipio_residencia = municipio.nome |
|||
parlamentar.uf_residencia = municipio.uf |
|||
parlamentar.save() |
|||
|
|||
|
|||
class Migration(migrations.Migration): |
|||
|
|||
dependencies = [ |
|||
('parlamentares', '0013_auto_20180130_1425'), |
|||
] |
|||
|
|||
operations = [ |
|||
migrations.RenameField( |
|||
model_name='parlamentar', |
|||
old_name='municipio_residencia', |
|||
new_name='municipio_residencia_old', |
|||
), |
|||
|
|||
migrations.AddField( |
|||
model_name='parlamentar', |
|||
name='municipio_residencia', |
|||
field=models.CharField(blank=True, max_length=50, |
|||
verbose_name='Município'), |
|||
), |
|||
migrations.AddField( |
|||
model_name='parlamentar', |
|||
name='uf_residencia', |
|||
field=models.CharField(blank=True, choices=LISTA_DE_UFS, |
|||
max_length=2, verbose_name='UF'), |
|||
), |
|||
migrations.RunPython(migrate_municipio_e_uf_como_charfields), |
|||
] |
@ -0,0 +1,22 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# Generated by Django 1.9.13 on 2018-01-31 18:29 |
|||
from __future__ import unicode_literals |
|||
|
|||
from django.db import migrations |
|||
|
|||
|
|||
class Migration(migrations.Migration): |
|||
|
|||
dependencies = [ |
|||
('parlamentares', '0014_auto_20180131_1014'), |
|||
] |
|||
|
|||
operations = [ |
|||
migrations.RemoveField( |
|||
model_name='parlamentar', |
|||
name='municipio_residencia_old', |
|||
), |
|||
migrations.DeleteModel( |
|||
name='Municipio', |
|||
), |
|||
] |
Loading…
Reference in new issue