text: # Generated by Django 2.2.7 on 2019-11-27 15:22
  # Modified by hand to ensure that initial dates of a salary grade change are the start date of the financial year
  
  from datetime import date
  from django.db import migrations, models
  import django.utils.timezone
  
  def set_initial_salarygradechange_date(apps, schema_editor):
      SalaryGradeChange = apps.get_model('rse', 'SalaryGradeChange')
      for sgc in SalaryGradeChange.objects.all():
          sgc.date = date(sgc.salary_band.year.year, 8, 1) #sgc.salary_band.year.start_date()
          sgc.save()
  
  def revert_initial_salarygradechange_date(apps, schema_editor):
      SalaryGradeChange = apps.get_model('rse', 'SalaryGradeChange')
      for sgc in SalaryGradeChange.objects.all():
          sgc.date = django.utils.timezone.now().date()
          sgc.save()
  
  
  class Migration(migrations.Migration):
  
      dependencies = [
          ('rse', '0004_auto_20191124_1946'),
      ]
  
      operations = [
          migrations.AddField(
              model_name='salarygradechange',
              name='date',
              field=models.DateField(default=django.utils.timezone.now),
              preserve_default=False,
          ),
          migrations.AlterField(
              model_name='rseallocation',
              name='created_date',
              field=models.DateTimeField(default=django.utils.timezone.now, editable=False),
          ),
          migrations.RunPython(set_initial_salarygradechange_date, revert_initial_salarygradechange_date),
      ]
  