mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-05 02:41:14 -05:00
Add new notification status types for technical_failure, temporary_failure, permanent_failure
This commit is contained in:
@@ -304,7 +304,8 @@ class VerifyCode(db.Model):
|
|||||||
return check_hash(cde, self._code)
|
return check_hash(cde, self._code)
|
||||||
|
|
||||||
|
|
||||||
NOTIFICATION_STATUS_TYPES = ['sending', 'delivered', 'failed']
|
NOTIFICATION_STATUS_TYPES = ['sending', 'delivered', 'failed',
|
||||||
|
'technical_failure', 'temporary_failure', 'permanent_failure']
|
||||||
|
|
||||||
|
|
||||||
class Notification(db.Model):
|
class Notification(db.Model):
|
||||||
@@ -339,7 +340,7 @@ class Notification(db.Model):
|
|||||||
nullable=True,
|
nullable=True,
|
||||||
onupdate=datetime.datetime.utcnow)
|
onupdate=datetime.datetime.utcnow)
|
||||||
status = db.Column(
|
status = db.Column(
|
||||||
db.Enum(*NOTIFICATION_STATUS_TYPES, name='notification_status_types'), nullable=False, default='sending')
|
db.Enum(*NOTIFICATION_STATUS_TYPES, name='notification_status_type'), nullable=False, default='sending')
|
||||||
reference = db.Column(db.String, nullable=True, index=True)
|
reference = db.Column(db.String, nullable=True, index=True)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
47
migrations/versions/0017_add_failure_types.py
Normal file
47
migrations/versions/0017_add_failure_types.py
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
"""empty message
|
||||||
|
|
||||||
|
Revision ID: 0017_add_failure_types
|
||||||
|
Revises: 0015_fix_template_data
|
||||||
|
Create Date: 2016-05-17 11:23:36.881219
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
# revision identifiers, used by Alembic.
|
||||||
|
revision = '0017_add_failure_types'
|
||||||
|
down_revision = '0015_fix_template_data'
|
||||||
|
|
||||||
|
from alembic import op
|
||||||
|
import sqlalchemy as sa
|
||||||
|
|
||||||
|
|
||||||
|
from alembic import op
|
||||||
|
import sqlalchemy as sa
|
||||||
|
from sqlalchemy.dialects import postgresql
|
||||||
|
|
||||||
|
def upgrade():
|
||||||
|
status_type = sa.Enum('sending', 'delivered', 'failed',
|
||||||
|
'technical_failure', 'temporary_failure', 'permanent_failure',
|
||||||
|
name='notification_status_type')
|
||||||
|
status_type.create(op.get_bind())
|
||||||
|
op.add_column('notifications', sa.Column('new_status', status_type, nullable=True))
|
||||||
|
op.execute('update notifications set new_status = CAST(CAST(status as text) as notification_status_type)')
|
||||||
|
op.alter_column('notifications', 'status', new_column_name='old_status')
|
||||||
|
op.alter_column('notifications', 'new_status', new_column_name='status')
|
||||||
|
op.drop_column('notifications', 'old_status')
|
||||||
|
op.get_bind()
|
||||||
|
op.execute('DROP TYPE notification_status_types')
|
||||||
|
op.alter_column('notifications', 'status', nullable=False)
|
||||||
|
|
||||||
|
|
||||||
|
def downgrade():
|
||||||
|
status_type = sa.Enum('sending', 'delivered', 'failed',
|
||||||
|
name='notification_status_types')
|
||||||
|
status_type.create(op.get_bind())
|
||||||
|
op.add_column('notifications', sa.Column('old_status', status_type, nullable=True))
|
||||||
|
op.execute('update notifications set old_status = CAST(CAST(status as text) as notification_status_types)')
|
||||||
|
op.alter_column('notifications', 'status', new_column_name='new_status')
|
||||||
|
op.alter_column('notifications', 'old_status', new_column_name='status')
|
||||||
|
op.drop_column('notifications', 'new_status')
|
||||||
|
op.get_bind()
|
||||||
|
op.execute('DROP TYPE notification_status_type')
|
||||||
|
op.alter_column('notifications', 'status', nullable=False)
|
||||||
Reference in New Issue
Block a user