Fix main app migration pathway
This commit is contained in:
parent
561522c6d3
commit
aff1a08a83
4 changed files with 23 additions and 8 deletions
|
@ -19,7 +19,13 @@ from release import GIT_HEAD, REGION, SERVICE
|
|||
from util.morecollections import AttrDict
|
||||
|
||||
config = context.config
|
||||
DB_URI = config.get_main_option('db_uri')
|
||||
DB_URI = config.get_main_option('db_uri', 'sqlite:///test/data/test.db')
|
||||
|
||||
if config.get_main_option('alembic_setup_app', 'True') == 'True':
|
||||
# needed for db connections
|
||||
from app import app
|
||||
DB_URI = app.config['DB_URI']
|
||||
|
||||
config.set_main_option('sqlalchemy.url', unquote(DB_URI))
|
||||
# Interpret the config file for Python logging.
|
||||
# This line sets up loggers basically.
|
||||
|
@ -68,7 +74,7 @@ def run_migrations_offline():
|
|||
context.configure(url=url, target_metadata=target_metadata, transactional_ddl=True)
|
||||
|
||||
with context.begin_transaction():
|
||||
context.run_migrations(tables=tables)
|
||||
context.run_migrations(tables=tables, tester=get_tester())
|
||||
|
||||
def run_migrations_online():
|
||||
"""Run migrations in 'online' mode.
|
||||
|
@ -97,7 +103,7 @@ def run_migrations_online():
|
|||
try:
|
||||
with context.begin_transaction():
|
||||
try:
|
||||
context.run_migrations(tables=tables)
|
||||
context.run_migrations(tables=tables, tester=get_tester())
|
||||
except (CommandError, ResolutionError) as ex:
|
||||
if 'No such revision' not in str(ex):
|
||||
raise
|
||||
|
|
Reference in a new issue