mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-03 01:41:05 -05:00
Set default to 0 for the notification_statistics table.
This commit is contained in:
45
migrations/versions/0042_default_stats_to_zero.py
Normal file
45
migrations/versions/0042_default_stats_to_zero.py
Normal file
@@ -0,0 +1,45 @@
|
||||
"""empty message
|
||||
|
||||
Revision ID: 0042_default_stats_to_zero
|
||||
Revises: 0040_add_reference
|
||||
Create Date: 2016-03-17 11:09:17.906910
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '0042_default_stats_to_zero'
|
||||
down_revision = '0040_add_reference'
|
||||
|
||||
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)
|
||||
op.alter_column('notification_statistics', 'emails_error', server_default=None)
|
||||
op.alter_column('notification_statistics', 'sms_requested', server_default=None)
|
||||
op.alter_column('notification_statistics', 'sms_delivered', server_default=None)
|
||||
op.alter_column('notification_statistics', 'sms_error', server_default=None)
|
||||
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 ###
|
||||
Reference in New Issue
Block a user