# -*- coding: utf-8 -*-
# Generated by Django 1.11.15 on 2019-04-17 19:51

import os
import uuid
from django.db import migrations, models
from django.conf import settings


class Migration(migrations.Migration):

    dependencies = [("models", "5967_related_resource_map_card_feature_editing")]

    operations = [
        migrations.RunSQL(
            """
            update d_data_types set defaultconfig = jsonb '{"dateFormat":"YYYY-MM-DD"}' where datatype = 'date';
            update nodes n set config = c.config from cards_x_nodes_x_widgets c where n.nodeid = c.nodeid and n.datatype = 'date';
            update nodes set config = config::jsonb - 'label' where datatype = 'date';
            update nodes set config = config::jsonb - 'maxDate' where datatype = 'date';
            update nodes set config = config::jsonb - 'minDate' where datatype = 'date';
            update nodes set config = config::jsonb - 'viewMode' where datatype = 'date';
            update nodes set config = config::jsonb - 'placeholder' where datatype = 'date';
            update nodes set config = config::jsonb - 'defaultValue' where datatype = 'date';
            update widgets set defaultconfig = defaultconfig::jsonb - 'dateFormat' where widgetid = '10000000-0000-0000-0000-000000000004';
            """,
            """
            update d_data_types set defaultconfig = null where datatype = 'date';
            update nodes set config = null where datatype = 'date';
            update widgets set defaultconfig = jsonb_set(defaultconfig, '{dateFormat}', '"YYYY-MM-DD"')
            where widgetid = '10000000-0000-0000-0000-000000000004';
            """,
        )
    ]
