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

Functions

def downgrade ()
 
def upgrade ()
 

Variables

string down_revision = '5950038a6ead'
 
list NEW_ENUM = ['yes', 'no', 'nonat', 'update', 'outgoing']
 
 new_type = sa.Enum(*NEW_ENUM, name='sip_directmedia_values_v2')
 
list OLD_ENUM = ['yes', 'no', 'nonat', 'update']
 
 old_type = sa.Enum(*OLD_ENUM, name='sip_directmedia_values')
 
string revision = '10aedae86a32'
 
 tcr
 

Function Documentation

◆ downgrade()

def 10aedae86a32_add_outgoing_enum_va.downgrade ( )

Definition at line 63 of file 10aedae86a32_add_outgoing_enum_va.py.

63 def downgrade():
64  context = op.get_context()
65 
66  op.execute(tcr.update().where(tcr.c.directmedia==u'outgoing')
67  .values(directmedia=None))
68 
69  if context.bind.dialect.name != 'postgresql':
70  op.alter_column('sippeers', 'directmedia',
71  type_=old_type,
72  existing_type=new_type)
73  else:
74  enum = ENUM("yes", "no", "nonat", "update",
75  name="sip_directmedia_values")
76  enum.create(op.get_bind(), checkfirst=False)
77 
78  op.execute('ALTER TABLE sippeers ALTER COLUMN directmedia TYPE'
79  ' sip_directmedia_values USING'
80  ' directmedia::text::sip_directmedia_values')
81 
82  ENUM(name="sip_directmedia_values_v2").drop(op.get_bind(),
83  checkfirst=False)

◆ upgrade()

def 10aedae86a32_add_outgoing_enum_va.upgrade ( )

Definition at line 44 of file 10aedae86a32_add_outgoing_enum_va.py.

44 def upgrade():
45  context = op.get_context()
46 
47  # Upgrading to this revision WILL clear your directmedia values.
48  if context.bind.dialect.name != 'postgresql':
49  op.alter_column('sippeers', 'directmedia',
50  type_=new_type,
51  existing_type=old_type)
52  else:
53  enum = ENUM("yes", "no", "nonat", "update", "outgoing",
54  name="sip_directmedia_values_v2")
55  enum.create(op.get_bind(), checkfirst=False)
56 
57  op.execute('ALTER TABLE sippeers ALTER COLUMN directmedia TYPE'
58  ' sip_directmedia_values_v2 USING'
59  ' directmedia::text::sip_directmedia_values_v2')
60 
61  ENUM(name="sip_directmedia_values").drop(op.get_bind(), checkfirst=False)
62 

Variable Documentation

◆ down_revision

string down_revision = '5950038a6ead'

Definition at line 29 of file 10aedae86a32_add_outgoing_enum_va.py.

◆ NEW_ENUM

list NEW_ENUM = ['yes', 'no', 'nonat', 'update', 'outgoing']

Definition at line 36 of file 10aedae86a32_add_outgoing_enum_va.py.

◆ new_type

◆ OLD_ENUM

list OLD_ENUM = ['yes', 'no', 'nonat', 'update']

Definition at line 35 of file 10aedae86a32_add_outgoing_enum_va.py.

◆ old_type

old_type = sa.Enum(*OLD_ENUM, name='sip_directmedia_values')

Definition at line 38 of file 10aedae86a32_add_outgoing_enum_va.py.

◆ revision

string revision = '10aedae86a32'

Definition at line 28 of file 10aedae86a32_add_outgoing_enum_va.py.

◆ tcr

tcr
Initial value:
1 = sa.sql.table('sippeers', sa.Column('directmedia', new_type,
2  nullable=True))

Definition at line 41 of file 10aedae86a32_add_outgoing_enum_va.py.