-
Notifications
You must be signed in to change notification settings - Fork 106
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
27e9eda
commit 5938455
Showing
1 changed file
with
52 additions
and
0 deletions.
There are no files selected for viewing
52 changes: 52 additions & 0 deletions
52
discovery-provider/alembic/versions/37a4458bb72c_fix_alembic_indexes.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
"""fix_alembic_indexes | ||
Revision ID: 37a4458bb72c | ||
Revises: d321f0a00721 | ||
Create Date: 2022-03-31 19:34:35.793844 | ||
""" | ||
from alembic import op | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = "37a4458bb72c" | ||
down_revision = "d321f0a00721" | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade(): | ||
conn = op.get_bind() | ||
conn.execute( | ||
""" | ||
BEGIN; | ||
DROP INDEX IF EXISTS track_id; | ||
DROP INDEX IF EXISTS user_id; | ||
DROP INDEX IF EXISTS name; | ||
CREATE INDEX IF NOT EXISTS track_routes_track_id_idx ON track_routes (track_id, is_current); | ||
CREATE INDEX IF NOT EXISTS user_events_user_id_idx ON user_events (user_id, is_current); | ||
CREATE INDEX IF NOT EXISTS milestones_name_idx ON milestones (name, id); | ||
COMMIT; | ||
""" | ||
) | ||
|
||
|
||
def downgrade(): | ||
conn = op.get_bind() | ||
conn.execute( | ||
""" | ||
BEGIN; | ||
DROP INDEX IF EXISTS track_routes_track_id_idx; | ||
DROP INDEX IF EXISTS user_events_user_id_idx; | ||
DROP INDEX IF EXISTS milestones_name_idx; | ||
CREATE INDEX IF NOT EXISTS track_id ON track_routes (is_current); | ||
CREATE INDEX IF NOT EXISTS user_id ON user_events (is_current); | ||
CREATE INDEX IF NOT EXISTS name ON milestones (id); | ||
COMMIT; | ||
""" | ||
) |