diff --git a/superset/migrations/versions/abe27eaf93db_add_extra_config_column_to_alerts.py b/superset/migrations/versions/abe27eaf93db_add_extra_config_column_to_alerts.py new file mode 100644 index 000000000000..c0cce0ac9e65 --- /dev/null +++ b/superset/migrations/versions/abe27eaf93db_add_extra_config_column_to_alerts.py @@ -0,0 +1,50 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +"""add_extra_config_column_to_alerts + +Revision ID: abe27eaf93db +Revises: aea15018d53b +Create Date: 2021-12-02 12:03:20.691171 + +""" + +# revision identifiers, used by Alembic. +revision = "abe27eaf93db" +down_revision = "aea15018d53b" + +import sqlalchemy as sa +from alembic import op +from sqlalchemy import String +from sqlalchemy.sql import column, table + +connection = op.get_bind() + +report_schedule = table("report_schedule", column("extra", String)) + + +def upgrade(): + with op.batch_alter_table("report_schedule") as batch_op: + batch_op.add_column( + sa.Column("extra", sa.Text(), nullable=True, default="{}",), + ) + connection.execute(report_schedule.update().values({"extra": "{}"})) + with op.batch_alter_table("report_schedule") as batch_op: + batch_op.alter_column("extra", existing_type=sa.Text(), nullable=False) + + +def downgrade(): + op.drop_column("report_schedule", "extra") diff --git a/superset/models/alerts.py b/superset/models/alerts.py index 85bad4e16d74..163dcf027de0 100644 --- a/superset/models/alerts.py +++ b/superset/models/alerts.py @@ -126,7 +126,7 @@ def __str__(self) -> str: @property def pretty_config(self) -> str: - """ String representing the comparison that will trigger a validator """ + """String representing the comparison that will trigger a validator""" config = json.loads(self.validator_config) if self.validator_type.lower() == "operator": diff --git a/superset/models/reports.py b/superset/models/reports.py index 6ed769dd4940..a0dc59917a42 100644 --- a/superset/models/reports.py +++ b/superset/models/reports.py @@ -145,6 +145,9 @@ class ReportSchedule(Model, AuditMixinNullable): # (Alerts/Reports) Unlock a possible stalled working state working_timeout = Column(Integer, default=60 * 60 * 1) + # Store the selected dashboard tabs etc. + extra = Column(Text, default="{}") + def __repr__(self) -> str: return str(self.name)