Merge "Remove predecessor column from raw_template."

This commit is contained in:
Jenkins 2015-06-16 09:53:58 +00:00 committed by Gerrit Code Review
commit 25cff7933d
4 changed files with 56 additions and 3 deletions

View File

@ -0,0 +1,52 @@
#
# 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 migrate
import sqlalchemy
from heat.db.sqlalchemy import utils as migrate_utils
def upgrade(migrate_engine):
if migrate_engine.name == 'sqlite':
upgrade_sqlite(migrate_engine)
return
meta = sqlalchemy.MetaData()
meta.bind = migrate_engine
tmpl_table = sqlalchemy.Table('raw_template', meta, autoload=True)
# drop constraint
fkey = migrate.ForeignKeyConstraint(
columns=[tmpl_table.c.predecessor],
refcolumns=[tmpl_table.c.id],
name='predecessor_fkey_ref')
fkey.drop()
tmpl_table.c.predecessor.drop()
def upgrade_sqlite(migrate_engine):
meta = sqlalchemy.MetaData()
meta.bind = migrate_engine
tmpl_table = sqlalchemy.Table('raw_template', meta, autoload=True)
ignorecols = [tmpl_table.c.predecessor.name]
new_template = migrate_utils.clone_table('new_raw_template',
tmpl_table,
meta, ignorecols=ignorecols)
# migrate stacks to new table
migrate_utils.migrate_data(migrate_engine,
tmpl_table,
new_template,
skip_columns=['predecessor'])

View File

@ -99,8 +99,6 @@ class RawTemplate(BASE, HeatBase):
template = sqlalchemy.Column(types.Json)
files = sqlalchemy.Column(types.Json)
environment = sqlalchemy.Column('environment', types.Json)
predecessor = sqlalchemy.Column('predecessor', sqlalchemy.Integer,
sqlalchemy.ForeignKey('raw_template.id'))
class StackTag(BASE, HeatBase):

View File

@ -40,7 +40,6 @@ class RawTemplate(
'files': heat_fields.JsonField(nullable=True),
'template': heat_fields.JsonField(),
'environment': heat_fields.JsonField(),
'predecessor': fields.IntegerField(),
}
@staticmethod

View File

@ -613,6 +613,10 @@ class HeatMigrationsCheckers(test_migrations.WalkVersionsMixin,
self.assertColumnExists(engine, 'resource',
'properties_data_encrypted')
def _check_064(self, engine, data):
self.assertColumnNotExists(engine, 'raw_template',
'predecessor')
class TestHeatMigrationsMySQL(HeatMigrationsCheckers,
test_base.MySQLOpportunisticTestCase):