db: Add new index
This commit is contained in:
30
db_repo/versions/005_second_step_generation_index.py
Normal file
30
db_repo/versions/005_second_step_generation_index.py
Normal file
@@ -0,0 +1,30 @@
|
||||
from sqlalchemy import Table, MetaData, Index
|
||||
|
||||
meta = MetaData()
|
||||
|
||||
|
||||
def _get_indices(meta):
|
||||
meta.reflect()
|
||||
Tasks = Table("analyze_tasks", meta, autoload=True, autoload_with=meta.bind)
|
||||
return [
|
||||
Index(
|
||||
"tasks_second_step_idx",
|
||||
Tasks.c.repository_id,
|
||||
Tasks.c.status,
|
||||
Tasks.c.level,
|
||||
Tasks.c.improvement_absolute,
|
||||
Tasks.c.improvement_relative,
|
||||
)
|
||||
]
|
||||
|
||||
|
||||
def upgrade(migrate_engine):
|
||||
meta.bind = migrate_engine
|
||||
for idx in _get_indices(meta):
|
||||
idx.create()
|
||||
|
||||
|
||||
def downgrade(migrate_engine):
|
||||
meta.bind = migrate_engine
|
||||
for idx in _get_indices(meta):
|
||||
idx.drop()
|
||||
Reference in New Issue
Block a user