Squash database patches
Remove patches up to the Liberty release to speed up initial deployment and tests, as we don't support previous versions anymore. Closes-bug: #1633975 Change-Id: Icdab0db3f3371cd4eb8a8fb11cbc2328c0a830e7
This commit is contained in:
parent
39302b4776
commit
f9fe6abdf9
|
@ -1,25 +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.
|
||||
|
||||
import sqlalchemy
|
||||
|
||||
|
||||
def upgrade(migrate_engine):
|
||||
meta = sqlalchemy.MetaData()
|
||||
meta.bind = migrate_engine
|
||||
|
||||
resource = sqlalchemy.Table('resource', meta, autoload=True)
|
||||
properties_data_encrypted = sqlalchemy.Column('properties_data_encrypted',
|
||||
sqlalchemy.Boolean,
|
||||
default=False)
|
||||
properties_data_encrypted.create(resource)
|
|
@ -1,52 +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.
|
||||
|
||||
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'])
|
|
@ -31,9 +31,7 @@ def upgrade(migrate_engine):
|
|||
sqlalchemy.Column('template', types.LongText),
|
||||
sqlalchemy.Column('files', types.Json),
|
||||
sqlalchemy.Column('environment', types.Json),
|
||||
sqlalchemy.Column('predecessor', sqlalchemy.Integer,
|
||||
sqlalchemy.ForeignKey('raw_template.id',
|
||||
name='predecessor_fkey_ref')),
|
||||
|
||||
mysql_engine='InnoDB',
|
||||
mysql_charset='utf8'
|
||||
)
|
||||
|
@ -93,6 +91,7 @@ def upgrade(migrate_engine):
|
|||
sqlalchemy.Column('parent_resource_name', sqlalchemy.String(255)),
|
||||
sqlalchemy.Index('ix_stack_name', 'name', mysql_length=255),
|
||||
sqlalchemy.Index('ix_stack_tenant', 'tenant', mysql_length=255),
|
||||
|
||||
mysql_engine='InnoDB',
|
||||
mysql_charset='utf8'
|
||||
)
|
||||
|
@ -122,6 +121,13 @@ def upgrade(migrate_engine):
|
|||
sqlalchemy.Column('replaced_by', sqlalchemy.Integer),
|
||||
sqlalchemy.Column('current_template_id', sqlalchemy.Integer,
|
||||
sqlalchemy.ForeignKey('raw_template.id')),
|
||||
sqlalchemy.Column('properties_data_encrypted',
|
||||
sqlalchemy.Boolean,
|
||||
default=False),
|
||||
sqlalchemy.Column('root_stack_id', sqlalchemy.String(36)),
|
||||
sqlalchemy.Index('ix_resource_root_stack_id',
|
||||
'root_stack_id',
|
||||
mysql_length=36),
|
||||
mysql_engine='InnoDB',
|
||||
mysql_charset='utf8'
|
||||
)
|
|
@ -1,48 +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.
|
||||
|
||||
import sqlalchemy
|
||||
|
||||
|
||||
def upgrade(migrate_engine):
|
||||
meta = sqlalchemy.MetaData(bind=migrate_engine)
|
||||
|
||||
res_table = sqlalchemy.Table('resource', meta, autoload=True)
|
||||
stack_table = sqlalchemy.Table('stack', meta, autoload=True)
|
||||
root_stack_id = sqlalchemy.Column('root_stack_id',
|
||||
sqlalchemy.String(36))
|
||||
|
||||
root_stack_id.create(res_table)
|
||||
root_stack_idx = sqlalchemy.Index('ix_resource_root_stack_id',
|
||||
res_table.c.root_stack_id,
|
||||
mysql_length=36)
|
||||
root_stack_idx.create(migrate_engine)
|
||||
|
||||
# build stack->owner relationship for all stacks
|
||||
stmt = sqlalchemy.select([stack_table.c.id, stack_table.c.owner_id])
|
||||
stacks = migrate_engine.execute(stmt)
|
||||
parent_stacks = dict([(s.id, s.owner_id) for s in stacks])
|
||||
|
||||
def root_for_stack(stack_id):
|
||||
owner_id = parent_stacks.get(stack_id)
|
||||
if owner_id:
|
||||
return root_for_stack(owner_id)
|
||||
return stack_id
|
||||
|
||||
# for each stack, update the resources with the root_stack_id
|
||||
for stack_id, owner_id in parent_stacks.items():
|
||||
root_id = root_for_stack(stack_id)
|
||||
values = {'root_stack_id': root_id}
|
||||
update = res_table.update().where(
|
||||
res_table.c.stack_id == stack_id).values(values)
|
||||
migrate_engine.execute(update)
|
|
@ -16,7 +16,7 @@ import os
|
|||
from oslo_db.sqlalchemy import migration as oslo_migration
|
||||
|
||||
|
||||
INIT_VERSION = 61
|
||||
INIT_VERSION = 64
|
||||
|
||||
|
||||
def db_sync(engine, version=None):
|
||||
|
|
|
@ -688,59 +688,9 @@ class HeatMigrationsCheckers(test_migrations.WalkVersionsMixin,
|
|||
self.assertColumnNotExists(engine, 'raw_template',
|
||||
'predecessor')
|
||||
|
||||
def _pre_upgrade_065(self, engine):
|
||||
raw_template = utils.get_table(engine, 'raw_template')
|
||||
templ = []
|
||||
for i in range(960, 963, 1):
|
||||
t = dict(id=i, template='{}', files='{}')
|
||||
engine.execute(raw_template.insert(), [t])
|
||||
templ.append(t)
|
||||
|
||||
user_creds = utils.get_table(engine, 'user_creds')
|
||||
user = [dict(id=uid, username='test_user', password='password',
|
||||
tenant='test_project', auth_url='bla',
|
||||
tenant_id=str(uuid.uuid4()),
|
||||
trust_id='',
|
||||
trustor_user_id='') for uid in range(960, 963)]
|
||||
engine.execute(user_creds.insert(), user)
|
||||
|
||||
stack = utils.get_table(engine, 'stack')
|
||||
root_sid = '9a6a3ddb-2219-452c-8fec-a4977f8fe474'
|
||||
stack_ids = [(root_sid, 0, None),
|
||||
('b6a23bc2-cd4e-496f-be2e-c11d06124ea2', 1, root_sid),
|
||||
('7a927947-e004-4afa-8d11-62c1e049ecbd', 2, root_sid)]
|
||||
data = [dict(id=ll_id, name=ll_id,
|
||||
owner_id=owner_id,
|
||||
raw_template_id=templ[templ_id]['id'],
|
||||
user_creds_id=user[templ_id]['id'],
|
||||
username='test_user',
|
||||
disable_rollback=True,
|
||||
parameters='test_params',
|
||||
created_at=timeutils.utcnow(),
|
||||
deleted_at=None)
|
||||
for ll_id, templ_id, owner_id in stack_ids]
|
||||
|
||||
engine.execute(stack.insert(), data)
|
||||
|
||||
res_table = utils.get_table(engine, 'resource')
|
||||
resource_ids = [(960, root_sid),
|
||||
(961, 'b6a23bc2-cd4e-496f-be2e-c11d06124ea2'),
|
||||
(962, '7a927947-e004-4afa-8d11-62c1e049ecbd')]
|
||||
resources = [dict(id=rid, stack_id=sid)
|
||||
for rid, sid in resource_ids]
|
||||
engine.execute(res_table.insert(), resources)
|
||||
|
||||
def _check_065(self, engine, data):
|
||||
self.assertColumnExists(engine, 'resource', 'root_stack_id')
|
||||
res_table = utils.get_table(engine, 'resource')
|
||||
res_in_db = list(res_table.select().execute())
|
||||
self.assertTrue(len(res_in_db) >= 3)
|
||||
# confirm the resource.root_stack_id is set for all resources
|
||||
for r in res_in_db:
|
||||
self.assertTrue(r.root_stack_id is not None)
|
||||
if r.id >= 960 and r.id <= 962:
|
||||
root_stack_id = '9a6a3ddb-2219-452c-8fec-a4977f8fe474'
|
||||
self.assertEqual(root_stack_id, r.root_stack_id)
|
||||
self.assertIndexExists(engine, 'resource', 'ix_resource_root_stack_id')
|
||||
|
||||
def _check_071(self, engine, data):
|
||||
self.assertIndexExists(engine, 'stack', 'ix_stack_owner_id')
|
||||
|
|
Loading…
Reference in New Issue