Merge "db: Move main DB migrations"

This commit is contained in:
Zuul 2021-08-06 16:57:04 +00:00 committed by Gerrit Code Review
commit b218f167cc
31 changed files with 14 additions and 9 deletions

View File

@ -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

View File

@ -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)

View File

@ -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

View File

@ -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):

View File

@ -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 = \