-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
WCM-291: Add indexes so we can sort by timestamp columns
- Loading branch information
Showing
9 changed files
with
151 additions
and
148 deletions.
There are no files selected for viewing
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 @@ | ||
WCM-291: Add indexes so we can sort by timestamp columns |
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
50 changes: 50 additions & 0 deletions
50
...connector/migrations/postdeploy/20240925_1630-a4c1b7f678d9_create_index_for_timestamps.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,50 @@ | ||
"""create index for timestamps | ||
Revision ID: a4c1b7f678d9 | ||
Revises: 6cc99f5afdc5 | ||
Create Date: 2024-09-25 16:30:59.236538 | ||
""" | ||
|
||
from typing import Sequence, Union | ||
|
||
from alembic import op | ||
from sqlalchemy import text as sql | ||
|
||
|
||
# revision identifiers, used by Alembic. | ||
revision: str = 'a4c1b7f678d9' | ||
down_revision: Union[str, None] = '6cc99f5afdc5' | ||
branch_labels: Union[str, Sequence[str], None] = None | ||
depends_on: Union[str, Sequence[str], None] = None | ||
|
||
|
||
COLUMNS = [ | ||
'date_last_modified_semantic', | ||
'date_last_published', | ||
'date_last_published_semantic', | ||
'date_first_released', | ||
] | ||
|
||
|
||
def upgrade() -> None: | ||
with op.get_context().autocommit_block(): | ||
for column in COLUMNS: | ||
op.create_index( | ||
f'ix_properties_{column}', | ||
'properties', | ||
[sql(f'{column} desc nulls last')], | ||
postgresql_concurrently=True, | ||
if_not_exists=True, | ||
) | ||
|
||
|
||
def downgrade() -> None: | ||
with op.get_context().autocommit_block(): | ||
for column in COLUMNS: | ||
op.drop_index( | ||
f'ix_properties_{column}', | ||
table_name='properties', | ||
postgresql_concurrently=True, | ||
if_exists=True, | ||
) |
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
Oops, something went wrong.