# 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
            PRIMARY KEY (id)
        );""", """
        CREATE SEQUENCE category_id_seq
            START WITH 1
            INCREMENT BY 1
            NO MAXVALUE
            NO MINVALUE
            CACHE 1
        ;""",
        "ALTER SEQUENCE category_id_seq OWNED BY category.id;",
        "ALTER TABLE ONLY category ALTER COLUMN id SET DEFAULT nextval('category_id_seq'::regclass);",
        'ALTER TABLE "thread" ADD COLUMN category_id INTEGER;',
        'ALTER TABLE "thread" ADD FOREIGN KEY (category_id) REFERENCES category(id);',
        'CREATE UNIQUE INDEX "ix_category_name" ON "category" (name);',
        ],
    "mysql": ["""
        CREATE TABLE `category` (
            id INTEGER NOT NULL AUTO_INCREMENT,
            name VARCHAR(255) NOT NULL,
            PRIMARY KEY (id)
        );""",
        'ALTER TABLE `thread` ADD COLUMN category_id INTEGER;',
        'ALTER TABLE `thread` ADD FOREIGN KEY (category_id) REFERENCES category(id);',
        'CREATE UNIQUE INDEX `ix_category_name` ON `category` (name);',
        ],
    }


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

            PRIMARY KEY (id)
        );""", """
        CREATE SEQUENCE category_id_seq
            START WITH 1
            INCREMENT BY 1
            NO MAXVALUE
            NO MINVALUE
            CACHE 1
        ;""",
        "ALTER SEQUENCE category_id_seq OWNED BY category.id;",
        "ALTER TABLE ONLY category ALTER COLUMN id SET DEFAULT nextval('category_id_seq'::regclass);",
        'ALTER TABLE "thread" ADD COLUMN category_id INTEGER;',
        'ALTER TABLE "thread" ADD FOREIGN KEY (category_id) REFERENCES category(id);',
        'CREATE UNIQUE INDEX "ix_category_name" ON "category" (name);',
        ],
    "mysql": ["""
        CREATE TABLE `category` (
            id INTEGER NOT NULL AUTO_INCREMENT,
            name VARCHAR(255) NOT NULL,
            PRIMARY KEY (id)
        );""",
        'ALTER TABLE `thread` ADD COLUMN category_id INTEGER;',
        'ALTER TABLE `thread` ADD FOREIGN KEY (category_id) REFERENCES category(id);',
        'CREATE UNIQUE INDEX `ix_category_name` ON `category` (name);',
        ],
    }


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

    dbtype = get_db_type(store)