From 05bd34d25bd816a50ef616ca07e276a11f3ba6d5 Mon Sep 17 00:00:00 2001 From: Ankur Rishi Date: Tue, 29 Apr 2014 13:53:34 -0700 Subject: [PATCH] Increase length of 'name' column in package table Cherry-picked from master When using mysql, we need to make sure that the name column is long enough to accomodate the package name. 'io.murano.lib.networks.Neutron' is more than 20 chars. Modify the schema to make it 80 chars Change-Id: I6f7154141ad4b728d98f436b2eaa839239ee302a Closes-Bug: #1314389 --- .../009_increase_package_name_length.py | 30 +++++++++++++++++++ muranoapi/db/models.py | 2 +- 2 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 muranoapi/db/migrate_repo/versions/009_increase_package_name_length.py diff --git a/muranoapi/db/migrate_repo/versions/009_increase_package_name_length.py b/muranoapi/db/migrate_repo/versions/009_increase_package_name_length.py new file mode 100644 index 000000000..d15a3d929 --- /dev/null +++ b/muranoapi/db/migrate_repo/versions/009_increase_package_name_length.py @@ -0,0 +1,30 @@ +# Copyright (c) 2014 Hewlett-Packard Development Company, L.P. +# +# 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. + +from sqlalchemy import schema +from sqlalchemy import types + +meta = schema.MetaData() + + +def upgrade(migrate_engine): + meta.bind = migrate_engine + table = schema.Table('package', meta, autoload=True) + table.c.name.alter(type=types.String(80)) + + +def downgrade(migrate_engine): + meta.bind = migrate_engine + table = schema.Table('package', meta, autoload=True) + table.c.name.alter(type=types.String(20)) diff --git a/muranoapi/db/models.py b/muranoapi/db/models.py index 2aeb0492c..89c0b5619 100644 --- a/muranoapi/db/models.py +++ b/muranoapi/db/models.py @@ -270,7 +270,7 @@ class Package(BASE, ModificationsTrackedObject): unique=True) type = sa.Column(sa.String(20), nullable=False, default='class') author = sa.Column(sa.String(80), default='Openstack') - name = sa.Column(sa.String(20), nullable=False) + name = sa.Column(sa.String(80), nullable=False) enabled = sa.Column(sa.Boolean, default=True) description = sa.Column(sa.String(512), nullable=False,