# 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
            participants_count INTEGER,
            threads_count INTEGER,
            PRIMARY KEY (list_name, year, month),
            FOREIGN KEY (list_name) REFERENCES list(name) ON DELETE CASCADE
        );""",
        'ALTER TABLE "thread" ADD CONSTRAINT fk_thread_list FOREIGN KEY (list_name) REFERENCES list(name) ON DELETE CASCADE;',
        'ALTER TABLE "email" ADD CONSTRAINT fk_email_list FOREIGN KEY (list_name) REFERENCES list(name) ON DELETE CASCADE;',
        'CREATE INDEX "ix_email_archived_date" ON "email" (archived_date);',
        'ALTER TABLE "list" ADD COLUMN created_at TIMESTAMP WITHOUT TIME ZONE;',
        ],
    "mysql": ["""
        CREATE TABLE `list_month_activity` (
            list_name VARCHAR(255) NOT NULL,
            year INTEGER NOT NULL,
            month INTEGER NOT NULL,
            participants_count INTEGER,
            threads_count INTEGER,
            PRIMARY KEY (list_name, year, month),
            FOREIGN KEY (list_name) REFERENCES list(name) ON DELETE CASCADE
        );""",
        'ALTER TABLE `thread` ADD CONSTRAINT fk_thread_list FOREIGN KEY (list_name) REFERENCES list(name) ON DELETE CASCADE;',
        'ALTER TABLE `email` ADD CONSTRAINT fk_email_list FOREIGN KEY (list_name) REFERENCES list(name) ON DELETE CASCADE;',
        'CREATE INDEX `ix_email_archived_date` ON `email` (archived_date);',
        'ALTER TABLE `list` ADD COLUMN created_at DATETIME;',
        ],
    }


def apply(store):
    """Add the category table"""

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

            participants_count INTEGER,
            threads_count INTEGER,
            PRIMARY KEY (list_name, year, month),
            FOREIGN KEY (list_name) REFERENCES list(name) ON DELETE CASCADE
        );""",
        'ALTER TABLE "thread" ADD CONSTRAINT fk_thread_list FOREIGN KEY (list_name) REFERENCES list(name) ON DELETE CASCADE;',
        'ALTER TABLE "email" ADD CONSTRAINT fk_email_list FOREIGN KEY (list_name) REFERENCES list(name) ON DELETE CASCADE;',
        'CREATE INDEX "ix_email_archived_date" ON "email" (archived_date);',
        'ALTER TABLE "list" ADD COLUMN created_at TIMESTAMP WITHOUT TIME ZONE;',
        ],
    "mysql": ["""
        CREATE TABLE `list_month_activity` (
            list_name VARCHAR(255) NOT NULL,
            year INTEGER NOT NULL,
            month INTEGER NOT NULL,
            participants_count INTEGER,
            threads_count INTEGER,
            PRIMARY KEY (list_name, year, month),
            FOREIGN KEY (list_name) REFERENCES list(name) ON DELETE CASCADE
        );""",
        'ALTER TABLE `thread` ADD CONSTRAINT fk_thread_list FOREIGN KEY (list_name) REFERENCES list(name) ON DELETE CASCADE;',
        'ALTER TABLE `email` ADD CONSTRAINT fk_email_list FOREIGN KEY (list_name) REFERENCES list(name) ON DELETE CASCADE;',
        'CREATE INDEX `ix_email_archived_date` ON `email` (archived_date);',
        'ALTER TABLE `list` ADD COLUMN created_at DATETIME;',
        ],
    }


def apply(store):
    """Add the category table"""

    dbtype = get_db_type(store)