mirror of
https://github.com/GSA/notifications-api.git
synced 2026-08-20 14:29:25 -04:00
Use the notification types enum for the notifications.notification_type.
Reuse EMAIL_TYPE in template_types and notification_types.
This commit is contained in:
@@ -13,10 +13,11 @@ down_revision = '0034_pwd_changed_at_not_null'
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
def upgrade():
|
||||
op.add_column('notifications', sa.Column('notification_type', sa.String(), nullable=True))
|
||||
op.execute('update notifications set notification_type = (select distinct(template_type) '
|
||||
notification_types = sa.Enum('email', 'sms', 'letter', name='notification_type')
|
||||
|
||||
op.add_column('notifications', sa.Column('notification_type', notification_types, nullable=True))
|
||||
op.execute('update notifications set notification_type = (select CAST(CAST(template_type as text) as notification_type) '
|
||||
'from templates where templates.id = notifications.template_id)')
|
||||
op.alter_column('notifications', 'notification_type', nullable=False)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user