Skip to content
Snippets Groups Projects
Commit 1e58b936 authored by Rajmund Hruška's avatar Rajmund Hruška
Browse files

Fix: Add not null constraint to emails_medium, emails_high and...

Fix: Add not null constraint to emails_medium, emails_high and emails_critical. (Redmine issue: #6227)
parent 096f4612
No related branches found
No related tags found
No related merge requests found
"""Add not null constraint to emails_medium, emails_high and emails_critical
Revision ID: 878a5655f9a8
Revises: c91b23f77fc1
Create Date: 2022-01-21 23:33:37.117842
"""
from alembic import op
# revision identifiers, used by Alembic.
revision = '878a5655f9a8'
down_revision = 'c91b23f77fc1'
branch_labels = None
depends_on = None
def upgrade():
op.execute(
"UPDATE settings_reporting SET emails_medium = ARRAY[]::varchar[] WHERE emails_medium IS NULL"
)
op.execute(
"ALTER TABLE settings_reporting ALTER COLUMN emails_medium SET NOT NULL"
)
op.execute(
"UPDATE settings_reporting SET emails_high = ARRAY[]::varchar[] WHERE emails_high IS NULL"
)
op.execute(
"ALTER TABLE settings_reporting ALTER COLUMN emails_high SET NOT NULL"
)
op.execute(
"UPDATE settings_reporting SET emails_critical = ARRAY[]::varchar[] WHERE emails_critical IS NULL"
)
op.execute(
"ALTER TABLE settings_reporting ALTER COLUMN emails_critical SET NOT NULL"
)
def downgrade():
op.execute(
"ALTER TABLE settings_reporting ALTER COLUMN emails_medium DROP NOT NULL"
)
op.execute(
"ALTER TABLE settings_reporting ALTER COLUMN emails_high DROP NOT NULL"
)
op.execute(
"ALTER TABLE settings_reporting ALTER COLUMN emails_critical DROP NOT NULL"
)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment