[Asterisk-code-review] alembic: Fix enum creation for dtls fingerprint (asterisk[13])

Joshua Colp asteriskteam at digium.com
Wed Sep 6 11:23:20 CDT 2017


Joshua Colp has submitted this change and it was merged. ( https://gerrit.asterisk.org/6429 )

Change subject: alembic: Fix enum creation for dtls_fingerprint
......................................................................

alembic: Fix enum creation for dtls_fingerprint

Change-Id: Ic061c5066a146616a68376881c7e4cf6d6e7e7db
---
M contrib/ast-db-manage/config/versions/b83645976fdd_add_dtls_fingerprint_to_ps_endpoints.py
1 file changed, 16 insertions(+), 1 deletion(-)

Approvals:
  Joshua Colp: Looks good to me, but someone else must approve; Approved for Submit
  Kevin Harwell: Looks good to me, approved



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 0efefa2..3d4f74d 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 @@
 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)

-- 
To view, visit https://gerrit.asterisk.org/6429
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: 13
Gerrit-MessageType: merged
Gerrit-Change-Id: Ic061c5066a146616a68376881c7e4cf6d6e7e7db
Gerrit-Change-Number: 6429
Gerrit-PatchSet: 1
Gerrit-Owner: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Jenkins2
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Kevin Harwell <kharwell at digium.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20170906/0b882988/attachment.html>


More information about the asterisk-code-review mailing list