# Generated by Django 3.2.4 on 2021-07-03 08:25

from django.db import migrations, models
import django.utils.timezone


def copy_created_date(app_registry, schema_editor):
    db_alias = schema_editor.connection.alias
    ShelfBook = app_registry.get_model("bookwyrm", "ShelfBook")
    ShelfBook.objects.all().update(shelved_date=models.F("created_date"))


def do_nothing(app_registry, schema_editor):
    pass


class Migration(migrations.Migration):

    dependencies = [
        ("bookwyrm", "0077_auto_20210623_2155"),
    ]

    operations = [
        migrations.AlterModelOptions(
            name="shelfbook",
            options={"ordering": ("-shelved_date",)},
        ),
        migrations.AddField(
            model_name="shelfbook",
            name="shelved_date",
            field=models.DateTimeField(default=django.utils.timezone.now),
        ),
        migrations.RunPython(copy_created_date, reverse_code=do_nothing),
    ]
