<p>Benjamin Keith Ford has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/11208">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">build: 'postgresql_using' was causing problems.<br><br>During local testing, using the parameter 'postgresql_using' when using<br>alembic to alter a column (op.alter_column) worked fine. It is<br>documented in their changelog as a valid keyword argument to use.<br>Unfortunately, this parameter is not recognized when running on<br>combuilder for unknown reasons. Quick fix to do an execute statement<br>with USING SQL syntax instead of the 'postgresql_using' parameter.<br><br>Change-Id: I7fdde0efa33ad91e761512bc2e2d0bab02cb6baf<br>---<br>M contrib/ast-db-manage/config/versions/fe6592859b85_fix_mwi_subscribe_replaces_.py<br>1 file changed, 17 insertions(+), 8 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/08/11208/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>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</span><br><span>index c0f528a..3d74c08 100644</span><br><span>--- a/contrib/ast-db-manage/config/versions/fe6592859b85_fix_mwi_subscribe_replaces_.py</span><br><span>+++ b/contrib/ast-db-manage/config/versions/fe6592859b85_fix_mwi_subscribe_replaces_.py</span><br><span>@@ -24,20 +24,28 @@</span><br><span> </span><br><span> </span><br><span> def upgrade():</span><br><span style="color: hsl(120, 100%, 40%);">+    context = op.get_context()</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span>     # Create the new enum</span><br><span>     ast_bool_values = ENUM(*AST_BOOL_VALUES, name=AST_BOOL_NAME, create_type=False)</span><br><span style="color: hsl(0, 100%, 40%);">-    if op.get_context().bind.dialect.name == 'postgresql':</span><br><span style="color: hsl(120, 100%, 40%);">+    if context.bind.dialect.name == 'postgresql':</span><br><span>         ast_bool_values.create(op.get_bind(), checkfirst=False)</span><br><span> </span><br><span>     # There is no direct way to convert from Integer to ENUM that is</span><br><span>     # not database specific so we transition through a string type.</span><br><span>     op.alter_column('ps_endpoints', 'mwi_subscribe_replaces_unsolicited',</span><br><span>                     type_=sa.String(5))</span><br><span style="color: hsl(0, 100%, 40%);">-    op.alter_column('ps_endpoints', 'mwi_subscribe_replaces_unsolicited',</span><br><span style="color: hsl(0, 100%, 40%);">-            type_=ast_bool_values, postgresql_using='mwi_subscribe_replaces_unsolicited::{0}'.format(AST_BOOL_NAME))</span><br><span style="color: hsl(120, 100%, 40%);">+    if context.bind.dialect.name != 'postgresql':</span><br><span style="color: hsl(120, 100%, 40%);">+        op.alter_column('ps_endpoints', 'mwi_subscribe_replaces_unsolicited',</span><br><span style="color: hsl(120, 100%, 40%);">+                type_=ast_bool_values)</span><br><span style="color: hsl(120, 100%, 40%);">+    else:</span><br><span style="color: hsl(120, 100%, 40%);">+        op.execute('ALTER TABLE ps_endpoints ALTER COLUMN mwi_subscribe_replaces_unsolicited '</span><br><span style="color: hsl(120, 100%, 40%);">+                   'TYPE {0} USING mwi_subscribe_replaces_unsolicited::{0}'.format(AST_BOOL_NAME))</span><br><span> </span><br><span> </span><br><span> def downgrade():</span><br><span style="color: hsl(120, 100%, 40%);">+    context = op.get_context()</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span>     # First we need to ensure the column is using only the 'numeric' bool enum values.</span><br><span>     op.execute("UPDATE ps_endpoints SET mwi_subscribe_replaces_unsolicited='0'"</span><br><span>                " WHERE mwi_subscribe_replaces_unsolicited='off'"</span><br><span>@@ -50,12 +58,13 @@</span><br><span> </span><br><span>     # There is no direct way to convert from ENUM to Integer that is</span><br><span>     # not database specific so we transition through a string type.</span><br><span style="color: hsl(0, 100%, 40%);">-    if op.get_context().bind.dialect.name == 'mssql':</span><br><span style="color: hsl(120, 100%, 40%);">+    if context.bind.dialect.name == 'mssql':</span><br><span>         op.drop_constraint('ck_ps_endpoints_mwi_subscribe_replaces_unsolicited_ast_bool_values', 'ps_endpoints')</span><br><span>     op.alter_column('ps_endpoints', 'mwi_subscribe_replaces_unsolicited',</span><br><span>                     type_=sa.String(5))</span><br><span style="color: hsl(0, 100%, 40%);">-    op.alter_column('ps_endpoints', 'mwi_subscribe_replaces_unsolicited',</span><br><span style="color: hsl(0, 100%, 40%);">-            type_=sa.Integer, postgresql_using='mwi_subscribe_replaces_unsolicited::Integer')</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-    if op.get_context().bind.dialect.name == 'postgresql':</span><br><span style="color: hsl(120, 100%, 40%);">+    if context.bind.dialect.name != 'postgresql':</span><br><span style="color: hsl(120, 100%, 40%);">+        op.alter_column('ps_endpoints', 'mwi_subscribe_replaces_unsolicited', type_=sa.Integer)</span><br><span style="color: hsl(120, 100%, 40%);">+    else:</span><br><span style="color: hsl(120, 100%, 40%);">+        op.execute('ALTER TABLE ps_endpoints ALTER COLUMN mwi_subscribe_replaces_unsolicited '</span><br><span style="color: hsl(120, 100%, 40%);">+                   'TYPE Integer USING mwi_subscribe_replaces_unsolicited::Integer')</span><br><span>         ENUM(name=AST_BOOL_NAME).drop(op.get_bind(), checkfirst=False)</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/11208">change 11208</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.asterisk.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.asterisk.org/c/asterisk/+/11208"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 13 </div>
<div style="display:none"> Gerrit-Change-Id: I7fdde0efa33ad91e761512bc2e2d0bab02cb6baf </div>
<div style="display:none"> Gerrit-Change-Number: 11208 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Benjamin Keith Ford <bford@digium.com> </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>