[Asterisk-code-review] alembic: add missing ps_endpoints columns (asterisk[master])

Michael Bradeen asteriskteam at digium.com
Mon Aug 29 14:21:32 CDT 2022


Michael Bradeen has uploaded this change for review. ( https://gerrit.asterisk.org/c/asterisk/+/19002 )


Change subject: alembic: add missing ps_endpoints columns
......................................................................

alembic: add missing ps_endpoints columns

The following required columns were missing,
now added to the ps_endpoints table:

incoming_call_offer_pref
outgoing_call_offer_pref
stir_shaken_profile

ASTERISK-29453

Change-Id: I5cf565edf30195844d6acbc1e1de8c5f0d837568
---
A contrib/ast-db-manage/config/versions/9f3692b1654b_add_stir_shaken_profile_and_codec_.py
1 file changed, 58 insertions(+), 0 deletions(-)



  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/02/19002/1

diff --git a/contrib/ast-db-manage/config/versions/9f3692b1654b_add_stir_shaken_profile_and_codec_.py b/contrib/ast-db-manage/config/versions/9f3692b1654b_add_stir_shaken_profile_and_codec_.py
new file mode 100644
index 0000000..e32c6851
--- /dev/null
+++ b/contrib/ast-db-manage/config/versions/9f3692b1654b_add_stir_shaken_profile_and_codec_.py
@@ -0,0 +1,58 @@
+"""Add Stir Shaken Profile and Codec Preference to ps endpoint
+
+Revision ID: 9f3692b1654b
+Revises: 7197536bb68d
+Create Date: 2022-08-17 11:20:56.433088
+
+"""
+
+# revision identifiers, used by Alembic.
+revision = '9f3692b1654b'
+down_revision = '7197536bb68d'
+
+from alembic import op
+import sqlalchemy as sa
+from sqlalchemy.dialects.postgresql import ENUM
+
+PJSIP_INCOMING_CALL_OFFER_PREF_NAME ='pjsip_incoming_call_offer_pref_values'
+PJSIP_INCOMING_CALL_OFFER_PREF_VALUES = ['local', 'local_first',
+                                         'remote', 'remote_first']
+
+PJSIP_OUTGOING_CALL_OFFER_PREF_NAME = 'pjsip_outgoing_call_offer_pref_values'
+PJSIP_OUTGOING_CALL_OFFER_PREF_VALUES = ['local', 'local_merge', 'local_first',
+                                         'remote', 'remote_merge', 'remote_first']
+
+def upgrade():
+    context = op.get_context()
+
+    if context.bind.dialect.name == 'postgresql':
+        enum_in = ENUM(*PJSIP_INCOMING_CALL_OFFER_PREF_VALUES, name=PJSIP_INCOMING_CALL_OFFER_PREF_NAME)
+        enum_out = ENUM(*PJSIP_OUTGOING_CALL_OFFER_PREF_VALUES, name=PJSIP_OUTGOING_CALL_OFFER_PREF_NAME)
+
+        enum_in.create(op.get_bind(), checkfirst=False)
+        enum_out.create(op.get_bind(), checkfirst=False)
+
+    op.add_column('ps_endpoints', sa.Column('incoming_call_offer_pref',
+            sa.Enum(*PJSIP_INCOMING_CALL_OFFER_PREF_VALUES, name=PJSIP_INCOMING_CALL_OFFER_PREF_NAME)))
+
+    op.add_column('ps_endpoints', sa.Column('outgoing_call_offer_pref',
+            sa.Enum(*PJSIP_OUTGOING_CALL_OFFER_PREF_VALUES, name=PJSIP_OUTGOING_CALL_OFFER_PREF_NAME)))
+
+    op.add_column('ps_endpoints', sa.Column('stir_shaken_profile', sa.String(80)))
+
+def downgrade():
+    context = op.get_context()
+
+    if context.bind.dialect.name == 'mssql':
+        op.drop_constraint('ck_ps_endpoints_incoming_call_offer_pref_pjsip_incoming_call_offer_pref_values', 'ps_endpoints')
+        op.drop_constraint('ck_ps_endpoints_outgoing_call_offer_pref_pjsip_outgoing_call_offer_pref_values', 'ps_endpoints')
+
+    op.drop_column('ps_endpoints', 'outgoing_call_offer_pref')
+    op.drop_column('ps_endpoints', 'incoming_call_offer_pref')
+    op.drop_column('ps_endpoints', 'stir_shaken_profile')
+
+    enums = [PJSIP_INCOMING_CALL_OFFER_PREF_NAME, PJSIP_OUTGOING_CALL_OFFER_PREF_NAME]
+
+    if context.bind.dialect.name == 'postgresql':
+        for e in enums:
+            ENUM(name=e).drop(op.get_bind(), checkfirst=False)
\ No newline at end of file

-- 
To view, visit https://gerrit.asterisk.org/c/asterisk/+/19002
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Change-Id: I5cf565edf30195844d6acbc1e1de8c5f0d837568
Gerrit-Change-Number: 19002
Gerrit-PatchSet: 1
Gerrit-Owner: Michael Bradeen <mbradeen at sangoma.com>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20220829/2ab931db/attachment.html>


More information about the asterisk-code-review mailing list