mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
[alembic] Log db name being used in a migration
Signed-off-by: Kevin Morris <kevr@0cost.org>
This commit is contained in:
parent
cec07c76b6
commit
ff3519ae11
1 changed files with 8 additions and 1 deletions
|
@ -1,3 +1,4 @@
|
||||||
|
import logging
|
||||||
import logging.config
|
import logging.config
|
||||||
|
|
||||||
import sqlalchemy
|
import sqlalchemy
|
||||||
|
@ -19,12 +20,14 @@ target_metadata = aurweb.schema.metadata
|
||||||
# my_important_option = config.get_main_option("my_important_option")
|
# my_important_option = config.get_main_option("my_important_option")
|
||||||
# ... etc.
|
# ... etc.
|
||||||
|
|
||||||
|
|
||||||
# If configure_logger is either True or not specified,
|
# If configure_logger is either True or not specified,
|
||||||
# configure the logger via fileConfig.
|
# configure the logger via fileConfig.
|
||||||
if config.attributes.get("configure_logger", True):
|
if config.attributes.get("configure_logger", True):
|
||||||
logging.config.fileConfig(config.config_file_name)
|
logging.config.fileConfig(config.config_file_name)
|
||||||
|
|
||||||
|
# This grabs the root logger in env.py.
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
def run_migrations_offline():
|
def run_migrations_offline():
|
||||||
"""Run migrations in 'offline' mode.
|
"""Run migrations in 'offline' mode.
|
||||||
|
@ -38,6 +41,8 @@ def run_migrations_offline():
|
||||||
script output.
|
script output.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
db_name = aurweb.config.get("database", "name")
|
||||||
|
logging.info(f"Performing offline migration on database '{db_name}'.")
|
||||||
context.configure(
|
context.configure(
|
||||||
url=aurweb.db.get_sqlalchemy_url(),
|
url=aurweb.db.get_sqlalchemy_url(),
|
||||||
target_metadata=target_metadata,
|
target_metadata=target_metadata,
|
||||||
|
@ -56,6 +61,8 @@ def run_migrations_online():
|
||||||
and associate a connection with the context.
|
and associate a connection with the context.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
db_name = aurweb.config.get("database", "name")
|
||||||
|
logging.info(f"Performing online migration on database '{db_name}'.")
|
||||||
connectable = sqlalchemy.create_engine(
|
connectable = sqlalchemy.create_engine(
|
||||||
aurweb.db.get_sqlalchemy_url(),
|
aurweb.db.get_sqlalchemy_url(),
|
||||||
poolclass=sqlalchemy.pool.NullPool,
|
poolclass=sqlalchemy.pool.NullPool,
|
||||||
|
|
Loading…
Add table
Reference in a new issue