neutron/neutron/db/migration
Kevin Benton 3e0328b992 Network RBAC DB setup and legacy migration
This patch implements the database model required for the network
RBAC work. In addition it migrates the current network and subnet
'shared' attributes to leverage the new table.

'shared' is no longer a property of the DB model because its status
is based on the tenant ID of the API caller. From an API perspective
this is the same (tenants will see networks as 'shared=True' if the
network is shared with them). However, internal callers (e.g. plugins,
drivers, services) will not be able to check for the 'shared' attribute
on network and subnet db objects any more.

This patch just achieves parity with the current shared behavior so it
doesn't add the ability to manipulate the RBAC entries directly. The
RBAC API is in the following patch.

Partially-Implements: blueprint rbac-networks
Change-Id: I3426b13eede8bfa29729cf3efea3419fb91175c4
2015-07-16 05:48:10 -07:00
..
alembic_migrations Network RBAC DB setup and legacy migration 2015-07-16 05:48:10 -07:00
models Network RBAC DB setup and legacy migration 2015-07-16 05:48:10 -07:00
README Drop support for SQL Schema Downgrades 2015-03-23 08:12:22 -04:00
__init__.py Drop and recreate FK if adding new PK to routerl3bindings 2014-11-05 15:10:04 +01:00
alembic.ini Ease debugging alembic by passing proper scripts path in alembic.ini 2015-06-22 15:44:55 +02:00
cli.py Improve check_migration command error message 2015-07-15 09:50:26 +00:00
migrate_to_ml2.py Restructure agent code in preparation for decomp 2015-06-26 15:06:49 +00:00

README

# Copyright 2012 New Dream Network, LLC (DreamHost)
#
#    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.

The migrations in the alembic/versions contain the changes needed to migrate
from older Neutron releases to newer versions. A migration occurs by executing
a script that details the changes needed to upgrade the database. The migration
scripts are ordered so that multiple scripts can run sequentially to update the
database. The scripts are executed by Neutron's migration wrapper which uses
the Alembic library to manage the migration.  Neutron supports migration from
Havana or later.


If you are a deployer or developer and want to migrate from Folsom to Grizzly
or later you must first add version tracking to the database:

$ neutron-db-manage --config-file /path/to/neutron.conf \
 --config-file /path/to/plugin/config.ini stamp folsom

You can then upgrade to the latest database version via:
$ neutron-db-manage --config-file /path/to/neutron.conf \
 --config-file /path/to/plugin/config.ini upgrade head

To check the current database version:
$ neutron-db-manage --config-file /path/to/neutron.conf \
 --config-file /path/to/plugin/config.ini current

To create a script to run the migration offline:
$ neutron-db-manage --config-file /path/to/neutron.conf \
 --config-file /path/to/plugin/config.ini upgrade head --sql

To run the offline migration between specific migration versions:
$ neutron-db-manage --config-file /path/to/neutron.conf \
--config-file /path/to/plugin/config.ini upgrade \
<start version>:<end version> --sql

Upgrade the database incrementally:
$ neutron-db-manage --config-file /path/to/neutron.conf \
--config-file /path/to/plugin/config.ini upgrade --delta <# of revs>

NOTE: Database downgrade is not supported.


DEVELOPERS:

A database migration script is required when you submit a change to Neutron
that alters the database model definition.  The migration script is a special
python file that includes code to upgrade the database to match the changes in
the model definition. Alembic will execute these scripts in order to provide a
linear migration path between revision. The neutron-db-manage command can be
used to generate migration template for you to complete.  The operations in the
template are those supported by the Alembic migration library.

$ neutron-db-manage --config-file /path/to/neutron.conf \
--config-file /path/to/plugin/config.ini revision \
-m "description of revision" \
--autogenerate

This generates a prepopulated template with the changes needed to match the
database state with the models.  You should inspect the autogenerated template
to ensure that the proper models have been altered.

In rare circumstances, you may want to start with an empty migration template
and manually author the changes necessary for an upgrade.  You can create a
blank file via:

$ neutron-db-manage --config-file /path/to/neutron.conf \
--config-file /path/to/plugin/config.ini revision \
-m "description of revision"

The migration timeline should remain linear so that there is a clear path when
upgrading.  To verify that the timeline does branch, you can run this command:
$ neutron-db-manage --config-file /path/to/neutron.conf \
--config-file /path/to/plugin/config.ini check_migration

If the migration path does branch, you can find the branch point via:
$ neutron-db-manage --config-file /path/to/neutron.conf \
--config-file /path/to/plugin/config.ini history