Add notification_type to notification table.

It seems like an oversight not to include the notification type in the notifcation.
When updating statistics a query to the template table is required to get the type, this update will mean that query does not have to happen.
This commit is contained in:
Rebecca Law
2016-06-29 11:23:02 +01:00
parent 340abae82c
commit 60e159e3c0
6 changed files with 35 additions and 3 deletions

View File

@@ -0,0 +1,26 @@
"""empty message
Revision ID: 0035_notification_type
Revises: 0034_pwd_changed_at_not_null
Create Date: 2016-06-29 10:48:55.955317
"""
# revision identifiers, used by Alembic.
revision = '0035_notification_type'
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) '
'from templates where templates.id = notifications.template_id)')
op.alter_column('notifications', 'notification_type', nullable=False)
def downgrade():
### commands auto generated by Alembic - please adjust! ###
op.drop_column('notifications', 'notification_type')
### end Alembic commands ###