Repository: apache/airflow

Issue:
alembic Logging
### Apache Airflow version

2.5.3

### What happened

When I call the airflow initdb function, it outputs these lines to the log

INFO  [alembic.runtime.migration] Context impl PostgresqlImpl.
INFO  [alembic.runtime.migration] Will assume transactional DDL.

### What you think should happen instead

There should be a mechanism to disable these logs, or they should just be set to WARN by default

### How to reproduce

Set up a new postgres connection and call:

from airflow.utils.db import initdb
initdb()

### Operating System

MacOS

### Versions of Apache Airflow Providers

_No response_

### Deployment

Virtualenv installation

### Deployment details

_No response_

### Anything else

_No response_

### Are you willing to submit PR?

- [X] Yes I am willing to submit a PR!

### Code of Conduct

- [X] I agree to follow this project's [Code of Conduct](https://github.com/apache/airflow/blob/main/CODE_OF_CONDUCT.md)



Discussion:
Thanks for opening your first issue here! Be sure to follow the issue template! If you are willing to raise PR to address this issue please do so, no need to wait for approval.

https://github.com/apache/airflow/pull/30563
@hussein-awala @geekykayaker I see this issue was never taken further. I would like to try my hand at it if its still open.
@amoghrajesh assigned you. [Here](https://github.com/apache/airflow/pull/30563#pullrequestreview-1380243607) is the solution we discussed to solve this issue

Resolving patch:
diff --git a/airflow/utils/db.py b/airflow/utils/db.py
--- a/airflow/utils/db.py
+++ b/airflow/utils/db.py
@@ -736,7 +736,11 @@ def _get_alembic_config():
 
     package_dir = os.path.dirname(airflow.__file__)
     directory = os.path.join(package_dir, "migrations")
-    config = Config(os.path.join(package_dir, "alembic.ini"))
+    alembic_file = conf.get("database", "alembic_ini_file_path")
+    if os.path.isabs(alembic_file):
+        config = Config(alembic_file)
+    else:
+        config = Config(os.path.join(package_dir, alembic_file))
     config.set_main_option("script_location", directory.replace("%", "%%"))
     config.set_main_option("sqlalchemy.url", settings.SQL_ALCHEMY_CONN.replace("%", "%%"))
     return config


Test patch:
diff --git a/tests/utils/test_db.py b/tests/utils/test_db.py
--- a/tests/utils/test_db.py
+++ b/tests/utils/test_db.py
@@ -19,6 +19,7 @@
 
 import inspect
 import io
+import os
 import re
 from contextlib import redirect_stdout
 from unittest import mock
@@ -36,6 +37,7 @@
 from airflow.models import Base as airflow_base
 from airflow.settings import engine
 from airflow.utils.db import (
+    _get_alembic_config,
     check_migrations,
     compare_server_default,
     compare_type,
@@ -233,3 +235,16 @@ def test_resetdb(
             mock_init.assert_not_called()
         else:
             mock_init.assert_called_once_with(session=session_mock)
+
+    def test_alembic_configuration(self):
+        with mock.patch.dict(
+            os.environ, {"AIRFLOW__DATABASE__ALEMBIC_INI_FILE_PATH": "/tmp/alembic.ini"}, clear=True
+        ):
+            config = _get_alembic_config()
+            assert config.config_file_name == "/tmp/alembic.ini"
+
+        # default behaviour
+        config = _get_alembic_config()
+        import airflow
+
+        assert config.config_file_name == os.path.join(os.path.dirname(airflow.__file__), "alembic.ini")