From 46776c77c475a0b66e3d2998c17ab3f9e3d78b22 Mon Sep 17 00:00:00 2001 From: Mike Bradeen <mbradeen@sangoma.com> Date: Wed, 17 Aug 2022 12:30:21 -0600 Subject: [PATCH] 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 --- ...654b_add_stir_shaken_profile_and_codec_.py | 58 +++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 contrib/ast-db-manage/config/versions/9f3692b1654b_add_stir_shaken_profile_and_codec_.py 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 0000000000..e32c6851a5 --- /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 -- GitLab