mirror of
https://github.com/daniviga/django-ram.git
synced 2025-08-04 21:27:49 +02:00
Move decoder interface def into rolling stock
This commit is contained in:
42
ram/roster/migrations/0013_rollingstock_decoder_interface.py
Normal file
42
ram/roster/migrations/0013_rollingstock_decoder_interface.py
Normal file
@@ -0,0 +1,42 @@
|
||||
# Generated by Django 4.1 on 2022-10-31 22:27
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
def meta_to_roster(apps, schema_editor):
|
||||
model = apps.get_model("roster", "RollingStock")
|
||||
|
||||
for row in model.objects.all():
|
||||
if row.decoder:
|
||||
decoder_interface = row.decoder.interface
|
||||
row.__dict__["decoder_interface"] = decoder_interface
|
||||
row.save(update_fields=["decoder_interface"])
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("roster", "0012_rollingstockjournal"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name="rollingstock",
|
||||
name="decoder_interface",
|
||||
field=models.PositiveSmallIntegerField(
|
||||
blank=True,
|
||||
choices=[
|
||||
(1, "NEM651"),
|
||||
(2, "NEM652"),
|
||||
(3, "PluX"),
|
||||
(4, "21MTC"),
|
||||
(5, "Next18/Next18S"),
|
||||
],
|
||||
null=True,
|
||||
),
|
||||
),
|
||||
migrations.RunPython(
|
||||
meta_to_roster,
|
||||
reverse_code=migrations.RunPython.noop
|
||||
),
|
||||
]
|
Reference in New Issue
Block a user