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
|
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
|
``nova/db/sqlalchemy/api_migrations/migrate_repo/versions``. They are
|
||||||
the routines that transform our database structure, which should be
|
the routines that transform our database structure, which should be
|
||||||
additive and able to be applied to a running system before service
|
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'):
|
def find_migrate_repo(database='main'):
|
||||||
"""Get the path for the migrate repository."""
|
"""Get the path for the migrate repository."""
|
||||||
global _REPOSITORY
|
global _REPOSITORY
|
||||||
rel_path = os.path.join('sqlalchemy', 'migrate_repo')
|
rel_path = os.path.join('main', 'legacy_migrations')
|
||||||
if database == 'api':
|
if database == 'api':
|
||||||
rel_path = os.path.join('sqlalchemy', 'api_migrations', 'migrate_repo')
|
rel_path = os.path.join('sqlalchemy', 'api_migrations', 'migrate_repo')
|
||||||
path = os.path.join(os.path.abspath(os.path.dirname(__file__)), rel_path)
|
path = os.path.join(os.path.abspath(os.path.dirname(__file__)), rel_path)
|
||||||
|
@ -46,8 +46,8 @@ import sqlalchemy
|
|||||||
import sqlalchemy.exc
|
import sqlalchemy.exc
|
||||||
import testtools
|
import testtools
|
||||||
|
|
||||||
|
from nova.db.main import legacy_migrations
|
||||||
from nova.db import migration
|
from nova.db import migration
|
||||||
from nova.db.sqlalchemy import migrate_repo
|
|
||||||
from nova.db.sqlalchemy import models
|
from nova.db.sqlalchemy import models
|
||||||
from nova import test
|
from nova import test
|
||||||
from nova.tests import fixtures as nova_fixtures
|
from nova.tests import fixtures as nova_fixtures
|
||||||
@ -73,7 +73,7 @@ class NovaMigrationsCheckers(test_migrations.ModelsMigrationsSync,
|
|||||||
@property
|
@property
|
||||||
def REPOSITORY(self):
|
def REPOSITORY(self):
|
||||||
return repository.Repository(
|
return repository.Repository(
|
||||||
os.path.abspath(os.path.dirname(migrate_repo.__file__)))
|
os.path.abspath(os.path.dirname(legacy_migrations.__file__)))
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def migration_api(self):
|
def migration_api(self):
|
||||||
@ -272,9 +272,14 @@ class ProjectTestCase(test.NoDBTestCase):
|
|||||||
topdir = os.path.normpath(os.path.dirname(__file__) + '/../../../')
|
topdir = os.path.normpath(os.path.dirname(__file__) + '/../../../')
|
||||||
# Walk both the nova_api and nova (cell) database migrations.
|
# Walk both the nova_api and nova (cell) database migrations.
|
||||||
includes_downgrade = []
|
includes_downgrade = []
|
||||||
for subdir in ('api_migrations', ''):
|
for directory in (
|
||||||
py_glob = os.path.join(topdir, "db", "sqlalchemy", subdir,
|
os.path.join(topdir, 'db', 'main', 'legacy_migrations'),
|
||||||
"migrate_repo", "versions", "*.py")
|
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):
|
for path in glob.iglob(py_glob):
|
||||||
has_upgrade = False
|
has_upgrade = False
|
||||||
has_downgrade = False
|
has_downgrade = False
|
||||||
|
@ -126,7 +126,7 @@ def _get_db_driver_class(db_url):
|
|||||||
# Migrate
|
# 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):
|
def _migrate(db_url, migration_version):
|
||||||
|
@ -5,7 +5,7 @@ import glob
|
|||||||
import os
|
import os
|
||||||
import subprocess
|
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('/')
|
API_BASE = 'nova/db/sqlalchemy/api_migrations/migrate_repo/versions'.split('/')
|
||||||
|
|
||||||
STUB = \
|
STUB = \
|
||||||
|
Loading…
x
Reference in New Issue
Block a user