# -*- coding: utf-8 -*-
# Generated by Django 1.9.13 on 2017-08-24 08:31

# Purpose of this migration:
# --------------------------
# Where there is a conflict between table names,
# the AIMS table must be moved out of the way of the IATI table
# while keeping relationships intact.


from __future__ import unicode_literals


from django.db import migrations
from django.db.migrations import SeparateDatabaseAndState

TABLES = [
    'location',
    'activity',
    'transaction',
    'title',
    'valuetype'
]


def alter_table_state(model):
    """
    Return an operation which will move the database table
    and then remove the model from Django's internal schema
    """
    return SeparateDatabaseAndState(
        [migrations.AlterModelTable(model, 'oldaims_%s' % (model.lower()))],  # This first parameter affects the database only
        [migrations.DeleteModel(model)]  # This second parameter affects Django's internal schema only
    )


class Migration(migrations.Migration):

    dependencies = [
        ('aims', '0042_iati_to_aims'),
    ]

    operations = [
        *[alter_table_state(m) for m in TABLES],
    ]
