db: Move main DB migrations
We place these in a 'legacy_migrations' directory, as we will soon be adding alembic-based migrations in a 'migration' directory. Change-Id: Ib927e4c48f59a467a913875111ffbf64ffe0de90 Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
This commit is contained in:
parent
4bbea58cbb
commit
bcf225daf4
@ -176,7 +176,7 @@ Schema Migrations
|
||||
''''''''''''''''''
|
||||
|
||||
Schema migrations are defined in
|
||||
``nova/db/sqlalchemy/migrate_repo/versions`` and in
|
||||
``nova/db/main/legacy_migrations/versions`` and in
|
||||
``nova/db/sqlalchemy/api_migrations/migrate_repo/versions``. They are
|
||||
the routines that transform our database structure, which should be
|
||||
additive and able to be applied to a running system before service
|
||||
|
@ -45,7 +45,7 @@ def get_engine(database='main', context=None):
|
||||
def find_migrate_repo(database='main'):
|
||||
"""Get the path for the migrate repository."""
|
||||
global _REPOSITORY
|
||||
rel_path = os.path.join('sqlalchemy', 'migrate_repo')
|
||||
rel_path = os.path.join('main', 'legacy_migrations')
|
||||
if database == 'api':
|
||||
rel_path = os.path.join('sqlalchemy', 'api_migrations', 'migrate_repo')
|
||||
path = os.path.join(os.path.abspath(os.path.dirname(__file__)), rel_path)
|
||||
|
@ -46,8 +46,8 @@ import sqlalchemy
|
||||
import sqlalchemy.exc
|
||||
import testtools
|
||||
|
||||
from nova.db.main import legacy_migrations
|
||||
from nova.db import migration
|
||||
from nova.db.sqlalchemy import migrate_repo
|
||||
from nova.db.sqlalchemy import models
|
||||
from nova import test
|
||||
from nova.tests import fixtures as nova_fixtures
|
||||
@ -73,7 +73,7 @@ class NovaMigrationsCheckers(test_migrations.ModelsMigrationsSync,
|
||||
@property
|
||||
def REPOSITORY(self):
|
||||
return repository.Repository(
|
||||
os.path.abspath(os.path.dirname(migrate_repo.__file__)))
|
||||
os.path.abspath(os.path.dirname(legacy_migrations.__file__)))
|
||||
|
||||
@property
|
||||
def migration_api(self):
|
||||
@ -272,9 +272,14 @@ class ProjectTestCase(test.NoDBTestCase):
|
||||
topdir = os.path.normpath(os.path.dirname(__file__) + '/../../../')
|
||||
# Walk both the nova_api and nova (cell) database migrations.
|
||||
includes_downgrade = []
|
||||
for subdir in ('api_migrations', ''):
|
||||
py_glob = os.path.join(topdir, "db", "sqlalchemy", subdir,
|
||||
"migrate_repo", "versions", "*.py")
|
||||
for directory in (
|
||||
os.path.join(topdir, 'db', 'main', 'legacy_migrations'),
|
||||
os.path.join(
|
||||
topdir, 'db', 'sqlalchemy', 'api_migrations',
|
||||
'migrate_repo',
|
||||
),
|
||||
):
|
||||
py_glob = os.path.join(directory, 'versions', '*.py')
|
||||
for path in glob.iglob(py_glob):
|
||||
has_upgrade = False
|
||||
has_downgrade = False
|
||||
|
@ -126,7 +126,7 @@ def _get_db_driver_class(db_url):
|
||||
# Migrate
|
||||
|
||||
|
||||
MIGRATE_REPO = os.path.join(os.getcwd(), "nova/db/sqlalchemy/migrate_repo")
|
||||
MIGRATE_REPO = os.path.join(os.getcwd(), "nova/db/main/legacy_migrations")
|
||||
|
||||
|
||||
def _migrate(db_url, migration_version):
|
||||
|
@ -5,7 +5,7 @@ import glob
|
||||
import os
|
||||
import subprocess
|
||||
|
||||
BASE = 'nova/db/sqlalchemy/migrate_repo/versions'.split('/')
|
||||
BASE = 'nova/db/main/legacy_migrations/versions'.split('/')
|
||||
API_BASE = 'nova/db/sqlalchemy/api_migrations/migrate_repo/versions'.split('/')
|
||||
|
||||
STUB = \
|
||||
|
Loading…
x
Reference in New Issue
Block a user