-
Notifications
You must be signed in to change notification settings - Fork 2
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
Showing
2 changed files
with
49 additions
and
6 deletions.
There are no files selected for viewing
39 changes: 39 additions & 0 deletions
39
src/api/qualicharge/migrations/versions/4b99d15436b0_add_statique_materialized_view.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,39 @@ | ||
"""Add statique materialized view | ||
Revision ID: 4b99d15436b0 | ||
Revises: d3d2c20f8efd | ||
Create Date: 2025-01-16 15:02:04.004411 | ||
""" | ||
|
||
from typing import Sequence, Union | ||
|
||
from alembic import op | ||
from sqlalchemy_utils.view import CreateView, DropView | ||
|
||
from qualicharge.schemas.core import _StatiqueMV | ||
|
||
# revision identifiers, used by Alembic. | ||
revision: str = "4b99d15436b0" | ||
down_revision: Union[str, None] = "d3d2c20f8efd" | ||
branch_labels: Union[str, Sequence[str], None] = None | ||
depends_on: Union[str, Sequence[str], None] = None | ||
|
||
|
||
def upgrade() -> None: | ||
"""Create the Statique Materialized view and related indexes.""" | ||
op.execute( | ||
CreateView( | ||
_StatiqueMV.__table__.fullname, _StatiqueMV.selectable, materialized=True | ||
) | ||
) | ||
for idx in _StatiqueMV.__table__.indexes: | ||
idx.create(op.get_bind()) | ||
|
||
|
||
def downgrade() -> None: | ||
"""Delete the Statique Materialized View.""" | ||
|
||
op.execute( | ||
DropView(_StatiqueMV.__table__.fullname, materialized=True, cascade=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