28887f25a46f_create_queue_tables.py

Go to the documentation of this file.
00001 #
00002 # Asterisk -- An open source telephony toolkit.
00003 #
00004 # Copyright (C) 2014, Richard Mudgett
00005 #
00006 # Richard Mudgett <rmudgett@digium.com>
00007 #
00008 # See http://www.asterisk.org for more information about
00009 # the Asterisk project. Please do not directly contact
00010 # any of the maintainers of this project for assistance;
00011 # the project provides a web site, mailing lists and IRC
00012 # channels for your use.
00013 #
00014 # This program is free software, distributed under the terms of
00015 # the GNU General Public License Version 2. See the LICENSE file
00016 # at the top of the source tree.
00017 #
00018 
00019 """Create queue tables
00020 
00021 Revision ID: 28887f25a46f
00022 Revises: 21e526ad3040
00023 Create Date: 2014-03-03 12:26:25.261640
00024 
00025 """
00026 
00027 # revision identifiers, used by Alembic.
00028 revision = '28887f25a46f'
00029 down_revision = '21e526ad3040'
00030 
00031 from alembic import op
00032 from alembic import context
00033 import sqlalchemy as sa
00034 from sqlalchemy.dialects.postgresql import ENUM
00035 
00036 
00037 YESNO_NAME = 'yesno_values'
00038 YESNO_VALUES = ['yes', 'no']
00039 
00040 QUEUE_STRATEGY_NAME = 'queue_strategy_values'
00041 QUEUE_STRATEGY_VALUES = [ 'ringall', 'leastrecent', 'fewestcalls', 'random', 'rrmemory',
00042     'linear', 'wrandom', 'rrordered', ]
00043 
00044 QUEUE_AUTOPAUSE_NAME = 'queue_autopause_values'
00045 QUEUE_AUTOPAUSE_VALUES = ['yes', 'no', 'all']
00046 
00047 
00048 def upgrade():
00049     ############################# Enums ##############################
00050 
00051     # yesno_values have already been created, so use postgres enum object
00052     # type to get around "already created" issue - works okay with mysql
00053     yesno_values = ENUM(*YESNO_VALUES, name=YESNO_NAME, create_type=False)
00054 
00055     queue_strategy_values = sa.Enum(*QUEUE_STRATEGY_VALUES, name=QUEUE_STRATEGY_NAME)
00056     queue_autopause_values = sa.Enum(*QUEUE_AUTOPAUSE_VALUES, name=QUEUE_AUTOPAUSE_NAME)
00057 
00058     ######################### create tables ##########################
00059 
00060     op.create_table(
00061         'queues',
00062         sa.Column('name', sa.String(128), primary_key=True, nullable=False),
00063         sa.Column('musiconhold', sa.String(128)),
00064         sa.Column('announce', sa.String(128)),
00065         sa.Column('context', sa.String(128)),
00066         sa.Column('timeout', sa.Integer),
00067         sa.Column('ringinuse', yesno_values),
00068         sa.Column('setinterfacevar', yesno_values),
00069         sa.Column('setqueuevar', yesno_values),
00070         sa.Column('setqueueentryvar', yesno_values),
00071         sa.Column('monitor_format', sa.String(8)),
00072         sa.Column('membermacro', sa.String(512)),
00073         sa.Column('membergosub', sa.String(512)),
00074         sa.Column('queue_youarenext', sa.String(128)),
00075         sa.Column('queue_thereare', sa.String(128)),
00076         sa.Column('queue_callswaiting', sa.String(128)),
00077         sa.Column('queue_quantity1', sa.String(128)),
00078         sa.Column('queue_quantity2', sa.String(128)),
00079         sa.Column('queue_holdtime', sa.String(128)),
00080         sa.Column('queue_minutes', sa.String(128)),
00081         sa.Column('queue_minute', sa.String(128)),
00082         sa.Column('queue_seconds', sa.String(128)),
00083         sa.Column('queue_thankyou', sa.String(128)),
00084         sa.Column('queue_callerannounce', sa.String(128)),
00085         sa.Column('queue_reporthold', sa.String(128)),
00086         sa.Column('announce_frequency', sa.Integer),
00087         sa.Column('announce_to_first_user', yesno_values),
00088         sa.Column('min_announce_frequency', sa.Integer),
00089         sa.Column('announce_round_seconds', sa.Integer),
00090         sa.Column('announce_holdtime', sa.String(128)),
00091         sa.Column('announce_position', sa.String(128)),
00092         sa.Column('announce_position_limit', sa.Integer),
00093         sa.Column('periodic_announce', sa.String(50)),
00094         sa.Column('periodic_announce_frequency', sa.Integer),
00095         sa.Column('relative_periodic_announce', yesno_values),
00096         sa.Column('random_periodic_announce', yesno_values),
00097         sa.Column('retry', sa.Integer),
00098         sa.Column('wrapuptime', sa.Integer),
00099         sa.Column('penaltymemberslimit', sa.Integer),
00100         sa.Column('autofill', yesno_values),
00101         sa.Column('monitor_type', sa.String(128)),
00102         sa.Column('autopause', queue_autopause_values),
00103         sa.Column('autopausedelay', sa.Integer),
00104         sa.Column('autopausebusy', yesno_values),
00105         sa.Column('autopauseunavail', yesno_values),
00106         sa.Column('maxlen', sa.Integer),
00107         sa.Column('servicelevel', sa.Integer),
00108         sa.Column('strategy', queue_strategy_values),
00109         sa.Column('joinempty', sa.String(128)),
00110         sa.Column('leavewhenempty', sa.String(128)),
00111         sa.Column('reportholdtime', yesno_values),
00112         sa.Column('memberdelay', sa.Integer),
00113         sa.Column('weight', sa.Integer),
00114         sa.Column('timeoutrestart', yesno_values),
00115         sa.Column('defaultrule', sa.String(128)),
00116         sa.Column('timeoutpriority', sa.String(128))
00117     )
00118 
00119     op.create_table(
00120         'queue_members',
00121         sa.Column('queue_name', sa.String(80), primary_key=True, nullable=False),
00122         sa.Column('interface', sa.String(80), primary_key=True, nullable=False),
00123         sa.Column('uniqueid', sa.String(80), nullable=False),
00124         sa.Column('membername', sa.String(80)),
00125         sa.Column('state_interface', sa.String(80)),
00126         sa.Column('penalty', sa.Integer),
00127         sa.Column('paused', sa.Integer)
00128     )
00129 
00130 
00131 def downgrade():
00132     ########################## drop tables ###########################
00133 
00134     op.drop_table('queues')
00135     op.drop_table('queue_members')
00136 
00137     ########################## drop enums ############################
00138 
00139     sa.Enum(name=QUEUE_STRATEGY_NAME).drop(op.get_bind(), checkfirst=False)
00140     sa.Enum(name=QUEUE_AUTOPAUSE_NAME).drop(op.get_bind(), checkfirst=False)
00141 

Generated on Thu Apr 16 06:27:05 2015 for Asterisk - The Open Source Telephony Project by  doxygen 1.5.6