mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-01 15:46:07 -05:00
add new notification_status_types static table
enums are hard to develop with - it is a slow and unchunkable change to add a new type or remove an old type. We're slowly moving away from using enums, in favour of static type tables, where the name is the primary key. This commit contains an alembic script that creates that table, and creates a new nullable column on notifications and notification_history that refer to it.
This commit is contained in:
33
migrations/versions/0081_noti_status_as_enum.py
Normal file
33
migrations/versions/0081_noti_status_as_enum.py
Normal file
@@ -0,0 +1,33 @@
|
||||
"""empty message
|
||||
|
||||
Revision ID: 0081_noti_status_as_enum
|
||||
Revises: 0080_fix_rate_start_date
|
||||
Create Date: 2017-05-02 14:50:04.070874
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '0081_noti_status_as_enum'
|
||||
down_revision = '0080_fix_rate_start_date'
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
def upgrade():
|
||||
op.create_table('notification_status',
|
||||
sa.Column('name', sa.String(), nullable=False),
|
||||
sa.PrimaryKeyConstraint('name')
|
||||
)
|
||||
|
||||
op.execute('ALTER TABLE notifications ADD COLUMN notification_status text')
|
||||
op.execute('ALTER TABLE notification_history ADD COLUMN notification_status text')
|
||||
|
||||
op.create_index(op.f('ix_notifications_notification_status'), 'notifications', ['notification_status'])
|
||||
op.create_index(op.f('ix_notification_history_notification_status'), 'notification_history', ['notification_status'])
|
||||
|
||||
|
||||
def downgrade():
|
||||
op.execute('ALTER TABLE notifications DROP COLUMN notification_status')
|
||||
op.execute('ALTER TABLE notification_history DROP COLUMN notification_status')
|
||||
op.execute('DROP TABLE notification_status')
|
||||
Reference in New Issue
Block a user