Move migration dir determination to common module
Also use it instead of __file__ magic in nailgun module. Change-Id: Ie60f817158c1b70d433f4ee2f4218f98f1982dbe
This commit is contained in:
parent
fe441d1862
commit
d66ed0922d
@ -13,7 +13,12 @@
|
||||
# under the License.
|
||||
|
||||
import pbr.version
|
||||
import pkg_resources
|
||||
|
||||
|
||||
__version__ = pbr.version.VersionInfo(
|
||||
'tuning_box').version_string()
|
||||
|
||||
|
||||
def get_migrations_dir():
|
||||
return pkg_resources.resource_filename('tuning_box', 'migrations')
|
||||
|
@ -13,7 +13,6 @@
|
||||
from __future__ import absolute_import
|
||||
|
||||
import itertools
|
||||
import os
|
||||
import threading
|
||||
|
||||
from nailgun import db as nailgun_db
|
||||
@ -84,4 +83,4 @@ class Extension(extensions.BaseExtension):
|
||||
|
||||
@classmethod
|
||||
def alembic_migrations_path(cls):
|
||||
return os.path.join(os.path.dirname(__file__), 'migrations')
|
||||
return tuning_box.get_migrations_dir()
|
||||
|
@ -22,11 +22,11 @@ from alembic import script as alembic_script
|
||||
import flask
|
||||
from oslo_db.sqlalchemy import test_base
|
||||
from oslo_db.sqlalchemy import test_migrations
|
||||
import pkg_resources
|
||||
import sqlalchemy as sa
|
||||
import testscenarios
|
||||
from werkzeug import exceptions
|
||||
|
||||
import tuning_box
|
||||
from tuning_box import db
|
||||
from tuning_box.tests import base
|
||||
|
||||
@ -152,13 +152,11 @@ class _RealDBTest(testscenarios.WithScenarios,
|
||||
('postgres', {'FIXTURE': test_base.PostgreSQLOpportunisticFixture}),
|
||||
]
|
||||
|
||||
def get_migrations_dir(self):
|
||||
return pkg_resources.resource_filename('tuning_box', 'migrations')
|
||||
|
||||
def get_alembic_config(self, engine):
|
||||
config = alembic_config.Config()
|
||||
config.set_main_option('sqlalchemy.url', str(engine.url))
|
||||
config.set_main_option('script_location', self.get_migrations_dir())
|
||||
config.set_main_option(
|
||||
'script_location', tuning_box.get_migrations_dir())
|
||||
config.set_main_option('version_table', 'alembic_version')
|
||||
return config
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user