Asterisk - The Open Source Telephony Project GIT-master-f36a736
164abbd708c_add_auto_info_to_endpoint_dtmf_mode.py
Go to the documentation of this file.
1"""Add auto_info to endpoint dtmf_mode
2
3Revision ID: 164abbd708c
4Revises: 39959b9c2566
5Create Date: 2017-06-19 13:55:15.354706
6
7"""
8
9# revision identifiers, used by Alembic.
10revision = '164abbd708c'
11down_revision = '39959b9c2566'
12
13from alembic import op
14import sqlalchemy as sa
15from sqlalchemy.dialects.postgresql import ENUM
16
17OLD_ENUM = ['rfc4733', 'inband', 'info', 'auto']
18NEW_ENUM = ['rfc4733', 'inband', 'info', 'auto', 'auto_info']
19
20old_type = sa.Enum(*OLD_ENUM, name='pjsip_dtmf_mode_values_v2')
21new_type = sa.Enum(*NEW_ENUM, name='pjsip_dtmf_mode_values_v3')
22
23def upgrade():
24 context = op.get_context()
25
26 # Upgrading to this revision WILL clear your directmedia values.
27 if context.bind.dialect.name != 'postgresql':
28 op.alter_column('ps_endpoints', 'dtmf_mode',
29 type_=new_type,
30 existing_type=old_type)
31 else:
32 enum = ENUM('rfc4733', 'inband', 'info', 'auto', 'auto_info',
33 name='pjsip_dtmf_mode_values_v3')
34 enum.create(op.get_bind(), checkfirst=False)
35
36 op.execute('ALTER TABLE ps_endpoints ALTER COLUMN dtmf_mode TYPE'
37 ' pjsip_dtmf_mode_values_v3 USING'
38 ' dtmf_mode::text::pjsip_dtmf_mode_values_v3')
39
40 ENUM(name="pjsip_dtmf_mode_values_v2").drop(op.get_bind(), checkfirst=False)
41
43 context = op.get_context()
44
45 if context.bind.dialect.name != 'postgresql':
46 op.alter_column('ps_endpoints', 'dtmf_mode',
47 type_=old_type,
48 existing_type=new_type)
49 else:
50 enum = ENUM('rfc4733', 'inband', 'info', 'auto',
51 name='pjsip_dtmf_mode_values_v2')
52 enum.create(op.get_bind(), checkfirst=False)
53
54 op.execute('ALTER TABLE ps_endpoints ALTER COLUMN dtmf_mode TYPE'
55 ' pjsip_dtmf_mode_values_v2 USING'
56 ' dtmf_mode::text::pjsip_dtmf_mode_values_v2')
57
58 ENUM(name="pjsip_dtmf_mode_values_v3").drop(op.get_bind(), checkfirst=False)