Asterisk - The Open Source Telephony Project GIT-master-f36a736
f3c0b8695b66_taskprocessor_overload_trigger.py
Go to the documentation of this file.
1"""taskprocessor_overload_trigger
2
3Revision ID: f3c0b8695b66
4Revises: 0838f8db6a61
5Create Date: 2019-02-15 15:03:50.106790
6
7"""
8
9# revision identifiers, used by Alembic.
10revision = 'f3c0b8695b66'
11down_revision = '0838f8db6a61'
12
13from alembic import op
14import sqlalchemy as sa
15from sqlalchemy.dialects.postgresql import ENUM
16
17PJSIP_TASKPROCESSOR_OVERLOAD_TRIGGER_NAME = 'pjsip_taskprocessor_overload_trigger_values'
18PJSIP_TASKPROCESSOR_OVERLOAD_TRIGGER_VALUES = ['none', 'global', 'pjsip_only']
19
20def 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
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)