Merge "Change autogenerate to be unconditional"
This commit is contained in:
commit
4a8b1d42ce
@ -22,8 +22,8 @@ from oslo.db.sqlalchemy import session
|
|||||||
import sqlalchemy as sa
|
import sqlalchemy as sa
|
||||||
from sqlalchemy import event
|
from sqlalchemy import event
|
||||||
|
|
||||||
|
from neutron.db.migration.models import head # noqa
|
||||||
from neutron.db import model_base
|
from neutron.db import model_base
|
||||||
from neutron.openstack.common import importutils
|
|
||||||
|
|
||||||
|
|
||||||
MYSQL_ENGINE = None
|
MYSQL_ENGINE = None
|
||||||
@ -41,9 +41,6 @@ plugin_class_path = neutron_config.core_plugin
|
|||||||
active_plugins = [plugin_class_path]
|
active_plugins = [plugin_class_path]
|
||||||
active_plugins += neutron_config.service_plugins
|
active_plugins += neutron_config.service_plugins
|
||||||
|
|
||||||
for class_path in active_plugins:
|
|
||||||
importutils.import_class(class_path)
|
|
||||||
|
|
||||||
# set the target for 'autogenerate' support
|
# set the target for 'autogenerate' support
|
||||||
target_metadata = model_base.BASEV2.metadata
|
target_metadata = model_base.BASEV2.metadata
|
||||||
|
|
||||||
|
@ -25,28 +25,14 @@ Create Date: ${create_date}
|
|||||||
revision = ${repr(up_revision)}
|
revision = ${repr(up_revision)}
|
||||||
down_revision = ${repr(down_revision)}
|
down_revision = ${repr(down_revision)}
|
||||||
|
|
||||||
# Change to ['*'] if this migration applies to all plugins
|
|
||||||
|
|
||||||
migration_for_plugins = [
|
|
||||||
'${config.neutron_config.core_plugin}'
|
|
||||||
]
|
|
||||||
|
|
||||||
from alembic import op
|
from alembic import op
|
||||||
import sqlalchemy as sa
|
import sqlalchemy as sa
|
||||||
${imports if imports else ""}
|
${imports if imports else ""}
|
||||||
|
|
||||||
from neutron.db import migration
|
|
||||||
|
|
||||||
|
|
||||||
def upgrade(active_plugins=None, options=None):
|
def upgrade(active_plugins=None, options=None):
|
||||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
|
||||||
return
|
|
||||||
|
|
||||||
${upgrades if upgrades else "pass"}
|
${upgrades if upgrades else "pass"}
|
||||||
|
|
||||||
|
|
||||||
def downgrade(active_plugins=None, options=None):
|
def downgrade(active_plugins=None, options=None):
|
||||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
|
||||||
return
|
|
||||||
|
|
||||||
${downgrades if downgrades else "pass"}
|
${downgrades if downgrades else "pass"}
|
||||||
|
@ -0,0 +1,45 @@
|
|||||||
|
# Copyright 2014 OpenStack Foundation
|
||||||
|
#
|
||||||
|
# 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.
|
||||||
|
#
|
||||||
|
|
||||||
|
"""Drop unused servicedefinitions and servicetypes tables.
|
||||||
|
|
||||||
|
These tables are created independently on plugins but only dropped if
|
||||||
|
LoadBalancer plugin is used. Meaning that if LoadBalancer plugin is not set
|
||||||
|
then these tables were created and never used.
|
||||||
|
|
||||||
|
Revision ID: 3b85b693a95f
|
||||||
|
Revises: 327ee5fde2c7
|
||||||
|
Create Date: 2014-07-22 03:30:05.837152
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
# revision identifiers, used by Alembic.
|
||||||
|
revision = '3b85b693a95f'
|
||||||
|
down_revision = '327ee5fde2c7'
|
||||||
|
|
||||||
|
from alembic import op
|
||||||
|
|
||||||
|
|
||||||
|
def upgrade(active_plugins=None, options=None):
|
||||||
|
for table in ('servicedefinitions', 'servicetypes'):
|
||||||
|
op.execute("DROP TABLE IF EXISTS %s" % table)
|
||||||
|
|
||||||
|
|
||||||
|
def downgrade(active_plugins=None, options=None):
|
||||||
|
"""Don't create the tables
|
||||||
|
|
||||||
|
These tables would be created during downgrade at correct place in
|
||||||
|
migration timeline at revision 557edfc53098.
|
||||||
|
"""
|
@ -1 +1 @@
|
|||||||
327ee5fde2c7
|
3b85b693a95f
|
||||||
|
Loading…
Reference in New Issue
Block a user