Extend status_description column in Clusters tables
Convert column type to * Text for psql - unlimited size * LongText for mysql - max size 2^32 Also fixed template for autogenerated migrations: added a blank line to avoid pep8 violation. Closes-Bug: #1338933 Change-Id: Ie4c4f57aeb7ff03aa7f6077629f6463a136f8f4b
This commit is contained in:
parent
0a31b16cd5
commit
a9d5f92c22
@ -29,6 +29,7 @@ from alembic import op
|
||||
import sqlalchemy as sa
|
||||
${imports if imports else ""}
|
||||
|
||||
|
||||
def upgrade():
|
||||
${upgrades if upgrades else "pass"}
|
||||
|
||||
|
@ -0,0 +1,43 @@
|
||||
# Copyright 2014 OpenStack Foundation.
|
||||
#
|
||||
# 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.
|
||||
|
||||
"""convert clusters.status_description to LongText
|
||||
|
||||
Revision ID: 007
|
||||
Revises: 006
|
||||
Create Date: 2014-06-20 22:36:00.783444
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '007'
|
||||
down_revision = '006'
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
from sahara.db.sqlalchemy import types as st
|
||||
|
||||
|
||||
def upgrade():
|
||||
op.alter_column('clusters', 'status_description',
|
||||
type_=st.LongText(), existing_nullable=True,
|
||||
existing_server_default=None)
|
||||
|
||||
|
||||
def downgrade():
|
||||
op.alter_column('clusters', 'status_description',
|
||||
type_=sa.String(length=200), existing_nullable=True,
|
||||
existing_server_default=None)
|
@ -62,7 +62,7 @@ class Cluster(mb.SaharaBase):
|
||||
management_public_key = sa.Column(sa.Text, nullable=False)
|
||||
user_keypair_id = sa.Column(sa.String(80))
|
||||
status = sa.Column(sa.String(80))
|
||||
status_description = sa.Column(sa.String(200))
|
||||
status_description = sa.Column(st.LongText())
|
||||
info = sa.Column(st.JsonDictType())
|
||||
extra = sa.Column(st.JsonDictType())
|
||||
node_groups = relationship('NodeGroup', cascade="all,delete",
|
||||
|
@ -116,3 +116,9 @@ def LargeBinary():
|
||||
if base.is_mysql_avail():
|
||||
return mysql.LONGBLOB
|
||||
return sa.LargeBinary
|
||||
|
||||
|
||||
def LongText():
|
||||
if base.is_mysql_avail():
|
||||
return mysql.LONGTEXT
|
||||
return sa.Text
|
||||
|
@ -355,3 +355,17 @@ class TestMigrations(base.BaseWalkMigrationTestCase, base.CommonTestsMixIn):
|
||||
def _check_006(self, engine, data):
|
||||
# currently, 006 is just a placeholder
|
||||
self._check_001(engine, data)
|
||||
|
||||
def _check_007(self, engine, data):
|
||||
self._check_001(engine, data)
|
||||
|
||||
# check that status_description can keep 128kb.
|
||||
# MySQL varchar can not keep more then 64kb
|
||||
desc = 'a' * 128 * 1024 # 128kb
|
||||
t = db_utils.get_table(engine, 'clusters')
|
||||
engine.execute(t.insert(), id='123', name='name', plugin_name='plname',
|
||||
hadoop_version='hversion', management_private_key='1',
|
||||
management_public_key='2', status_description=desc)
|
||||
new_desc = engine.execute(t.select()).fetchone().status_description
|
||||
self.assertEqual(desc, new_desc)
|
||||
engine.execute(t.delete())
|
||||
|
Loading…
Reference in New Issue
Block a user