Squash Havana migration scripts

Havana is not supported now (https://wiki.openstack.org/wiki/Releases),
and the db migration scripts take time to execute. This patch squash DB
migration scripts for Havana (aka. 2013.2).

Change-Id: I1f8843462bba4c5775840e68cf24c5ddba0cc2b8
Closes-Bug: 1420103
This commit is contained in:
tengqm 2015-05-28 02:12:22 -04:00
parent 60300b0149
commit 0ff728bc3a
16 changed files with 41 additions and 361 deletions

View File

@ -1,22 +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
stack = sqlalchemy.Table('stack', meta, autoload=True)
stack.c.timeout.alter(nullable=True)

View File

@ -1,26 +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
event = sqlalchemy.Table('event', meta, autoload=True)
# Currently there is a 'name' column which really holds the
# resource status, so rename it and add a separate action column
# action is e.g "CREATE" and status is e.g "IN_PROGRESS"
event.c.name.alter(name='resource_status')
sqlalchemy.Column('resource_action', sqlalchemy.String(255)).create(event)

View File

@ -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 uuid
import sqlalchemy
def upgrade(migrate_engine):
meta = sqlalchemy.MetaData(bind=migrate_engine)
resource = sqlalchemy.Table('resource', meta, autoload=True)
resource.c.id.alter(sqlalchemy.String(36), primary_key=True,
default=lambda: str(uuid.uuid4()))

View File

@ -1,27 +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)
resource = sqlalchemy.Table('resource', meta, autoload=True)
# Align the current state/state_description with the
# action/status now used in the event table
action = sqlalchemy.Column('action',
sqlalchemy.String(length=255))
action.create(resource)
resource.c.state.alter(name='status')
resource.c.state_description.alter(name='status_reason')

View File

@ -1,24 +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)
stack = sqlalchemy.Table('stack', meta, autoload=True)
# Align with action/status now used in the event/resource tables
action = sqlalchemy.Column('action',
sqlalchemy.String(length=255))
action.create(stack)

View File

@ -1,40 +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_data = sqlalchemy.Table(
'resource_data', meta,
sqlalchemy.Column('id',
sqlalchemy.Integer,
primary_key=True,
nullable=False),
sqlalchemy.Column('created_at', sqlalchemy.DateTime),
sqlalchemy.Column('updated_at', sqlalchemy.DateTime),
sqlalchemy.Column('key', sqlalchemy.String(255)),
sqlalchemy.Column('value', sqlalchemy.Text),
sqlalchemy.Column('redact', sqlalchemy.Boolean),
sqlalchemy.Column('resource_id',
sqlalchemy.String(36),
sqlalchemy.ForeignKey('resource.id'),
nullable=False),
mysql_engine='InnoDB',
mysql_charset='utf8'
)
sqlalchemy.Table('resource', meta, autoload=True)
resource_data.create()

View File

@ -1,21 +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)
stack = sqlalchemy.Table('stack', meta, autoload=True)
sqlalchemy.Column('deleted_at', sqlalchemy.DateTime).create(stack)

View File

@ -1,24 +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
from sqlalchemy.dialects import mysql
def upgrade(migrate_engine):
if migrate_engine.name != 'mysql':
return
meta = sqlalchemy.MetaData(bind=migrate_engine)
raw_template = sqlalchemy.Table('raw_template', meta, autoload=True)
raw_template.c.template.alter(type=mysql.LONGTEXT())

View File

@ -1,21 +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
event = sqlalchemy.Table('event', meta, autoload=True)
event.c.logical_resource_id.alter(name='resource_name')

View File

@ -1,23 +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)
user_creds = sqlalchemy.Table('user_creds', meta, autoload=True)
user_creds.c.service_user.drop()
user_creds.c.service_password.drop()

View File

@ -1,23 +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)
user_creds = sqlalchemy.Table('user_creds', meta, autoload=True)
user_creds.c.aws_creds.drop()
user_creds.c.aws_auth_url.drop()

View File

@ -1,29 +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)
user_creds = sqlalchemy.Table('user_creds', meta, autoload=True)
# keystone IDs are 32 characters long, but the keystone DB schema
# specifies varchar(64) so align with that here, for the trust_id
# we encrypt it, so align with the 255 chars allowed for password
trustor_user_id = sqlalchemy.Column('trustor_user_id',
sqlalchemy.String(length=64))
trust_id = sqlalchemy.Column('trust_id', sqlalchemy.String(length=255))
trustor_user_id.create(user_creds)
trust_id.create(user_creds)

View File

@ -11,8 +11,12 @@
# License for the specific language governing permissions and limitations
# under the License.
import uuid
import sqlalchemy
from heat.db.sqlalchemy import types
def upgrade(migrate_engine):
meta = sqlalchemy.MetaData()
@ -24,7 +28,7 @@ def upgrade(migrate_engine):
nullable=False),
sqlalchemy.Column('created_at', sqlalchemy.DateTime),
sqlalchemy.Column('updated_at', sqlalchemy.DateTime),
sqlalchemy.Column('template', sqlalchemy.Text),
sqlalchemy.Column('template', types.LongText),
mysql_engine='InnoDB',
mysql_charset='utf8'
)
@ -37,13 +41,11 @@ def upgrade(migrate_engine):
sqlalchemy.Column('updated_at', sqlalchemy.DateTime),
sqlalchemy.Column('username', sqlalchemy.String(255)),
sqlalchemy.Column('password', sqlalchemy.String(255)),
sqlalchemy.Column('service_user', sqlalchemy.String(255)),
sqlalchemy.Column('service_password', sqlalchemy.String(255)),
sqlalchemy.Column('tenant', sqlalchemy.String(1024)),
sqlalchemy.Column('auth_url', sqlalchemy.Text),
sqlalchemy.Column('aws_auth_url', sqlalchemy.Text),
sqlalchemy.Column('tenant_id', sqlalchemy.String(256)),
sqlalchemy.Column('aws_creds', sqlalchemy.Text),
sqlalchemy.Column('trust_id', sqlalchemy.String(255)),
sqlalchemy.Column('trustor_user_id', sqlalchemy.String(64)),
mysql_engine='InnoDB',
mysql_charset='utf8'
)
@ -54,6 +56,7 @@ def upgrade(migrate_engine):
primary_key=True, nullable=False),
sqlalchemy.Column('created_at', sqlalchemy.DateTime),
sqlalchemy.Column('updated_at', sqlalchemy.DateTime),
sqlalchemy.Column('deleted_at', sqlalchemy.DateTime),
sqlalchemy.Column('name', sqlalchemy.String(255)),
sqlalchemy.Column('raw_template_id',
sqlalchemy.Integer,
@ -64,10 +67,11 @@ def upgrade(migrate_engine):
nullable=False),
sqlalchemy.Column('username', sqlalchemy.String(256)),
sqlalchemy.Column('owner_id', sqlalchemy.String(36)),
sqlalchemy.Column('action', sqlalchemy.String(255)),
sqlalchemy.Column('status', sqlalchemy.String(255)),
sqlalchemy.Column('status_reason', sqlalchemy.String(255)),
sqlalchemy.Column('parameters', sqlalchemy.Text),
sqlalchemy.Column('timeout', sqlalchemy.Integer, nullable=False),
sqlalchemy.Column('parameters', types.LongText),
sqlalchemy.Column('timeout', sqlalchemy.Integer),
sqlalchemy.Column('tenant', sqlalchemy.String(256)),
sqlalchemy.Column('disable_rollback', sqlalchemy.Boolean,
nullable=False),
@ -77,17 +81,35 @@ def upgrade(migrate_engine):
resource = sqlalchemy.Table(
'resource', meta,
sqlalchemy.Column('id', sqlalchemy.Integer, primary_key=True,
nullable=False),
sqlalchemy.Column('id', sqlalchemy.String(36), primary_key=True,
default=lambda: str(uuid.uuid4())),
sqlalchemy.Column('nova_instance', sqlalchemy.String(255)),
sqlalchemy.Column('name', sqlalchemy.String(255)),
sqlalchemy.Column('created_at', sqlalchemy.DateTime),
sqlalchemy.Column('updated_at', sqlalchemy.DateTime),
sqlalchemy.Column('state', sqlalchemy.String(255)),
sqlalchemy.Column('state_description', sqlalchemy.String(255)),
sqlalchemy.Column('action', sqlalchemy.String(255)),
sqlalchemy.Column('status', sqlalchemy.String(255)),
sqlalchemy.Column('status_reason', sqlalchemy.String(255)),
sqlalchemy.Column('stack_id', sqlalchemy.String(36),
sqlalchemy.ForeignKey('stack.id'), nullable=False),
sqlalchemy.Column('rsrc_metadata', sqlalchemy.Text),
sqlalchemy.Column('rsrc_metadata', types.LongText),
mysql_engine='InnoDB',
mysql_charset='utf8'
)
resource_data = sqlalchemy.Table(
'resource_data', meta,
sqlalchemy.Column('id', sqlalchemy.Integer, primary_key=True,
nullable=False),
sqlalchemy.Column('created_at', sqlalchemy.DateTime),
sqlalchemy.Column('updated_at', sqlalchemy.DateTime),
sqlalchemy.Column('key', sqlalchemy.String(255)),
sqlalchemy.Column('value', sqlalchemy.Text),
sqlalchemy.Column('redact', sqlalchemy.Boolean),
sqlalchemy.Column('resource_id',
sqlalchemy.String(36),
sqlalchemy.ForeignKey('resource.id'),
nullable=False),
mysql_engine='InnoDB',
mysql_charset='utf8'
)
@ -100,8 +122,9 @@ def upgrade(migrate_engine):
sqlalchemy.ForeignKey('stack.id'), nullable=False),
sqlalchemy.Column('created_at', sqlalchemy.DateTime),
sqlalchemy.Column('updated_at', sqlalchemy.DateTime),
sqlalchemy.Column('name', sqlalchemy.String(255)),
sqlalchemy.Column('logical_resource_id', sqlalchemy.String(255)),
sqlalchemy.Column('resource_action', sqlalchemy.String(255)),
sqlalchemy.Column('resource_status', sqlalchemy.String(255)),
sqlalchemy.Column('resource_name', sqlalchemy.String(255)),
sqlalchemy.Column('physical_resource_id', sqlalchemy.String(255)),
sqlalchemy.Column('resource_status_reason', sqlalchemy.String(255)),
sqlalchemy.Column('resource_type', sqlalchemy.String(255)),
@ -118,7 +141,7 @@ def upgrade(migrate_engine):
sqlalchemy.Column('updated_at', sqlalchemy.DateTime),
sqlalchemy.Column('name', sqlalchemy.String(255)),
sqlalchemy.Column('state', sqlalchemy.String(255)),
sqlalchemy.Column('rule', sqlalchemy.Text),
sqlalchemy.Column('rule', types.LongText),
sqlalchemy.Column('last_evaluated', sqlalchemy.DateTime),
sqlalchemy.Column('stack_id', sqlalchemy.String(36),
sqlalchemy.ForeignKey('stack.id'), nullable=False),
@ -132,7 +155,7 @@ def upgrade(migrate_engine):
nullable=False),
sqlalchemy.Column('created_at', sqlalchemy.DateTime),
sqlalchemy.Column('updated_at', sqlalchemy.DateTime),
sqlalchemy.Column('data', sqlalchemy.Text),
sqlalchemy.Column('data', types.LongText),
sqlalchemy.Column('watch_rule_id', sqlalchemy.Integer,
sqlalchemy.ForeignKey('watch_rule.id'),
nullable=False),
@ -145,6 +168,7 @@ def upgrade(migrate_engine):
user_creds,
stack,
resource,
resource_data,
event,
watch_rule,
watch_data,

View File

@ -1,34 +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
from sqlalchemy.dialects import mysql
def upgrade(migrate_engine):
if migrate_engine.name != 'mysql':
return
meta = sqlalchemy.MetaData(bind=migrate_engine)
stack = sqlalchemy.Table('stack', meta, autoload=True)
stack.c.parameters.alter(type=mysql.LONGTEXT())
resource = sqlalchemy.Table('resource', meta, autoload=True)
resource.c.rsrc_metadata.alter(type=mysql.LONGTEXT())
watch_rule = sqlalchemy.Table('watch_rule', meta, autoload=True)
watch_rule.c.rule.alter(type=mysql.LONGTEXT())
watch_data = sqlalchemy.Table('watch_data', meta, autoload=True)
watch_data.c.data.alter(type=mysql.LONGTEXT())

View File

@ -145,11 +145,6 @@ def upgrade_resource(migrate_engine):
constraint_kwargs['name'] = 'uniq_resource0uuid0'
cons = constraint.UniqueConstraint('uuid', **constraint_kwargs)
cons.create()
if migrate_engine.name == 'postgresql':
# resource_id_seq will be dropped in the case of removing `id` column
# set owner to none for saving this sequence (it is needed in the
# earlier migration)
migrate_engine.execute('alter sequence resource_id_seq owned by none')
res_table.c.id.drop()

View File

@ -16,7 +16,7 @@ import os
from oslo_db.sqlalchemy import migration as oslo_migration
INIT_VERSION = 14
INIT_VERSION = 27
def db_sync(engine, version=None):