Files
shopdb-flask/migrations/versions/7d29_supportteam_webhookurl.py
cproudlock fb188fd302 alerts: per-support-team webhook; printedparts routes low-stock to a chosen team
Support teams gain a webhookurl (migration 7d29 + API + settings-page field), so
a team is a notification target. send_webhook(url=) lets a caller override the
site default with a team's webhook. Printedparts gains a 'alert support team'
setting (printedparts_alert_supportteamid) + selector on its settings page;
low-stock alerts post to that team's webhook, falling back to the site
alert_webhook_url. Email leg unchanged. Same pattern extends to other alerting
plugins (printers low-toner next).
2026-07-22 13:32:00 -04:00

42 lines
1.1 KiB
Python

"""Add supportteams.webhookurl (per-team alert webhook)
A support team can carry a Teams (or other) webhook; alerting plugins route
alerts to a team by selecting it. Nullable. Idempotent guard.
Revision ID: 7d29_supportteam_webhookurl
Revises: 7d28_dashboarddefault_displayrole
Create Date: 2026-07-22
"""
from alembic import op
import sqlalchemy as sa
revision = '7d29_supportteam_webhookurl'
down_revision = '7d28_dashboarddefault_displayrole'
branch_labels = None
depends_on = None
def _has_col(insp):
return any(c['name'] == 'webhookurl'
for c in insp.get_columns('supportteams'))
def upgrade():
bind = op.get_bind()
insp = sa.inspect(bind)
if 'supportteams' not in insp.get_table_names():
return
if not _has_col(insp):
op.add_column('supportteams', sa.Column('webhookurl', sa.Text(), nullable=True))
def downgrade():
bind = op.get_bind()
insp = sa.inspect(bind)
if 'supportteams' not in insp.get_table_names():
return
if _has_col(insp):
op.drop_column('supportteams', 'webhookurl')