Asterisk - The Open Source Telephony Project  21.4.1
6c475a93f48a_correct_nullability_of_pjsip_id_columns.py
1 """correct nullability of pjsip id columns
2 
3 Revision ID: 6c475a93f48a
4 Revises: d5122576cca8
5 Create Date: 2024-04-06 09:48:33.116410
6 
7 """
8 
9 # revision identifiers, used by Alembic.
10 revision = '6c475a93f48a'
11 down_revision = 'd5122576cca8'
12 
13 from alembic import op
14 import sqlalchemy as sa
15 
16 PJSIP_TABLES = [ 'ps_aors',
17  'ps_auths',
18  'ps_domain_aliases',
19  'ps_endpoint_id_ips',
20  'ps_endpoints',
21  'ps_inbound_publications',
22  'ps_outbound_publishes',
23  'ps_registrations' ]
24 
25 def upgrade():
26  for table_name in PJSIP_TABLES:
27  with op.batch_alter_table(table_name) as batch_op:
28  batch_op.alter_column('id', nullable=False,
29  existing_type=sa.String(255), existing_server_default=None,
30  existing_nullable=True)
31 
32 
33 def downgrade():
34  for table_name in reversed(PJSIP_TABLES):
35  with op.batch_alter_table(table_name) as batch_op:
36  batch_op.alter_column('id', nullable=True,
37  existing_type=sa.String(255), existing_server_default=None,
38  existing_nullable=True)