1"""update pjsip tls method list
3Revision ID: 37a5332640e2
5Create Date: 2023-11-14 18:02:18.857452
10revision =
'37a5332640e2'
11down_revision =
'dac2b4c328b8'
14from sqlalchemy.dialects.postgresql
import ENUM
15import sqlalchemy
as sa
17PJSIP_TRANSPORT_METHOD_OLD_NAME =
'pjsip_transport_method_values'
18PJSIP_TRANSPORT_METHOD_NEW_NAME =
'pjsip_transport_method_values_v2'
20PJSIP_TRANSPORT_METHOD_OLD_VALUES = [
'default',
'unspecified',
'tlsv1',
'sslv2',
22PJSIP_TRANSPORT_METHOD_NEW_VALUES = [
'default',
'unspecified',
23 'tlsv1',
'tlsv1_1',
'tlsv1_2',
'tlsv1_3',
24 'sslv2',
'sslv23',
'sslv3']
26PJSIP_TRANSPORT_METHOD_OLD_TYPE = sa.Enum(*PJSIP_TRANSPORT_METHOD_OLD_VALUES,
27 name=PJSIP_TRANSPORT_METHOD_OLD_NAME)
28PJSIP_TRANSPORT_METHOD_NEW_TYPE = sa.Enum(*PJSIP_TRANSPORT_METHOD_NEW_VALUES,
29 name=PJSIP_TRANSPORT_METHOD_NEW_NAME)
31 if op.get_context().bind.dialect.name ==
'postgresql':
32 enum = PJSIP_TRANSPORT_METHOD_NEW_TYPE
33 enum.create(op.get_bind(), checkfirst=
False)
35 op.alter_column(
'ps_transports',
'method',
36 type_=PJSIP_TRANSPORT_METHOD_NEW_TYPE,
37 existing_type=PJSIP_TRANSPORT_METHOD_OLD_TYPE,
38 postgresql_using=
'method::text::' + PJSIP_TRANSPORT_METHOD_NEW_NAME)
40 if op.get_context().bind.dialect.name ==
'postgresql':
41 ENUM(name=PJSIP_TRANSPORT_METHOD_OLD_NAME).drop(op.get_bind(), checkfirst=
False)
46 op.execute(
"UPDATE ps_transports SET method = 'tlsv1' WHERE method IN ('tlsv1_1', 'tlsv1_2', 'tlsv1_3')")
48 if op.get_context().bind.dialect.name ==
'postgresql':
49 enum = PJSIP_TRANSPORT_METHOD_OLD_TYPE
50 enum.create(op.get_bind(), checkfirst=
False)
52 op.alter_column(
'ps_transports',
'method',
53 type_=PJSIP_TRANSPORT_METHOD_OLD_TYPE,
54 existing_type=PJSIP_TRANSPORT_METHOD_NEW_TYPE,
55 postgresql_using=
'method::text::' + PJSIP_TRANSPORT_METHOD_OLD_NAME)
57 if op.get_context().bind.dialect.name ==
'postgresql':
58 ENUM(name=PJSIP_TRANSPORT_METHOD_NEW_NAME).drop(op.get_bind(), checkfirst=
False)