mirror of
https://github.com/GSA/notifications-api.git
synced 2026-01-15 07:01:20 -05:00
46 lines
2.4 KiB
Python
46 lines
2.4 KiB
Python
"""empty message
|
|
|
|
Revision ID: 0042_default_stats_to_zero
|
|
Revises: 0041_platform_admin
|
|
Create Date: 2016-03-17 11:09:17.906910
|
|
|
|
"""
|
|
|
|
# revision identifiers, used by Alembic.
|
|
revision = '0042_default_stats_to_zero'
|
|
down_revision = '0041_platform_admin'
|
|
|
|
from alembic import op
|
|
import sqlalchemy as sa
|
|
|
|
|
|
def upgrade():
|
|
### commands auto generated by Alembic - please adjust! ###
|
|
op.get_bind()
|
|
op.execute('update notification_statistics set emails_delivered = 0 where emails_delivered is Null')
|
|
op.execute('update notification_statistics set emails_error = 0 where emails_error is Null')
|
|
op.execute('update notification_statistics set sms_delivered = 0 where sms_delivered is Null')
|
|
op.execute('update notification_statistics set sms_error = 0 where sms_error is Null')
|
|
op.alter_column('notification_statistics', 'emails_requested', server_default='0')
|
|
op.alter_column('notification_statistics', 'emails_delivered', server_default='0', nullable=False)
|
|
op.alter_column('notification_statistics', 'emails_error', server_default='0', nullable=False)
|
|
op.alter_column('notification_statistics', 'sms_requested', server_default='0')
|
|
op.alter_column('notification_statistics', 'sms_delivered', server_default='0', nullable=False)
|
|
op.alter_column('notification_statistics', 'sms_error', server_default='0', nullable=False)
|
|
### end Alembic commands ###
|
|
|
|
|
|
def downgrade():
|
|
### commands auto generated by Alembic - please adjust! ###
|
|
op.alter_column('notification_statistics', 'emails_requested', server_default=None)
|
|
op.alter_column('notification_statistics', 'emails_delivered', server_default=None, nullable=True)
|
|
op.alter_column('notification_statistics', 'emails_error', server_default=None, nullable=True)
|
|
op.alter_column('notification_statistics', 'sms_requested', server_default=None)
|
|
op.alter_column('notification_statistics', 'sms_delivered', server_default=None, nullable=True)
|
|
op.alter_column('notification_statistics', 'sms_error', server_default=None, nullable=True)
|
|
op.execute('update notification_statistics set emails_delivered = Null where emails_delivered = 0')
|
|
op.execute('update notification_statistics set emails_error = Null where emails_error = 0')
|
|
op.execute('update notification_statistics set sms_delivered = Null where sms_delivered = 0')
|
|
op.execute('update notification_statistics set sms_error = Null where sms_error = 0')
|
|
### end Alembic commands ###
|