-
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.
* Add user created_at index * lint
- Loading branch information
Showing
1 changed file
with
33 additions
and
0 deletions.
There are no files selected for viewing
33 changes: 33 additions & 0 deletions
33
discovery-provider/alembic/versions/1eec1d124caf_create_index_on_users_created_at.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,33 @@ | ||
"""create index on users created_at | ||
Revision ID: 1eec1d124caf | ||
Revises: 959f15b94094 | ||
Create Date: 2022-11-23 00:01:06.643480 | ||
""" | ||
import sqlalchemy as sa | ||
from alembic import op | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = '1eec1d124caf' | ||
down_revision = '959f15b94094' | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade(): | ||
conn = op.get_bind() | ||
conn.execute( | ||
""" | ||
CREATE INDEX IF NOT EXISTS user_created_at_idx ON users (created_at, user_id) WHERE is_current; | ||
""" | ||
) | ||
|
||
|
||
def downgrade(): | ||
conn = op.get_bind() | ||
conn.execute( | ||
""" | ||
DROP INDEX IF EXISTS user_created_at_idx; | ||
""" | ||
) |