lin
2025-07-30 fcd736bf35fd93b563e9bbf594f2aa7b62028cc9
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
27
INDICES = (
    ('afe_host_queue_entries', 'active'),
    ('afe_host_queue_entries', 'complete'),
    ('afe_host_queue_entries', 'deleted'),
    ('afe_host_queue_entries', 'aborted'),
    ('afe_host_queue_entries', 'started_on'),
    ('afe_host_queue_entries', 'finished_on'),
    ('afe_host_queue_entries', 'job_id'),
)
 
def get_index_name(table, field):
    """Formats the index name from a |table| and |field|."""
    return table + '_' + field
 
 
def migrate_up(manager):
    """Creates the indices."""
    for table, field in INDICES:
        manager.execute('CREATE INDEX %s ON %s (%s)' %
                        (get_index_name(table, field), table, field))
 
 
def migrate_down(manager):
    """Removes the indices."""
    for table, field in INDICES:
        manager.execute('DROP INDEX %s ON %s' %
                        (get_index_name(table, field), table))