diff --git a/aurweb/initdb.py b/aurweb/initdb.py index c8d0b2ae..5f55bfc9 100644 --- a/aurweb/initdb.py +++ b/aurweb/initdb.py @@ -40,6 +40,7 @@ def run(args): if args.use_alembic: alembic_config = alembic.config.Config('alembic.ini') alembic_config.get_main_option('script_location') + alembic_config.attributes["configure_logger"] = False engine = sqlalchemy.create_engine(aurweb.db.get_sqlalchemy_url(), echo=(args.verbose >= 1)) diff --git a/migrations/env.py b/migrations/env.py index 23759123..dfe14804 100644 --- a/migrations/env.py +++ b/migrations/env.py @@ -20,6 +20,12 @@ target_metadata = aurweb.schema.metadata # ... etc. +# If configure_logger is either True or not specified, +# configure the logger via fileConfig. +if config.attributes.get("configure_logger", True): + logging.config.fileConfig(config.config_file_name) + + def run_migrations_offline(): """Run migrations in 'offline' mode. @@ -64,12 +70,7 @@ def run_migrations_online(): context.run_migrations() -if __name__ == "__main__": - # Interpret the config file for Python logging. - # This line sets up loggers basically. - logging.config.fileConfig(config.config_file_name) - - if context.is_offline_mode(): - run_migrations_offline() - else: - run_migrations_online() +if context.is_offline_mode(): + run_migrations_offline() +else: + run_migrations_online()