Allow db schema downgrades

When a destination version is specified, check the current version and allow
downgrading the schema. Fixes bug 865357.

Change-Id: I47104158884421de92f50322a72243c170a4f1ad
This commit is contained in:
Stanislaw Pitucha 2011-09-21 14:10:39 +01:00
parent 3837f09ee0
commit eed546053a
2 changed files with 14 additions and 2 deletions

View File

@ -107,6 +107,7 @@ Sandy Walsh <sandy.walsh@rackspace.com>
Sateesh Chodapuneedi <sateesh.chodapuneedi@citrix.com>
Scott Moser <smoser@ubuntu.com>
Soren Hansen <soren.hansen@rackspace.com>
Stanislaw Pitucha <stanislaw.pitucha@hp.com>
Stephanie Reese <reese.sm@gmail.com>
Thierry Carrez <thierry@openstack.org>
Tim Simpson <tim.simpson@rackspace.com>

View File

@ -19,6 +19,7 @@
import os
import sys
from nova import exception
from nova import flags
import sqlalchemy
@ -38,9 +39,19 @@ FLAGS = flags.FLAGS
def db_sync(version=None):
db_version()
if version is not None:
try:
version = int(version)
except ValueError:
raise exception.Error(_("version should be an integer"))
current_version = db_version()
repo_path = _find_migrate_repo()
return versioning_api.upgrade(FLAGS.sql_connection, repo_path, version)
if version is None or version > current_version:
return versioning_api.upgrade(FLAGS.sql_connection, repo_path, version)
else:
return versioning_api.downgrade(FLAGS.sql_connection, repo_path,
version)
def db_version():