Merge "alembic: Fix enum creation for dtls_fingerprint"

This commit is contained in:
George Joseph 2017-09-06 11:52:26 -05:00 committed by Gerrit Code Review
commit 2857a3334a
1 changed files with 16 additions and 1 deletions

View File

@ -14,10 +14,25 @@ from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects.postgresql import ENUM
SHA_HASH_NAME = 'sha_hash_values'
SHA_HASH_VALUES = ['SHA-1', 'SHA-256']
def upgrade():
op.add_column('ps_endpoints', sa.Column('dtls_fingerprint', sa.Enum(*SHA_HASH_VALUES, name='sha_hash_values')))
context = op.get_context()
if context.bind.dialect.name == 'postgresql':
enum = ENUM(*SHA_HASH_VALUES, name=SHA_HASH_NAME)
enum.create(op.get_bind(), checkfirst=False)
op.add_column('ps_endpoints',
sa.Column('dtls_fingerprint', ENUM(*SHA_HASH_VALUES,
name=SHA_HASH_NAME, create_type=False)))
def downgrade():
context = op.get_context()
op.drop_column('ps_endpoints', 'dtls_fingerprint')
if context.bind.dialect.name == 'postgresql':
enum = ENUM(*SHA_HASH_VALUES, name=SHA_HASH_NAME)
enum.drop(op.get_bind(), checkfirst=False)