Skip to content

Commit

Permalink
Add migration to set default alert selector
Browse files Browse the repository at this point in the history
In commits fc1e1f7 and e44fcdb a new Selector option was added to
alerts, which may be "first", "min" or "max".  This migration sets the
default to "first" for existing alerts.
  • Loading branch information
eradman committed Nov 1, 2024
1 parent 49277d2 commit 47ecd4a
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions migrations/versions/1655999df5e3_default_alert_selector.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
"""set default alert selector
Revision ID: 1655999df5e3
Revises: 9e8c841d1a30
Create Date: 2024-10-18 11:24:49
"""

from alembic import op

# revision identifiers, used by Alembic.
revision = '1655999df5e3'
down_revision = '9e8c841d1a30'
branch_labels = None
depends_on = None


def upgrade():
op.execute("""
UPDATE alerts
SET options = jsonb_set(options, '{selector}', '"first"')
WHERE options->>'selector' IS NULL;
""")

def downgrade():
pass

0 comments on commit 47ecd4a

Please sign in to comment.