]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
alembic: add missing ps_endpoints columns
authorMike Bradeen <mbradeen@sangoma.com>
Wed, 17 Aug 2022 18:30:21 +0000 (12:30 -0600)
committerFriendly Automation <jenkins2@gerrit.asterisk.org>
Fri, 9 Sep 2022 16:34:48 +0000 (11:34 -0500)
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

contrib/ast-db-manage/config/versions/9f3692b1654b_add_stir_shaken_profile_and_codec_.py [new file with mode: 0644]

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 (file)
index 0000000..e32c685
--- /dev/null
@@ -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