# Generated by Django 2.1.2 on 2020-03-15 03:42

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


def switch_to_post(apps, schema_editor):
    OldUnbrella = apps.get_model('login', 'OldUnbrella')
    NewUnbrella = apps.get_model('login', 'NewUnbrella')
    for un in OldUnbrella.objects.all():
        un.delete()

def switch_to_nopost(apps, schema_editor):
    OldUnbrella = apps.get_model('login', 'OldUnbrella')
    NewUnbrella = apps.get_model('login', 'NewUnbrella')

    for un in NewUnbrella.objects.all():
        un.delete()


class Migration(migrations.Migration):

    dependencies = [
        ('login', '0007_rentalitem'),
    ]

    operations = [
       migrations.RenameModel('Unbrella', 'OldUnbrella'),
        migrations.CreateModel(
            name="NewUnbrella",
            fields=[
                ('rentalitem_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True,serialize=False, to='login.RentalItem')),
                ('borrowed_by', models.OneToOneField('login.Student', null=True, related_name = "un", blank=True, on_delete=models.CASCADE)),
                
            ],
            bases=('login.RentalItem',),
        ),
        migrations.RunPython(switch_to_post, switch_to_nopost),
        migrations.DeleteModel('OldUnbrella'),
        migrations.RenameModel('NewUnbrella', 'Unbrella')
    ]
