# Generated by Django 4.0.6 on 2022-07-15 15:55

from django.db import migrations, models


def gen_road_number_cleaned(apps, schema_editor):
    RollingStock = apps.get_model('roster', 'RollingStock')
    for row in RollingStock.objects.all():
        row.road_number_cleaned = row.road_number.lstrip('#').lstrip('0')
        row.save(update_fields=['road_number_cleaned'])


class Migration(migrations.Migration):

    dependencies = [
        ('roster', '0007_alter_rollingclass_company_alter_rollingclass_type'),
    ]

    operations = [
        migrations.AddField(
            model_name='rollingstock',
            name='road_number_cleaned',
            field=models.CharField(default='', max_length=128),
            preserve_default=False,
        ),
        migrations.RunPython(
            gen_road_number_cleaned,
            reverse_code=migrations.RunPython.noop
        ),
        migrations.AlterModelOptions(
            name='rollingstock',
            options={'ordering': ['rolling_class', 'road_number_cleaned'], 'verbose_name_plural': 'Rolling stock'},
        ),
    ]
