Merge "Squash database patches"
This commit is contained in:
commit
244a53d13e
|
@ -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
|
||||
|
||||
from heat.db.sqlalchemy import types
|
||||
|
||||
|
||||
def upgrade(migrate_engine):
|
||||
meta = sqlalchemy.MetaData(bind=migrate_engine)
|
||||
raw_template_files = sqlalchemy.Table(
|
||||
'raw_template_files', meta,
|
||||
sqlalchemy.Column('id', sqlalchemy.Integer,
|
||||
primary_key=True,
|
||||
nullable=False),
|
||||
sqlalchemy.Column('files', types.Json),
|
||||
sqlalchemy.Column('created_at', sqlalchemy.DateTime),
|
||||
sqlalchemy.Column('updated_at', sqlalchemy.DateTime),
|
||||
mysql_engine='InnoDB',
|
||||
mysql_charset='utf8'
|
||||
|
||||
)
|
||||
raw_template_files.create()
|
||||
|
||||
raw_template = sqlalchemy.Table('raw_template', meta, autoload=True)
|
||||
files_id = sqlalchemy.Column(
|
||||
'files_id', sqlalchemy.Integer(),
|
||||
sqlalchemy.ForeignKey('raw_template_files.id',
|
||||
name='raw_tmpl_files_fkey_ref'))
|
||||
files_id.create(raw_template)
|
|
@ -22,6 +22,18 @@ def upgrade(migrate_engine):
|
|||
meta = sqlalchemy.MetaData()
|
||||
meta.bind = migrate_engine
|
||||
|
||||
raw_template_files = sqlalchemy.Table(
|
||||
'raw_template_files', meta,
|
||||
sqlalchemy.Column('id', sqlalchemy.Integer,
|
||||
primary_key=True,
|
||||
nullable=False),
|
||||
sqlalchemy.Column('files', types.Json),
|
||||
sqlalchemy.Column('created_at', sqlalchemy.DateTime),
|
||||
sqlalchemy.Column('updated_at', sqlalchemy.DateTime),
|
||||
mysql_engine='InnoDB',
|
||||
mysql_charset='utf8'
|
||||
)
|
||||
|
||||
raw_template = sqlalchemy.Table(
|
||||
'raw_template', meta,
|
||||
sqlalchemy.Column('id', sqlalchemy.Integer, primary_key=True,
|
||||
|
@ -31,7 +43,10 @@ def upgrade(migrate_engine):
|
|||
sqlalchemy.Column('template', types.LongText),
|
||||
sqlalchemy.Column('files', types.Json),
|
||||
sqlalchemy.Column('environment', types.Json),
|
||||
|
||||
sqlalchemy.Column('files_id', sqlalchemy.Integer(),
|
||||
sqlalchemy.ForeignKey(
|
||||
'raw_template_files.id',
|
||||
name='raw_tmpl_files_fkey_ref')),
|
||||
mysql_engine='InnoDB',
|
||||
mysql_charset='utf8'
|
||||
)
|
||||
|
@ -145,7 +160,9 @@ def upgrade(migrate_engine):
|
|||
sqlalchemy.Column('decrypt_method', sqlalchemy.String(length=64)),
|
||||
sqlalchemy.Column('resource_id',
|
||||
sqlalchemy.Integer,
|
||||
sqlalchemy.ForeignKey('resource.id'),
|
||||
sqlalchemy.ForeignKey('resource.id',
|
||||
name='fk_resource_id',
|
||||
ondelete='CASCADE'),
|
||||
nullable=False),
|
||||
mysql_engine='InnoDB',
|
||||
mysql_charset='utf8'
|
||||
|
@ -342,6 +359,7 @@ def upgrade(migrate_engine):
|
|||
)
|
||||
|
||||
tables = (
|
||||
raw_template_files,
|
||||
raw_template,
|
||||
user_creds,
|
||||
stack,
|
|
@ -1,44 +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.
|
||||
|
||||
# This is a placeholder for Liberty backports.
|
||||
# Do not use this number for new Mitaka work. New Mitaka work starts after
|
||||
# all the placeholders.
|
||||
|
||||
|
||||
import sqlalchemy
|
||||
|
||||
from migrate import ForeignKeyConstraint
|
||||
|
||||
|
||||
def upgrade(migrate_engine):
|
||||
meta = sqlalchemy.MetaData()
|
||||
meta.bind = migrate_engine
|
||||
|
||||
resource_data = sqlalchemy.Table('resource_data', meta, autoload=True)
|
||||
resource = sqlalchemy.Table('resource', meta, autoload=True)
|
||||
|
||||
for fk in resource_data.foreign_keys:
|
||||
if fk.column == resource.c.id:
|
||||
# delete the existing fk
|
||||
# and create with ondelete cascade and a proper name
|
||||
existing_fkey = ForeignKeyConstraint(
|
||||
columns=[resource_data.c.resource_id],
|
||||
refcolumns=[resource.c.id], name=fk.name)
|
||||
existing_fkey.drop()
|
||||
fkey = ForeignKeyConstraint(
|
||||
columns=[resource_data.c.resource_id],
|
||||
refcolumns=[resource.c.id],
|
||||
name="fk_resource_id", ondelete='CASCADE')
|
||||
fkey.create()
|
||||
break
|
|
@ -16,7 +16,7 @@ import os
|
|||
from oslo_db.sqlalchemy import migration as oslo_migration
|
||||
|
||||
|
||||
INIT_VERSION = 70
|
||||
INIT_VERSION = 72
|
||||
|
||||
|
||||
def db_sync(engine, version=None):
|
||||
|
|
Loading…
Reference in New Issue