Asterisk - The Open Source Telephony Project  18.5.0
f3c0b8695b66_taskprocessor_overload_trigger.py
Go to the documentation of this file.
1 """taskprocessor_overload_trigger
2 
3 Revision ID: f3c0b8695b66
4 Revises: 0838f8db6a61
5 Create Date: 2019-02-15 15:03:50.106790
6 
7 """
8 
9 # revision identifiers, used by Alembic.
10 revision = 'f3c0b8695b66'
11 down_revision = '0838f8db6a61'
12 
13 from alembic import op
14 import sqlalchemy as sa
15 from sqlalchemy.dialects.postgresql import ENUM
16 
17 PJSIP_TASKPROCESSOR_OVERLOAD_TRIGGER_NAME = 'pjsip_taskprocessor_overload_trigger_values'
18 PJSIP_TASKPROCESSOR_OVERLOAD_TRIGGER_VALUES = ['none', 'global', 'pjsip_only']
19 
20 def upgrade():
21  context = op.get_context()
22 
23  if context.bind.dialect.name == 'postgresql':
24  enum = ENUM(*PJSIP_TASKPROCESSOR_OVERLOAD_TRIGGER_VALUES,
25  name=PJSIP_TASKPROCESSOR_OVERLOAD_TRIGGER_NAME)
26  enum.create(op.get_bind(), checkfirst=False)
27 
28  op.add_column('ps_globals',
29  sa.Column('taskprocessor_overload_trigger',
30  sa.Enum(*PJSIP_TASKPROCESSOR_OVERLOAD_TRIGGER_VALUES,
31  name=PJSIP_TASKPROCESSOR_OVERLOAD_TRIGGER_NAME)))
32 
33 def downgrade():
34  context = op.get_context()
35 
36  if context.bind.dialect.name == 'mssql':
37  op.drop_constraint('ck_ps_globals_taskprocessor_overload_trigger_pjsip_taskprocessor_overload_trigger_values', 'ps_globals')
38  op.drop_column('ps_globals', 'taskprocessor_overload_trigger')
39 
40  if context.bind.dialect.name == 'postgresql':
41  enum = ENUM(*PJSIP_TASKPROCESSOR_OVERLOAD_TRIGGER_VALUES,
42  name=PJSIP_TASKPROCESSOR_OVERLOAD_TRIGGER_NAME)
43  enum.drop(op.get_bind(), checkfirst=False)