alembic: Adjust sippeers, queue_members, and voicemail_messages tables.
[asterisk/asterisk.git] / contrib / ast-db-manage / config / versions / 43956d550a44_add_tables_for_pjsip.py
1 """Add tables for pjsip
2
3 Revision ID: 43956d550a44
4 Revises: 4da0c5f79a9c
5 Create Date: 2013-09-30 13:23:59.676690
6
7 """
8
9 # revision identifiers, used by Alembic.
10 revision = '43956d550a44'
11 down_revision = '4da0c5f79a9c'
12
13 from alembic import op
14 import sqlalchemy as sa
15
16
17 YESNO_VALUES = ['yes', 'no']
18 PJSIP_CID_PRIVACY_VALUES = ['allowed_not_screened', 'allowed_passed_screened',
19                             'allowed_failed_screened', 'allowed',
20                             'prohib_not_screened', 'prohib_passed_screened',
21                             'prohib_failed_screened', 'prohib', 'unavailable']
22 PJSIP_100REL_VALUES = ['no', 'required', 'yes']
23 PJSIP_CONNECTED_LINE_METHOD_VALUES = ['invite', 'reinvite', 'update']
24 PJSIP_DIRECT_MEDIA_GLARE_MITIGATION_VALUES = ['none', 'outgoing', 'incoming']
25 PJSIP_DTMF_MODE_VALUES = ['rfc4733', 'inband', 'info']
26 PJSIP_IDENTIFY_BY_VALUES = ['username']
27 PJSIP_TIMERS_VALUES = ['forced', 'no', 'required', 'yes']
28 PJSIP_MEDIA_ENCRYPTION_VALUES = ['no', 'sdes', 'dtls']
29 PJSIP_T38UDPTL_EC_VALUES = ['none', 'fec', 'redundancy']
30 PJSIP_DTLS_SETUP_VALUES = ['active', 'passive', 'actpass']
31 PJSIP_AUTH_TYPE_VALUES = ['md5', 'userpass']
32 PJSIP_TRANSPORT_METHOD_VALUES = ['default', 'unspecified', 'tlsv1', 'sslv2',
33                                  'sslv3', 'sslv23']
34 PJSIP_TRANSPORT_PROTOCOL_VALUES = ['udp', 'tcp', 'tls', 'ws', 'wss']
35
36
37 def upgrade():
38     op.create_table(
39         'ps_endpoints',
40         sa.Column('id', sa.String(40), nullable=False, unique=True),
41         sa.Column('transport', sa.String(40)),
42         sa.Column('aors', sa.String(200)),
43         sa.Column('auth', sa.String(40)),
44         sa.Column('context', sa.String(40)),
45         sa.Column('disallow', sa.String(200)),
46         sa.Column('allow', sa.String(200)),
47         sa.Column('direct_media', sa.Enum(*YESNO_VALUES, name='yesno_values')),
48         sa.Column('connected_line_method',
49                   sa.Enum(*PJSIP_CONNECTED_LINE_METHOD_VALUES, name='pjsip_connected_line_method_values')),
50         sa.Column('direct_media_method',
51                   sa.Enum(*PJSIP_CONNECTED_LINE_METHOD_VALUES, name='pjsip_connected_line_method_values')),
52         sa.Column('direct_media_glare_mitigation',
53                   sa.Enum(*PJSIP_DIRECT_MEDIA_GLARE_MITIGATION_VALUES, name='pjsip_direct_media_glare_mitigation_values')),
54         sa.Column('disable_direct_media_on_nat', sa.Enum(*YESNO_VALUES, name='yesno_values')),
55         sa.Column('dtmf_mode', sa.Enum(*PJSIP_DTMF_MODE_VALUES, name='pjsip_dtmf_mode_values')),
56         sa.Column('external_media_address', sa.String(40)),
57         sa.Column('force_rport', sa.Enum(*YESNO_VALUES, name='yesno_values')),
58         sa.Column('ice_support', sa.Enum(*YESNO_VALUES, name='yesno_values')),
59         sa.Column('identify_by', sa.Enum(*PJSIP_IDENTIFY_BY_VALUES, name='pjsip_identify_by_values')),
60         sa.Column('mailboxes', sa.String(40)),
61         sa.Column('moh_suggest', sa.String(40)),
62         sa.Column('outbound_auth', sa.String(40)),
63         sa.Column('outbound_proxy', sa.String(40)),
64         sa.Column('rewrite_contact', sa.Enum(*YESNO_VALUES, name='yesno_values')),
65         sa.Column('rtp_ipv6', sa.Enum(*YESNO_VALUES, name='yesno_values')),
66         sa.Column('rtp_symmetric', sa.Enum(*YESNO_VALUES, name='yesno_values')),
67         sa.Column('send_diversion', sa.Enum(*YESNO_VALUES, name='yesno_values')),
68         sa.Column('send_pai', sa.Enum(*YESNO_VALUES, name='yesno_values')),
69         sa.Column('send_rpid', sa.Enum(*YESNO_VALUES, name='yesno_values')),
70         sa.Column('timers_min_se', sa.Integer),
71         sa.Column('timers', sa.Enum(*PJSIP_TIMERS_VALUES, name='pjsip_timer_values')),
72         sa.Column('timers_sess_expires', sa.Integer),
73         sa.Column('callerid', sa.String(40)),
74         sa.Column('callerid_privacy', sa.Enum(*PJSIP_CID_PRIVACY_VALUES, name='pjsip_cid_privacy_values')),
75         sa.Column('callerid_tag', sa.String(40)),
76         sa.Column('100rel', sa.Enum(*PJSIP_100REL_VALUES, name='pjsip_100rel_values')),
77         sa.Column('aggregate_mwi', sa.Enum(*YESNO_VALUES, name='yesno_values')),
78         sa.Column('trust_id_inbound', sa.Enum(*YESNO_VALUES, name='yesno_values')),
79         sa.Column('trust_id_outbound', sa.Enum(*YESNO_VALUES, name='yesno_values')),
80         sa.Column('use_ptime', sa.Enum(*YESNO_VALUES, name='yesno_values')),
81         sa.Column('use_avpf', sa.Enum(*YESNO_VALUES, name='yesno_values')),
82         sa.Column('media_encryption', sa.Enum(*PJSIP_MEDIA_ENCRYPTION_VALUES, name='pjsip_media_encryption_values')),
83         sa.Column('inband_progress', sa.Enum(*YESNO_VALUES, name='yesno_values')),
84         sa.Column('call_group', sa.String(40)),
85         sa.Column('pickup_group', sa.String(40)),
86         sa.Column('named_call_group', sa.String(40)),
87         sa.Column('named_pickup_group', sa.String(40)),
88         sa.Column('device_state_busy_at', sa.Integer),
89         sa.Column('fax_detect', sa.Enum(*YESNO_VALUES, name='yesno_values')),
90         sa.Column('t38_udptl', sa.Enum(*YESNO_VALUES, name='yesno_values')),
91         sa.Column('t38_udptl_ec', sa.Enum(*PJSIP_T38UDPTL_EC_VALUES, name='pjsip_t38udptl_ec_values')),
92         sa.Column('t38_udptl_maxdatagram', sa.Integer),
93         sa.Column('t38_udptl_nat', sa.Enum(*YESNO_VALUES, name='yesno_values')),
94         sa.Column('t38_udptl_ipv6', sa.Enum(*YESNO_VALUES, name='yesno_values')),
95         sa.Column('tone_zone', sa.String(40)),
96         sa.Column('language', sa.String(40)),
97         sa.Column('one_touch_recording', sa.Enum(*YESNO_VALUES, name='yesno_values')),
98         sa.Column('record_on_feature', sa.String(40)),
99         sa.Column('record_off_feature', sa.String(40)),
100         sa.Column('rtp_engine', sa.String(40)),
101         sa.Column('allow_transfer', sa.Enum(*YESNO_VALUES, name='yesno_values')),
102         sa.Column('allow_subscribe', sa.Enum(*YESNO_VALUES, name='yesno_values')),
103         sa.Column('sdp_owner', sa.String(40)),
104         sa.Column('sdp_session', sa.String(40)),
105         sa.Column('tos_audio', sa.Integer),
106         sa.Column('tos_video', sa.Integer),
107         sa.Column('cos_audio', sa.Integer),
108         sa.Column('cos_video', sa.Integer),
109         sa.Column('sub_min_expiry', sa.Integer),
110         sa.Column('from_domain', sa.String(40)),
111         sa.Column('from_user', sa.String(40)),
112         sa.Column('mwi_fromuser', sa.String(40)),
113         sa.Column('dtls_verify', sa.String(40)),
114         sa.Column('dtls_rekey', sa.String(40)),
115         sa.Column('dtls_cert_file', sa.String(200)),
116         sa.Column('dtls_private_key', sa.String(200)),
117         sa.Column('dtls_cipher', sa.String(200)),
118         sa.Column('dtls_ca_file', sa.String(200)),
119         sa.Column('dtls_ca_path', sa.String(200)),
120         sa.Column('dtls_setup', sa.Enum(*PJSIP_DTLS_SETUP_VALUES, name='pjsip_dtls_setup_values')),
121         sa.Column('srtp_tag_32', sa.Enum(*YESNO_VALUES, name='yesno_values')),
122     )
123
124     op.create_index('ps_endpoints_id', 'ps_endpoints', ['id'])
125
126     op.create_table(
127         'ps_auths',
128         sa.Column('id', sa.String(40), nullable=False, unique=True),
129         sa.Column('auth_type', sa.Enum(*PJSIP_AUTH_TYPE_VALUES, name='pjsip_auth_type_values')),
130         sa.Column('nonce_lifetime', sa.Integer),
131         sa.Column('md5_cred', sa.String(40)),
132         sa.Column('password', sa.String(80)),
133         sa.Column('realm', sa.String(40)),
134         sa.Column('username', sa.String(40)),
135     )
136
137     op.create_index('ps_auths_id', 'ps_auths', ['id'])
138
139     op.create_table(
140         'ps_aors',
141         sa.Column('id', sa.String(40), nullable=False, unique=True),
142         sa.Column('contact', sa.String(40)),
143         sa.Column('default_expiration', sa.Integer),
144         sa.Column('mailboxes', sa.String(80)),
145         sa.Column('max_contacts', sa.Integer),
146         sa.Column('minimum_expiration', sa.Integer),
147         sa.Column('remove_existing', sa.Enum(*YESNO_VALUES, name='yesno_values')),
148         sa.Column('qualify_frequency', sa.Integer),
149         sa.Column('authenticate_qualify', sa.Enum(*YESNO_VALUES, name='yesno_values')),
150     )
151
152     op.create_index('ps_aors_id', 'ps_aors', ['id'])
153
154     op.create_table(
155         'ps_contacts',
156         sa.Column('id', sa.String(40), nullable=False, unique=True),
157         sa.Column('uri', sa.String(40)),
158         sa.Column('expiration_time', sa.String(40)),
159         sa.Column('qualify_frequency', sa.Integer),
160     )
161
162     op.create_index('ps_contacts_id', 'ps_contacts', ['id'])
163
164     op.create_table(
165         'ps_domain_aliases',
166         sa.Column('id', sa.String(40), nullable=False, unique=True),
167         sa.Column('domain', sa.String(80)),
168     )
169
170     op.create_index('ps_domain_aliases_id', 'ps_domain_aliases', ['id'])
171
172     op.create_table(
173         'ps_endpoint_id_ips',
174         sa.Column('id', sa.String(40), nullable=False, unique=True),
175         sa.Column('endpoint', sa.String(40)),
176         sa.Column('match', sa.String(80)),
177     )
178
179     op.create_index('ps_endpoint_id_ips_id',
180                     'ps_endpoint_id_ips', ['id'])
181
182
183 def downgrade():
184     op.drop_table('ps_endpoints')
185     op.drop_table('ps_auths')
186     op.drop_table('ps_aors')
187     op.drop_table('ps_contacts')
188     op.drop_table('ps_domain_aliases')
189     op.drop_table('ps_endpoint_id_ips')