mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-02-06 03:13:42 -05:00
109526036: Migration script for new table
This commit is contained in:
42
migrations/versions/40_verify_codes.py
Normal file
42
migrations/versions/40_verify_codes.py
Normal file
@@ -0,0 +1,42 @@
|
||||
"""empty message
|
||||
|
||||
Revision ID: 40_verify_codes
|
||||
Revises: 30_update_indexes
|
||||
Create Date: 2015-12-09 16:39:44.673094
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '40_verify_codes'
|
||||
down_revision = '30_update_indexes'
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
def upgrade():
|
||||
code_type_enum = sa.Enum('email', 'sms', name='verify_code_types')
|
||||
# code_type_enum.create(op.get_bind(), checkfirst=False)
|
||||
|
||||
op.create_table('verify_codes',
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('user_id', sa.Integer(), nullable=False),
|
||||
sa.Column('code', sa.String, nullable=False),
|
||||
sa.Column('code_type', code_type_enum),
|
||||
sa.Column('expiry_datetime', sa.DateTime(), nullable=False),
|
||||
sa.Column('code_used', sa.Boolean(), nullable=True),
|
||||
sa.ForeignKeyConstraint(['user_id'], ['users.id'], ),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.create_index(op.f('ix_verify_codes_user_id'), 'verify_codes', ['user_id'], unique=False)
|
||||
op.drop_constraint('users_name_key', 'users', type_='unique')
|
||||
### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
### commands auto generated by Alembic - please adjust! ###
|
||||
op.create_unique_constraint('users_name_key', 'users', ['name'])
|
||||
op.drop_index(op.f('ix_verify_codes_user_id'), table_name='verify_codes')
|
||||
op.drop_type('verify_code_types')
|
||||
op.drop_table('verify_codes')
|
||||
### end Alembic commands ###
|
||||
Reference in New Issue
Block a user