Asterisk - The Open Source Telephony Project  18.5.0
0be05c3a8225_add_early_media_options.py
Go to the documentation of this file.
1 """Add early media options
2 
3 Revision ID: 0be05c3a8225
4 Revises: d3e4284f8707
5 Create Date: 2018-06-18 17:26:16.737692
6 
7 """
8 
9 # revision identifiers, used by Alembic.
10 revision = '0be05c3a8225'
11 down_revision = 'd3e4284f8707'
12 
13 from alembic import op
14 import sqlalchemy as sa
15 from sqlalchemy.dialects.postgresql import ENUM
16 
17 YESNO_NAME = 'yesno_values'
18 YESNO_VALUES = ['yes', 'no']
19 
20 def upgrade():
21  yesno_values = ENUM(*YESNO_VALUES, name=YESNO_NAME, create_type=False)
22 
23  op.add_column('ps_systems', sa.Column('follow_early_media_fork', yesno_values))
24  op.add_column('ps_systems', sa.Column('accept_multiple_sdp_answers', yesno_values))
25  op.add_column('ps_endpoints', sa.Column('follow_early_media_fork', yesno_values))
26  op.add_column('ps_endpoints', sa.Column('accept_multiple_sdp_answers', yesno_values))
27 
28 def downgrade():
29  if op.get_context().bind.dialect.name == 'mssql':
30  op.drop_constraint('ck_ps_systems_follow_early_media_fork_yesno_values','ps_systems')
31  op.drop_constraint('ck_ps_systems_accept_multiple_sdp_answers_yesno_values','ps_systems')
32  op.drop_constraint('ck_ps_endpoints_follow_early_media_fork_yesno_values','ps_endpoints')
33  op.drop_constraint('ck_ps_endpoints_accept_multiple_sdp_answers_yesno_values','ps_endpoints')
34  op.drop_column('ps_systems', 'follow_early_media_fork')
35  op.drop_column('ps_systems', 'accept_multiple_sdp_answers')
36  op.drop_column('ps_endpoints', 'follow_early_media_fork')
37  op.drop_column('ps_endpoints', 'accept_multiple_sdp_answers')