[Asterisk-code-review] alembic: Fix errors during upgrade head. (...asterisk[master])
Friendly Automation
asteriskteam at digium.com
Thu Mar 28 14:43:37 CDT 2019
Friendly Automation has submitted this change and it was merged. ( https://gerrit.asterisk.org/c/asterisk/+/11185 )
Change subject: alembic: Fix errors during upgrade head.
......................................................................
alembic: Fix errors during upgrade head.
When trying to upgrade using alembic, a couple different errors kept
popping up that prevented the upgrade. An additional parameter was
needed when changing the schema for mwi_subscribe_replaces_unsolicited
from an integer to an enum. When changing from a string to an enum, the
type needed to be cast for postgresql. The other issue was a parameter
being used during column creation that did not exist.
After fixing the upgrade process, it revealed errors with the downgrade
process. One was a variable not being defined in the downgrade function,
and the other was tables not existing when using MySQL. This was due to
a context check that should have encompassed MySQL, but in the end was
not doing so.
Change-Id: Ib4d70cf3ce5080023a50be496272a777b55d6c8e
---
M contrib/ast-db-manage/config/versions/ef7efc2d3964_ps_contacts_add_endpoint_and_modify_.py
M contrib/ast-db-manage/config/versions/f3c0b8695b66_taskprocessor_overload_trigger.py
M contrib/ast-db-manage/config/versions/fe6592859b85_fix_mwi_subscribe_replaces_.py
3 files changed, 8 insertions(+), 6 deletions(-)
Approvals:
Kevin Harwell: Looks good to me, but someone else must approve
Joshua Colp: Looks good to me, but someone else must approve
mattf: Looks good to me, approved; Verified
Friendly Automation: Approved for Submit
diff --git a/contrib/ast-db-manage/config/versions/ef7efc2d3964_ps_contacts_add_endpoint_and_modify_.py b/contrib/ast-db-manage/config/versions/ef7efc2d3964_ps_contacts_add_endpoint_and_modify_.py
index 0ac63c8..4818185 100644
--- a/contrib/ast-db-manage/config/versions/ef7efc2d3964_ps_contacts_add_endpoint_and_modify_.py
+++ b/contrib/ast-db-manage/config/versions/ef7efc2d3964_ps_contacts_add_endpoint_and_modify_.py
@@ -27,7 +27,8 @@
op.create_index('ps_contacts_qualifyfreq_exp', 'ps_contacts', ['qualify_frequency', 'expiration_time'])
op.create_index('ps_aors_qualifyfreq_contact', 'ps_aors', ['qualify_frequency', 'contact'])
def downgrade():
- if op.get_context().bind.dialect.name != 'mssql':
+ context_name = op.get_context().bind.dialect.name
+ if context_name != 'mssql' and context_name != 'mysql':
op.drop_index('ps_aors_qualifyfreq_contact')
op.drop_index('ps_contacts_qualifyfreq_exp')
else:
diff --git a/contrib/ast-db-manage/config/versions/f3c0b8695b66_taskprocessor_overload_trigger.py b/contrib/ast-db-manage/config/versions/f3c0b8695b66_taskprocessor_overload_trigger.py
index 6a5b9b2..fccda35 100644
--- a/contrib/ast-db-manage/config/versions/f3c0b8695b66_taskprocessor_overload_trigger.py
+++ b/contrib/ast-db-manage/config/versions/f3c0b8695b66_taskprocessor_overload_trigger.py
@@ -28,11 +28,12 @@
op.add_column('ps_globals',
sa.Column('taskprocessor_overload_trigger',
sa.Enum(*PJSIP_TASKPROCESSOR_OVERLOAD_TRIGGER_VALUES,
- name=PJSIP_TASKPROCESSOR_OVERLOAD_TRIGGER_NAME,
- create_type=False)))
+ name=PJSIP_TASKPROCESSOR_OVERLOAD_TRIGGER_NAME)))
def downgrade():
- if op.get_context().bind.dialect.name == 'mssql':
+ context = op.get_context()
+
+ if context.bind.dialect.name == 'mssql':
op.drop_constraint('ck_ps_globals_taskprocessor_overload_trigger_pjsip_taskprocessor_overload_trigger_values', 'ps_globals')
op.drop_column('ps_globals', 'taskprocessor_overload_trigger')
diff --git a/contrib/ast-db-manage/config/versions/fe6592859b85_fix_mwi_subscribe_replaces_.py b/contrib/ast-db-manage/config/versions/fe6592859b85_fix_mwi_subscribe_replaces_.py
index 4ecaaf7..c0f528a 100644
--- a/contrib/ast-db-manage/config/versions/fe6592859b85_fix_mwi_subscribe_replaces_.py
+++ b/contrib/ast-db-manage/config/versions/fe6592859b85_fix_mwi_subscribe_replaces_.py
@@ -34,7 +34,7 @@
op.alter_column('ps_endpoints', 'mwi_subscribe_replaces_unsolicited',
type_=sa.String(5))
op.alter_column('ps_endpoints', 'mwi_subscribe_replaces_unsolicited',
- type_=ast_bool_values)
+ type_=ast_bool_values, postgresql_using='mwi_subscribe_replaces_unsolicited::{0}'.format(AST_BOOL_NAME))
def downgrade():
@@ -55,7 +55,7 @@
op.alter_column('ps_endpoints', 'mwi_subscribe_replaces_unsolicited',
type_=sa.String(5))
op.alter_column('ps_endpoints', 'mwi_subscribe_replaces_unsolicited',
- type_=sa.Integer)
+ type_=sa.Integer, postgresql_using='mwi_subscribe_replaces_unsolicited::Integer')
if op.get_context().bind.dialect.name == 'postgresql':
ENUM(name=AST_BOOL_NAME).drop(op.get_bind(), checkfirst=False)
--
To view, visit https://gerrit.asterisk.org/c/asterisk/+/11185
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings
Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Change-Id: Ib4d70cf3ce5080023a50be496272a777b55d6c8e
Gerrit-Change-Number: 11185
Gerrit-PatchSet: 3
Gerrit-Owner: Benjamin Keith Ford <bford at digium.com>
Gerrit-Reviewer: Friendly Automation
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Kevin Harwell <kharwell at digium.com>
Gerrit-Reviewer: mattf <creslin at digium.com>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20190328/2b594ec7/attachment.html>
More information about the asterisk-code-review
mailing list