# Path: kittystore/storm/schema/utils.py
# def get_db_type(store):
#     database = store.get_database()
#     return database.__class__.__module__.split(".")[-1]


from .utils import get_db_type
# -*- coding: utf-8 -*-

from __future__ import absolute_import



SQL = {
    "sqlite": [
        # No 'ALTER TABLE DROP COLUMN' in SQLite
        'ALTER TABLE "list" ADD COLUMN subject_prefix TEXT;',
        'UPDATE "list" SET subject_prefix = \'[\' || display_name || \']\';'
        ],
    "postgres": [
        'ALTER TABLE "list" DROP COLUMN "description";',
        'ALTER TABLE "list" ADD COLUMN subject_prefix TEXT;',
        'UPDATE "list" SET subject_prefix = \'[\' || display_name || \']\';',
        ],
    "mysql": [
        'ALTER TABLE `list` DROP COLUMN `description`;',
        'ALTER TABLE `list` ADD COLUMN subject_prefix TEXT;',
        'UPDATE `list`" SET subject_prefix = CONCAT(\'[\', display_name, \']\');',
        ],
    }


def apply(store):
    """Add the subject_prefix column and delete the description column"""

# Path: kittystore/storm/schema/utils.py
# def get_db_type(store):
#     database = store.get_database()
#     return database.__class__.__module__.split(".")[-1]


# Path: kittystore/storm/schema/patch_7.py
from .utils import get_db_type

# -*- coding: utf-8 -*-

from __future__ import absolute_import



SQL = {
    "sqlite": [
        # No 'ALTER TABLE DROP COLUMN' in SQLite
        'ALTER TABLE "list" ADD COLUMN subject_prefix TEXT;',
        'UPDATE "list" SET subject_prefix = \'[\' || display_name || \']\';'
        ],
    "postgres": [
        'ALTER TABLE "list" DROP COLUMN "description";',
        'ALTER TABLE "list" ADD COLUMN subject_prefix TEXT;',
        'UPDATE "list" SET subject_prefix = \'[\' || display_name || \']\';',
        ],
    "mysql": [
        'ALTER TABLE `list` DROP COLUMN `description`;',
        'ALTER TABLE `list` ADD COLUMN subject_prefix TEXT;',
        'UPDATE `list`" SET subject_prefix = CONCAT(\'[\', display_name, \']\');',
        ],
    }


def apply(store):
    """Add the subject_prefix column and delete the description column"""

    dbtype = get_db_type(store)