Following up patch of bbbe964ff4

This merges db migrations file into one, will not add new migration
scrips until we are offical.

Change-Id: Ibd70c05e42a6b8ad63f3818e385bc347b9ff8afa
This commit is contained in:
Zhenguo Niu 2017-10-28 15:34:12 +08:00
parent b7a9018cb3
commit d5d480d1e6
3 changed files with 13 additions and 59 deletions

View File

@ -250,7 +250,6 @@ def upgrade():
mysql_engine='InnoDB',
mysql_charset='utf8'
)
op.create_table(
'server_group_member',
sa.Column('created_at', sa.DateTime(), nullable=True),
@ -263,3 +262,16 @@ def upgrade():
mysql_engine='InnoDB',
mysql_charset='utf8'
)
op.create_table(
'server_tags',
sa.Column('created_at', sa.DateTime(), nullable=True),
sa.Column('updated_at', sa.DateTime(), nullable=True),
sa.Column('server_id', sa.Integer(), nullable=False),
sa.Column('tag', sa.String(length=255), nullable=False),
sa.PrimaryKeyConstraint('server_id', 'tag'),
sa.ForeignKeyConstraint(['server_id'],
['servers.id']),
sa.Index('server_tags_tag_idx', 'tag'),
mysql_ENGINE='InnoDB',
mysql_DEFAULT_CHARSET='UTF8'
)

View File

@ -1,43 +0,0 @@
#
# 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.
"""add server tags
Revision ID: cf73c09d3ff2
Revises: 0de89f877016
Create Date: 2017-09-21 04:11:09.636891
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = 'cf73c09d3ff2'
down_revision = '91941bf1ebc9'
def upgrade():
op.create_table(
'server_tags',
sa.Column('created_at', sa.DateTime(), nullable=True),
sa.Column('updated_at', sa.DateTime(), nullable=True),
sa.Column('server_id', sa.Integer(), nullable=False),
sa.Column('tag', sa.String(length=255), nullable=False),
sa.PrimaryKeyConstraint('server_id', 'tag'),
sa.ForeignKeyConstraint(['server_id'],
['servers.id']),
sa.Index('server_tags_tag_idx', 'tag'),
mysql_ENGINE='InnoDB',
mysql_DEFAULT_CHARSET='UTF8'
)

View File

@ -245,21 +245,6 @@ class MigrationCheckersMixin(object):
self.assertIsInstance(nodes.c.resource_name.type,
sqlalchemy.types.String)
def _check_cf73c09d3ff2(self, engine, data):
server_tags = db_utils.get_table(engine, 'server_tags')
col_names = [column.name for column in server_tags.c]
self.assertIn('tag', col_names)
self.assertIsInstance(server_tags.c.tag.type,
sqlalchemy.types.String)
servers = db_utils.get_table(engine, 'servers')
data = {'id': '123', 'name': 'server1'}
servers.insert().execute(data)
data = {'server_id': '123', 'tag': 'tag1'}
server_tags.insert().execute(data)
tag = server_tags.select(server_tags.c.server_id == '123').execute().\
first()
self.assertEqual('tag1', tag['tag'])
def test_upgrade_and_version(self):
with patch_with_engine(self.engine):
self.migration_api.upgrade('head')