1"""add pjsip google voice sip options
3Revision ID: 465f47f880be
5Create Date: 2018-09-25 17:26:12.892161
10revision =
'465f47f880be'
11down_revision =
'7f85dd44c775'
14from sqlalchemy.dialects.postgresql
import ENUM
15import sqlalchemy
as sa
17AST_BOOL_NAME =
'ast_bool_values'
20AST_BOOL_VALUES = [
'0',
'1',
25PJSIP_TRANSPORT_PROTOCOL_OLD_NAME =
'pjsip_transport_protocol_values'
26PJSIP_TRANSPORT_PROTOCOL_NEW_NAME =
'pjsip_transport_protocol_values_v2'
28PJSIP_TRANSPORT_PROTOCOL_OLD_VALUES = [
'udp',
'tcp',
'tls',
'ws',
'wss']
29PJSIP_TRANSPORT_PROTOCOL_NEW_VALUES = [
'udp',
'tcp',
'tls',
'ws',
'wss',
'flow']
31PJSIP_TRANSPORT_PROTOCOL_OLD_TYPE = sa.Enum(*PJSIP_TRANSPORT_PROTOCOL_OLD_VALUES,
32 name=PJSIP_TRANSPORT_PROTOCOL_OLD_NAME)
33PJSIP_TRANSPORT_PROTOCOL_NEW_TYPE = sa.Enum(*PJSIP_TRANSPORT_PROTOCOL_NEW_VALUES,
34 name=PJSIP_TRANSPORT_PROTOCOL_NEW_NAME)
36PJSIP_AUTH_TYPE_OLD_NAME =
'pjsip_auth_type_values'
37PJSIP_AUTH_TYPE_NEW_NAME =
'pjsip_auth_type_values_v2'
39PJSIP_AUTH_TYPE_OLD_VALUES = [
'md5',
'userpass']
40PJSIP_AUTH_TYPE_NEW_VALUES = [
'md5',
'userpass',
'google_oauth']
42PJSIP_AUTH_TYPE_OLD_TYPE = sa.Enum(*PJSIP_AUTH_TYPE_OLD_VALUES,
43 name=PJSIP_AUTH_TYPE_OLD_NAME)
44PJSIP_AUTH_TYPE_NEW_TYPE = sa.Enum(*PJSIP_AUTH_TYPE_NEW_VALUES,
45 name=PJSIP_AUTH_TYPE_NEW_NAME)
49 if op.get_context().bind.dialect.name ==
'postgresql':
50 enum = PJSIP_TRANSPORT_PROTOCOL_NEW_TYPE
51 enum.create(op.get_bind(), checkfirst=
False)
52 op.execute(
'ALTER TABLE ps_transports ALTER COLUMN protocol TYPE'
53 ' ' + PJSIP_TRANSPORT_PROTOCOL_NEW_NAME +
' USING'
54 ' protocol::text::' + PJSIP_TRANSPORT_PROTOCOL_NEW_NAME)
55 ENUM(name=PJSIP_TRANSPORT_PROTOCOL_OLD_NAME).drop(op.get_bind(), checkfirst=
False)
57 enum = PJSIP_AUTH_TYPE_NEW_TYPE
58 enum.create(op.get_bind(), checkfirst=
False)
59 op.execute(
'ALTER TABLE ps_auths ALTER COLUMN auth_type TYPE'
60 ' ' + PJSIP_AUTH_TYPE_NEW_NAME +
' USING'
61 ' auth_type::text::' + PJSIP_AUTH_TYPE_NEW_NAME)
62 ENUM(name=PJSIP_AUTH_TYPE_OLD_NAME).drop(op.get_bind(), checkfirst=
False)
64 op.alter_column(
'ps_transports',
'protocol',
65 type_=PJSIP_TRANSPORT_PROTOCOL_NEW_TYPE,
66 existing_type=PJSIP_TRANSPORT_PROTOCOL_OLD_TYPE)
67 op.alter_column(
'ps_auths',
'auth_type',
68 type_=PJSIP_AUTH_TYPE_NEW_TYPE,
69 existing_type=PJSIP_AUTH_TYPE_OLD_TYPE)
73 ast_bool_values = ENUM(*AST_BOOL_VALUES, name=AST_BOOL_NAME, create_type=
False)
75 op.add_column(
'ps_registrations', sa.Column(
'support_outbound', ast_bool_values))
76 op.add_column(
'ps_registrations', sa.Column(
'contact_header_params', sa.String(255)))
78 op.add_column(
'ps_auths', sa.Column(
'refresh_token', sa.String(255)))
79 op.add_column(
'ps_auths', sa.Column(
'oauth_clientid', sa.String(255)))
80 op.add_column(
'ps_auths', sa.Column(
'oauth_secret', sa.String(255)))
85 op.execute(
"UPDATE ps_transports SET protocol='udp' WHERE protocol='flow'")
86 op.execute(
"UPDATE ps_auths SET auth_type='userpass' WHERE auth_type='google_oauth'")
88 if op.get_context().bind.dialect.name ==
'postgresql':
89 enum = PJSIP_TRANSPORT_PROTOCOL_OLD_TYPE
90 enum.create(op.get_bind(), checkfirst=
False)
91 op.execute(
'ALTER TABLE ps_transports ALTER COLUMN protocol TYPE'
92 ' ' + PJSIP_TRANSPORT_PROTOCOL_OLD_NAME +
' USING'
93 ' protocol::text::' + PJSIP_TRANSPORT_PROTOCOL_OLD_NAME)
94 ENUM(name=PJSIP_TRANSPORT_PROTOCOL_NEW_NAME).drop(op.get_bind(), checkfirst=
False)
96 enum = PJSIP_AUTH_TYPE_OLD_TYPE
97 enum.create(op.get_bind(), checkfirst=
False)
98 op.execute(
'ALTER TABLE ps_auths ALTER COLUMN auth_type TYPE'
99 ' ' + PJSIP_AUTH_TYPE_OLD_NAME +
' USING'
100 ' auth_type::text::' + PJSIP_AUTH_TYPE_OLD_NAME)
101 ENUM(name=PJSIP_AUTH_TYPE_NEW_NAME).drop(op.get_bind(), checkfirst=
False)
103 op.alter_column(
'ps_transports',
'protocol',
104 type_=PJSIP_TRANSPORT_PROTOCOL_OLD_TYPE,
105 existing_type=PJSIP_TRANSPORT_PROTOCOL_NEW_TYPE)
106 op.alter_column(
'ps_auths',
'auth_type',
107 type_=PJSIP_AUTH_TYPE_OLD_TYPE,
108 existing_type=PJSIP_AUTH_TYPE_NEW_TYPE)
110 op.drop_column(
'ps_registrations',
'support_outbound')
111 op.drop_column(
'ps_registrations',
'contact_header_params')
113 op.drop_column(
'ps_auths',
'refresh_token')
114 op.drop_column(
'ps_auths',
'oauth_clientid')
115 op.drop_column(
'ps_auths',
'oauth_secret')