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
This commit is contained in:
wu.chunyang 2020-11-04 14:54:03 +08:00 committed by Adam Harwell
parent d2d5fc80f8
commit 53f8c28aa3
2 changed files with 40 additions and 1 deletions

View File

@ -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())

View File

@ -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