# -*- coding: utf-8 -*-
# Generated by Django 1.11.13 on 2018-06-19 20:24
from __future__ import unicode_literals

import django.core.serializers.json
from django.db import migrations, models
import oxdjango.fields


class Migration(migrations.Migration):

    dependencies = [
        ('item', '0003_jsonfield'),
    ]

    operations = [
        migrations.RenameField(
            model_name='item',
            old_name='json',
            new_name='cache',
        ),
        migrations.RunSQL(
            """UPDATE item_item SET cache = jsonb_set(cache, '{created}', cache->'created'->'__value__', true) WHERE cache @> '{"created": {"__class__": "datetime.datetime"}}'"""
        ),
        migrations.RunSQL(
            """UPDATE item_item SET cache = jsonb_set(cache, '{accessed}', cache->'accessed'->'__value__', true) WHERE cache @> '{"accessed": {"__class__": "datetime.datetime"}}'"""
        ),
        migrations.RunSQL(
            """UPDATE item_item SET cache = jsonb_set(cache, '{modified}', cache->'modified'->'__value__', true) WHERE cache @> '{"modified": {"__class__": "datetime.datetime"}}'"""
        ),
    ]
