[Asterisk-code-review] alembic: add auth username to endpoint's identify by enum (asterisk[13])

Anonymous Coward asteriskteam at digium.com
Fri Aug 12 01:27:31 CDT 2016


Anonymous Coward #1000019 has submitted this change and it was merged.

Change subject: alembic: add auth_username to endpoint's identify_by enum
......................................................................


alembic: add auth_username to endpoint's identify_by enum

A new identify_by option was added recently, auth_username. However, this
setting was not added as an allowable choice in the database enumeration
value.

This patch updates the current enumeration, adding in the new setting.

ASTERISK-26268 #close

Change-Id: Ib4788e8485e4cd40172ec0abbf5810a147ab8bf8
---
A contrib/ast-db-manage/config/versions/3772f8f828da_update_identify_by.py
1 file changed, 44 insertions(+), 0 deletions(-)

Approvals:
  Mark Michelson: Looks good to me, but someone else must approve
  George Joseph: Looks good to me, approved
  Anonymous Coward #1000019: Verified



diff --git a/contrib/ast-db-manage/config/versions/3772f8f828da_update_identify_by.py b/contrib/ast-db-manage/config/versions/3772f8f828da_update_identify_by.py
new file mode 100644
index 0000000..92695b0
--- /dev/null
+++ b/contrib/ast-db-manage/config/versions/3772f8f828da_update_identify_by.py
@@ -0,0 +1,44 @@
+"""update_identify_by
+
+Revision ID: 3772f8f828da
+Revises: c7a44a5a0851
+Create Date: 2016-08-11 10:47:29.211063
+
+"""
+
+# revision identifiers, used by Alembic.
+revision = '3772f8f828da'
+down_revision = 'c7a44a5a0851'
+
+from alembic import op
+import sqlalchemy as sa
+
+
+def enum_update(table_name, column_name, enum_name, enum_values):
+    if op.get_context().bind.dialect.name != 'postgresql':
+        op.alter_column(table_name, column_name,
+                        type_=sa.Enum(*enum_values, name=enum_name))
+        return
+
+    # Postgres requires a few more steps
+    tmp = enum_name + '_tmp'
+
+    op.execute('ALTER TYPE ' + enum_name + ' RENAME TO ' + tmp)
+
+    updated = sa.Enum(*enum_values, name=enum_name)
+    updated.create(op.get_bind(), checkfirst=False)
+
+    op.execute('ALTER TABLE ' + table_name + ' ALTER COLUMN ' + column_name +
+               ' TYPE ' + enum_name + ' USING identify_by::text::' + enum_name)
+
+    op.execute('DROP TYPE ' + tmp)
+
+
+def upgrade():
+    enum_update('ps_endpoints', 'identify_by', 'pjsip_identify_by_values',
+                ['username', 'auth_username'])
+
+
+def downgrade():
+    enum_update('ps_endpoints', 'identify_by', 'pjsip_identify_by_values',
+                ['username'])

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Ib4788e8485e4cd40172ec0abbf5810a147ab8bf8
Gerrit-PatchSet: 1
Gerrit-Project: asterisk
Gerrit-Branch: 13
Gerrit-Owner: Kevin Harwell <kharwell at digium.com>
Gerrit-Reviewer: Anonymous Coward #1000019
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Mark Michelson <mmichelson at digium.com>



More information about the asterisk-code-review mailing list