DB downgrade from 7.0 to 6.1 fixed
Tests for downgrading added. Alembic migration file for 7.0 fixed. Change-Id: I333e832b0eaef9e6214d86949c9035206c409770 Closes-Bug: #1471792
This commit is contained in:
parent
969076b8cb
commit
087f14e450
|
@ -67,14 +67,16 @@ task_names_new = consts.TASK_NAMES
|
|||
|
||||
def upgrade():
|
||||
op.create_foreign_key(
|
||||
None, 'network_groups', 'nodegroups', ['group_id'], ['id'])
|
||||
'network_groups_nodegroups_fk', 'network_groups', 'nodegroups',
|
||||
['group_id'], ['id'])
|
||||
op.create_foreign_key(
|
||||
None, 'nodes', 'nodegroups', ['group_id'], ['id'])
|
||||
'nodes_nodegroups_fk', 'nodes', 'nodegroups', ['group_id'], ['id'])
|
||||
op.alter_column(
|
||||
'oswl_stats', 'resource_checksum', existing_type=sa.TEXT(),
|
||||
nullable=False)
|
||||
op.create_unique_constraint(
|
||||
None, 'oswl_stats', ['cluster_id', 'created_date', 'resource_type'])
|
||||
'oswl_stats_cluster_id_created_date_resource_type_unique_key',
|
||||
'oswl_stats', ['cluster_id', 'created_date', 'resource_type'])
|
||||
|
||||
extend_ip_addrs_model_upgrade()
|
||||
extend_node_model_upgrade()
|
||||
|
@ -101,12 +103,15 @@ def downgrade():
|
|||
downgrade_task_names()
|
||||
vms_conf_downgrade()
|
||||
|
||||
op.drop_constraint(None, 'oswl_stats', type_='unique')
|
||||
op.drop_constraint(
|
||||
'oswl_stats_cluster_id_created_date_resource_type_unique_key',
|
||||
'oswl_stats', type_='unique')
|
||||
op.alter_column(
|
||||
'oswl_stats', 'resource_checksum', existing_type=sa.TEXT(),
|
||||
nullable=True)
|
||||
op.drop_constraint(None, 'nodes', type_='foreignkey')
|
||||
op.drop_constraint(None, 'network_groups', type_='foreignkey')
|
||||
op.drop_constraint('nodes_nodegroups_fk', 'nodes', type_='foreignkey')
|
||||
op.drop_constraint('network_groups_nodegroups_fk', 'network_groups',
|
||||
type_='foreignkey')
|
||||
|
||||
|
||||
def extend_node_model_upgrade():
|
||||
|
@ -225,7 +230,9 @@ def extend_ip_addrs_model_downgrade():
|
|||
vrouter_enum = sa.Enum('haproxy', 'vrouter',
|
||||
name='network_vip_types')
|
||||
vrouter_enum.create(op.get_bind(), checkfirst=False)
|
||||
op.alter_column('ip_addrs', 'vip_type', type_=vrouter_enum)
|
||||
op.execute('ALTER TABLE ip_addrs ALTER COLUMN vip_type '
|
||||
'TYPE network_vip_types '
|
||||
'USING vip_type::text::network_vip_types')
|
||||
|
||||
|
||||
def extend_releases_model_upgrade():
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
# Copyright 2015 Mirantis, Inc.
|
||||
#
|
||||
# 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.
|
||||
|
||||
|
||||
import alembic
|
||||
|
||||
from nailgun.db import dropdb
|
||||
from nailgun.db.migration import ALEMBIC_CONFIG
|
||||
from nailgun.test import base
|
||||
|
||||
|
||||
class TestDbMigrations(base.BaseTestCase):
|
||||
|
||||
def test_clean_downgrade(self):
|
||||
# We don't have data migration for clusters with vip_type 'ovs'
|
||||
# so checking migration only for clean DB
|
||||
dropdb()
|
||||
alembic.command.upgrade(ALEMBIC_CONFIG, 'head')
|
||||
alembic.command.downgrade(ALEMBIC_CONFIG, 'base')
|
Loading…
Reference in New Issue