From 0668e5494a05b87b811033c139a58dfbc4a4c200 Mon Sep 17 00:00:00 2001 From: Mike Bradeen Date: Wed, 10 Jan 2024 09:47:24 -0700 Subject: [PATCH] app_voicemail_odbc: remove macrocontext from voicemail_messages table When app_macro was deprecated, the macrocontext column was removed from the INSERT statement but the binds were not renumbered. This broke the insert. This change removes the macrocontext column via alembic and re-numbers the existing columns in the INSERT. Fixes: #527 UserNote: The fix requires removing the macrocontext column from the voicemail_messages table in the voicemail database via alembic upgrade. UpgradeNote: The fix requires that the voicemail database be upgraded via alembic. Upgrading to the latest voicemail database via alembic will remove the macrocontext column from the voicemail_messages table. --- apps/app_voicemail.c | 16 +++++++------- .../1c55c341360f_remove_macrocontext_field.py | 22 +++++++++++++++++++ 2 files changed, 30 insertions(+), 8 deletions(-) create mode 100644 contrib/ast-db-manage/voicemail/versions/1c55c341360f_remove_macrocontext_field.py diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c index 2ffdd7674d..d4a5e96566 100644 --- a/apps/app_voicemail.c +++ b/apps/app_voicemail.c @@ -4404,15 +4404,15 @@ static SQLHSTMT insert_data_cb(struct odbc_obj *obj, void *vdata) SQLBindParameter(stmt, 2, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, strlen(data->msgnums), 0, (void *) data->msgnums, 0, NULL); SQLBindParameter(stmt, 3, SQL_PARAM_INPUT, SQL_C_BINARY, SQL_LONGVARBINARY, data->datalen, 0, (void *) data->data, data->datalen, &data->indlen); SQLBindParameter(stmt, 4, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, strlen(data->context), 0, (void *) data->context, 0, NULL); - SQLBindParameter(stmt, 6, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, strlen(data->callerid), 0, (void *) data->callerid, 0, NULL); - SQLBindParameter(stmt, 7, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, strlen(data->origtime), 0, (void *) data->origtime, 0, NULL); - SQLBindParameter(stmt, 8, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, strlen(data->duration), 0, (void *) data->duration, 0, NULL); - SQLBindParameter(stmt, 9, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, strlen(data->mailboxuser), 0, (void *) data->mailboxuser, 0, NULL); - SQLBindParameter(stmt, 10, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, strlen(data->mailboxcontext), 0, (void *) data->mailboxcontext, 0, NULL); - SQLBindParameter(stmt, 11, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, strlen(data->flag), 0, (void *) data->flag, 0, NULL); - SQLBindParameter(stmt, 12, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, strlen(data->msg_id), 0, (void *) data->msg_id, 0, NULL); + SQLBindParameter(stmt, 5, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, strlen(data->callerid), 0, (void *) data->callerid, 0, NULL); + SQLBindParameter(stmt, 6, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, strlen(data->origtime), 0, (void *) data->origtime, 0, NULL); + SQLBindParameter(stmt, 7, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, strlen(data->duration), 0, (void *) data->duration, 0, NULL); + SQLBindParameter(stmt, 8, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, strlen(data->mailboxuser), 0, (void *) data->mailboxuser, 0, NULL); + SQLBindParameter(stmt, 9, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, strlen(data->mailboxcontext), 0, (void *) data->mailboxcontext, 0, NULL); + SQLBindParameter(stmt, 10, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, strlen(data->flag), 0, (void *) data->flag, 0, NULL); + SQLBindParameter(stmt, 11, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, strlen(data->msg_id), 0, (void *) data->msg_id, 0, NULL); if (!ast_strlen_zero(data->category)) { - SQLBindParameter(stmt, 13, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, strlen(data->category), 0, (void *) data->category, 0, NULL); + SQLBindParameter(stmt, 12, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, strlen(data->category), 0, (void *) data->category, 0, NULL); } res = ast_odbc_execute_sql(obj, stmt, data->sql); if (!SQL_SUCCEEDED(res)) { diff --git a/contrib/ast-db-manage/voicemail/versions/1c55c341360f_remove_macrocontext_field.py b/contrib/ast-db-manage/voicemail/versions/1c55c341360f_remove_macrocontext_field.py new file mode 100644 index 0000000000..f845458bb3 --- /dev/null +++ b/contrib/ast-db-manage/voicemail/versions/1c55c341360f_remove_macrocontext_field.py @@ -0,0 +1,22 @@ +"""Remove macrocontext field + +Revision ID: 1c55c341360f +Revises: 39428242f7f5 +Create Date: 2024-01-09 15:01:39.698918 + +""" + +# revision identifiers, used by Alembic. +revision = '1c55c341360f' +down_revision = '39428242f7f5' + +from alembic import op +import sqlalchemy as sa + + +def upgrade(): + op.drop_column('voicemail_messages', 'macrocontext') + + +def downgrade(): + op.add_column('voicemail_messages', sa.Column('macrocontext', sa.String(80)))