mirror of
https://github.com/GSA/notifications-api.git
synced 2026-09-11 10:28:55 -04:00
code review feedback
This commit is contained in:
@@ -7,6 +7,7 @@ Create Date: 2021-02-18 15:25:30.667098
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy import text
|
||||
from sqlalchemy.dialects import postgresql
|
||||
|
||||
revision = '0348_migrate_broadcast_settings'
|
||||
@@ -36,15 +37,20 @@ def upgrade():
|
||||
for service in services:
|
||||
input_params = {"service_id": service.id}
|
||||
setting = conn.execute(
|
||||
"SELECT service_id, channel, provider FROM service_broadcast_settings WHERE service_id=:service_id;",
|
||||
text("SELECT service_id, channel, provider FROM service_broadcast_settings WHERE service_id=:service_id;"),
|
||||
input_params).first()
|
||||
if setting:
|
||||
print(f"Service {service.id} already has service_broadcast_settings. No action required")
|
||||
else:
|
||||
channel = "severe" if service.restricted else "test"
|
||||
print(f"Service {service.id} does not have service_broadcast_settings. Will insert one with channel {channel}")
|
||||
conn.execute("INSERT INTO service_broadcast_settings (service_id, channel, created_at) VALUES (%s, %s, now());",
|
||||
{service.id, channel})
|
||||
input_params = {
|
||||
"service_id": service.id,
|
||||
"channel": channel
|
||||
}
|
||||
conn.execute(text("INSERT INTO service_broadcast_settings (service_id, channel, created_at) "
|
||||
"VALUES (:service_id, :channel, now());"),
|
||||
input_params)
|
||||
|
||||
|
||||
def downgrade():
|
||||
|
||||
Reference in New Issue
Block a user