# -*- coding: utf-8 -*-
# Generated by Django 1.9.13 on 2017-08-10 02:28
from __future__ import unicode_literals

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

TABLES = [
    'vocabulary',
    'activityparticipatingorganisation',
    'activitypolicymarker',
    'activityrecipientcountry',
    'activityrecipientregion',
    'otheridentifier',
    'activitywebsite',
    'contactinfo',
    'relatedactivity',
    'planneddisbursement',
    'documentlink',
    'result',
    'resultindicator',
    'resultindicatorperiod',
    'description',
    'budget',
    'condition',
]


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(
        # This first parameter affects the database only
        [
            migrations.AlterModelTable(model, 'oldaims_%s' % (model.lower()))
        ],
        # This second parameter affects Django's internal schema only
        [
            migrations.DeleteModel(model)
        ]
    )


def alter_table_states(models):
    return [alter_table_state(m) for m in models]


class Migration(migrations.Migration):
    """
    This Migration must accomplish 3 things:
     - Rename the Vocabulary table in the database
     - Drop any Foreign Keys to Vocabulary from the state
     - Drop the table from the model state
    """
    dependencies = [
        ('aims', '0041_aimsy_language_fks'),
    ]

    operations = alter_table_states(TABLES)
