summaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
authorGeorge Joseph <gjoseph@digium.com>2017-09-06 11:52:26 -0500
committerGerrit Code Review <gerrit2@gerrit.digium.api>2017-09-06 11:52:26 -0500
commit2857a3334aa430b81baac31bdfe0efb3871f37d4 (patch)
tree1e5667e2b602901ee8adb7c5098737e37cb7761a /contrib
parent6c89ffad2aa63636abb284265fecbbb3a7debbd9 (diff)
parent0cbb17ce8f5c6afa7ac63e3b468ae40388d98b72 (diff)
Merge "alembic: Fix enum creation for dtls_fingerprint"
Diffstat (limited to 'contrib')
-rw-r--r--contrib/ast-db-manage/config/versions/b83645976fdd_add_dtls_fingerprint_to_ps_endpoints.py17
1 files changed, 16 insertions, 1 deletions
diff --git a/contrib/ast-db-manage/config/versions/b83645976fdd_add_dtls_fingerprint_to_ps_endpoints.py b/contrib/ast-db-manage/config/versions/b83645976fdd_add_dtls_fingerprint_to_ps_endpoints.py
index 0efefa2fd..3d4f74de5 100644
--- a/contrib/ast-db-manage/config/versions/b83645976fdd_add_dtls_fingerprint_to_ps_endpoints.py
+++ b/contrib/ast-db-manage/config/versions/b83645976fdd_add_dtls_fingerprint_to_ps_endpoints.py
@@ -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)