Files
notifications-api/migrations/versions/0159_add_historical_redact.py

51 lines
1.1 KiB
Python
Raw Normal View History

"""empty message
Revision ID: 0159_add_historical_redact
Revises: 0158_remove_rate_limit_default
Create Date: 2017-01-17 15:00:00.000000
"""
# revision identifiers, used by Alembic.
2023-07-17 11:29:08 -07:00
from sqlalchemy import text
2023-08-29 14:54:30 -07:00
revision = "0159_add_historical_redact"
down_revision = "0158_remove_rate_limit_default"
import sqlalchemy as sa
from alembic import op
from flask import current_app
from sqlalchemy.dialects import postgresql
2023-07-17 11:29:08 -07:00
def upgrade():
2023-07-17 11:29:08 -07:00
conn = op.get_bind()
2023-08-29 14:54:30 -07:00
input_params = {"notify_user": current_app.config["NOTIFY_USER_ID"]}
conn.execute(
text(
"""
INSERT INTO template_redacted
(
template_id,
redact_personalisation,
updated_at,
updated_by_id
)
SELECT
templates.id,
false,
now(),
2023-07-17 11:29:08 -07:00
:notify_user
FROM
templates
LEFT JOIN template_redacted on template_redacted.template_id = templates.id
WHERE template_redacted.template_id IS NULL
2023-08-29 14:54:30 -07:00
"""
),
input_params,
)
def downgrade():
pass