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

Functions

def downgrade ()
 
def enum_update (table_name, column_name, enum_name, enum_values)
 
def upgrade ()
 

Variables

string down_revision = '3a094a18e75b'
 
string revision = 'fbb7766f17bc'
 

Detailed Description

add playlist to moh

Revision ID: fbb7766f17bc
Revises: 3a094a18e75b
Create Date: 2019-09-18 10:24:18.731798

Function Documentation

◆ downgrade()

def fbb7766f17bc_add_playlist_to_moh.downgrade ( )

Definition at line 51 of file fbb7766f17bc_add_playlist_to_moh.py.

References enum_update().

51 def downgrade():
52  enum_update('musiconhold', 'mode', 'moh_mode_values',
53  ['custom', 'files', 'mp3nb', 'quietmp3nb', 'quietmp3'])
54  op.drop_table('musiconhold_entry')
55 
def enum_update(table_name, column_name, enum_name, enum_values)

◆ enum_update()

def fbb7766f17bc_add_playlist_to_moh.enum_update (   table_name,
  column_name,
  enum_name,
  enum_values 
)

Definition at line 17 of file fbb7766f17bc_add_playlist_to_moh.py.

Referenced by downgrade(), and upgrade().

17 def enum_update(table_name, column_name, enum_name, enum_values):
18  if op.get_context().bind.dialect.name != 'postgresql':
19  if op.get_context().bind.dialect.name == 'mssql':
20  op.drop_constraint('ck_musiconhold_mode_moh_mode_values', 'musiconhold')
21  op.alter_column(table_name, column_name,
22  type_=sa.Enum(*enum_values, name=enum_name))
23  return
24 
25  # Postgres requires a few more steps
26  tmp = enum_name + '_tmp'
27 
28  op.execute('ALTER TYPE ' + enum_name + ' RENAME TO ' + tmp)
29 
30  updated = sa.Enum(*enum_values, name=enum_name)
31  updated.create(op.get_bind(), checkfirst=False)
32 
33  op.execute('ALTER TABLE ' + table_name + ' ALTER COLUMN ' + column_name +
34  ' TYPE ' + enum_name + ' USING mode::text::' + enum_name)
35 
36  op.execute('DROP TYPE ' + tmp)
37 
38 
def enum_update(table_name, column_name, enum_name, enum_values)

◆ upgrade()

def fbb7766f17bc_add_playlist_to_moh.upgrade ( )

Definition at line 39 of file fbb7766f17bc_add_playlist_to_moh.py.

References enum_update().

39 def upgrade():
40  op.create_table(
41  'musiconhold_entry',
42  sa.Column('name', sa.String(80), primary_key=True, nullable=False),
43  sa.Column('position', sa.Integer, primary_key=True, nullable=False),
44  sa.Column('entry', sa.String(1024), nullable=False)
45  )
46  op.create_foreign_key('fk_musiconhold_entry_name_musiconhold', 'musiconhold_entry', 'musiconhold', ['name'], ['name'])
47  enum_update('musiconhold', 'mode', 'moh_mode_values',
48  ['custom', 'files', 'mp3nb', 'quietmp3nb', 'quietmp3', 'playlist'])
49 
50 
def enum_update(table_name, column_name, enum_name, enum_values)

Variable Documentation

◆ down_revision

string down_revision = '3a094a18e75b'

Definition at line 11 of file fbb7766f17bc_add_playlist_to_moh.py.

◆ revision

string revision = 'fbb7766f17bc'

Definition at line 10 of file fbb7766f17bc_add_playlist_to_moh.py.