Merge "sqlalchemy: allow to upgrade schema from Ceilometer Liberty"
This commit is contained in:
commit
1bea859df0
@ -20,6 +20,7 @@ import os.path
|
|||||||
from alembic import command
|
from alembic import command
|
||||||
from alembic import config
|
from alembic import config
|
||||||
from alembic import migration
|
from alembic import migration
|
||||||
|
from oslo_db import exception
|
||||||
from oslo_db.sqlalchemy import session as db_session
|
from oslo_db.sqlalchemy import session as db_session
|
||||||
from oslo_db.sqlalchemy import utils as oslo_sql_utils
|
from oslo_db.sqlalchemy import utils as oslo_sql_utils
|
||||||
from oslo_log import log
|
from oslo_log import log
|
||||||
@ -94,8 +95,15 @@ class Connection(base.Connection):
|
|||||||
ctxt = migration.MigrationContext.configure(engine.connect())
|
ctxt = migration.MigrationContext.configure(engine.connect())
|
||||||
current_version = ctxt.get_current_revision()
|
current_version = ctxt.get_current_revision()
|
||||||
if current_version is None:
|
if current_version is None:
|
||||||
models.Base.metadata.create_all(engine)
|
try:
|
||||||
command.stamp(cfg, "head")
|
models.Base.metadata.create_all(engine, checkfirst=False)
|
||||||
|
except exception.DBError:
|
||||||
|
# Assume tables exist from Ceilometer, take control
|
||||||
|
# FIXME(jd) Remove in Ocata
|
||||||
|
command.stamp(cfg, "12fe8fac9fe4")
|
||||||
|
command.upgrade(cfg, "head")
|
||||||
|
else:
|
||||||
|
command.stamp(cfg, "head")
|
||||||
else:
|
else:
|
||||||
command.upgrade(cfg, "head")
|
command.upgrade(cfg, "head")
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user