summaryrefslogtreecommitdiffstats
path: root/kittystore/storm/schema/patch_9.py
blob: d1ae069305d8255b991f823adb59848033d901b2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# -*- coding: utf-8 -*-

from __future__ import absolute_import

from . import get_db_type


SQL = {
    "sqlite": [
        'CREATE INDEX "ix_sender_email" ON "email" (sender_email);',
        ],
    "postgres": [
        'CREATE INDEX "ix_sender_email" ON "email" USING btree (sender_email);',
        ],
    "mysql": [
        'CREATE INDEX `ix_sender_email` ON `email` (sender_email);',
        ],
    }


def apply(store):
    """Add indexes on email.sender_email"""
    dbtype = get_db_type(store)
    for statement in SQL[dbtype]:
        store.execute(statement)
    store.commit()