1 """Add/Update tables for pjsip 3 Revision ID: 2fc7930b41b3 5 Create Date: 2014-01-14 09:23:53.923454 10 revision =
'2fc7930b41b3' 11 down_revision =
'581a4264e537' 13 from alembic
import op
14 from alembic
import context
15 import sqlalchemy
as sa
16 from sqlalchemy.dialects.postgresql
import ENUM
18 YESNO_NAME =
'yesno_values' 19 YESNO_VALUES = [
'yes',
'no']
21 PJSIP_REDIRECT_METHOD_NAME =
'pjsip_redirect_method_values' 22 PJSIP_REDIRECT_METHOD_VALUES = [
'user',
'uri_core',
'uri_pjsip']
24 PJSIP_TRANSPORT_METHOD_NAME =
'pjsip_transport_method_values' 25 PJSIP_TRANSPORT_METHOD_VALUES = [
'default',
'unspecified',
'tlsv1',
'sslv2',
28 PJSIP_TRANSPORT_PROTOCOL_NAME =
'pjsip_transport_protocol_values' 29 PJSIP_TRANSPORT_PROTOCOL_VALUES = [
'udp',
'tcp',
'tls',
'ws',
'wss']
36 yesno_values = ENUM(*YESNO_VALUES, name=YESNO_NAME, create_type=
False)
40 pjsip_redirect_method_values = sa.Enum(
41 *PJSIP_REDIRECT_METHOD_VALUES, name=PJSIP_REDIRECT_METHOD_NAME)
42 check =
False if context.is_offline_mode()
else True 43 pjsip_redirect_method_values.create(op.get_bind(), checkfirst=check)
45 pjsip_transport_method_values = sa.Enum(
46 *PJSIP_TRANSPORT_METHOD_VALUES, name=PJSIP_TRANSPORT_METHOD_NAME)
48 pjsip_transport_protocol_values = sa.Enum(
49 *PJSIP_TRANSPORT_PROTOCOL_VALUES, name=PJSIP_TRANSPORT_PROTOCOL_NAME)
55 sa.Column(
'id', sa.String(40), nullable=
False, unique=
True),
56 sa.Column(
'timer_t1', sa.Integer),
57 sa.Column(
'timer_b', sa.Integer),
58 sa.Column(
'compact_headers', yesno_values),
59 sa.Column(
'threadpool_initial_size', sa.Integer),
60 sa.Column(
'threadpool_auto_increment', sa.Integer),
61 sa.Column(
'threadpool_idle_timeout', sa.Integer),
62 sa.Column(
'threadpool_max_size', sa.Integer),
65 op.create_index(
'ps_systems_id',
'ps_systems', [
'id'])
69 sa.Column(
'id', sa.String(40), nullable=
False, unique=
True),
70 sa.Column(
'max_forwards', sa.Integer),
71 sa.Column(
'user_agent', sa.String(40)),
72 sa.Column(
'default_outbound_endpoint', sa.String(40)),
75 op.create_index(
'ps_globals_id',
'ps_globals', [
'id'])
79 sa.Column(
'id', sa.String(40), nullable=
False, unique=
True),
80 sa.Column(
'async_operations', sa.Integer),
81 sa.Column(
'bind', sa.String(40)),
82 sa.Column(
'ca_list_file', sa.String(200)),
83 sa.Column(
'cert_file', sa.String(200)),
84 sa.Column(
'cipher', sa.String(200)),
85 sa.Column(
'domain', sa.String(40)),
86 sa.Column(
'external_media_address', sa.String(40)),
87 sa.Column(
'external_signaling_address', sa.String(40)),
88 sa.Column(
'external_signaling_port', sa.Integer),
89 sa.Column(
'method', pjsip_transport_method_values),
90 sa.Column(
'local_net', sa.String(40)),
91 sa.Column(
'password', sa.String(40)),
92 sa.Column(
'priv_key_file', sa.String(200)),
93 sa.Column(
'protocol', pjsip_transport_protocol_values),
94 sa.Column(
'require_client_cert', yesno_values),
95 sa.Column(
'verify_client', yesno_values),
96 sa.Column(
'verifiy_server', yesno_values),
97 sa.Column(
'tos', yesno_values),
98 sa.Column(
'cos', yesno_values),
101 op.create_index(
'ps_transports_id',
'ps_transports', [
'id'])
105 sa.Column(
'id', sa.String(40), nullable=
False, unique=
True),
106 sa.Column(
'auth_rejection_permanent', yesno_values),
107 sa.Column(
'client_uri', sa.String(40)),
108 sa.Column(
'contact_user', sa.String(40)),
109 sa.Column(
'expiration', sa.Integer),
110 sa.Column(
'max_retries', sa.Integer),
111 sa.Column(
'outbound_auth', sa.String(40)),
112 sa.Column(
'outbound_proxy', sa.String(40)),
113 sa.Column(
'retry_interval', sa.Integer),
114 sa.Column(
'forbidden_retry_interval', sa.Integer),
115 sa.Column(
'server_uri', sa.String(40)),
116 sa.Column(
'transport', sa.String(40)),
117 sa.Column(
'support_path', yesno_values),
120 op.create_index(
'ps_registrations_id',
'ps_registrations', [
'id'])
124 op.add_column(
'ps_endpoints', sa.Column(
'media_address', sa.String(40)))
125 op.add_column(
'ps_endpoints', sa.Column(
'redirect_method',
126 pjsip_redirect_method_values))
127 op.add_column(
'ps_endpoints', sa.Column(
'set_var', sa.Text()))
130 op.alter_column(
'ps_endpoints',
'mwi_fromuser',
131 new_column_name=
'mwi_from_user', existing_type=sa.String(40))
134 op.add_column(
'ps_contacts', sa.Column(
'outbound_proxy', sa.String(40)))
135 op.add_column(
'ps_contacts', sa.Column(
'path', sa.Text()))
138 op.add_column(
'ps_aors', sa.Column(
'maximum_expiration', sa.Integer))
139 op.add_column(
'ps_aors', sa.Column(
'outbound_proxy', sa.String(40)))
140 op.add_column(
'ps_aors', sa.Column(
'support_path', yesno_values))
145 if op.get_context().bind.dialect.name ==
'mssql':
146 op.drop_constraint(
'ck_ps_aors_support_path_yesno_values',
'ps_aors')
147 op.drop_column(
'ps_aors',
'support_path')
148 op.drop_column(
'ps_aors',
'outbound_proxy')
149 op.drop_column(
'ps_aors',
'maximum_expiration')
151 op.drop_column(
'ps_contacts',
'path')
152 op.drop_column(
'ps_contacts',
'outbound_proxy')
154 op.alter_column(
'ps_endpoints',
'mwi_from_user',
155 new_column_name=
'mwi_fromuser', existing_type=sa.String(40))
157 op.drop_column(
'ps_endpoints',
'set_var')
158 if op.get_context().bind.dialect.name ==
'mssql':
159 op.drop_constraint(
'ck_ps_endpoints_redirect_method_pjsip_redirect_method_values',
'ps_endpoints')
160 op.drop_column(
'ps_endpoints',
'redirect_method')
161 op.drop_column(
'ps_endpoints',
'media_address')
165 op.drop_table(
'ps_registrations')
166 op.drop_table(
'ps_transports')
167 op.drop_table(
'ps_globals')
168 op.drop_table(
'ps_systems')
172 sa.Enum(name=PJSIP_TRANSPORT_PROTOCOL_NAME).drop(
173 op.get_bind(), checkfirst=
False)
174 sa.Enum(name=PJSIP_TRANSPORT_METHOD_NAME).drop(
175 op.get_bind(), checkfirst=
False)
176 sa.Enum(name=PJSIP_REDIRECT_METHOD_NAME).drop(
177 op.get_bind(), checkfirst=
False)