old_contents: # -*- coding: utf-8 -*-
  # Generated by Django 1.11.20 on 2019-06-19 13:43
  from __future__ import unicode_literals
  
  from django.db import migrations
  
  
  class Migration(migrations.Migration):
  
      dependencies = [
          ('marketplace', '0086_cartitem_project'),
      ]
  
      operations = [
          migrations.AlterUniqueTogether(
              name='componentusage',
              unique_together=set([('resource', 'component', 'plan_period', 'date')]),
          ),
      ]
  
new_contents: # -*- coding: utf-8 -*-
  # Generated by Django 1.11.20 on 2019-06-19 13:43
  from __future__ import unicode_literals
  
  from django.db import migrations
  
  from waldur_core.core.utils import month_start
  
  
  def update_component_usage_date(apps, schema_editor):
      ComponentUsage = apps.get_model('marketplace', 'ComponentUsage')
      for component_usage in ComponentUsage.objects.all():
          component_usage.date = month_start(component_usage.date)
          component_usage.save(update_fields=['date'])
  
  
  class Migration(migrations.Migration):
  
      dependencies = [
          ('marketplace', '0086_cartitem_project'),
      ]
  
      operations = [
          migrations.RunPython(update_component_usage_date),
          migrations.AlterUniqueTogether(
              name='componentusage',
              unique_together=set([('resource', 'component', 'plan_period', 'date')]),
          ),
      ]
  
subject: Add data migration script.