| 1 |
"""add security_negotiation and security_mechanisms to endpoint |
| 2 |
|
| 3 |
Revision ID: 417c0247fd7e |
| 4 |
Revises: 539f68bede2c |
| 5 |
Create Date: 2022-08-08 15:35:31.416964 |
| 6 |
|
| 7 |
""" |
| 8 |
|
| 9 |
|
| 10 |
revision = '417c0247fd7e' |
| 11 |
down_revision = '539f68bede2c' |
| 12 |
|
| 13 |
from alembic import op |
| 14 |
import sqlalchemy as sa |
| 15 |
from sqlalchemy.dialects.postgresql import ENUM |
| 16 |
|
| 17 |
SECURITY_NEGOTIATION_NAME = 'security_negotiation_values' |
| 18 |
SECURITY_NEGOTIATION_VALUES = ['no', 'mediasec'] |
| 19 |
|
| 20 |
def upgrade(): |
| 21 |
context = op.get_context() |
| 22 |
|
| 23 |
if context.bind.dialect.name == 'postgresql': |
| 24 |
security_negotiation_values = ENUM(*SECURITY_NEGOTIATION_VALUES, name=SECURITY_NEGOTIATION_NAME) |
| 25 |
security_negotiation_values.create(op.get_bind(), checkfirst=False) |
| 26 |
|
| 27 |
op.add_column('ps_endpoints', sa.Column('security_negotiation', |
| 28 |
ENUM(*SECURITY_NEGOTIATION_VALUES, name=SECURITY_NEGOTIATION_NAME, create_type=False))) |
| 29 |
op.add_column('ps_endpoints', sa.Column('security_mechanisms', sa.String(512))) |
| 30 |
|
| 31 |
op.add_column('ps_registrations', sa.Column('security_negotiation', |
| 32 |
ENUM(*SECURITY_NEGOTIATION_VALUES, name=SECURITY_NEGOTIATION_NAME, create_type=False))) |
| 33 |
op.add_column('ps_registrations', sa.Column('security_mechanisms', sa.String(512))) |
| 34 |
|
| 35 |
def downgrade(): |
| 36 |
context = op.get_context() |
| 37 |
|
| 38 |
if context.bind.dialect.name == 'mssql': |
| 39 |
op.drop_constraint('ck_ps_endpoints_security_negotiation_security_negotiation_values', 'ps_endpoints') |
| 40 |
op.drop_constraint('ck_ps_registrations_security_negotiation_security_negotiation_values', 'ps_registrations') |
| 41 |
|
| 42 |
op.drop_column('ps_endpoints', 'security_negotiation') |
| 43 |
op.drop_column('ps_endpoints', 'security_mechanisms') |
| 44 |
op.drop_column('ps_registrations', 'security_negotiation') |
| 45 |
op.drop_column('ps_registrations', 'security_mechanisms') |
| 46 |
|
| 47 |
if context.bind.dialect.name == 'postgresql': |
| 48 |
enum = ENUM(*SECURITY_NEGOTIATION_VALUES, name=SECURITY_NEGOTIATION_NAME) |
| 49 |
enum.drop(op.get_bind(), checkfirst=False) |