From 53f8c28aa3fadc0feaaad9d073f006dc36a39b7a Mon Sep 17 00:00:00 2001 From: "wu.chunyang" Date: Wed, 4 Nov 2020 14:54:03 +0800 Subject: [PATCH] Add default value for enabled column in l7rule table we don't set default value for enabled column now, and mysql will fill them with 0 value(false) if we upgrade from ocata or ealier, all l7rules is disabled. so they will not render to haproxy config file in amphora. this will cause all l7rules stop work after a update. Change-Id: Ib8549d71b7adb95d0dcb36903c1744190056adae --- ...e7_update_default_value_in_l7rule_table.py | 37 +++++++++++++++++++ .../versions/d85ca7258d21_modernize_l7rule.py | 4 +- 2 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 octavia/db/migration/alembic_migrations/versions/b8bd389cbae7_update_default_value_in_l7rule_table.py diff --git a/octavia/db/migration/alembic_migrations/versions/b8bd389cbae7_update_default_value_in_l7rule_table.py b/octavia/db/migration/alembic_migrations/versions/b8bd389cbae7_update_default_value_in_l7rule_table.py new file mode 100644 index 0000000000..ba5614e42f --- /dev/null +++ b/octavia/db/migration/alembic_migrations/versions/b8bd389cbae7_update_default_value_in_l7rule_table.py @@ -0,0 +1,37 @@ +# Copyright 2020 Yovole +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +# + +"""update default value in l7rule table + +Revision ID: b8bd389cbae7 +Revises: 8b47b2546312 +Create Date: 2020-12-03 13:40:00.520336 + +""" + +from alembic import op +import sqlalchemy as sa + +# revision identifiers, used by Alembic. +revision = 'b8bd389cbae7' +down_revision = 'be9fdc039b51' + + +def upgrade(): + op.alter_column( + 'l7rule', + 'enabled', + existing_nullable=False, + server_default=sa.sql.expression.true()) diff --git a/octavia/db/migration/alembic_migrations/versions/d85ca7258d21_modernize_l7rule.py b/octavia/db/migration/alembic_migrations/versions/d85ca7258d21_modernize_l7rule.py index 3a0f6244bd..11e91ed5ae 100644 --- a/octavia/db/migration/alembic_migrations/versions/d85ca7258d21_modernize_l7rule.py +++ b/octavia/db/migration/alembic_migrations/versions/d85ca7258d21_modernize_l7rule.py @@ -50,7 +50,9 @@ def upgrade(): # Add enabled op.add_column( u'l7rule', - sa.Column(u'enabled', sa.Boolean(), nullable=False) + sa.Column(u'enabled', sa.Boolean(), + server_default=sa.sql.expression.true(), + nullable=False) ) # Add new operating_status column, setting existing rows to ONLINE