diff options
author | Anant Patil <anant.patil@hp.com> | 2015-06-11 14:19:26 +0530 |
---|---|---|
committer | Anant Patil <anant.patil@hp.com> | 2015-06-11 14:36:11 +0530 |
commit | 9c64482eb51fd675097d7f4d3daac89429197e91 (patch) | |
tree | 6994b59081290ed0f45c22f3a648d03d2a98591c /heat/db/sqlalchemy/migrate_repo | |
parent | 1b44bf806a5475b5d35febe58c0aacbc92dcd4c5 (diff) | |
download | heat-9c64482eb51fd675097d7f4d3daac89429197e91.tar.gz |
Remove predecessor column from raw_template.
This column is never used. The logic to retrieve the previous template
for rollback is based on stack table's prev_template_id.
Change-Id: Ib0af21502d0cc94613b3963d6ccdeffbc8103f6b
Diffstat (limited to 'heat/db/sqlalchemy/migrate_repo')
-rw-r--r-- | heat/db/sqlalchemy/migrate_repo/versions/064_raw_template_predecessor.py | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/heat/db/sqlalchemy/migrate_repo/versions/064_raw_template_predecessor.py b/heat/db/sqlalchemy/migrate_repo/versions/064_raw_template_predecessor.py new file mode 100644 index 000000000..984a15252 --- /dev/null +++ b/heat/db/sqlalchemy/migrate_repo/versions/064_raw_template_predecessor.py @@ -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']) |