Asterisk - The Open Source Telephony Project  18.5.0
2da192dbbc65_add_publish_tables.py
Go to the documentation of this file.
1 """add publish tables
2 
3 Revision ID: 2da192dbbc65
4 Revises: 8fce4c573e15
5 Create Date: 2017-04-05 10:16:52.504699
6 
7 """
8 
9 # revision identifiers, used by Alembic.
10 revision = '2da192dbbc65'
11 down_revision = '8fce4c573e15'
12 
13 from alembic import op
14 import sqlalchemy as sa
15 from sqlalchemy.dialects.postgresql import ENUM
16 
17 YESNO_NAME = 'yesno_values'
18 YESNO_VALUES = ['yes', 'no']
19 
20 def upgrade():
21  ############################# Enums ##############################
22 
23  # yesno_values have already been created, so use postgres enum object
24  # type to get around "already created" issue - works okay with mysql
25  yesno_values = ENUM(*YESNO_VALUES, name=YESNO_NAME, create_type=False)
26 
27  op.create_table(
28  'ps_outbound_publishes',
29  sa.Column('id', sa.String(40), nullable=False, unique=True),
30  sa.Column('expiration', sa.Integer),
31  sa.Column('outbound_auth', sa.String(40)),
32  sa.Column('outbound_proxy', sa.String(256)),
33  sa.Column('server_uri', sa.String(256)),
34  sa.Column('from_uri', sa.String(256)),
35  sa.Column('to_uri', sa.String(256)),
36  sa.Column('event', sa.String(40)),
37  sa.Column('max_auth_attempts', sa.Integer),
38  sa.Column('transport', sa.String(40)),
39  sa.Column('multi_user', yesno_values),
40  sa.Column('@body', sa.String(40)),
41  sa.Column('@context', sa.String(256)),
42  sa.Column('@exten', sa.String(256)),
43  )
44 
45  op.create_index('ps_outbound_publishes_id', 'ps_outbound_publishes', ['id'])
46 
47  op.create_table(
48  'ps_inbound_publications',
49  sa.Column('id', sa.String(40), nullable=False, unique=True),
50  sa.Column('endpoint', sa.String(40)),
51  sa.Column('event_asterisk-devicestate', sa.String(40)),
52  sa.Column('event_asterisk-mwi', sa.String(40)),
53  )
54 
55  op.create_index('ps_inbound_publications_id', 'ps_inbound_publications', ['id'])
56 
57  op.create_table(
58  'ps_asterisk_publications',
59  sa.Column('id', sa.String(40), nullable=False, unique=True),
60  sa.Column('devicestate_publish', sa.String(40)),
61  sa.Column('mailboxstate_publish', sa.String(40)),
62  sa.Column('device_state', yesno_values),
63  sa.Column('device_state_filter', sa.String(256)),
64  sa.Column('mailbox_state', yesno_values),
65  sa.Column('mailbox_state_filter', sa.String(256)),
66  )
67 
68  op.create_index('ps_asterisk_publications_id', 'ps_asterisk_publications', ['id'])
69 
70 def downgrade():
71  op.drop_table('ps_outbound_publishes')
72  op.drop_table('ps_inbound_publications')
73  op.drop_table('ps_asterisk_publications')