# -*- coding: utf-8 -*-
# Generated by Django 1.10.4 on 2017-01-10 20:35
from __future__ import unicode_literals

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


def populate_new_fields(apps, schema_editor):
    TillClosure = apps.get_model('cashup', 'TillClosure')
    for tc in TillClosure.objects.all():
        tc.identity = tc.pk
        tc.object_created_time = tc.close_time
        tc.updated_by = tc.closed_by
        tc.version_created_time = tc.close_time
        tc.save()


class Migration(migrations.Migration):

    dependencies = [
        ('cashup', '0001_initial'),
    ]

    operations = [
        migrations.AddField(
            model_name='tillclosure',
            name='identity',
            field=models.PositiveIntegerField(default=0, editable=False, blank=True),
            preserve_default=False,
        ),
        migrations.AddField(
            model_name='tillclosure',
            name='object_created_time',
            field=models.DateTimeField(default=django.utils.timezone.now, editable=False, blank=True),
            preserve_default=False,
        ),
        migrations.AddField(
            model_name='tillclosure',
            name='updated_by',
            field=models.ForeignKey(editable=False, blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='updated_tillclosures', to='cashup.Personnel'),
        ),
        migrations.AddField(
            model_name='tillclosure',
            name='version_created_time',
            field=models.DateTimeField(default=django.utils.timezone.now, editable=False, blank=True),
            preserve_default=False,
        ),
        migrations.AddField(
            model_name='tillclosure',
            name='version_number',
            field=models.PositiveIntegerField(default=1, editable=False, blank=True),
            preserve_default=False,
        ),
        migrations.AddField(
            model_name='tillclosure',
            name='version_superseded_time',
            field=models.DateTimeField(editable=False, blank=True, null=True),
        ),
        migrations.RunPython(populate_new_fields, migrations.RunPython.noop),
        migrations.AlterField(
            model_name='tillclosure',
            name='identity',
            field=models.PositiveIntegerField(editable=False, blank=True),
            preserve_default=True,
        ),
        migrations.AlterField(
            model_name='tillclosure',
            name='object_created_time',
            field=models.DateTimeField(editable=False, blank=True),
            preserve_default=True,
        ),
        migrations.AlterField(
            model_name='tillclosure',
            name='updated_by',
            field=models.ForeignKey(editable=False, blank=True, on_delete=django.db.models.deletion.PROTECT, related_name='updated_tillclosures', to='cashup.Personnel'),
        ),
        migrations.AlterField(
            model_name='tillclosure',
            name='version_created_time',
            field=models.DateTimeField(editable=False, blank=True),
            preserve_default=True,
        ),
        migrations.AlterField(
            model_name='tillclosure',
            name='version_number',
            field=models.PositiveIntegerField(editable=False, blank=True),
            preserve_default=True,
        ),
    ]

# -*- coding: utf-8 -*-
# Generated by Django 1.10.4 on 2017-01-10 20:35
from __future__ import unicode_literals

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


def populate_new_fields(apps, schema_editor):
    TillClosure = apps.get_model('cashup', 'TillClosure')
    for tc in TillClosure.objects.all():
        tc.identity = tc.pk
        tc.object_created_time = tc.close_time
        tc.updated_by = tc.closed_by
        tc.version_created_time = tc.close_time
        tc.save()


class Migration(migrations.Migration):

    dependencies = [
        ('cashup', '0001_initial'),
    ]

    operations = [
        migrations.AddField(
            model_name='tillclosure',
            name='identity',
            field=models.PositiveIntegerField(default=0, editable=False, blank=True),
            preserve_default=False,
        ),
        migrations.AddField(
            model_name='tillclosure',
            name='object_created_time',
            field=models.DateTimeField(default=django.utils.timezone.now, editable=False, blank=True),
            preserve_default=False,
        ),
        migrations.AddField(
            model_name='tillclosure',
            name='updated_by',
            field=models.ForeignKey(editable=False, blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='updated_tillclosures', to='cashup.Personnel'),
        ),
        migrations.AddField(
            model_name='tillclosure',
            name='version_created_time',
            field=models.DateTimeField(default=django.utils.timezone.now, editable=False, blank=True),
            preserve_default=False,
        ),
        migrations.AddField(
            model_name='tillclosure',
            name='version_number',
            field=models.PositiveIntegerField(default=1, editable=False, blank=True),
            preserve_default=False,
        ),
        migrations.AddField(
            model_name='tillclosure',
            name='version_superseded_time',
            field=models.DateTimeField(editable=False, blank=True, null=True),
        ),
        migrations.RunPython(populate_new_fields, migrations.RunPython.noop),
        migrations.AlterField(
            model_name='tillclosure',
            name='identity',
            field=models.PositiveIntegerField(editable=False, blank=True),
            preserve_default=True,
        ),
        migrations.AlterField(
            model_name='tillclosure',
            name='object_created_time',
            field=models.DateTimeField(editable=False, blank=True),
            preserve_default=True,
        ),
        migrations.AlterField(
            model_name='tillclosure',
            name='updated_by',
            field=models.ForeignKey(editable=False, blank=True, on_delete=django.db.models.deletion.PROTECT, related_name='updated_tillclosures', to='cashup.Personnel'),
        ),
        migrations.AlterField(
            model_name='tillclosure',
            name='version_created_time',
            field=models.DateTimeField(editable=False, blank=True),
            preserve_default=True,
        ),
        migrations.AlterField(
            model_name='tillclosure',
            name='version_number',
            field=models.PositiveIntegerField(editable=False, blank=True),
            preserve_default=True,
        ),
    ]

# -*- coding: utf-8 -*- # Generated by Django 1.10.4 on 2017-01-10 20:35