Files
notifications-api/migrations/versions/0103_add_historical_redact.py
Cliff Hill 1157f5639d black, isort, flake8
Signed-off-by: Cliff Hill <Clifford.hill@gsa.gov>
2023-12-08 21:43:52 -05:00

52 lines
1.1 KiB
Python

"""empty message
Revision ID: 0103_add_historical_redact
Revises: db6d9d9f06bc
Create Date: 2017-06-29 12:44:16.815039
"""
# revision identifiers, used by Alembic.
from sqlalchemy import text
revision = "0103_add_historical_redact"
down_revision = "db6d9d9f06bc"
import sqlalchemy as sa
from alembic import op
from flask import current_app
from sqlalchemy.dialects import postgresql
def upgrade():
conn = op.get_bind()
input_params = {"notify_user_id": 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(),
:notify_user_id
FROM
templates
LEFT JOIN template_redacted on template_redacted.template_id = templates.id
WHERE template_redacted.template_id IS NULL
"""
),
input_params,
)
def downgrade():
# data migration, no downloads
pass