Asterisk - The Open Source Telephony Project GIT-master-f36a736
Functions | Variables
74dc751dfe8e_more_permission_boolean_columns Namespace Reference

Functions

def downgrade ()
 
def upgrade ()
 

Variables

string AST_BOOL_NAME = 'ast_bool_values'
 
list AST_BOOL_VALUES
 
 ast_bool_values = ENUM(*AST_BOOL_VALUES, name=AST_BOOL_NAME, create_type=False)
 
list COLUMNS
 
string down_revision = 'bd335bae5d33'
 
string revision = '74dc751dfe8e'
 
string YESNO_NAME = 'yesno_values'
 
list YESNO_VALUES = ['yes', 'no']
 
 yesno_values = ENUM(*YESNO_VALUES, name=YESNO_NAME, create_type=False)
 

Function Documentation

◆ downgrade()

def downgrade ( )

Definition at line 115 of file 74dc751dfe8e_more_permission_boolean_columns.py.

115def downgrade():
116 for table_name, column_list in itertools.groupby(COLUMNS, operator.itemgetter(0)):
117 subject = table(table_name)
118 values_exprs = {}
119 for _, column_name in column_list:
120 subject.append_column(column(column_name))
121 values_exprs[column_name] = cast(
122 case((or_(subject.c[column_name] == text("'yes'"),
123 subject.c[column_name] == text("'1'"),
124 subject.c[column_name] == text("'on'"),
125 subject.c[column_name] == text("'true'")), text("'yes'")),
126 else_=text("'no'")),
127 ast_bool_values)
128
129 op.execute(
130 subject.update().values(values_exprs)
131 )
132
133 for table_name, column_list in itertools.groupby(COLUMNS, operator.itemgetter(0)):
134 with op.batch_alter_table(table_name) as batch_op:
135 for _, column_name in column_list:
136 batch_op.alter_column(column_name,
137 type_=yesno_values,
138 existing_type=ast_bool_values,
139 postgresql_using='"{}"::text::{}'.format(column_name, YESNO_NAME))
char * text
Definition: app_queue.c:1668
static char * table
Definition: cdr_odbc.c:55

References table, and text.

◆ upgrade()

def upgrade ( )

Definition at line 106 of file 74dc751dfe8e_more_permission_boolean_columns.py.

106def upgrade():
107 for table_name, column_list in itertools.groupby(COLUMNS, operator.itemgetter(0)):
108 with op.batch_alter_table(table_name) as batch_op:
109 for _, column_name in column_list:
110 batch_op.alter_column(column_name,
111 type_=ast_bool_values,
112 existing_type=yesno_values,
113 postgresql_using='"{}"::text::{}'.format(column_name, AST_BOOL_NAME))
114

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 98 of file 74dc751dfe8e_more_permission_boolean_columns.py.

◆ ast_bool_values

ast_bool_values = ENUM(*AST_BOOL_VALUES, name=AST_BOOL_NAME, create_type=False)

◆ COLUMNS

list COLUMNS

◆ down_revision

string down_revision = 'bd335bae5d33'

◆ revision

string revision = '74dc751dfe8e'

◆ YESNO_NAME

string YESNO_NAME = 'yesno_values'

◆ YESNO_VALUES

list YESNO_VALUES = ['yes', 'no']

◆ yesno_values

yesno_values = ENUM(*YESNO_VALUES, name=YESNO_NAME, create_type=False)