Merge "Following up patch of bbbe964ff4e19232ce3dd326fbd3f04f0781f5b1"
This commit is contained in:
commit
a8050e3d5c
@ -250,7 +250,6 @@ def upgrade():
|
|||||||
mysql_engine='InnoDB',
|
mysql_engine='InnoDB',
|
||||||
mysql_charset='utf8'
|
mysql_charset='utf8'
|
||||||
)
|
)
|
||||||
|
|
||||||
op.create_table(
|
op.create_table(
|
||||||
'server_group_member',
|
'server_group_member',
|
||||||
sa.Column('created_at', sa.DateTime(), nullable=True),
|
sa.Column('created_at', sa.DateTime(), nullable=True),
|
||||||
@ -263,3 +262,16 @@ def upgrade():
|
|||||||
mysql_engine='InnoDB',
|
mysql_engine='InnoDB',
|
||||||
mysql_charset='utf8'
|
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'
|
||||||
|
)
|
||||||
|
@ -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'
|
|
||||||
)
|
|
@ -245,21 +245,6 @@ class MigrationCheckersMixin(object):
|
|||||||
self.assertIsInstance(nodes.c.resource_name.type,
|
self.assertIsInstance(nodes.c.resource_name.type,
|
||||||
sqlalchemy.types.String)
|
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):
|
def test_upgrade_and_version(self):
|
||||||
with patch_with_engine(self.engine):
|
with patch_with_engine(self.engine):
|
||||||
self.migration_api.upgrade('head')
|
self.migration_api.upgrade('head')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user