# 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
                REFERENCES email(list_name, message_id) ON DELETE CASCADE,
            FOREIGN KEY (user_id) REFERENCES "user"(id)
        );""",
        'CREATE INDEX "ix_vote_list_name_message_id" ON "vote" (list_name, message_id);',
        'CREATE INDEX "ix_vote_user_id" ON "vote" (user_id);',
        'CREATE INDEX "ix_vote_value" ON "vote" (value);',
        ],
    "mysql": ["""
        CREATE TABLE `vote` (
            list_name VARCHAR(255) NOT NULL,
            message_id VARCHAR(255) NOT NULL,
            user_id VARCHAR(255) NOT NULL,
            value TINYINT NOT NULL,
            PRIMARY KEY (list_name, message_id, user_id),
            FOREIGN KEY (list_name) REFERENCES list(name) ON DELETE CASCADE,
            FOREIGN KEY (list_name, message_id)
                REFERENCES email(list_name, message_id) ON DELETE CASCADE,
            FOREIGN KEY (user_id) REFERENCES `user`(id)
        );""",
        'CREATE INDEX `ix_vote_list_name_message_id` ON `vote` (list_name, message_id);',
        'CREATE INDEX `ix_vote_user_id" ON "vote` (user_id);',
        'CREATE INDEX `ix_vote_value" ON "vote` (value);',
        ],
    }


def apply(store):
    """
    Remove the database-based cache.
    """

# 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_18.py
from .utils import get_db_type

                REFERENCES email(list_name, message_id) ON DELETE CASCADE,
            FOREIGN KEY (user_id) REFERENCES "user"(id)
        );""",
        'CREATE INDEX "ix_vote_list_name_message_id" ON "vote" (list_name, message_id);',
        'CREATE INDEX "ix_vote_user_id" ON "vote" (user_id);',
        'CREATE INDEX "ix_vote_value" ON "vote" (value);',
        ],
    "mysql": ["""
        CREATE TABLE `vote` (
            list_name VARCHAR(255) NOT NULL,
            message_id VARCHAR(255) NOT NULL,
            user_id VARCHAR(255) NOT NULL,
            value TINYINT NOT NULL,
            PRIMARY KEY (list_name, message_id, user_id),
            FOREIGN KEY (list_name) REFERENCES list(name) ON DELETE CASCADE,
            FOREIGN KEY (list_name, message_id)
                REFERENCES email(list_name, message_id) ON DELETE CASCADE,
            FOREIGN KEY (user_id) REFERENCES `user`(id)
        );""",
        'CREATE INDEX `ix_vote_list_name_message_id` ON `vote` (list_name, message_id);',
        'CREATE INDEX `ix_vote_user_id" ON "vote` (user_id);',
        'CREATE INDEX `ix_vote_value" ON "vote` (value);',
        ],
    }


def apply(store):
    """
    Remove the database-based cache.
    """

    dbtype = get_db_type(store)