[Asterisk-code-review] alembic: Fix downgrade and tweak for sqlite (asterisk[master])
George Joseph
asteriskteam at digium.com
Wed Mar 2 16:43:02 CST 2016
Hello Kevin Harwell, Anonymous Coward #1000019,
I'd like you to reexamine a change. Please visit
https://gerrit.asterisk.org/2328
to look at the new patch set (#2).
Change subject: alembic: Fix downgrade and tweak for sqlite
......................................................................
alembic: Fix downgrade and tweak for sqlite
Downgrade had a few issues. First there was an errant 'update' statement in
add_auto_dtmf_mode that looks like it was a copy/paste error. Second, we
weren't cleaning up the ENUMs so subsequent upgrades on postgres failed
because the types already existed.
For sqlite... sqlite doesn't support ALTER or DROP COLUMN directly.
Fortunately alembic batch_operations takes care of this for us if we
use it so the alter and drops were converted to use batch operations.
Here's an example downgrade:
with op.batch_alter_table('ps_endpoints') as batch_op:
batch_op.drop_column('tos_audio')
batch_op.drop_column('tos_video')
batch_op.add_column(sa.Column('tos_audio', yesno_values))
batch_op.add_column(sa.Column('tos_video', yesno_values))
batch_op.drop_column('cos_audio')
batch_op.drop_column('cos_video')
batch_op.add_column(sa.Column('cos_audio', yesno_values))
batch_op.add_column(sa.Column('cos_video', yesno_values))
with op.batch_alter_table('ps_transports') as batch_op:
batch_op.drop_column('tos')
batch_op.add_column(sa.Column('tos', yesno_values))
# Can't cast integers to YESNO_VALUES, so dropping and adding is required
batch_op.drop_column('cos')
batch_op.add_column(sa.Column('cos', yesno_values))
Upgrades from base to head and downgrades from head to base were tested
repeatedly for postgresql, mysql/mariadb, and sqlite3.
Change-Id: I862b0739eb3fd45ec3412dcc13c2340e1b7baef8
---
M contrib/ast-db-manage/config/env.py
M contrib/ast-db-manage/config/versions/10aedae86a32_add_outgoing_enum_va.py
M contrib/ast-db-manage/config/versions/136885b81223_add_regcontext_to_pj.py
M contrib/ast-db-manage/config/versions/154177371065_add_default_from_user.py
M contrib/ast-db-manage/config/versions/15b1430ad6f1_add_moh_passthrough_option_to_pjsip.py
M contrib/ast-db-manage/config/versions/1758e8bbf6b_increase_useragent_column_size.py
M contrib/ast-db-manage/config/versions/189a235b3fd7_add_keep_alive_interval.py
M contrib/ast-db-manage/config/versions/1d50859ed02e_create_accountcode.py
M contrib/ast-db-manage/config/versions/21e526ad3040_add_pjsip_debug_option.py
M contrib/ast-db-manage/config/versions/23530d604b96_add_rpid_immediate.py
M contrib/ast-db-manage/config/versions/26d7f3bf0fa5_add_bind_rtp_to_media_address_to_pjsip.py
M contrib/ast-db-manage/config/versions/26f10cadc157_add_pjsip_timeout_options.py
M contrib/ast-db-manage/config/versions/28b8e71e541f_add_g726_non_standard.py
M contrib/ast-db-manage/config/versions/28ce1e718f05_add_fatal_response_interval.py
M contrib/ast-db-manage/config/versions/2d078ec071b7_increaes_contact_column_size.py
M contrib/ast-db-manage/config/versions/2fc7930b41b3_add_pjsip_endpoint_options_for_12_1.py
M contrib/ast-db-manage/config/versions/31cd4f4891ec_add_auto_dtmf_mode.py
M contrib/ast-db-manage/config/versions/339a3bdf53fc_expand_accountcode_to_80.py
M contrib/ast-db-manage/config/versions/371a3bf4143e_add_user_eq_phone_option_to_pjsip.py
M contrib/ast-db-manage/config/versions/3855ee4e5f85_add_missing_pjsip_options.py
M contrib/ast-db-manage/config/versions/3bcc0b5bc2c9_add_allow_reload_to_ps_transports.py
M contrib/ast-db-manage/config/versions/423f34ad36e2_fix_pjsip_qualify_ti.py
M contrib/ast-db-manage/config/versions/43956d550a44_add_tables_for_pjsip.py
M contrib/ast-db-manage/config/versions/45e3f47c6c44_add_pjsip_endpoint_identifier_order.py
M contrib/ast-db-manage/config/versions/461d7d691209_add_pjsip_qualify_timeout.py
M contrib/ast-db-manage/config/versions/498357a710ae_add_rtp_keepalive.py
M contrib/ast-db-manage/config/versions/4c573e7135bd_fix_tos_field_types.py
M contrib/ast-db-manage/config/versions/4da0c5f79a9c_create_tables.py
M contrib/ast-db-manage/config/versions/5139253c0423_make_q_member_uniqueid_autoinc.py
M contrib/ast-db-manage/config/versions/51f8cb66540e_add_further_dtls_options.py
M contrib/ast-db-manage/config/versions/5950038a6ead_fix_pjsip_verifiy_typo.py
M contrib/ast-db-manage/config/versions/945b1098bdd_add_media_encryption_optimistic_to_pjsip.py
M contrib/ast-db-manage/config/versions/a541e0b5e89_add_pjsip_max_initial_qualify_time.py
M contrib/ast-db-manage/config/versions/dbc44d5a908_add_missing_columns_to_sys_and_reg.py
M contrib/ast-db-manage/config/versions/e96a0b8071c_increase_pjsip_column_size.py
35 files changed, 206 insertions(+), 136 deletions(-)
git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/28/2328/2
--
To view, visit https://gerrit.asterisk.org/2328
To unsubscribe, visit https://gerrit.asterisk.org/settings
Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I862b0739eb3fd45ec3412dcc13c2340e1b7baef8
Gerrit-PatchSet: 2
Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Owner: George Joseph <george.joseph at fairview5.com>
Gerrit-Reviewer: Anonymous Coward #1000019
Gerrit-Reviewer: Kevin Harwell <kharwell at digium.com>
More information about the asterisk-code-review
mailing list