diff options
author | Kevin Harwell <kharwell@digium.com> | 2014-02-06 18:11:34 +0000 |
---|---|---|
committer | Kevin Harwell <kharwell@digium.com> | 2014-02-06 18:11:34 +0000 |
commit | 6a1cb65679c367751b331e944234a915845ece30 (patch) | |
tree | cffcd5afb2a59b10e837bec86f8fba29277e7201 | |
parent | b5ca213e34055724a5cd669938e356569847edcb (diff) |
pjsip realtime: already created enum failure for postgresql
If an enum had been previously created the alembic script would attempt to
re-create it and an error would be generated while running migrations for a
postgresql server. The work around for this is to use the ENUM object type
for postgres as opposed to the generic enum type used by sqlalchemy. Using
this type in the script seems to work properly for both postgres and mysql.
........
Merged revisions 407572 from http://svn.asterisk.org/svn/asterisk/branches/12
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@407574 65c4cc65-6c06-0410-ace0-fbb531ad65f3
-rwxr-xr-x | contrib/ast-db-manage/config/versions/2fc7930b41b3_add_pjsip_endpoint_options_for_12_1.py | 15 |
1 files changed, 4 insertions, 11 deletions
diff --git a/contrib/ast-db-manage/config/versions/2fc7930b41b3_add_pjsip_endpoint_options_for_12_1.py b/contrib/ast-db-manage/config/versions/2fc7930b41b3_add_pjsip_endpoint_options_for_12_1.py index 3119563f7..7b3f132d6 100755 --- a/contrib/ast-db-manage/config/versions/2fc7930b41b3_add_pjsip_endpoint_options_for_12_1.py +++ b/contrib/ast-db-manage/config/versions/2fc7930b41b3_add_pjsip_endpoint_options_for_12_1.py @@ -12,6 +12,7 @@ down_revision = '581a4264e537' from alembic import op import sqlalchemy as sa +from sqlalchemy.dialects.postgresql import ENUM YESNO_NAME = 'yesno_values' YESNO_VALUES = ['yes', 'no'] @@ -26,20 +27,12 @@ PJSIP_TRANSPORT_METHOD_VALUES = ['default', 'unspecified', 'tlsv1', 'sslv2', PJSIP_TRANSPORT_PROTOCOL_NAME = 'pjsip_transport_protocol_values' PJSIP_TRANSPORT_PROTOCOL_VALUES = ['udp', 'tcp', 'tls', 'ws', 'wss'] -def create_enum(name, check_first, *args): - """Create an enumeration with the given name.""" - res = sa.Enum(*args, name=name) - res.create(op.get_bind(), checkfirst=check_first) - return res - -def drop_enum(name): - """Drop the named enumeration from the database.""" - sa.Enum(name=name).drop(op.get_bind(), checkfirst=False) - def upgrade(): ############################# Enums ############################## - yesno_values = sa.Enum(*YESNO_VALUES, name=YESNO_NAME) + # yesno_values have already been created, so use postgres enum object + # type to get around "already created" issue - works okay with mysql + yesno_values = ENUM(*YESNO_VALUES, name=YESNO_NAME, create_type=False) # for some reason when using 'add_column' if you don't create the enum # first it will think it already exists and fail |