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

Functions

def downgrade ()
 
def upgrade ()
 

Variables

string AST_BOOL_NAME = 'ast_bool_values'
 
list AST_BOOL_VALUES
 
string down_revision = '1d3ed26d9978'
 
string revision = 'fe6592859b85'
 

Detailed Description

Fix mwi_subscribe_replaces_unsolicited

Revision ID: fe6592859b85
Revises: 19b00bc19b7b
Create Date: 2018-08-06 15:50:44.405534

Function Documentation

◆ downgrade()

def fe6592859b85_fix_mwi_subscribe_replaces_.downgrade ( )

Definition at line 40 of file fe6592859b85_fix_mwi_subscribe_replaces_.py.

40 def downgrade():
41  # First we need to ensure the column is using only the 'numeric' bool enum values.
42  op.execute("UPDATE ps_endpoints SET mwi_subscribe_replaces_unsolicited='0'"
43  " WHERE mwi_subscribe_replaces_unsolicited='off'"
44  " OR mwi_subscribe_replaces_unsolicited='false'"
45  " OR mwi_subscribe_replaces_unsolicited='no'")
46  op.execute("UPDATE ps_endpoints SET mwi_subscribe_replaces_unsolicited='1'"
47  " WHERE mwi_subscribe_replaces_unsolicited='on'"
48  " OR mwi_subscribe_replaces_unsolicited='true'"
49  " OR mwi_subscribe_replaces_unsolicited='yes'")
50 
51  # There is no direct way to convert from ENUM to Integer that is
52  # not database specific so we transition through a string type.
53  if op.get_context().bind.dialect.name == 'mssql':
54  op.drop_constraint('ck_ps_endpoints_mwi_subscribe_replaces_unsolicited_ast_bool_values', 'ps_endpoints')
55  op.alter_column('ps_endpoints', 'mwi_subscribe_replaces_unsolicited',
56  type_=sa.String(5))
57  op.alter_column('ps_endpoints', 'mwi_subscribe_replaces_unsolicited',
58  type_=sa.Integer, postgresql_using='mwi_subscribe_replaces_unsolicited::Integer')
59 
60  if op.get_context().bind.dialect.name == 'postgresql':
61  ENUM(name=AST_BOOL_NAME).drop(op.get_bind(), checkfirst=False)

◆ upgrade()

def fe6592859b85_fix_mwi_subscribe_replaces_.upgrade ( )

Definition at line 26 of file fe6592859b85_fix_mwi_subscribe_replaces_.py.

References format.

26 def upgrade():
27  # Create the new enum
28  ast_bool_values = ENUM(*AST_BOOL_VALUES, name=AST_BOOL_NAME, create_type=False)
29  if op.get_context().bind.dialect.name == 'postgresql':
30  ast_bool_values.create(op.get_bind(), checkfirst=False)
31 
32  # There is no direct way to convert from Integer to ENUM that is
33  # not database specific so we transition through a string type.
34  op.alter_column('ps_endpoints', 'mwi_subscribe_replaces_unsolicited',
35  type_=sa.String(5))
36  op.alter_column('ps_endpoints', 'mwi_subscribe_replaces_unsolicited',
37  type_=ast_bool_values, postgresql_using='mwi_subscribe_replaces_unsolicited::{0}'.format(AST_BOOL_NAME))
38 
39 
static snd_pcm_format_t format
Definition: chan_alsa.c:102

Variable Documentation

◆ AST_BOOL_NAME

string AST_BOOL_NAME = 'ast_bool_values'

Definition at line 17 of file fe6592859b85_fix_mwi_subscribe_replaces_.py.

◆ 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 fe6592859b85_fix_mwi_subscribe_replaces_.py.

◆ down_revision

string down_revision = '1d3ed26d9978'

Definition at line 11 of file fe6592859b85_fix_mwi_subscribe_replaces_.py.

◆ revision

string revision = 'fe6592859b85'

Definition at line 10 of file fe6592859b85_fix_mwi_subscribe_replaces_.py.