Files
web2.0-backend/webapp/migrations/0048_auto_20181117_2128.py
T
2018-11-18 04:21:01 +02:00

38 lines
1.1 KiB
Python

# Generated by Django 2.0.7 on 2018-11-17 19:28
from django.db import migrations, models
i = 1
def gen_uuid(apps, schema_editor):
tag = apps.get_model('webapp', 'Tag')
for row in tag.objects.all():
global i
row.id = i
i += 1
row.save()
class Migration(migrations.Migration):
dependencies = [
('webapp', '0047_auto_20180710_2110'),
]
operations = [
migrations.AddField(
model_name='tag',
name='id',
field=models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID'),
preserve_default=False,
),
migrations.AlterField(
model_name='tag',
name='slug',
field=models.SlugField(unique=True),
),
migrations.RunPython(gen_uuid, reverse_code=migrations.RunPython.noop),
# Check if this fixes the database in production, not compliant with sqlite
# https://code.djangoproject.com/ticket/25012
# migrations.RunSQL('ALTER TABLE webapp_basefeed_tags ALTER tag_id TYPE int ALTER tag_id REFERENCES ("id")'),
]