# Generated by Django 2.0.6 on 2018-06-18 12:07

from django.db import migrations, models
import django.db.models.deletion


def atualizarTags(apps, schema_editor):
    tags = apps.get_model('trabalhos', 'tag')
    i = 1
    for tag in tags.objects.all().iterator():
        tag.ordem = i
        tag.save()
        i += 1


class Migration(migrations.Migration):

    dependencies = [
        ('trabalhos', '0009'),
    ]

    operations = [
        migrations.CreateModel(
            name='Natureza',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('nome', models.CharField(max_length=255, unique=True)),
            ],
        ),
        migrations.AddField(
            model_name='tag',
            name='ordem',
            field=models.PositiveSmallIntegerField(unique=True, null=True),
        ),
        migrations.RunPython(atualizarTags),
        migrations.AlterField(
            model_name='tag',
            name='ordem',
            field=models.PositiveSmallIntegerField(null=False),
        ),
        migrations.AddField(
            model_name='trabalho',
            name='nova_natureza',
            field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to='trabalhos.Natureza'),
        ),
    ]
