Asterisk - The Open Source Telephony Project  18.5.0
Functions | Variables
465f47f880be_add_pjsip_google_voice_sip_options Namespace Reference

Functions

def downgrade ()
 
def upgrade ()
 

Variables

string AST_BOOL_NAME = 'ast_bool_values'
 
list AST_BOOL_VALUES
 
string down_revision = '7f85dd44c775'
 
string PJSIP_AUTH_TYPE_NEW_NAME = 'pjsip_auth_type_values_v2'
 
 PJSIP_AUTH_TYPE_NEW_TYPE
 
list PJSIP_AUTH_TYPE_NEW_VALUES = ['md5', 'userpass', 'google_oauth']
 
string PJSIP_AUTH_TYPE_OLD_NAME = 'pjsip_auth_type_values'
 
 PJSIP_AUTH_TYPE_OLD_TYPE
 
list PJSIP_AUTH_TYPE_OLD_VALUES = ['md5', 'userpass']
 
string PJSIP_TRANSPORT_PROTOCOL_NEW_NAME = 'pjsip_transport_protocol_values_v2'
 
 PJSIP_TRANSPORT_PROTOCOL_NEW_TYPE
 
list PJSIP_TRANSPORT_PROTOCOL_NEW_VALUES = ['udp', 'tcp', 'tls', 'ws', 'wss', 'flow']
 
string PJSIP_TRANSPORT_PROTOCOL_OLD_NAME = 'pjsip_transport_protocol_values'
 
 PJSIP_TRANSPORT_PROTOCOL_OLD_TYPE
 
list PJSIP_TRANSPORT_PROTOCOL_OLD_VALUES = ['udp', 'tcp', 'tls', 'ws', 'wss']
 
string revision = '465f47f880be'
 

Function Documentation

◆ downgrade()

def 465f47f880be_add_pjsip_google_voice_sip_options.downgrade ( )

Definition at line 82 of file 465f47f880be_add_pjsip_google_voice_sip_options.py.

82 def downgrade():
83  # First we need to ensure that columns are not using the enum values
84  # that are going away.
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'")
87 
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)
95 
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)
102  else:
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)
109 
110  op.drop_column('ps_registrations', 'support_outbound')
111  op.drop_column('ps_registrations', 'contact_header_params')
112 
113  op.drop_column('ps_auths', 'refresh_token')
114  op.drop_column('ps_auths', 'oauth_clientid')
115  op.drop_column('ps_auths', 'oauth_secret')

◆ upgrade()

def 465f47f880be_add_pjsip_google_voice_sip_options.upgrade ( )

Definition at line 48 of file 465f47f880be_add_pjsip_google_voice_sip_options.py.

48 def upgrade():
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)
56 
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)
63  else:
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)
70 
71  # ast_bool_values have already been created, so use postgres enum object
72  # type to get around "already created" issue - works okay with mysql
73  ast_bool_values = ENUM(*AST_BOOL_VALUES, name=AST_BOOL_NAME, create_type=False)
74 
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)))
77 
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)))
81 

Variable Documentation

◆ AST_BOOL_NAME

string AST_BOOL_NAME = 'ast_bool_values'

◆ AST_BOOL_VALUES

list AST_BOOL_VALUES
Initial value:
1 = [ '0', '1',
2  'off', 'on',
3  'false', 'true',
4  'no', 'yes' ]

Definition at line 20 of file 465f47f880be_add_pjsip_google_voice_sip_options.py.

◆ down_revision

string down_revision = '7f85dd44c775'

◆ PJSIP_AUTH_TYPE_NEW_NAME

string PJSIP_AUTH_TYPE_NEW_NAME = 'pjsip_auth_type_values_v2'

◆ PJSIP_AUTH_TYPE_NEW_TYPE

PJSIP_AUTH_TYPE_NEW_TYPE
Initial value:
1 = sa.Enum(*PJSIP_AUTH_TYPE_NEW_VALUES,
2  name=PJSIP_AUTH_TYPE_NEW_NAME)

Definition at line 44 of file 465f47f880be_add_pjsip_google_voice_sip_options.py.

◆ PJSIP_AUTH_TYPE_NEW_VALUES

list PJSIP_AUTH_TYPE_NEW_VALUES = ['md5', 'userpass', 'google_oauth']

◆ PJSIP_AUTH_TYPE_OLD_NAME

string PJSIP_AUTH_TYPE_OLD_NAME = 'pjsip_auth_type_values'

◆ PJSIP_AUTH_TYPE_OLD_TYPE

PJSIP_AUTH_TYPE_OLD_TYPE
Initial value:
1 = sa.Enum(*PJSIP_AUTH_TYPE_OLD_VALUES,
2  name=PJSIP_AUTH_TYPE_OLD_NAME)

Definition at line 42 of file 465f47f880be_add_pjsip_google_voice_sip_options.py.

◆ PJSIP_AUTH_TYPE_OLD_VALUES

list PJSIP_AUTH_TYPE_OLD_VALUES = ['md5', 'userpass']

◆ PJSIP_TRANSPORT_PROTOCOL_NEW_NAME

string PJSIP_TRANSPORT_PROTOCOL_NEW_NAME = 'pjsip_transport_protocol_values_v2'

◆ PJSIP_TRANSPORT_PROTOCOL_NEW_TYPE

PJSIP_TRANSPORT_PROTOCOL_NEW_TYPE
Initial value:
1 = sa.Enum(*PJSIP_TRANSPORT_PROTOCOL_NEW_VALUES,
2  name=PJSIP_TRANSPORT_PROTOCOL_NEW_NAME)

Definition at line 33 of file 465f47f880be_add_pjsip_google_voice_sip_options.py.

◆ PJSIP_TRANSPORT_PROTOCOL_NEW_VALUES

list PJSIP_TRANSPORT_PROTOCOL_NEW_VALUES = ['udp', 'tcp', 'tls', 'ws', 'wss', 'flow']

◆ PJSIP_TRANSPORT_PROTOCOL_OLD_NAME

string PJSIP_TRANSPORT_PROTOCOL_OLD_NAME = 'pjsip_transport_protocol_values'

◆ PJSIP_TRANSPORT_PROTOCOL_OLD_TYPE

PJSIP_TRANSPORT_PROTOCOL_OLD_TYPE
Initial value:
1 = sa.Enum(*PJSIP_TRANSPORT_PROTOCOL_OLD_VALUES,
2  name=PJSIP_TRANSPORT_PROTOCOL_OLD_NAME)

Definition at line 31 of file 465f47f880be_add_pjsip_google_voice_sip_options.py.

◆ PJSIP_TRANSPORT_PROTOCOL_OLD_VALUES

list PJSIP_TRANSPORT_PROTOCOL_OLD_VALUES = ['udp', 'tcp', 'tls', 'ws', 'wss']

◆ revision

string revision = '465f47f880be'