Files
notifications-api/migrations/versions/0103_add_historical_redact.py
T

50 lines
1.1 KiB
Python
Raw Normal View History

2017-06-29 12:54:48 +01:00
"""empty message
Revision ID: 0103_add_historical_redact
Revises: db6d9d9f06bc
Create Date: 2017-06-29 12:44:16.815039
"""
# revision identifiers, used by Alembic.
2023-07-18 09:02:40 -07:00
from sqlalchemy import text
2023-08-29 14:54:30 -07:00
revision = "0103_add_historical_redact"
down_revision = "db6d9d9f06bc"
2017-06-29 12:54:48 +01:00
import sqlalchemy as sa
2023-12-08 21:43:52 -05:00
from alembic import op
2017-06-29 12:54:48 +01:00
from flask import current_app
2023-12-08 21:43:52 -05:00
from sqlalchemy.dialects import postgresql
2017-06-29 12:54:48 +01:00
2023-07-18 09:02:40 -07:00
2017-06-29 12:54:48 +01:00
def upgrade():
2023-07-18 09:02:40 -07:00
conn = op.get_bind()
2023-08-29 14:54:30 -07:00
input_params = {"notify_user_id": current_app.config["NOTIFY_USER_ID"]}
2023-07-18 09:02:40 -07:00
conn.execute(
2026-01-27 07:33:54 -08:00
text("""
2017-06-29 12:54:48 +01:00
INSERT INTO template_redacted
(
template_id,
redact_personalisation,
updated_at,
updated_by_id
)
SELECT
templates.id,
false,
now(),
2023-07-18 09:02:40 -07:00
:notify_user_id
2017-06-29 12:54:48 +01:00
FROM
templates
LEFT JOIN template_redacted on template_redacted.template_id = templates.id
WHERE template_redacted.template_id IS NULL
2026-01-27 07:33:54 -08:00
"""),
2023-08-29 14:54:30 -07:00
input_params,
2017-06-29 12:54:48 +01:00
)
def downgrade():
# data migration, no downloads
pass