Skip to content

Commit

Permalink
Add user created_at index (#4392)
Browse files Browse the repository at this point in the history
* Add user created_at index

* lint
  • Loading branch information
isaacsolo committed Nov 23, 2022
1 parent 8cc7a18 commit 192776c
Showing 1 changed file with 33 additions and 0 deletions.
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;
"""
)

0 comments on commit 192776c

Please sign in to comment.