Browse Source

Squash database patches

Remove patches up to the Newton release to speed up
initial deployment and tests, as we don't support
previous versions anymore.

Depends-On: https://review.opendev.org/686996
Change-Id: I49129d926c0ea3d613a4ab698cbeb46c06547813
changes/92/496192/7
ricolin 2 years ago
parent
commit
c3344970d5

+ 0
- 40
heat/db/sqlalchemy/migrate_repo/versions/072_raw_template_files.py 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

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)

heat/db/sqlalchemy/migrate_repo/versions/071_mitaka.py → heat/db/sqlalchemy/migrate_repo/versions/073_newton.py View File

@@ -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,

+ 0
- 44
heat/db/sqlalchemy/migrate_repo/versions/073_resource_data_fk_ondelete_cascade.py View File

@@ -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

+ 1
- 1
heat/db/sqlalchemy/migration.py View File

@@ -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…
Cancel
Save