commit 8fdd20b29fa845fa0bf3d0ebce82f1cd50192114 Author: Shubhankar45 Date: Tue Sep 22 06:23:46 2026 +0000 Production diff --git a/.api.log b/.api.log new file mode 100644 index 0000000..941f5c9 --- /dev/null +++ b/.api.log @@ -0,0 +1,10680 @@ +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | psycopg.OperationalError: connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | +api-1 | The above exception was the direct cause of the following exception: +api-1 | +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/bin/alembic", line 8, in +api-1 | sys.exit(main()) +api-1 | ^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1039, in main +api-1 | CommandLine(prog=prog).main(argv=argv) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1029, in main +api-1 | self.run_cmd(cfg, options) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 963, in run_cmd +api-1 | fn( +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/command.py", line 487, in upgrade +api-1 | script.run_env() +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/script/base.py", line 550, in run_env +api-1 | util.load_python_file(self.dir, "env.py") +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 114, in load_python_file +api-1 | module = load_module_py(module_id, path) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 132, in load_module_py +api-1 | spec.loader.exec_module(module) # type: ignore +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "", line 999, in exec_module +api-1 | File "", line 488, in _call_with_frames_removed +api-1 | File "/srv/alembic/env.py", line 47, in +api-1 | run_migrations_online() +api-1 | File "/srv/alembic/env.py", line 36, in run_migrations_online +api-1 | with connectable.connect() as connection: +api-1 | ^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3295, in connect +api-1 | return self._connection_cls(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 146, in __init__ +api-1 | Connection._handle_dbapi_exception_noconnection( +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 2450, in _handle_dbapi_exception_noconnection +api-1 | raise sqlalchemy_exception.with_traceback(exc_info[2]) from e +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | sqlalchemy.exc.OperationalError: (psycopg.OperationalError) connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | (Background on this error at: https://sqlalche.me/e/20/e3q8) +api-1 | entrypoint: database not ready (attempt 1), retrying in 3s +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | psycopg.OperationalError: connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | +api-1 | The above exception was the direct cause of the following exception: +api-1 | +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/bin/alembic", line 8, in +api-1 | sys.exit(main()) +api-1 | ^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1039, in main +api-1 | CommandLine(prog=prog).main(argv=argv) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1029, in main +api-1 | self.run_cmd(cfg, options) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 963, in run_cmd +api-1 | fn( +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/command.py", line 487, in upgrade +api-1 | script.run_env() +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/script/base.py", line 550, in run_env +api-1 | util.load_python_file(self.dir, "env.py") +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 114, in load_python_file +api-1 | module = load_module_py(module_id, path) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 132, in load_module_py +api-1 | spec.loader.exec_module(module) # type: ignore +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "", line 999, in exec_module +api-1 | File "", line 488, in _call_with_frames_removed +api-1 | File "/srv/alembic/env.py", line 47, in +api-1 | run_migrations_online() +api-1 | File "/srv/alembic/env.py", line 36, in run_migrations_online +api-1 | with connectable.connect() as connection: +api-1 | ^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3295, in connect +api-1 | return self._connection_cls(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 146, in __init__ +api-1 | Connection._handle_dbapi_exception_noconnection( +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 2450, in _handle_dbapi_exception_noconnection +api-1 | raise sqlalchemy_exception.with_traceback(exc_info[2]) from e +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | sqlalchemy.exc.OperationalError: (psycopg.OperationalError) connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | (Background on this error at: https://sqlalche.me/e/20/e3q8) +api-1 | entrypoint: database not ready (attempt 2), retrying in 3s +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | psycopg.OperationalError: connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | +api-1 | The above exception was the direct cause of the following exception: +api-1 | +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/bin/alembic", line 8, in +api-1 | sys.exit(main()) +api-1 | ^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1039, in main +api-1 | CommandLine(prog=prog).main(argv=argv) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1029, in main +api-1 | self.run_cmd(cfg, options) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 963, in run_cmd +api-1 | fn( +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/command.py", line 487, in upgrade +api-1 | script.run_env() +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/script/base.py", line 550, in run_env +api-1 | util.load_python_file(self.dir, "env.py") +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 114, in load_python_file +api-1 | module = load_module_py(module_id, path) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 132, in load_module_py +api-1 | spec.loader.exec_module(module) # type: ignore +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "", line 999, in exec_module +api-1 | File "", line 488, in _call_with_frames_removed +api-1 | File "/srv/alembic/env.py", line 47, in +api-1 | run_migrations_online() +api-1 | File "/srv/alembic/env.py", line 36, in run_migrations_online +api-1 | with connectable.connect() as connection: +api-1 | ^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3295, in connect +api-1 | return self._connection_cls(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 146, in __init__ +api-1 | Connection._handle_dbapi_exception_noconnection( +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 2450, in _handle_dbapi_exception_noconnection +api-1 | raise sqlalchemy_exception.with_traceback(exc_info[2]) from e +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | sqlalchemy.exc.OperationalError: (psycopg.OperationalError) connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | (Background on this error at: https://sqlalche.me/e/20/e3q8) +api-1 | entrypoint: database not ready (attempt 3), retrying in 3s +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | psycopg.OperationalError: connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | +api-1 | The above exception was the direct cause of the following exception: +api-1 | +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/bin/alembic", line 8, in +api-1 | sys.exit(main()) +api-1 | ^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1039, in main +api-1 | CommandLine(prog=prog).main(argv=argv) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1029, in main +api-1 | self.run_cmd(cfg, options) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 963, in run_cmd +api-1 | fn( +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/command.py", line 487, in upgrade +api-1 | script.run_env() +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/script/base.py", line 550, in run_env +api-1 | util.load_python_file(self.dir, "env.py") +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 114, in load_python_file +api-1 | module = load_module_py(module_id, path) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 132, in load_module_py +api-1 | spec.loader.exec_module(module) # type: ignore +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "", line 999, in exec_module +api-1 | File "", line 488, in _call_with_frames_removed +api-1 | File "/srv/alembic/env.py", line 47, in +api-1 | run_migrations_online() +api-1 | File "/srv/alembic/env.py", line 36, in run_migrations_online +api-1 | with connectable.connect() as connection: +api-1 | ^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3295, in connect +api-1 | return self._connection_cls(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 146, in __init__ +api-1 | Connection._handle_dbapi_exception_noconnection( +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 2450, in _handle_dbapi_exception_noconnection +api-1 | raise sqlalchemy_exception.with_traceback(exc_info[2]) from e +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | sqlalchemy.exc.OperationalError: (psycopg.OperationalError) connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | (Background on this error at: https://sqlalche.me/e/20/e3q8) +api-1 | entrypoint: database not ready (attempt 4), retrying in 3s +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | psycopg.OperationalError: connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | +api-1 | The above exception was the direct cause of the following exception: +api-1 | +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/bin/alembic", line 8, in +api-1 | sys.exit(main()) +api-1 | ^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1039, in main +api-1 | CommandLine(prog=prog).main(argv=argv) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1029, in main +api-1 | self.run_cmd(cfg, options) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 963, in run_cmd +api-1 | fn( +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/command.py", line 487, in upgrade +api-1 | script.run_env() +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/script/base.py", line 550, in run_env +api-1 | util.load_python_file(self.dir, "env.py") +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 114, in load_python_file +api-1 | module = load_module_py(module_id, path) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 132, in load_module_py +api-1 | spec.loader.exec_module(module) # type: ignore +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "", line 999, in exec_module +api-1 | File "", line 488, in _call_with_frames_removed +api-1 | File "/srv/alembic/env.py", line 47, in +api-1 | run_migrations_online() +api-1 | File "/srv/alembic/env.py", line 36, in run_migrations_online +api-1 | with connectable.connect() as connection: +api-1 | ^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3295, in connect +api-1 | return self._connection_cls(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 146, in __init__ +api-1 | Connection._handle_dbapi_exception_noconnection( +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 2450, in _handle_dbapi_exception_noconnection +api-1 | raise sqlalchemy_exception.with_traceback(exc_info[2]) from e +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | sqlalchemy.exc.OperationalError: (psycopg.OperationalError) connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | (Background on this error at: https://sqlalche.me/e/20/e3q8) +api-1 | entrypoint: database not ready (attempt 5), retrying in 3s +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | psycopg.OperationalError: connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | +api-1 | The above exception was the direct cause of the following exception: +api-1 | +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/bin/alembic", line 8, in +api-1 | sys.exit(main()) +api-1 | ^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1039, in main +api-1 | CommandLine(prog=prog).main(argv=argv) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1029, in main +api-1 | self.run_cmd(cfg, options) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 963, in run_cmd +api-1 | fn( +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/command.py", line 487, in upgrade +api-1 | script.run_env() +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/script/base.py", line 550, in run_env +api-1 | util.load_python_file(self.dir, "env.py") +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 114, in load_python_file +api-1 | module = load_module_py(module_id, path) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 132, in load_module_py +api-1 | spec.loader.exec_module(module) # type: ignore +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "", line 999, in exec_module +api-1 | File "", line 488, in _call_with_frames_removed +api-1 | File "/srv/alembic/env.py", line 47, in +api-1 | run_migrations_online() +api-1 | File "/srv/alembic/env.py", line 36, in run_migrations_online +api-1 | with connectable.connect() as connection: +api-1 | ^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3295, in connect +api-1 | return self._connection_cls(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 146, in __init__ +api-1 | Connection._handle_dbapi_exception_noconnection( +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 2450, in _handle_dbapi_exception_noconnection +api-1 | raise sqlalchemy_exception.with_traceback(exc_info[2]) from e +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | sqlalchemy.exc.OperationalError: (psycopg.OperationalError) connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | (Background on this error at: https://sqlalche.me/e/20/e3q8) +api-1 | entrypoint: database not ready (attempt 6), retrying in 3s +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | psycopg.OperationalError: connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | +api-1 | The above exception was the direct cause of the following exception: +api-1 | +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/bin/alembic", line 8, in +api-1 | sys.exit(main()) +api-1 | ^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1039, in main +api-1 | CommandLine(prog=prog).main(argv=argv) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1029, in main +api-1 | self.run_cmd(cfg, options) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 963, in run_cmd +api-1 | fn( +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/command.py", line 487, in upgrade +api-1 | script.run_env() +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/script/base.py", line 550, in run_env +api-1 | util.load_python_file(self.dir, "env.py") +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 114, in load_python_file +api-1 | module = load_module_py(module_id, path) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 132, in load_module_py +api-1 | spec.loader.exec_module(module) # type: ignore +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "", line 999, in exec_module +api-1 | File "", line 488, in _call_with_frames_removed +api-1 | File "/srv/alembic/env.py", line 47, in +api-1 | run_migrations_online() +api-1 | File "/srv/alembic/env.py", line 36, in run_migrations_online +api-1 | with connectable.connect() as connection: +api-1 | ^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3295, in connect +api-1 | return self._connection_cls(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 146, in __init__ +api-1 | Connection._handle_dbapi_exception_noconnection( +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 2450, in _handle_dbapi_exception_noconnection +api-1 | raise sqlalchemy_exception.with_traceback(exc_info[2]) from e +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | sqlalchemy.exc.OperationalError: (psycopg.OperationalError) connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | (Background on this error at: https://sqlalche.me/e/20/e3q8) +api-1 | entrypoint: database not ready (attempt 7), retrying in 3s +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | psycopg.OperationalError: connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | +api-1 | The above exception was the direct cause of the following exception: +api-1 | +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/bin/alembic", line 8, in +api-1 | sys.exit(main()) +api-1 | ^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1039, in main +api-1 | CommandLine(prog=prog).main(argv=argv) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1029, in main +api-1 | self.run_cmd(cfg, options) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 963, in run_cmd +api-1 | fn( +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/command.py", line 487, in upgrade +api-1 | script.run_env() +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/script/base.py", line 550, in run_env +api-1 | util.load_python_file(self.dir, "env.py") +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 114, in load_python_file +api-1 | module = load_module_py(module_id, path) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 132, in load_module_py +api-1 | spec.loader.exec_module(module) # type: ignore +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "", line 999, in exec_module +api-1 | File "", line 488, in _call_with_frames_removed +api-1 | File "/srv/alembic/env.py", line 47, in +api-1 | run_migrations_online() +api-1 | File "/srv/alembic/env.py", line 36, in run_migrations_online +api-1 | with connectable.connect() as connection: +api-1 | ^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3295, in connect +api-1 | return self._connection_cls(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 146, in __init__ +api-1 | Connection._handle_dbapi_exception_noconnection( +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 2450, in _handle_dbapi_exception_noconnection +api-1 | raise sqlalchemy_exception.with_traceback(exc_info[2]) from e +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | sqlalchemy.exc.OperationalError: (psycopg.OperationalError) connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | (Background on this error at: https://sqlalche.me/e/20/e3q8) +api-1 | entrypoint: database not ready (attempt 8), retrying in 3s +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | psycopg.OperationalError: connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | +api-1 | The above exception was the direct cause of the following exception: +api-1 | +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/bin/alembic", line 8, in +api-1 | sys.exit(main()) +api-1 | ^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1039, in main +api-1 | CommandLine(prog=prog).main(argv=argv) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1029, in main +api-1 | self.run_cmd(cfg, options) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 963, in run_cmd +api-1 | fn( +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/command.py", line 487, in upgrade +api-1 | script.run_env() +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/script/base.py", line 550, in run_env +api-1 | util.load_python_file(self.dir, "env.py") +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 114, in load_python_file +api-1 | module = load_module_py(module_id, path) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 132, in load_module_py +api-1 | spec.loader.exec_module(module) # type: ignore +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "", line 999, in exec_module +api-1 | File "", line 488, in _call_with_frames_removed +api-1 | File "/srv/alembic/env.py", line 47, in +api-1 | run_migrations_online() +api-1 | File "/srv/alembic/env.py", line 36, in run_migrations_online +api-1 | with connectable.connect() as connection: +api-1 | ^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3295, in connect +api-1 | return self._connection_cls(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 146, in __init__ +api-1 | Connection._handle_dbapi_exception_noconnection( +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 2450, in _handle_dbapi_exception_noconnection +api-1 | raise sqlalchemy_exception.with_traceback(exc_info[2]) from e +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | sqlalchemy.exc.OperationalError: (psycopg.OperationalError) connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | (Background on this error at: https://sqlalche.me/e/20/e3q8) +api-1 | entrypoint: database not ready (attempt 9), retrying in 3s +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | psycopg.OperationalError: connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | +api-1 | The above exception was the direct cause of the following exception: +api-1 | +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/bin/alembic", line 8, in +api-1 | sys.exit(main()) +api-1 | ^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1039, in main +api-1 | CommandLine(prog=prog).main(argv=argv) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1029, in main +api-1 | self.run_cmd(cfg, options) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 963, in run_cmd +api-1 | fn( +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/command.py", line 487, in upgrade +api-1 | script.run_env() +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/script/base.py", line 550, in run_env +api-1 | util.load_python_file(self.dir, "env.py") +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 114, in load_python_file +api-1 | module = load_module_py(module_id, path) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 132, in load_module_py +api-1 | spec.loader.exec_module(module) # type: ignore +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "", line 999, in exec_module +api-1 | File "", line 488, in _call_with_frames_removed +api-1 | File "/srv/alembic/env.py", line 47, in +api-1 | run_migrations_online() +api-1 | File "/srv/alembic/env.py", line 36, in run_migrations_online +api-1 | with connectable.connect() as connection: +api-1 | ^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3295, in connect +api-1 | return self._connection_cls(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 146, in __init__ +api-1 | Connection._handle_dbapi_exception_noconnection( +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 2450, in _handle_dbapi_exception_noconnection +api-1 | raise sqlalchemy_exception.with_traceback(exc_info[2]) from e +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | sqlalchemy.exc.OperationalError: (psycopg.OperationalError) connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | (Background on this error at: https://sqlalche.me/e/20/e3q8) +api-1 | entrypoint: database not ready (attempt 10), retrying in 3s +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | psycopg.OperationalError: connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | +api-1 | The above exception was the direct cause of the following exception: +api-1 | +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/bin/alembic", line 8, in +api-1 | sys.exit(main()) +api-1 | ^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1039, in main +api-1 | CommandLine(prog=prog).main(argv=argv) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1029, in main +api-1 | self.run_cmd(cfg, options) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 963, in run_cmd +api-1 | fn( +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/command.py", line 487, in upgrade +api-1 | script.run_env() +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/script/base.py", line 550, in run_env +api-1 | util.load_python_file(self.dir, "env.py") +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 114, in load_python_file +api-1 | module = load_module_py(module_id, path) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 132, in load_module_py +api-1 | spec.loader.exec_module(module) # type: ignore +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "", line 999, in exec_module +api-1 | File "", line 488, in _call_with_frames_removed +api-1 | File "/srv/alembic/env.py", line 47, in +api-1 | run_migrations_online() +api-1 | File "/srv/alembic/env.py", line 36, in run_migrations_online +api-1 | with connectable.connect() as connection: +api-1 | ^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3295, in connect +api-1 | return self._connection_cls(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 146, in __init__ +api-1 | Connection._handle_dbapi_exception_noconnection( +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 2450, in _handle_dbapi_exception_noconnection +api-1 | raise sqlalchemy_exception.with_traceback(exc_info[2]) from e +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | sqlalchemy.exc.OperationalError: (psycopg.OperationalError) connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | (Background on this error at: https://sqlalche.me/e/20/e3q8) +api-1 | entrypoint: database not ready (attempt 11), retrying in 3s +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | psycopg.OperationalError: connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | +api-1 | The above exception was the direct cause of the following exception: +api-1 | +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/bin/alembic", line 8, in +api-1 | sys.exit(main()) +api-1 | ^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1039, in main +api-1 | CommandLine(prog=prog).main(argv=argv) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1029, in main +api-1 | self.run_cmd(cfg, options) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 963, in run_cmd +api-1 | fn( +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/command.py", line 487, in upgrade +api-1 | script.run_env() +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/script/base.py", line 550, in run_env +api-1 | util.load_python_file(self.dir, "env.py") +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 114, in load_python_file +api-1 | module = load_module_py(module_id, path) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 132, in load_module_py +api-1 | spec.loader.exec_module(module) # type: ignore +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "", line 999, in exec_module +api-1 | File "", line 488, in _call_with_frames_removed +api-1 | File "/srv/alembic/env.py", line 47, in +api-1 | run_migrations_online() +api-1 | File "/srv/alembic/env.py", line 36, in run_migrations_online +api-1 | with connectable.connect() as connection: +api-1 | ^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3295, in connect +api-1 | return self._connection_cls(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 146, in __init__ +api-1 | Connection._handle_dbapi_exception_noconnection( +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 2450, in _handle_dbapi_exception_noconnection +api-1 | raise sqlalchemy_exception.with_traceback(exc_info[2]) from e +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | sqlalchemy.exc.OperationalError: (psycopg.OperationalError) connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | (Background on this error at: https://sqlalche.me/e/20/e3q8) +api-1 | entrypoint: database not ready (attempt 12), retrying in 3s +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | psycopg.OperationalError: connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | +api-1 | The above exception was the direct cause of the following exception: +api-1 | +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/bin/alembic", line 8, in +api-1 | sys.exit(main()) +api-1 | ^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1039, in main +api-1 | CommandLine(prog=prog).main(argv=argv) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1029, in main +api-1 | self.run_cmd(cfg, options) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 963, in run_cmd +api-1 | fn( +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/command.py", line 487, in upgrade +api-1 | script.run_env() +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/script/base.py", line 550, in run_env +api-1 | util.load_python_file(self.dir, "env.py") +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 114, in load_python_file +api-1 | module = load_module_py(module_id, path) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 132, in load_module_py +api-1 | spec.loader.exec_module(module) # type: ignore +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "", line 999, in exec_module +api-1 | File "", line 488, in _call_with_frames_removed +api-1 | File "/srv/alembic/env.py", line 47, in +api-1 | run_migrations_online() +api-1 | File "/srv/alembic/env.py", line 36, in run_migrations_online +api-1 | with connectable.connect() as connection: +api-1 | ^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3295, in connect +api-1 | return self._connection_cls(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 146, in __init__ +api-1 | Connection._handle_dbapi_exception_noconnection( +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 2450, in _handle_dbapi_exception_noconnection +api-1 | raise sqlalchemy_exception.with_traceback(exc_info[2]) from e +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | sqlalchemy.exc.OperationalError: (psycopg.OperationalError) connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | (Background on this error at: https://sqlalche.me/e/20/e3q8) +api-1 | entrypoint: database not ready (attempt 13), retrying in 3s +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | psycopg.OperationalError: connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | +api-1 | The above exception was the direct cause of the following exception: +api-1 | +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/bin/alembic", line 8, in +api-1 | sys.exit(main()) +api-1 | ^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1039, in main +api-1 | CommandLine(prog=prog).main(argv=argv) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1029, in main +api-1 | self.run_cmd(cfg, options) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 963, in run_cmd +api-1 | fn( +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/command.py", line 487, in upgrade +api-1 | script.run_env() +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/script/base.py", line 550, in run_env +api-1 | util.load_python_file(self.dir, "env.py") +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 114, in load_python_file +api-1 | module = load_module_py(module_id, path) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 132, in load_module_py +api-1 | spec.loader.exec_module(module) # type: ignore +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "", line 999, in exec_module +api-1 | File "", line 488, in _call_with_frames_removed +api-1 | File "/srv/alembic/env.py", line 47, in +api-1 | run_migrations_online() +api-1 | File "/srv/alembic/env.py", line 36, in run_migrations_online +api-1 | with connectable.connect() as connection: +api-1 | ^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3295, in connect +api-1 | return self._connection_cls(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 146, in __init__ +api-1 | Connection._handle_dbapi_exception_noconnection( +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 2450, in _handle_dbapi_exception_noconnection +api-1 | raise sqlalchemy_exception.with_traceback(exc_info[2]) from e +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | sqlalchemy.exc.OperationalError: (psycopg.OperationalError) connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | (Background on this error at: https://sqlalche.me/e/20/e3q8) +api-1 | entrypoint: database not ready (attempt 14), retrying in 3s +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | psycopg.OperationalError: connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | +api-1 | The above exception was the direct cause of the following exception: +api-1 | +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/bin/alembic", line 8, in +api-1 | sys.exit(main()) +api-1 | ^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1039, in main +api-1 | CommandLine(prog=prog).main(argv=argv) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1029, in main +api-1 | self.run_cmd(cfg, options) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 963, in run_cmd +api-1 | fn( +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/command.py", line 487, in upgrade +api-1 | script.run_env() +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/script/base.py", line 550, in run_env +api-1 | util.load_python_file(self.dir, "env.py") +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 114, in load_python_file +api-1 | module = load_module_py(module_id, path) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 132, in load_module_py +api-1 | spec.loader.exec_module(module) # type: ignore +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "", line 999, in exec_module +api-1 | File "", line 488, in _call_with_frames_removed +api-1 | File "/srv/alembic/env.py", line 47, in +api-1 | run_migrations_online() +api-1 | File "/srv/alembic/env.py", line 36, in run_migrations_online +api-1 | with connectable.connect() as connection: +api-1 | ^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3295, in connect +api-1 | return self._connection_cls(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 146, in __init__ +api-1 | Connection._handle_dbapi_exception_noconnection( +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 2450, in _handle_dbapi_exception_noconnection +api-1 | raise sqlalchemy_exception.with_traceback(exc_info[2]) from e +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | sqlalchemy.exc.OperationalError: (psycopg.OperationalError) connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | (Background on this error at: https://sqlalche.me/e/20/e3q8) +api-1 | entrypoint: database migration failed after 15 attempts +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | psycopg.OperationalError: connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | +api-1 | The above exception was the direct cause of the following exception: +api-1 | +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/bin/alembic", line 8, in +api-1 | sys.exit(main()) +api-1 | ^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1039, in main +api-1 | CommandLine(prog=prog).main(argv=argv) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1029, in main +api-1 | self.run_cmd(cfg, options) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 963, in run_cmd +api-1 | fn( +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/command.py", line 487, in upgrade +api-1 | script.run_env() +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/script/base.py", line 550, in run_env +api-1 | util.load_python_file(self.dir, "env.py") +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 114, in load_python_file +api-1 | module = load_module_py(module_id, path) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 132, in load_module_py +api-1 | spec.loader.exec_module(module) # type: ignore +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "", line 999, in exec_module +api-1 | File "", line 488, in _call_with_frames_removed +api-1 | File "/srv/alembic/env.py", line 47, in +api-1 | run_migrations_online() +api-1 | File "/srv/alembic/env.py", line 36, in run_migrations_online +api-1 | with connectable.connect() as connection: +api-1 | ^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3295, in connect +api-1 | return self._connection_cls(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 146, in __init__ +api-1 | Connection._handle_dbapi_exception_noconnection( +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 2450, in _handle_dbapi_exception_noconnection +api-1 | raise sqlalchemy_exception.with_traceback(exc_info[2]) from e +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | sqlalchemy.exc.OperationalError: (psycopg.OperationalError) connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | (Background on this error at: https://sqlalche.me/e/20/e3q8) +api-1 | entrypoint: database not ready (attempt 1), retrying in 3s +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | psycopg.OperationalError: connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | +api-1 | The above exception was the direct cause of the following exception: +api-1 | +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/bin/alembic", line 8, in +api-1 | sys.exit(main()) +api-1 | ^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1039, in main +api-1 | CommandLine(prog=prog).main(argv=argv) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1029, in main +api-1 | self.run_cmd(cfg, options) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 963, in run_cmd +api-1 | fn( +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/command.py", line 487, in upgrade +api-1 | script.run_env() +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/script/base.py", line 550, in run_env +api-1 | util.load_python_file(self.dir, "env.py") +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 114, in load_python_file +api-1 | module = load_module_py(module_id, path) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 132, in load_module_py +api-1 | spec.loader.exec_module(module) # type: ignore +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "", line 999, in exec_module +api-1 | File "", line 488, in _call_with_frames_removed +api-1 | File "/srv/alembic/env.py", line 47, in +api-1 | run_migrations_online() +api-1 | File "/srv/alembic/env.py", line 36, in run_migrations_online +api-1 | with connectable.connect() as connection: +api-1 | ^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3295, in connect +api-1 | return self._connection_cls(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 146, in __init__ +api-1 | Connection._handle_dbapi_exception_noconnection( +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 2450, in _handle_dbapi_exception_noconnection +api-1 | raise sqlalchemy_exception.with_traceback(exc_info[2]) from e +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | sqlalchemy.exc.OperationalError: (psycopg.OperationalError) connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | (Background on this error at: https://sqlalche.me/e/20/e3q8) +api-1 | entrypoint: database not ready (attempt 2), retrying in 3s +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | psycopg.OperationalError: connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | +api-1 | The above exception was the direct cause of the following exception: +api-1 | +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/bin/alembic", line 8, in +api-1 | sys.exit(main()) +api-1 | ^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1039, in main +api-1 | CommandLine(prog=prog).main(argv=argv) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1029, in main +api-1 | self.run_cmd(cfg, options) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 963, in run_cmd +api-1 | fn( +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/command.py", line 487, in upgrade +api-1 | script.run_env() +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/script/base.py", line 550, in run_env +api-1 | util.load_python_file(self.dir, "env.py") +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 114, in load_python_file +api-1 | module = load_module_py(module_id, path) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 132, in load_module_py +api-1 | spec.loader.exec_module(module) # type: ignore +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "", line 999, in exec_module +api-1 | File "", line 488, in _call_with_frames_removed +api-1 | File "/srv/alembic/env.py", line 47, in +api-1 | run_migrations_online() +api-1 | File "/srv/alembic/env.py", line 36, in run_migrations_online +api-1 | with connectable.connect() as connection: +api-1 | ^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3295, in connect +api-1 | return self._connection_cls(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 146, in __init__ +api-1 | Connection._handle_dbapi_exception_noconnection( +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 2450, in _handle_dbapi_exception_noconnection +api-1 | raise sqlalchemy_exception.with_traceback(exc_info[2]) from e +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | sqlalchemy.exc.OperationalError: (psycopg.OperationalError) connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | (Background on this error at: https://sqlalche.me/e/20/e3q8) +api-1 | entrypoint: database not ready (attempt 3), retrying in 3s +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | psycopg.OperationalError: connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | +api-1 | The above exception was the direct cause of the following exception: +api-1 | +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/bin/alembic", line 8, in +api-1 | sys.exit(main()) +api-1 | ^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1039, in main +api-1 | CommandLine(prog=prog).main(argv=argv) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1029, in main +api-1 | self.run_cmd(cfg, options) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 963, in run_cmd +api-1 | fn( +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/command.py", line 487, in upgrade +api-1 | script.run_env() +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/script/base.py", line 550, in run_env +api-1 | util.load_python_file(self.dir, "env.py") +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 114, in load_python_file +api-1 | module = load_module_py(module_id, path) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 132, in load_module_py +api-1 | spec.loader.exec_module(module) # type: ignore +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "", line 999, in exec_module +api-1 | File "", line 488, in _call_with_frames_removed +api-1 | File "/srv/alembic/env.py", line 47, in +api-1 | run_migrations_online() +api-1 | File "/srv/alembic/env.py", line 36, in run_migrations_online +api-1 | with connectable.connect() as connection: +api-1 | ^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3295, in connect +api-1 | return self._connection_cls(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 146, in __init__ +api-1 | Connection._handle_dbapi_exception_noconnection( +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 2450, in _handle_dbapi_exception_noconnection +api-1 | raise sqlalchemy_exception.with_traceback(exc_info[2]) from e +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | sqlalchemy.exc.OperationalError: (psycopg.OperationalError) connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | (Background on this error at: https://sqlalche.me/e/20/e3q8) +api-1 | entrypoint: database not ready (attempt 4), retrying in 3s +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | psycopg.OperationalError: connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | +api-1 | The above exception was the direct cause of the following exception: +api-1 | +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/bin/alembic", line 8, in +api-1 | sys.exit(main()) +api-1 | ^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1039, in main +api-1 | CommandLine(prog=prog).main(argv=argv) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1029, in main +api-1 | self.run_cmd(cfg, options) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 963, in run_cmd +api-1 | fn( +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/command.py", line 487, in upgrade +api-1 | script.run_env() +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/script/base.py", line 550, in run_env +api-1 | util.load_python_file(self.dir, "env.py") +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 114, in load_python_file +api-1 | module = load_module_py(module_id, path) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 132, in load_module_py +api-1 | spec.loader.exec_module(module) # type: ignore +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "", line 999, in exec_module +api-1 | File "", line 488, in _call_with_frames_removed +api-1 | File "/srv/alembic/env.py", line 47, in +api-1 | run_migrations_online() +api-1 | File "/srv/alembic/env.py", line 36, in run_migrations_online +api-1 | with connectable.connect() as connection: +api-1 | ^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3295, in connect +api-1 | return self._connection_cls(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 146, in __init__ +api-1 | Connection._handle_dbapi_exception_noconnection( +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 2450, in _handle_dbapi_exception_noconnection +api-1 | raise sqlalchemy_exception.with_traceback(exc_info[2]) from e +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | sqlalchemy.exc.OperationalError: (psycopg.OperationalError) connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | (Background on this error at: https://sqlalche.me/e/20/e3q8) +api-1 | entrypoint: database not ready (attempt 5), retrying in 3s +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | psycopg.OperationalError: connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | +api-1 | The above exception was the direct cause of the following exception: +api-1 | +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/bin/alembic", line 8, in +api-1 | sys.exit(main()) +api-1 | ^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1039, in main +api-1 | CommandLine(prog=prog).main(argv=argv) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1029, in main +api-1 | self.run_cmd(cfg, options) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 963, in run_cmd +api-1 | fn( +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/command.py", line 487, in upgrade +api-1 | script.run_env() +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/script/base.py", line 550, in run_env +api-1 | util.load_python_file(self.dir, "env.py") +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 114, in load_python_file +api-1 | module = load_module_py(module_id, path) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 132, in load_module_py +api-1 | spec.loader.exec_module(module) # type: ignore +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "", line 999, in exec_module +api-1 | File "", line 488, in _call_with_frames_removed +api-1 | File "/srv/alembic/env.py", line 47, in +api-1 | run_migrations_online() +api-1 | File "/srv/alembic/env.py", line 36, in run_migrations_online +api-1 | with connectable.connect() as connection: +api-1 | ^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3295, in connect +api-1 | return self._connection_cls(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 146, in __init__ +api-1 | Connection._handle_dbapi_exception_noconnection( +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 2450, in _handle_dbapi_exception_noconnection +api-1 | raise sqlalchemy_exception.with_traceback(exc_info[2]) from e +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | sqlalchemy.exc.OperationalError: (psycopg.OperationalError) connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | (Background on this error at: https://sqlalche.me/e/20/e3q8) +api-1 | entrypoint: database not ready (attempt 6), retrying in 3s +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | psycopg.OperationalError: connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | +api-1 | The above exception was the direct cause of the following exception: +api-1 | +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/bin/alembic", line 8, in +api-1 | sys.exit(main()) +api-1 | ^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1039, in main +api-1 | CommandLine(prog=prog).main(argv=argv) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1029, in main +api-1 | self.run_cmd(cfg, options) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 963, in run_cmd +api-1 | fn( +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/command.py", line 487, in upgrade +api-1 | script.run_env() +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/script/base.py", line 550, in run_env +api-1 | util.load_python_file(self.dir, "env.py") +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 114, in load_python_file +api-1 | module = load_module_py(module_id, path) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 132, in load_module_py +api-1 | spec.loader.exec_module(module) # type: ignore +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "", line 999, in exec_module +api-1 | File "", line 488, in _call_with_frames_removed +api-1 | File "/srv/alembic/env.py", line 47, in +api-1 | run_migrations_online() +api-1 | File "/srv/alembic/env.py", line 36, in run_migrations_online +api-1 | with connectable.connect() as connection: +api-1 | ^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3295, in connect +api-1 | return self._connection_cls(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 146, in __init__ +api-1 | Connection._handle_dbapi_exception_noconnection( +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 2450, in _handle_dbapi_exception_noconnection +api-1 | raise sqlalchemy_exception.with_traceback(exc_info[2]) from e +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | sqlalchemy.exc.OperationalError: (psycopg.OperationalError) connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | (Background on this error at: https://sqlalche.me/e/20/e3q8) +api-1 | entrypoint: database not ready (attempt 7), retrying in 3s +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | psycopg.OperationalError: connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | +api-1 | The above exception was the direct cause of the following exception: +api-1 | +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/bin/alembic", line 8, in +api-1 | sys.exit(main()) +api-1 | ^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1039, in main +api-1 | CommandLine(prog=prog).main(argv=argv) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1029, in main +api-1 | self.run_cmd(cfg, options) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 963, in run_cmd +api-1 | fn( +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/command.py", line 487, in upgrade +api-1 | script.run_env() +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/script/base.py", line 550, in run_env +api-1 | util.load_python_file(self.dir, "env.py") +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 114, in load_python_file +api-1 | module = load_module_py(module_id, path) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 132, in load_module_py +api-1 | spec.loader.exec_module(module) # type: ignore +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "", line 999, in exec_module +api-1 | File "", line 488, in _call_with_frames_removed +api-1 | File "/srv/alembic/env.py", line 47, in +api-1 | run_migrations_online() +api-1 | File "/srv/alembic/env.py", line 36, in run_migrations_online +api-1 | with connectable.connect() as connection: +api-1 | ^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3295, in connect +api-1 | return self._connection_cls(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 146, in __init__ +api-1 | Connection._handle_dbapi_exception_noconnection( +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 2450, in _handle_dbapi_exception_noconnection +api-1 | raise sqlalchemy_exception.with_traceback(exc_info[2]) from e +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | sqlalchemy.exc.OperationalError: (psycopg.OperationalError) connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | (Background on this error at: https://sqlalche.me/e/20/e3q8) +api-1 | entrypoint: database not ready (attempt 8), retrying in 3s +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | psycopg.OperationalError: connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | +api-1 | The above exception was the direct cause of the following exception: +api-1 | +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/bin/alembic", line 8, in +api-1 | sys.exit(main()) +api-1 | ^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1039, in main +api-1 | CommandLine(prog=prog).main(argv=argv) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1029, in main +api-1 | self.run_cmd(cfg, options) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 963, in run_cmd +api-1 | fn( +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/command.py", line 487, in upgrade +api-1 | script.run_env() +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/script/base.py", line 550, in run_env +api-1 | util.load_python_file(self.dir, "env.py") +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 114, in load_python_file +api-1 | module = load_module_py(module_id, path) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 132, in load_module_py +api-1 | spec.loader.exec_module(module) # type: ignore +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "", line 999, in exec_module +api-1 | File "", line 488, in _call_with_frames_removed +api-1 | File "/srv/alembic/env.py", line 47, in +api-1 | run_migrations_online() +api-1 | File "/srv/alembic/env.py", line 36, in run_migrations_online +api-1 | with connectable.connect() as connection: +api-1 | ^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3295, in connect +api-1 | return self._connection_cls(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 146, in __init__ +api-1 | Connection._handle_dbapi_exception_noconnection( +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 2450, in _handle_dbapi_exception_noconnection +api-1 | raise sqlalchemy_exception.with_traceback(exc_info[2]) from e +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | sqlalchemy.exc.OperationalError: (psycopg.OperationalError) connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | (Background on this error at: https://sqlalche.me/e/20/e3q8) +api-1 | entrypoint: database not ready (attempt 9), retrying in 3s +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | psycopg.OperationalError: connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | +api-1 | The above exception was the direct cause of the following exception: +api-1 | +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/bin/alembic", line 8, in +api-1 | sys.exit(main()) +api-1 | ^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1039, in main +api-1 | CommandLine(prog=prog).main(argv=argv) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1029, in main +api-1 | self.run_cmd(cfg, options) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 963, in run_cmd +api-1 | fn( +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/command.py", line 487, in upgrade +api-1 | script.run_env() +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/script/base.py", line 550, in run_env +api-1 | util.load_python_file(self.dir, "env.py") +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 114, in load_python_file +api-1 | module = load_module_py(module_id, path) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 132, in load_module_py +api-1 | spec.loader.exec_module(module) # type: ignore +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "", line 999, in exec_module +api-1 | File "", line 488, in _call_with_frames_removed +api-1 | File "/srv/alembic/env.py", line 47, in +api-1 | run_migrations_online() +api-1 | File "/srv/alembic/env.py", line 36, in run_migrations_online +api-1 | with connectable.connect() as connection: +api-1 | ^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3295, in connect +api-1 | return self._connection_cls(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 146, in __init__ +api-1 | Connection._handle_dbapi_exception_noconnection( +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 2450, in _handle_dbapi_exception_noconnection +api-1 | raise sqlalchemy_exception.with_traceback(exc_info[2]) from e +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | sqlalchemy.exc.OperationalError: (psycopg.OperationalError) connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | (Background on this error at: https://sqlalche.me/e/20/e3q8) +api-1 | entrypoint: database not ready (attempt 10), retrying in 3s +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | psycopg.OperationalError: connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | +api-1 | The above exception was the direct cause of the following exception: +api-1 | +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/bin/alembic", line 8, in +api-1 | sys.exit(main()) +api-1 | ^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1039, in main +api-1 | CommandLine(prog=prog).main(argv=argv) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1029, in main +api-1 | self.run_cmd(cfg, options) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 963, in run_cmd +api-1 | fn( +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/command.py", line 487, in upgrade +api-1 | script.run_env() +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/script/base.py", line 550, in run_env +api-1 | util.load_python_file(self.dir, "env.py") +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 114, in load_python_file +api-1 | module = load_module_py(module_id, path) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 132, in load_module_py +api-1 | spec.loader.exec_module(module) # type: ignore +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "", line 999, in exec_module +api-1 | File "", line 488, in _call_with_frames_removed +api-1 | File "/srv/alembic/env.py", line 47, in +api-1 | run_migrations_online() +api-1 | File "/srv/alembic/env.py", line 36, in run_migrations_online +api-1 | with connectable.connect() as connection: +api-1 | ^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3295, in connect +api-1 | return self._connection_cls(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 146, in __init__ +api-1 | Connection._handle_dbapi_exception_noconnection( +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 2450, in _handle_dbapi_exception_noconnection +api-1 | raise sqlalchemy_exception.with_traceback(exc_info[2]) from e +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | sqlalchemy.exc.OperationalError: (psycopg.OperationalError) connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | (Background on this error at: https://sqlalche.me/e/20/e3q8) +api-1 | entrypoint: database not ready (attempt 11), retrying in 3s +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | psycopg.OperationalError: connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | +api-1 | The above exception was the direct cause of the following exception: +api-1 | +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/bin/alembic", line 8, in +api-1 | sys.exit(main()) +api-1 | ^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1039, in main +api-1 | CommandLine(prog=prog).main(argv=argv) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1029, in main +api-1 | self.run_cmd(cfg, options) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 963, in run_cmd +api-1 | fn( +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/command.py", line 487, in upgrade +api-1 | script.run_env() +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/script/base.py", line 550, in run_env +api-1 | util.load_python_file(self.dir, "env.py") +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 114, in load_python_file +api-1 | module = load_module_py(module_id, path) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 132, in load_module_py +api-1 | spec.loader.exec_module(module) # type: ignore +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "", line 999, in exec_module +api-1 | File "", line 488, in _call_with_frames_removed +api-1 | File "/srv/alembic/env.py", line 47, in +api-1 | run_migrations_online() +api-1 | File "/srv/alembic/env.py", line 36, in run_migrations_online +api-1 | with connectable.connect() as connection: +api-1 | ^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3295, in connect +api-1 | return self._connection_cls(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 146, in __init__ +api-1 | Connection._handle_dbapi_exception_noconnection( +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 2450, in _handle_dbapi_exception_noconnection +api-1 | raise sqlalchemy_exception.with_traceback(exc_info[2]) from e +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | sqlalchemy.exc.OperationalError: (psycopg.OperationalError) connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | (Background on this error at: https://sqlalche.me/e/20/e3q8) +api-1 | entrypoint: database not ready (attempt 12), retrying in 3s +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | psycopg.OperationalError: connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | +api-1 | The above exception was the direct cause of the following exception: +api-1 | +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/bin/alembic", line 8, in +api-1 | sys.exit(main()) +api-1 | ^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1039, in main +api-1 | CommandLine(prog=prog).main(argv=argv) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1029, in main +api-1 | self.run_cmd(cfg, options) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 963, in run_cmd +api-1 | fn( +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/command.py", line 487, in upgrade +api-1 | script.run_env() +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/script/base.py", line 550, in run_env +api-1 | util.load_python_file(self.dir, "env.py") +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 114, in load_python_file +api-1 | module = load_module_py(module_id, path) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 132, in load_module_py +api-1 | spec.loader.exec_module(module) # type: ignore +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "", line 999, in exec_module +api-1 | File "", line 488, in _call_with_frames_removed +api-1 | File "/srv/alembic/env.py", line 47, in +api-1 | run_migrations_online() +api-1 | File "/srv/alembic/env.py", line 36, in run_migrations_online +api-1 | with connectable.connect() as connection: +api-1 | ^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3295, in connect +api-1 | return self._connection_cls(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 146, in __init__ +api-1 | Connection._handle_dbapi_exception_noconnection( +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 2450, in _handle_dbapi_exception_noconnection +api-1 | raise sqlalchemy_exception.with_traceback(exc_info[2]) from e +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | sqlalchemy.exc.OperationalError: (psycopg.OperationalError) connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | (Background on this error at: https://sqlalche.me/e/20/e3q8) +api-1 | entrypoint: database not ready (attempt 13), retrying in 3s +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | psycopg.OperationalError: connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | +api-1 | The above exception was the direct cause of the following exception: +api-1 | +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/bin/alembic", line 8, in +api-1 | sys.exit(main()) +api-1 | ^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1039, in main +api-1 | CommandLine(prog=prog).main(argv=argv) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1029, in main +api-1 | self.run_cmd(cfg, options) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 963, in run_cmd +api-1 | fn( +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/command.py", line 487, in upgrade +api-1 | script.run_env() +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/script/base.py", line 550, in run_env +api-1 | util.load_python_file(self.dir, "env.py") +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 114, in load_python_file +api-1 | module = load_module_py(module_id, path) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 132, in load_module_py +api-1 | spec.loader.exec_module(module) # type: ignore +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "", line 999, in exec_module +api-1 | File "", line 488, in _call_with_frames_removed +api-1 | File "/srv/alembic/env.py", line 47, in +api-1 | run_migrations_online() +api-1 | File "/srv/alembic/env.py", line 36, in run_migrations_online +api-1 | with connectable.connect() as connection: +api-1 | ^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3295, in connect +api-1 | return self._connection_cls(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 146, in __init__ +api-1 | Connection._handle_dbapi_exception_noconnection( +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 2450, in _handle_dbapi_exception_noconnection +api-1 | raise sqlalchemy_exception.with_traceback(exc_info[2]) from e +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | sqlalchemy.exc.OperationalError: (psycopg.OperationalError) connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | (Background on this error at: https://sqlalche.me/e/20/e3q8) +api-1 | entrypoint: database not ready (attempt 14), retrying in 3s +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | psycopg.OperationalError: connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | +api-1 | The above exception was the direct cause of the following exception: +api-1 | +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/bin/alembic", line 8, in +api-1 | sys.exit(main()) +api-1 | ^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1039, in main +api-1 | CommandLine(prog=prog).main(argv=argv) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1029, in main +api-1 | self.run_cmd(cfg, options) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 963, in run_cmd +api-1 | fn( +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/command.py", line 487, in upgrade +api-1 | script.run_env() +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/script/base.py", line 550, in run_env +api-1 | util.load_python_file(self.dir, "env.py") +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 114, in load_python_file +api-1 | module = load_module_py(module_id, path) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 132, in load_module_py +api-1 | spec.loader.exec_module(module) # type: ignore +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "", line 999, in exec_module +api-1 | File "", line 488, in _call_with_frames_removed +api-1 | File "/srv/alembic/env.py", line 47, in +api-1 | run_migrations_online() +api-1 | File "/srv/alembic/env.py", line 36, in run_migrations_online +api-1 | with connectable.connect() as connection: +api-1 | ^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3295, in connect +api-1 | return self._connection_cls(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 146, in __init__ +api-1 | Connection._handle_dbapi_exception_noconnection( +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 2450, in _handle_dbapi_exception_noconnection +api-1 | raise sqlalchemy_exception.with_traceback(exc_info[2]) from e +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | sqlalchemy.exc.OperationalError: (psycopg.OperationalError) connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | (Background on this error at: https://sqlalche.me/e/20/e3q8) +api-1 | entrypoint: database migration failed after 15 attempts +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | psycopg.OperationalError: connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | +api-1 | The above exception was the direct cause of the following exception: +api-1 | +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/bin/alembic", line 8, in +api-1 | sys.exit(main()) +api-1 | ^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1039, in main +api-1 | CommandLine(prog=prog).main(argv=argv) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1029, in main +api-1 | self.run_cmd(cfg, options) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 963, in run_cmd +api-1 | fn( +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/command.py", line 487, in upgrade +api-1 | script.run_env() +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/script/base.py", line 550, in run_env +api-1 | util.load_python_file(self.dir, "env.py") +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 114, in load_python_file +api-1 | module = load_module_py(module_id, path) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 132, in load_module_py +api-1 | spec.loader.exec_module(module) # type: ignore +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "", line 999, in exec_module +api-1 | File "", line 488, in _call_with_frames_removed +api-1 | File "/srv/alembic/env.py", line 47, in +api-1 | run_migrations_online() +api-1 | File "/srv/alembic/env.py", line 36, in run_migrations_online +api-1 | with connectable.connect() as connection: +api-1 | ^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3295, in connect +api-1 | return self._connection_cls(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 146, in __init__ +api-1 | Connection._handle_dbapi_exception_noconnection( +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 2450, in _handle_dbapi_exception_noconnection +api-1 | raise sqlalchemy_exception.with_traceback(exc_info[2]) from e +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | sqlalchemy.exc.OperationalError: (psycopg.OperationalError) connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | (Background on this error at: https://sqlalche.me/e/20/e3q8) +api-1 | entrypoint: database not ready (attempt 1), retrying in 3s +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | psycopg.OperationalError: connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | +api-1 | The above exception was the direct cause of the following exception: +api-1 | +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/bin/alembic", line 8, in +api-1 | sys.exit(main()) +api-1 | ^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1039, in main +api-1 | CommandLine(prog=prog).main(argv=argv) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1029, in main +api-1 | self.run_cmd(cfg, options) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 963, in run_cmd +api-1 | fn( +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/command.py", line 487, in upgrade +api-1 | script.run_env() +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/script/base.py", line 550, in run_env +api-1 | util.load_python_file(self.dir, "env.py") +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 114, in load_python_file +api-1 | module = load_module_py(module_id, path) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 132, in load_module_py +api-1 | spec.loader.exec_module(module) # type: ignore +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "", line 999, in exec_module +api-1 | File "", line 488, in _call_with_frames_removed +api-1 | File "/srv/alembic/env.py", line 47, in +api-1 | run_migrations_online() +api-1 | File "/srv/alembic/env.py", line 36, in run_migrations_online +api-1 | with connectable.connect() as connection: +api-1 | ^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3295, in connect +api-1 | return self._connection_cls(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 146, in __init__ +api-1 | Connection._handle_dbapi_exception_noconnection( +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 2450, in _handle_dbapi_exception_noconnection +api-1 | raise sqlalchemy_exception.with_traceback(exc_info[2]) from e +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | sqlalchemy.exc.OperationalError: (psycopg.OperationalError) connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | (Background on this error at: https://sqlalche.me/e/20/e3q8) +api-1 | entrypoint: database not ready (attempt 2), retrying in 3s +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | psycopg.OperationalError: connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | +api-1 | The above exception was the direct cause of the following exception: +api-1 | +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/bin/alembic", line 8, in +api-1 | sys.exit(main()) +api-1 | ^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1039, in main +api-1 | CommandLine(prog=prog).main(argv=argv) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1029, in main +api-1 | self.run_cmd(cfg, options) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 963, in run_cmd +api-1 | fn( +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/command.py", line 487, in upgrade +api-1 | script.run_env() +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/script/base.py", line 550, in run_env +api-1 | util.load_python_file(self.dir, "env.py") +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 114, in load_python_file +api-1 | module = load_module_py(module_id, path) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 132, in load_module_py +api-1 | spec.loader.exec_module(module) # type: ignore +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "", line 999, in exec_module +api-1 | File "", line 488, in _call_with_frames_removed +api-1 | File "/srv/alembic/env.py", line 47, in +api-1 | run_migrations_online() +api-1 | File "/srv/alembic/env.py", line 36, in run_migrations_online +api-1 | with connectable.connect() as connection: +api-1 | ^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3295, in connect +api-1 | return self._connection_cls(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 146, in __init__ +api-1 | Connection._handle_dbapi_exception_noconnection( +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 2450, in _handle_dbapi_exception_noconnection +api-1 | raise sqlalchemy_exception.with_traceback(exc_info[2]) from e +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | sqlalchemy.exc.OperationalError: (psycopg.OperationalError) connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | (Background on this error at: https://sqlalche.me/e/20/e3q8) +api-1 | entrypoint: database not ready (attempt 3), retrying in 3s +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | psycopg.OperationalError: connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | +api-1 | The above exception was the direct cause of the following exception: +api-1 | +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/bin/alembic", line 8, in +api-1 | sys.exit(main()) +api-1 | ^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1039, in main +api-1 | CommandLine(prog=prog).main(argv=argv) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1029, in main +api-1 | self.run_cmd(cfg, options) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 963, in run_cmd +api-1 | fn( +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/command.py", line 487, in upgrade +api-1 | script.run_env() +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/script/base.py", line 550, in run_env +api-1 | util.load_python_file(self.dir, "env.py") +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 114, in load_python_file +api-1 | module = load_module_py(module_id, path) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 132, in load_module_py +api-1 | spec.loader.exec_module(module) # type: ignore +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "", line 999, in exec_module +api-1 | File "", line 488, in _call_with_frames_removed +api-1 | File "/srv/alembic/env.py", line 47, in +api-1 | run_migrations_online() +api-1 | File "/srv/alembic/env.py", line 36, in run_migrations_online +api-1 | with connectable.connect() as connection: +api-1 | ^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3295, in connect +api-1 | return self._connection_cls(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 146, in __init__ +api-1 | Connection._handle_dbapi_exception_noconnection( +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 2450, in _handle_dbapi_exception_noconnection +api-1 | raise sqlalchemy_exception.with_traceback(exc_info[2]) from e +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | sqlalchemy.exc.OperationalError: (psycopg.OperationalError) connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | (Background on this error at: https://sqlalche.me/e/20/e3q8) +api-1 | entrypoint: database not ready (attempt 4), retrying in 3s +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | psycopg.OperationalError: connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | +api-1 | The above exception was the direct cause of the following exception: +api-1 | +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/bin/alembic", line 8, in +api-1 | sys.exit(main()) +api-1 | ^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1039, in main +api-1 | CommandLine(prog=prog).main(argv=argv) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1029, in main +api-1 | self.run_cmd(cfg, options) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 963, in run_cmd +api-1 | fn( +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/command.py", line 487, in upgrade +api-1 | script.run_env() +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/script/base.py", line 550, in run_env +api-1 | util.load_python_file(self.dir, "env.py") +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 114, in load_python_file +api-1 | module = load_module_py(module_id, path) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 132, in load_module_py +api-1 | spec.loader.exec_module(module) # type: ignore +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "", line 999, in exec_module +api-1 | File "", line 488, in _call_with_frames_removed +api-1 | File "/srv/alembic/env.py", line 47, in +api-1 | run_migrations_online() +api-1 | File "/srv/alembic/env.py", line 36, in run_migrations_online +api-1 | with connectable.connect() as connection: +api-1 | ^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3295, in connect +api-1 | return self._connection_cls(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 146, in __init__ +api-1 | Connection._handle_dbapi_exception_noconnection( +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 2450, in _handle_dbapi_exception_noconnection +api-1 | raise sqlalchemy_exception.with_traceback(exc_info[2]) from e +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | sqlalchemy.exc.OperationalError: (psycopg.OperationalError) connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | (Background on this error at: https://sqlalche.me/e/20/e3q8) +api-1 | entrypoint: database not ready (attempt 5), retrying in 3s +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | psycopg.OperationalError: connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | +api-1 | The above exception was the direct cause of the following exception: +api-1 | +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/bin/alembic", line 8, in +api-1 | sys.exit(main()) +api-1 | ^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1039, in main +api-1 | CommandLine(prog=prog).main(argv=argv) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1029, in main +api-1 | self.run_cmd(cfg, options) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 963, in run_cmd +api-1 | fn( +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/command.py", line 487, in upgrade +api-1 | script.run_env() +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/script/base.py", line 550, in run_env +api-1 | util.load_python_file(self.dir, "env.py") +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 114, in load_python_file +api-1 | module = load_module_py(module_id, path) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 132, in load_module_py +api-1 | spec.loader.exec_module(module) # type: ignore +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "", line 999, in exec_module +api-1 | File "", line 488, in _call_with_frames_removed +api-1 | File "/srv/alembic/env.py", line 47, in +api-1 | run_migrations_online() +api-1 | File "/srv/alembic/env.py", line 36, in run_migrations_online +api-1 | with connectable.connect() as connection: +api-1 | ^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3295, in connect +api-1 | return self._connection_cls(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 146, in __init__ +api-1 | Connection._handle_dbapi_exception_noconnection( +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 2450, in _handle_dbapi_exception_noconnection +api-1 | raise sqlalchemy_exception.with_traceback(exc_info[2]) from e +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | sqlalchemy.exc.OperationalError: (psycopg.OperationalError) connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | (Background on this error at: https://sqlalche.me/e/20/e3q8) +api-1 | entrypoint: database not ready (attempt 6), retrying in 3s +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | psycopg.OperationalError: connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | +api-1 | The above exception was the direct cause of the following exception: +api-1 | +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/bin/alembic", line 8, in +api-1 | sys.exit(main()) +api-1 | ^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1039, in main +api-1 | CommandLine(prog=prog).main(argv=argv) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1029, in main +api-1 | self.run_cmd(cfg, options) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 963, in run_cmd +api-1 | fn( +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/command.py", line 487, in upgrade +api-1 | script.run_env() +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/script/base.py", line 550, in run_env +api-1 | util.load_python_file(self.dir, "env.py") +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 114, in load_python_file +api-1 | module = load_module_py(module_id, path) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 132, in load_module_py +api-1 | spec.loader.exec_module(module) # type: ignore +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "", line 999, in exec_module +api-1 | File "", line 488, in _call_with_frames_removed +api-1 | File "/srv/alembic/env.py", line 47, in +api-1 | run_migrations_online() +api-1 | File "/srv/alembic/env.py", line 36, in run_migrations_online +api-1 | with connectable.connect() as connection: +api-1 | ^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3295, in connect +api-1 | return self._connection_cls(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 146, in __init__ +api-1 | Connection._handle_dbapi_exception_noconnection( +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 2450, in _handle_dbapi_exception_noconnection +api-1 | raise sqlalchemy_exception.with_traceback(exc_info[2]) from e +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | sqlalchemy.exc.OperationalError: (psycopg.OperationalError) connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | (Background on this error at: https://sqlalche.me/e/20/e3q8) +api-1 | entrypoint: database not ready (attempt 7), retrying in 3s +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | psycopg.OperationalError: connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | +api-1 | The above exception was the direct cause of the following exception: +api-1 | +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/bin/alembic", line 8, in +api-1 | sys.exit(main()) +api-1 | ^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1039, in main +api-1 | CommandLine(prog=prog).main(argv=argv) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1029, in main +api-1 | self.run_cmd(cfg, options) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 963, in run_cmd +api-1 | fn( +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/command.py", line 487, in upgrade +api-1 | script.run_env() +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/script/base.py", line 550, in run_env +api-1 | util.load_python_file(self.dir, "env.py") +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 114, in load_python_file +api-1 | module = load_module_py(module_id, path) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 132, in load_module_py +api-1 | spec.loader.exec_module(module) # type: ignore +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "", line 999, in exec_module +api-1 | File "", line 488, in _call_with_frames_removed +api-1 | File "/srv/alembic/env.py", line 47, in +api-1 | run_migrations_online() +api-1 | File "/srv/alembic/env.py", line 36, in run_migrations_online +api-1 | with connectable.connect() as connection: +api-1 | ^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3295, in connect +api-1 | return self._connection_cls(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 146, in __init__ +api-1 | Connection._handle_dbapi_exception_noconnection( +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 2450, in _handle_dbapi_exception_noconnection +api-1 | raise sqlalchemy_exception.with_traceback(exc_info[2]) from e +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | sqlalchemy.exc.OperationalError: (psycopg.OperationalError) connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | (Background on this error at: https://sqlalche.me/e/20/e3q8) +api-1 | entrypoint: database not ready (attempt 8), retrying in 3s +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | psycopg.OperationalError: connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | +api-1 | The above exception was the direct cause of the following exception: +api-1 | +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/bin/alembic", line 8, in +api-1 | sys.exit(main()) +api-1 | ^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1039, in main +api-1 | CommandLine(prog=prog).main(argv=argv) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1029, in main +api-1 | self.run_cmd(cfg, options) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 963, in run_cmd +api-1 | fn( +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/command.py", line 487, in upgrade +api-1 | script.run_env() +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/script/base.py", line 550, in run_env +api-1 | util.load_python_file(self.dir, "env.py") +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 114, in load_python_file +api-1 | module = load_module_py(module_id, path) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 132, in load_module_py +api-1 | spec.loader.exec_module(module) # type: ignore +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "", line 999, in exec_module +api-1 | File "", line 488, in _call_with_frames_removed +api-1 | File "/srv/alembic/env.py", line 47, in +api-1 | run_migrations_online() +api-1 | File "/srv/alembic/env.py", line 36, in run_migrations_online +api-1 | with connectable.connect() as connection: +api-1 | ^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3295, in connect +api-1 | return self._connection_cls(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 146, in __init__ +api-1 | Connection._handle_dbapi_exception_noconnection( +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 2450, in _handle_dbapi_exception_noconnection +api-1 | raise sqlalchemy_exception.with_traceback(exc_info[2]) from e +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | sqlalchemy.exc.OperationalError: (psycopg.OperationalError) connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | (Background on this error at: https://sqlalche.me/e/20/e3q8) +api-1 | entrypoint: database not ready (attempt 9), retrying in 3s +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | psycopg.OperationalError: connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | +api-1 | The above exception was the direct cause of the following exception: +api-1 | +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/bin/alembic", line 8, in +api-1 | sys.exit(main()) +api-1 | ^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1039, in main +api-1 | CommandLine(prog=prog).main(argv=argv) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1029, in main +api-1 | self.run_cmd(cfg, options) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 963, in run_cmd +api-1 | fn( +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/command.py", line 487, in upgrade +api-1 | script.run_env() +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/script/base.py", line 550, in run_env +api-1 | util.load_python_file(self.dir, "env.py") +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 114, in load_python_file +api-1 | module = load_module_py(module_id, path) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 132, in load_module_py +api-1 | spec.loader.exec_module(module) # type: ignore +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "", line 999, in exec_module +api-1 | File "", line 488, in _call_with_frames_removed +api-1 | File "/srv/alembic/env.py", line 47, in +api-1 | run_migrations_online() +api-1 | File "/srv/alembic/env.py", line 36, in run_migrations_online +api-1 | with connectable.connect() as connection: +api-1 | ^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3295, in connect +api-1 | return self._connection_cls(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 146, in __init__ +api-1 | Connection._handle_dbapi_exception_noconnection( +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 2450, in _handle_dbapi_exception_noconnection +api-1 | raise sqlalchemy_exception.with_traceback(exc_info[2]) from e +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | sqlalchemy.exc.OperationalError: (psycopg.OperationalError) connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | (Background on this error at: https://sqlalche.me/e/20/e3q8) +api-1 | entrypoint: database not ready (attempt 10), retrying in 3s +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | psycopg.OperationalError: connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | +api-1 | The above exception was the direct cause of the following exception: +api-1 | +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/bin/alembic", line 8, in +api-1 | sys.exit(main()) +api-1 | ^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1039, in main +api-1 | CommandLine(prog=prog).main(argv=argv) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1029, in main +api-1 | self.run_cmd(cfg, options) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 963, in run_cmd +api-1 | fn( +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/command.py", line 487, in upgrade +api-1 | script.run_env() +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/script/base.py", line 550, in run_env +api-1 | util.load_python_file(self.dir, "env.py") +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 114, in load_python_file +api-1 | module = load_module_py(module_id, path) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 132, in load_module_py +api-1 | spec.loader.exec_module(module) # type: ignore +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "", line 999, in exec_module +api-1 | File "", line 488, in _call_with_frames_removed +api-1 | File "/srv/alembic/env.py", line 47, in +api-1 | run_migrations_online() +api-1 | File "/srv/alembic/env.py", line 36, in run_migrations_online +api-1 | with connectable.connect() as connection: +api-1 | ^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3295, in connect +api-1 | return self._connection_cls(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 146, in __init__ +api-1 | Connection._handle_dbapi_exception_noconnection( +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 2450, in _handle_dbapi_exception_noconnection +api-1 | raise sqlalchemy_exception.with_traceback(exc_info[2]) from e +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | sqlalchemy.exc.OperationalError: (psycopg.OperationalError) connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | (Background on this error at: https://sqlalche.me/e/20/e3q8) +api-1 | entrypoint: database not ready (attempt 11), retrying in 3s +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | psycopg.OperationalError: connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | +api-1 | The above exception was the direct cause of the following exception: +api-1 | +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/bin/alembic", line 8, in +api-1 | sys.exit(main()) +api-1 | ^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1039, in main +api-1 | CommandLine(prog=prog).main(argv=argv) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1029, in main +api-1 | self.run_cmd(cfg, options) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 963, in run_cmd +api-1 | fn( +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/command.py", line 487, in upgrade +api-1 | script.run_env() +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/script/base.py", line 550, in run_env +api-1 | util.load_python_file(self.dir, "env.py") +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 114, in load_python_file +api-1 | module = load_module_py(module_id, path) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 132, in load_module_py +api-1 | spec.loader.exec_module(module) # type: ignore +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "", line 999, in exec_module +api-1 | File "", line 488, in _call_with_frames_removed +api-1 | File "/srv/alembic/env.py", line 47, in +api-1 | run_migrations_online() +api-1 | File "/srv/alembic/env.py", line 36, in run_migrations_online +api-1 | with connectable.connect() as connection: +api-1 | ^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3295, in connect +api-1 | return self._connection_cls(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 146, in __init__ +api-1 | Connection._handle_dbapi_exception_noconnection( +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 2450, in _handle_dbapi_exception_noconnection +api-1 | raise sqlalchemy_exception.with_traceback(exc_info[2]) from e +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | sqlalchemy.exc.OperationalError: (psycopg.OperationalError) connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | (Background on this error at: https://sqlalche.me/e/20/e3q8) +api-1 | entrypoint: database not ready (attempt 12), retrying in 3s +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | psycopg.OperationalError: connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | +api-1 | The above exception was the direct cause of the following exception: +api-1 | +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/bin/alembic", line 8, in +api-1 | sys.exit(main()) +api-1 | ^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1039, in main +api-1 | CommandLine(prog=prog).main(argv=argv) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1029, in main +api-1 | self.run_cmd(cfg, options) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 963, in run_cmd +api-1 | fn( +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/command.py", line 487, in upgrade +api-1 | script.run_env() +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/script/base.py", line 550, in run_env +api-1 | util.load_python_file(self.dir, "env.py") +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 114, in load_python_file +api-1 | module = load_module_py(module_id, path) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 132, in load_module_py +api-1 | spec.loader.exec_module(module) # type: ignore +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "", line 999, in exec_module +api-1 | File "", line 488, in _call_with_frames_removed +api-1 | File "/srv/alembic/env.py", line 47, in +api-1 | run_migrations_online() +api-1 | File "/srv/alembic/env.py", line 36, in run_migrations_online +api-1 | with connectable.connect() as connection: +api-1 | ^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3295, in connect +api-1 | return self._connection_cls(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 146, in __init__ +api-1 | Connection._handle_dbapi_exception_noconnection( +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 2450, in _handle_dbapi_exception_noconnection +api-1 | raise sqlalchemy_exception.with_traceback(exc_info[2]) from e +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | sqlalchemy.exc.OperationalError: (psycopg.OperationalError) connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | (Background on this error at: https://sqlalche.me/e/20/e3q8) +api-1 | entrypoint: database not ready (attempt 13), retrying in 3s +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | psycopg.OperationalError: connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | +api-1 | The above exception was the direct cause of the following exception: +api-1 | +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/bin/alembic", line 8, in +api-1 | sys.exit(main()) +api-1 | ^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1039, in main +api-1 | CommandLine(prog=prog).main(argv=argv) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1029, in main +api-1 | self.run_cmd(cfg, options) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 963, in run_cmd +api-1 | fn( +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/command.py", line 487, in upgrade +api-1 | script.run_env() +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/script/base.py", line 550, in run_env +api-1 | util.load_python_file(self.dir, "env.py") +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 114, in load_python_file +api-1 | module = load_module_py(module_id, path) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 132, in load_module_py +api-1 | spec.loader.exec_module(module) # type: ignore +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "", line 999, in exec_module +api-1 | File "", line 488, in _call_with_frames_removed +api-1 | File "/srv/alembic/env.py", line 47, in +api-1 | run_migrations_online() +api-1 | File "/srv/alembic/env.py", line 36, in run_migrations_online +api-1 | with connectable.connect() as connection: +api-1 | ^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3295, in connect +api-1 | return self._connection_cls(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 146, in __init__ +api-1 | Connection._handle_dbapi_exception_noconnection( +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 2450, in _handle_dbapi_exception_noconnection +api-1 | raise sqlalchemy_exception.with_traceback(exc_info[2]) from e +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | sqlalchemy.exc.OperationalError: (psycopg.OperationalError) connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | (Background on this error at: https://sqlalche.me/e/20/e3q8) +api-1 | entrypoint: database not ready (attempt 14), retrying in 3s +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | psycopg.OperationalError: connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | +api-1 | The above exception was the direct cause of the following exception: +api-1 | +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/bin/alembic", line 8, in +api-1 | sys.exit(main()) +api-1 | ^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1039, in main +api-1 | CommandLine(prog=prog).main(argv=argv) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1029, in main +api-1 | self.run_cmd(cfg, options) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 963, in run_cmd +api-1 | fn( +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/command.py", line 487, in upgrade +api-1 | script.run_env() +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/script/base.py", line 550, in run_env +api-1 | util.load_python_file(self.dir, "env.py") +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 114, in load_python_file +api-1 | module = load_module_py(module_id, path) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 132, in load_module_py +api-1 | spec.loader.exec_module(module) # type: ignore +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "", line 999, in exec_module +api-1 | File "", line 488, in _call_with_frames_removed +api-1 | File "/srv/alembic/env.py", line 47, in +api-1 | run_migrations_online() +api-1 | File "/srv/alembic/env.py", line 36, in run_migrations_online +api-1 | with connectable.connect() as connection: +api-1 | ^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3295, in connect +api-1 | return self._connection_cls(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 146, in __init__ +api-1 | Connection._handle_dbapi_exception_noconnection( +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 2450, in _handle_dbapi_exception_noconnection +api-1 | raise sqlalchemy_exception.with_traceback(exc_info[2]) from e +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | sqlalchemy.exc.OperationalError: (psycopg.OperationalError) connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | (Background on this error at: https://sqlalche.me/e/20/e3q8) +api-1 | entrypoint: database migration failed after 15 attempts +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | psycopg.OperationalError: connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | +api-1 | The above exception was the direct cause of the following exception: +api-1 | +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/bin/alembic", line 8, in +api-1 | sys.exit(main()) +api-1 | ^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1039, in main +api-1 | CommandLine(prog=prog).main(argv=argv) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1029, in main +api-1 | self.run_cmd(cfg, options) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 963, in run_cmd +api-1 | fn( +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/command.py", line 487, in upgrade +api-1 | script.run_env() +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/script/base.py", line 550, in run_env +api-1 | util.load_python_file(self.dir, "env.py") +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 114, in load_python_file +api-1 | module = load_module_py(module_id, path) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 132, in load_module_py +api-1 | spec.loader.exec_module(module) # type: ignore +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "", line 999, in exec_module +api-1 | File "", line 488, in _call_with_frames_removed +api-1 | File "/srv/alembic/env.py", line 47, in +api-1 | run_migrations_online() +api-1 | File "/srv/alembic/env.py", line 36, in run_migrations_online +api-1 | with connectable.connect() as connection: +api-1 | ^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3295, in connect +api-1 | return self._connection_cls(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 146, in __init__ +api-1 | Connection._handle_dbapi_exception_noconnection( +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 2450, in _handle_dbapi_exception_noconnection +api-1 | raise sqlalchemy_exception.with_traceback(exc_info[2]) from e +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | sqlalchemy.exc.OperationalError: (psycopg.OperationalError) connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | (Background on this error at: https://sqlalche.me/e/20/e3q8) +api-1 | entrypoint: database not ready (attempt 1), retrying in 3s +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | psycopg.OperationalError: connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | +api-1 | The above exception was the direct cause of the following exception: +api-1 | +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/bin/alembic", line 8, in +api-1 | sys.exit(main()) +api-1 | ^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1039, in main +api-1 | CommandLine(prog=prog).main(argv=argv) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1029, in main +api-1 | self.run_cmd(cfg, options) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 963, in run_cmd +api-1 | fn( +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/command.py", line 487, in upgrade +api-1 | script.run_env() +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/script/base.py", line 550, in run_env +api-1 | util.load_python_file(self.dir, "env.py") +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 114, in load_python_file +api-1 | module = load_module_py(module_id, path) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 132, in load_module_py +api-1 | spec.loader.exec_module(module) # type: ignore +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "", line 999, in exec_module +api-1 | File "", line 488, in _call_with_frames_removed +api-1 | File "/srv/alembic/env.py", line 47, in +api-1 | run_migrations_online() +api-1 | File "/srv/alembic/env.py", line 36, in run_migrations_online +api-1 | with connectable.connect() as connection: +api-1 | ^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3295, in connect +api-1 | return self._connection_cls(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 146, in __init__ +api-1 | Connection._handle_dbapi_exception_noconnection( +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 2450, in _handle_dbapi_exception_noconnection +api-1 | raise sqlalchemy_exception.with_traceback(exc_info[2]) from e +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | sqlalchemy.exc.OperationalError: (psycopg.OperationalError) connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | (Background on this error at: https://sqlalche.me/e/20/e3q8) +api-1 | entrypoint: database not ready (attempt 2), retrying in 3s +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | psycopg.OperationalError: connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | +api-1 | The above exception was the direct cause of the following exception: +api-1 | +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/bin/alembic", line 8, in +api-1 | sys.exit(main()) +api-1 | ^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1039, in main +api-1 | CommandLine(prog=prog).main(argv=argv) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1029, in main +api-1 | self.run_cmd(cfg, options) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 963, in run_cmd +api-1 | fn( +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/command.py", line 487, in upgrade +api-1 | script.run_env() +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/script/base.py", line 550, in run_env +api-1 | util.load_python_file(self.dir, "env.py") +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 114, in load_python_file +api-1 | module = load_module_py(module_id, path) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 132, in load_module_py +api-1 | spec.loader.exec_module(module) # type: ignore +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "", line 999, in exec_module +api-1 | File "", line 488, in _call_with_frames_removed +api-1 | File "/srv/alembic/env.py", line 47, in +api-1 | run_migrations_online() +api-1 | File "/srv/alembic/env.py", line 36, in run_migrations_online +api-1 | with connectable.connect() as connection: +api-1 | ^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3295, in connect +api-1 | return self._connection_cls(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 146, in __init__ +api-1 | Connection._handle_dbapi_exception_noconnection( +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 2450, in _handle_dbapi_exception_noconnection +api-1 | raise sqlalchemy_exception.with_traceback(exc_info[2]) from e +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | sqlalchemy.exc.OperationalError: (psycopg.OperationalError) connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | (Background on this error at: https://sqlalche.me/e/20/e3q8) +api-1 | entrypoint: database not ready (attempt 3), retrying in 3s +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | psycopg.OperationalError: connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | +api-1 | The above exception was the direct cause of the following exception: +api-1 | +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/bin/alembic", line 8, in +api-1 | sys.exit(main()) +api-1 | ^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1039, in main +api-1 | CommandLine(prog=prog).main(argv=argv) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1029, in main +api-1 | self.run_cmd(cfg, options) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 963, in run_cmd +api-1 | fn( +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/command.py", line 487, in upgrade +api-1 | script.run_env() +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/script/base.py", line 550, in run_env +api-1 | util.load_python_file(self.dir, "env.py") +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 114, in load_python_file +api-1 | module = load_module_py(module_id, path) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 132, in load_module_py +api-1 | spec.loader.exec_module(module) # type: ignore +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "", line 999, in exec_module +api-1 | File "", line 488, in _call_with_frames_removed +api-1 | File "/srv/alembic/env.py", line 47, in +api-1 | run_migrations_online() +api-1 | File "/srv/alembic/env.py", line 36, in run_migrations_online +api-1 | with connectable.connect() as connection: +api-1 | ^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3295, in connect +api-1 | return self._connection_cls(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 146, in __init__ +api-1 | Connection._handle_dbapi_exception_noconnection( +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 2450, in _handle_dbapi_exception_noconnection +api-1 | raise sqlalchemy_exception.with_traceback(exc_info[2]) from e +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | sqlalchemy.exc.OperationalError: (psycopg.OperationalError) connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | (Background on this error at: https://sqlalche.me/e/20/e3q8) +api-1 | entrypoint: database not ready (attempt 4), retrying in 3s +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | psycopg.OperationalError: connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | +api-1 | The above exception was the direct cause of the following exception: +api-1 | +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/bin/alembic", line 8, in +api-1 | sys.exit(main()) +api-1 | ^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1039, in main +api-1 | CommandLine(prog=prog).main(argv=argv) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1029, in main +api-1 | self.run_cmd(cfg, options) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 963, in run_cmd +api-1 | fn( +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/command.py", line 487, in upgrade +api-1 | script.run_env() +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/script/base.py", line 550, in run_env +api-1 | util.load_python_file(self.dir, "env.py") +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 114, in load_python_file +api-1 | module = load_module_py(module_id, path) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 132, in load_module_py +api-1 | spec.loader.exec_module(module) # type: ignore +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "", line 999, in exec_module +api-1 | File "", line 488, in _call_with_frames_removed +api-1 | File "/srv/alembic/env.py", line 47, in +api-1 | run_migrations_online() +api-1 | File "/srv/alembic/env.py", line 36, in run_migrations_online +api-1 | with connectable.connect() as connection: +api-1 | ^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3295, in connect +api-1 | return self._connection_cls(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 146, in __init__ +api-1 | Connection._handle_dbapi_exception_noconnection( +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 2450, in _handle_dbapi_exception_noconnection +api-1 | raise sqlalchemy_exception.with_traceback(exc_info[2]) from e +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | sqlalchemy.exc.OperationalError: (psycopg.OperationalError) connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | (Background on this error at: https://sqlalche.me/e/20/e3q8) +api-1 | entrypoint: database not ready (attempt 5), retrying in 3s +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | psycopg.OperationalError: connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | +api-1 | The above exception was the direct cause of the following exception: +api-1 | +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/bin/alembic", line 8, in +api-1 | sys.exit(main()) +api-1 | ^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1039, in main +api-1 | CommandLine(prog=prog).main(argv=argv) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1029, in main +api-1 | self.run_cmd(cfg, options) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 963, in run_cmd +api-1 | fn( +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/command.py", line 487, in upgrade +api-1 | script.run_env() +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/script/base.py", line 550, in run_env +api-1 | util.load_python_file(self.dir, "env.py") +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 114, in load_python_file +api-1 | module = load_module_py(module_id, path) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 132, in load_module_py +api-1 | spec.loader.exec_module(module) # type: ignore +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "", line 999, in exec_module +api-1 | File "", line 488, in _call_with_frames_removed +api-1 | File "/srv/alembic/env.py", line 47, in +api-1 | run_migrations_online() +api-1 | File "/srv/alembic/env.py", line 36, in run_migrations_online +api-1 | with connectable.connect() as connection: +api-1 | ^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3295, in connect +api-1 | return self._connection_cls(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 146, in __init__ +api-1 | Connection._handle_dbapi_exception_noconnection( +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 2450, in _handle_dbapi_exception_noconnection +api-1 | raise sqlalchemy_exception.with_traceback(exc_info[2]) from e +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | sqlalchemy.exc.OperationalError: (psycopg.OperationalError) connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | (Background on this error at: https://sqlalche.me/e/20/e3q8) +api-1 | entrypoint: database not ready (attempt 6), retrying in 3s +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | psycopg.OperationalError: connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | +api-1 | The above exception was the direct cause of the following exception: +api-1 | +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/bin/alembic", line 8, in +api-1 | sys.exit(main()) +api-1 | ^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1039, in main +api-1 | CommandLine(prog=prog).main(argv=argv) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1029, in main +api-1 | self.run_cmd(cfg, options) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 963, in run_cmd +api-1 | fn( +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/command.py", line 487, in upgrade +api-1 | script.run_env() +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/script/base.py", line 550, in run_env +api-1 | util.load_python_file(self.dir, "env.py") +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 114, in load_python_file +api-1 | module = load_module_py(module_id, path) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 132, in load_module_py +api-1 | spec.loader.exec_module(module) # type: ignore +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "", line 999, in exec_module +api-1 | File "", line 488, in _call_with_frames_removed +api-1 | File "/srv/alembic/env.py", line 47, in +api-1 | run_migrations_online() +api-1 | File "/srv/alembic/env.py", line 36, in run_migrations_online +api-1 | with connectable.connect() as connection: +api-1 | ^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3295, in connect +api-1 | return self._connection_cls(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 146, in __init__ +api-1 | Connection._handle_dbapi_exception_noconnection( +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 2450, in _handle_dbapi_exception_noconnection +api-1 | raise sqlalchemy_exception.with_traceback(exc_info[2]) from e +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | sqlalchemy.exc.OperationalError: (psycopg.OperationalError) connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | (Background on this error at: https://sqlalche.me/e/20/e3q8) +api-1 | entrypoint: database not ready (attempt 7), retrying in 3s +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | psycopg.OperationalError: connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | +api-1 | The above exception was the direct cause of the following exception: +api-1 | +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/bin/alembic", line 8, in +api-1 | sys.exit(main()) +api-1 | ^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1039, in main +api-1 | CommandLine(prog=prog).main(argv=argv) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1029, in main +api-1 | self.run_cmd(cfg, options) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 963, in run_cmd +api-1 | fn( +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/command.py", line 487, in upgrade +api-1 | script.run_env() +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/script/base.py", line 550, in run_env +api-1 | util.load_python_file(self.dir, "env.py") +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 114, in load_python_file +api-1 | module = load_module_py(module_id, path) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 132, in load_module_py +api-1 | spec.loader.exec_module(module) # type: ignore +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "", line 999, in exec_module +api-1 | File "", line 488, in _call_with_frames_removed +api-1 | File "/srv/alembic/env.py", line 47, in +api-1 | run_migrations_online() +api-1 | File "/srv/alembic/env.py", line 36, in run_migrations_online +api-1 | with connectable.connect() as connection: +api-1 | ^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3295, in connect +api-1 | return self._connection_cls(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 146, in __init__ +api-1 | Connection._handle_dbapi_exception_noconnection( +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 2450, in _handle_dbapi_exception_noconnection +api-1 | raise sqlalchemy_exception.with_traceback(exc_info[2]) from e +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | sqlalchemy.exc.OperationalError: (psycopg.OperationalError) connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | (Background on this error at: https://sqlalche.me/e/20/e3q8) +api-1 | entrypoint: database not ready (attempt 8), retrying in 3s +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | psycopg.OperationalError: connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | +api-1 | The above exception was the direct cause of the following exception: +api-1 | +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/bin/alembic", line 8, in +api-1 | sys.exit(main()) +api-1 | ^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1039, in main +api-1 | CommandLine(prog=prog).main(argv=argv) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1029, in main +api-1 | self.run_cmd(cfg, options) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 963, in run_cmd +api-1 | fn( +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/command.py", line 487, in upgrade +api-1 | script.run_env() +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/script/base.py", line 550, in run_env +api-1 | util.load_python_file(self.dir, "env.py") +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 114, in load_python_file +api-1 | module = load_module_py(module_id, path) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 132, in load_module_py +api-1 | spec.loader.exec_module(module) # type: ignore +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "", line 999, in exec_module +api-1 | File "", line 488, in _call_with_frames_removed +api-1 | File "/srv/alembic/env.py", line 47, in +api-1 | run_migrations_online() +api-1 | File "/srv/alembic/env.py", line 36, in run_migrations_online +api-1 | with connectable.connect() as connection: +api-1 | ^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3295, in connect +api-1 | return self._connection_cls(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 146, in __init__ +api-1 | Connection._handle_dbapi_exception_noconnection( +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 2450, in _handle_dbapi_exception_noconnection +api-1 | raise sqlalchemy_exception.with_traceback(exc_info[2]) from e +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | sqlalchemy.exc.OperationalError: (psycopg.OperationalError) connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | (Background on this error at: https://sqlalche.me/e/20/e3q8) +api-1 | entrypoint: database not ready (attempt 9), retrying in 3s +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | psycopg.OperationalError: connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | +api-1 | The above exception was the direct cause of the following exception: +api-1 | +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/bin/alembic", line 8, in +api-1 | sys.exit(main()) +api-1 | ^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1039, in main +api-1 | CommandLine(prog=prog).main(argv=argv) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1029, in main +api-1 | self.run_cmd(cfg, options) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 963, in run_cmd +api-1 | fn( +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/command.py", line 487, in upgrade +api-1 | script.run_env() +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/script/base.py", line 550, in run_env +api-1 | util.load_python_file(self.dir, "env.py") +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 114, in load_python_file +api-1 | module = load_module_py(module_id, path) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 132, in load_module_py +api-1 | spec.loader.exec_module(module) # type: ignore +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "", line 999, in exec_module +api-1 | File "", line 488, in _call_with_frames_removed +api-1 | File "/srv/alembic/env.py", line 47, in +api-1 | run_migrations_online() +api-1 | File "/srv/alembic/env.py", line 36, in run_migrations_online +api-1 | with connectable.connect() as connection: +api-1 | ^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3295, in connect +api-1 | return self._connection_cls(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 146, in __init__ +api-1 | Connection._handle_dbapi_exception_noconnection( +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 2450, in _handle_dbapi_exception_noconnection +api-1 | raise sqlalchemy_exception.with_traceback(exc_info[2]) from e +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | sqlalchemy.exc.OperationalError: (psycopg.OperationalError) connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | (Background on this error at: https://sqlalche.me/e/20/e3q8) +api-1 | entrypoint: database not ready (attempt 10), retrying in 3s +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | psycopg.OperationalError: connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | +api-1 | The above exception was the direct cause of the following exception: +api-1 | +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/bin/alembic", line 8, in +api-1 | sys.exit(main()) +api-1 | ^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1039, in main +api-1 | CommandLine(prog=prog).main(argv=argv) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1029, in main +api-1 | self.run_cmd(cfg, options) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 963, in run_cmd +api-1 | fn( +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/command.py", line 487, in upgrade +api-1 | script.run_env() +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/script/base.py", line 550, in run_env +api-1 | util.load_python_file(self.dir, "env.py") +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 114, in load_python_file +api-1 | module = load_module_py(module_id, path) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 132, in load_module_py +api-1 | spec.loader.exec_module(module) # type: ignore +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "", line 999, in exec_module +api-1 | File "", line 488, in _call_with_frames_removed +api-1 | File "/srv/alembic/env.py", line 47, in +api-1 | run_migrations_online() +api-1 | File "/srv/alembic/env.py", line 36, in run_migrations_online +api-1 | with connectable.connect() as connection: +api-1 | ^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3295, in connect +api-1 | return self._connection_cls(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 146, in __init__ +api-1 | Connection._handle_dbapi_exception_noconnection( +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 2450, in _handle_dbapi_exception_noconnection +api-1 | raise sqlalchemy_exception.with_traceback(exc_info[2]) from e +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | sqlalchemy.exc.OperationalError: (psycopg.OperationalError) connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | (Background on this error at: https://sqlalche.me/e/20/e3q8) +api-1 | entrypoint: database not ready (attempt 11), retrying in 3s +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | psycopg.OperationalError: connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | +api-1 | The above exception was the direct cause of the following exception: +api-1 | +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/bin/alembic", line 8, in +api-1 | sys.exit(main()) +api-1 | ^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1039, in main +api-1 | CommandLine(prog=prog).main(argv=argv) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1029, in main +api-1 | self.run_cmd(cfg, options) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 963, in run_cmd +api-1 | fn( +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/command.py", line 487, in upgrade +api-1 | script.run_env() +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/script/base.py", line 550, in run_env +api-1 | util.load_python_file(self.dir, "env.py") +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 114, in load_python_file +api-1 | module = load_module_py(module_id, path) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 132, in load_module_py +api-1 | spec.loader.exec_module(module) # type: ignore +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "", line 999, in exec_module +api-1 | File "", line 488, in _call_with_frames_removed +api-1 | File "/srv/alembic/env.py", line 47, in +api-1 | run_migrations_online() +api-1 | File "/srv/alembic/env.py", line 36, in run_migrations_online +api-1 | with connectable.connect() as connection: +api-1 | ^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3295, in connect +api-1 | return self._connection_cls(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 146, in __init__ +api-1 | Connection._handle_dbapi_exception_noconnection( +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 2450, in _handle_dbapi_exception_noconnection +api-1 | raise sqlalchemy_exception.with_traceback(exc_info[2]) from e +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | sqlalchemy.exc.OperationalError: (psycopg.OperationalError) connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | (Background on this error at: https://sqlalche.me/e/20/e3q8) +api-1 | entrypoint: database not ready (attempt 12), retrying in 3s +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | psycopg.OperationalError: connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | +api-1 | The above exception was the direct cause of the following exception: +api-1 | +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/bin/alembic", line 8, in +api-1 | sys.exit(main()) +api-1 | ^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1039, in main +api-1 | CommandLine(prog=prog).main(argv=argv) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1029, in main +api-1 | self.run_cmd(cfg, options) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 963, in run_cmd +api-1 | fn( +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/command.py", line 487, in upgrade +api-1 | script.run_env() +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/script/base.py", line 550, in run_env +api-1 | util.load_python_file(self.dir, "env.py") +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 114, in load_python_file +api-1 | module = load_module_py(module_id, path) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 132, in load_module_py +api-1 | spec.loader.exec_module(module) # type: ignore +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "", line 999, in exec_module +api-1 | File "", line 488, in _call_with_frames_removed +api-1 | File "/srv/alembic/env.py", line 47, in +api-1 | run_migrations_online() +api-1 | File "/srv/alembic/env.py", line 36, in run_migrations_online +api-1 | with connectable.connect() as connection: +api-1 | ^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3295, in connect +api-1 | return self._connection_cls(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 146, in __init__ +api-1 | Connection._handle_dbapi_exception_noconnection( +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 2450, in _handle_dbapi_exception_noconnection +api-1 | raise sqlalchemy_exception.with_traceback(exc_info[2]) from e +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | sqlalchemy.exc.OperationalError: (psycopg.OperationalError) connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | (Background on this error at: https://sqlalche.me/e/20/e3q8) +api-1 | entrypoint: database not ready (attempt 13), retrying in 3s +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | psycopg.OperationalError: connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | +api-1 | The above exception was the direct cause of the following exception: +api-1 | +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/bin/alembic", line 8, in +api-1 | sys.exit(main()) +api-1 | ^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1039, in main +api-1 | CommandLine(prog=prog).main(argv=argv) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1029, in main +api-1 | self.run_cmd(cfg, options) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 963, in run_cmd +api-1 | fn( +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/command.py", line 487, in upgrade +api-1 | script.run_env() +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/script/base.py", line 550, in run_env +api-1 | util.load_python_file(self.dir, "env.py") +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 114, in load_python_file +api-1 | module = load_module_py(module_id, path) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 132, in load_module_py +api-1 | spec.loader.exec_module(module) # type: ignore +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "", line 999, in exec_module +api-1 | File "", line 488, in _call_with_frames_removed +api-1 | File "/srv/alembic/env.py", line 47, in +api-1 | run_migrations_online() +api-1 | File "/srv/alembic/env.py", line 36, in run_migrations_online +api-1 | with connectable.connect() as connection: +api-1 | ^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3295, in connect +api-1 | return self._connection_cls(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 146, in __init__ +api-1 | Connection._handle_dbapi_exception_noconnection( +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 2450, in _handle_dbapi_exception_noconnection +api-1 | raise sqlalchemy_exception.with_traceback(exc_info[2]) from e +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | sqlalchemy.exc.OperationalError: (psycopg.OperationalError) connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | (Background on this error at: https://sqlalche.me/e/20/e3q8) +api-1 | entrypoint: database not ready (attempt 14), retrying in 3s +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | psycopg.OperationalError: connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | +api-1 | The above exception was the direct cause of the following exception: +api-1 | +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/bin/alembic", line 8, in +api-1 | sys.exit(main()) +api-1 | ^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1039, in main +api-1 | CommandLine(prog=prog).main(argv=argv) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1029, in main +api-1 | self.run_cmd(cfg, options) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 963, in run_cmd +api-1 | fn( +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/command.py", line 487, in upgrade +api-1 | script.run_env() +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/script/base.py", line 550, in run_env +api-1 | util.load_python_file(self.dir, "env.py") +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 114, in load_python_file +api-1 | module = load_module_py(module_id, path) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 132, in load_module_py +api-1 | spec.loader.exec_module(module) # type: ignore +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "", line 999, in exec_module +api-1 | File "", line 488, in _call_with_frames_removed +api-1 | File "/srv/alembic/env.py", line 47, in +api-1 | run_migrations_online() +api-1 | File "/srv/alembic/env.py", line 36, in run_migrations_online +api-1 | with connectable.connect() as connection: +api-1 | ^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3295, in connect +api-1 | return self._connection_cls(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 146, in __init__ +api-1 | Connection._handle_dbapi_exception_noconnection( +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 2450, in _handle_dbapi_exception_noconnection +api-1 | raise sqlalchemy_exception.with_traceback(exc_info[2]) from e +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | sqlalchemy.exc.OperationalError: (psycopg.OperationalError) connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | (Background on this error at: https://sqlalche.me/e/20/e3q8) +api-1 | entrypoint: database migration failed after 15 attempts +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | psycopg.OperationalError: connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | +api-1 | The above exception was the direct cause of the following exception: +api-1 | +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/bin/alembic", line 8, in +api-1 | sys.exit(main()) +api-1 | ^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1039, in main +api-1 | CommandLine(prog=prog).main(argv=argv) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1029, in main +api-1 | self.run_cmd(cfg, options) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 963, in run_cmd +api-1 | fn( +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/command.py", line 487, in upgrade +api-1 | script.run_env() +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/script/base.py", line 550, in run_env +api-1 | util.load_python_file(self.dir, "env.py") +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 114, in load_python_file +api-1 | module = load_module_py(module_id, path) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 132, in load_module_py +api-1 | spec.loader.exec_module(module) # type: ignore +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "", line 999, in exec_module +api-1 | File "", line 488, in _call_with_frames_removed +api-1 | File "/srv/alembic/env.py", line 47, in +api-1 | run_migrations_online() +api-1 | File "/srv/alembic/env.py", line 36, in run_migrations_online +api-1 | with connectable.connect() as connection: +api-1 | ^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3295, in connect +api-1 | return self._connection_cls(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 146, in __init__ +api-1 | Connection._handle_dbapi_exception_noconnection( +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 2450, in _handle_dbapi_exception_noconnection +api-1 | raise sqlalchemy_exception.with_traceback(exc_info[2]) from e +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | sqlalchemy.exc.OperationalError: (psycopg.OperationalError) connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | (Background on this error at: https://sqlalche.me/e/20/e3q8) +api-1 | entrypoint: database not ready (attempt 1), retrying in 3s +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | psycopg.OperationalError: connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | +api-1 | The above exception was the direct cause of the following exception: +api-1 | +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/bin/alembic", line 8, in +api-1 | sys.exit(main()) +api-1 | ^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1039, in main +api-1 | CommandLine(prog=prog).main(argv=argv) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1029, in main +api-1 | self.run_cmd(cfg, options) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 963, in run_cmd +api-1 | fn( +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/command.py", line 487, in upgrade +api-1 | script.run_env() +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/script/base.py", line 550, in run_env +api-1 | util.load_python_file(self.dir, "env.py") +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 114, in load_python_file +api-1 | module = load_module_py(module_id, path) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 132, in load_module_py +api-1 | spec.loader.exec_module(module) # type: ignore +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "", line 999, in exec_module +api-1 | File "", line 488, in _call_with_frames_removed +api-1 | File "/srv/alembic/env.py", line 47, in +api-1 | run_migrations_online() +api-1 | File "/srv/alembic/env.py", line 36, in run_migrations_online +api-1 | with connectable.connect() as connection: +api-1 | ^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3295, in connect +api-1 | return self._connection_cls(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 146, in __init__ +api-1 | Connection._handle_dbapi_exception_noconnection( +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 2450, in _handle_dbapi_exception_noconnection +api-1 | raise sqlalchemy_exception.with_traceback(exc_info[2]) from e +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | sqlalchemy.exc.OperationalError: (psycopg.OperationalError) connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | (Background on this error at: https://sqlalche.me/e/20/e3q8) +api-1 | entrypoint: database not ready (attempt 2), retrying in 3s +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | psycopg.OperationalError: connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | +api-1 | The above exception was the direct cause of the following exception: +api-1 | +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/bin/alembic", line 8, in +api-1 | sys.exit(main()) +api-1 | ^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1039, in main +api-1 | CommandLine(prog=prog).main(argv=argv) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1029, in main +api-1 | self.run_cmd(cfg, options) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 963, in run_cmd +api-1 | fn( +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/command.py", line 487, in upgrade +api-1 | script.run_env() +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/script/base.py", line 550, in run_env +api-1 | util.load_python_file(self.dir, "env.py") +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 114, in load_python_file +api-1 | module = load_module_py(module_id, path) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 132, in load_module_py +api-1 | spec.loader.exec_module(module) # type: ignore +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "", line 999, in exec_module +api-1 | File "", line 488, in _call_with_frames_removed +api-1 | File "/srv/alembic/env.py", line 47, in +api-1 | run_migrations_online() +api-1 | File "/srv/alembic/env.py", line 36, in run_migrations_online +api-1 | with connectable.connect() as connection: +api-1 | ^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3295, in connect +api-1 | return self._connection_cls(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 146, in __init__ +api-1 | Connection._handle_dbapi_exception_noconnection( +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 2450, in _handle_dbapi_exception_noconnection +api-1 | raise sqlalchemy_exception.with_traceback(exc_info[2]) from e +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | sqlalchemy.exc.OperationalError: (psycopg.OperationalError) connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | (Background on this error at: https://sqlalche.me/e/20/e3q8) +api-1 | entrypoint: database not ready (attempt 3), retrying in 3s +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | psycopg.OperationalError: connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | +api-1 | The above exception was the direct cause of the following exception: +api-1 | +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/bin/alembic", line 8, in +api-1 | sys.exit(main()) +api-1 | ^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1039, in main +api-1 | CommandLine(prog=prog).main(argv=argv) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1029, in main +api-1 | self.run_cmd(cfg, options) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 963, in run_cmd +api-1 | fn( +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/command.py", line 487, in upgrade +api-1 | script.run_env() +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/script/base.py", line 550, in run_env +api-1 | util.load_python_file(self.dir, "env.py") +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 114, in load_python_file +api-1 | module = load_module_py(module_id, path) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 132, in load_module_py +api-1 | spec.loader.exec_module(module) # type: ignore +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "", line 999, in exec_module +api-1 | File "", line 488, in _call_with_frames_removed +api-1 | File "/srv/alembic/env.py", line 47, in +api-1 | run_migrations_online() +api-1 | File "/srv/alembic/env.py", line 36, in run_migrations_online +api-1 | with connectable.connect() as connection: +api-1 | ^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3295, in connect +api-1 | return self._connection_cls(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 146, in __init__ +api-1 | Connection._handle_dbapi_exception_noconnection( +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 2450, in _handle_dbapi_exception_noconnection +api-1 | raise sqlalchemy_exception.with_traceback(exc_info[2]) from e +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | sqlalchemy.exc.OperationalError: (psycopg.OperationalError) connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | (Background on this error at: https://sqlalche.me/e/20/e3q8) +api-1 | entrypoint: database not ready (attempt 4), retrying in 3s +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | psycopg.OperationalError: connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | +api-1 | The above exception was the direct cause of the following exception: +api-1 | +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/bin/alembic", line 8, in +api-1 | sys.exit(main()) +api-1 | ^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1039, in main +api-1 | CommandLine(prog=prog).main(argv=argv) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1029, in main +api-1 | self.run_cmd(cfg, options) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 963, in run_cmd +api-1 | fn( +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/command.py", line 487, in upgrade +api-1 | script.run_env() +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/script/base.py", line 550, in run_env +api-1 | util.load_python_file(self.dir, "env.py") +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 114, in load_python_file +api-1 | module = load_module_py(module_id, path) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 132, in load_module_py +api-1 | spec.loader.exec_module(module) # type: ignore +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "", line 999, in exec_module +api-1 | File "", line 488, in _call_with_frames_removed +api-1 | File "/srv/alembic/env.py", line 47, in +api-1 | run_migrations_online() +api-1 | File "/srv/alembic/env.py", line 36, in run_migrations_online +api-1 | with connectable.connect() as connection: +api-1 | ^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3295, in connect +api-1 | return self._connection_cls(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 146, in __init__ +api-1 | Connection._handle_dbapi_exception_noconnection( +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 2450, in _handle_dbapi_exception_noconnection +api-1 | raise sqlalchemy_exception.with_traceback(exc_info[2]) from e +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | sqlalchemy.exc.OperationalError: (psycopg.OperationalError) connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | (Background on this error at: https://sqlalche.me/e/20/e3q8) +api-1 | entrypoint: database not ready (attempt 5), retrying in 3s +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | psycopg.OperationalError: connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | +api-1 | The above exception was the direct cause of the following exception: +api-1 | +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/bin/alembic", line 8, in +api-1 | sys.exit(main()) +api-1 | ^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1039, in main +api-1 | CommandLine(prog=prog).main(argv=argv) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1029, in main +api-1 | self.run_cmd(cfg, options) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 963, in run_cmd +api-1 | fn( +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/command.py", line 487, in upgrade +api-1 | script.run_env() +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/script/base.py", line 550, in run_env +api-1 | util.load_python_file(self.dir, "env.py") +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 114, in load_python_file +api-1 | module = load_module_py(module_id, path) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 132, in load_module_py +api-1 | spec.loader.exec_module(module) # type: ignore +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "", line 999, in exec_module +api-1 | File "", line 488, in _call_with_frames_removed +api-1 | File "/srv/alembic/env.py", line 47, in +api-1 | run_migrations_online() +api-1 | File "/srv/alembic/env.py", line 36, in run_migrations_online +api-1 | with connectable.connect() as connection: +api-1 | ^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3295, in connect +api-1 | return self._connection_cls(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 146, in __init__ +api-1 | Connection._handle_dbapi_exception_noconnection( +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 2450, in _handle_dbapi_exception_noconnection +api-1 | raise sqlalchemy_exception.with_traceback(exc_info[2]) from e +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | sqlalchemy.exc.OperationalError: (psycopg.OperationalError) connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | (Background on this error at: https://sqlalche.me/e/20/e3q8) +api-1 | entrypoint: database not ready (attempt 6), retrying in 3s +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | psycopg.OperationalError: connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | +api-1 | The above exception was the direct cause of the following exception: +api-1 | +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/bin/alembic", line 8, in +api-1 | sys.exit(main()) +api-1 | ^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1039, in main +api-1 | CommandLine(prog=prog).main(argv=argv) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1029, in main +api-1 | self.run_cmd(cfg, options) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 963, in run_cmd +api-1 | fn( +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/command.py", line 487, in upgrade +api-1 | script.run_env() +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/script/base.py", line 550, in run_env +api-1 | util.load_python_file(self.dir, "env.py") +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 114, in load_python_file +api-1 | module = load_module_py(module_id, path) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 132, in load_module_py +api-1 | spec.loader.exec_module(module) # type: ignore +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "", line 999, in exec_module +api-1 | File "", line 488, in _call_with_frames_removed +api-1 | File "/srv/alembic/env.py", line 47, in +api-1 | run_migrations_online() +api-1 | File "/srv/alembic/env.py", line 36, in run_migrations_online +api-1 | with connectable.connect() as connection: +api-1 | ^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3295, in connect +api-1 | return self._connection_cls(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 146, in __init__ +api-1 | Connection._handle_dbapi_exception_noconnection( +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 2450, in _handle_dbapi_exception_noconnection +api-1 | raise sqlalchemy_exception.with_traceback(exc_info[2]) from e +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | sqlalchemy.exc.OperationalError: (psycopg.OperationalError) connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | (Background on this error at: https://sqlalche.me/e/20/e3q8) +api-1 | entrypoint: database not ready (attempt 7), retrying in 3s +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | psycopg.OperationalError: connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | +api-1 | The above exception was the direct cause of the following exception: +api-1 | +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/bin/alembic", line 8, in +api-1 | sys.exit(main()) +api-1 | ^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1039, in main +api-1 | CommandLine(prog=prog).main(argv=argv) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1029, in main +api-1 | self.run_cmd(cfg, options) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 963, in run_cmd +api-1 | fn( +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/command.py", line 487, in upgrade +api-1 | script.run_env() +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/script/base.py", line 550, in run_env +api-1 | util.load_python_file(self.dir, "env.py") +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 114, in load_python_file +api-1 | module = load_module_py(module_id, path) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 132, in load_module_py +api-1 | spec.loader.exec_module(module) # type: ignore +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "", line 999, in exec_module +api-1 | File "", line 488, in _call_with_frames_removed +api-1 | File "/srv/alembic/env.py", line 47, in +api-1 | run_migrations_online() +api-1 | File "/srv/alembic/env.py", line 36, in run_migrations_online +api-1 | with connectable.connect() as connection: +api-1 | ^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3295, in connect +api-1 | return self._connection_cls(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 146, in __init__ +api-1 | Connection._handle_dbapi_exception_noconnection( +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 2450, in _handle_dbapi_exception_noconnection +api-1 | raise sqlalchemy_exception.with_traceback(exc_info[2]) from e +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | sqlalchemy.exc.OperationalError: (psycopg.OperationalError) connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | (Background on this error at: https://sqlalche.me/e/20/e3q8) +api-1 | entrypoint: database not ready (attempt 8), retrying in 3s +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | psycopg.OperationalError: connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | +api-1 | The above exception was the direct cause of the following exception: +api-1 | +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/bin/alembic", line 8, in +api-1 | sys.exit(main()) +api-1 | ^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1039, in main +api-1 | CommandLine(prog=prog).main(argv=argv) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1029, in main +api-1 | self.run_cmd(cfg, options) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 963, in run_cmd +api-1 | fn( +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/command.py", line 487, in upgrade +api-1 | script.run_env() +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/script/base.py", line 550, in run_env +api-1 | util.load_python_file(self.dir, "env.py") +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 114, in load_python_file +api-1 | module = load_module_py(module_id, path) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 132, in load_module_py +api-1 | spec.loader.exec_module(module) # type: ignore +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "", line 999, in exec_module +api-1 | File "", line 488, in _call_with_frames_removed +api-1 | File "/srv/alembic/env.py", line 47, in +api-1 | run_migrations_online() +api-1 | File "/srv/alembic/env.py", line 36, in run_migrations_online +api-1 | with connectable.connect() as connection: +api-1 | ^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3295, in connect +api-1 | return self._connection_cls(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 146, in __init__ +api-1 | Connection._handle_dbapi_exception_noconnection( +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 2450, in _handle_dbapi_exception_noconnection +api-1 | raise sqlalchemy_exception.with_traceback(exc_info[2]) from e +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | sqlalchemy.exc.OperationalError: (psycopg.OperationalError) connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | (Background on this error at: https://sqlalche.me/e/20/e3q8) +api-1 | entrypoint: database not ready (attempt 9), retrying in 3s +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | psycopg.OperationalError: connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | +api-1 | The above exception was the direct cause of the following exception: +api-1 | +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/bin/alembic", line 8, in +api-1 | sys.exit(main()) +api-1 | ^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1039, in main +api-1 | CommandLine(prog=prog).main(argv=argv) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1029, in main +api-1 | self.run_cmd(cfg, options) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 963, in run_cmd +api-1 | fn( +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/command.py", line 487, in upgrade +api-1 | script.run_env() +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/script/base.py", line 550, in run_env +api-1 | util.load_python_file(self.dir, "env.py") +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 114, in load_python_file +api-1 | module = load_module_py(module_id, path) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 132, in load_module_py +api-1 | spec.loader.exec_module(module) # type: ignore +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "", line 999, in exec_module +api-1 | File "", line 488, in _call_with_frames_removed +api-1 | File "/srv/alembic/env.py", line 47, in +api-1 | run_migrations_online() +api-1 | File "/srv/alembic/env.py", line 36, in run_migrations_online +api-1 | with connectable.connect() as connection: +api-1 | ^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3295, in connect +api-1 | return self._connection_cls(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 146, in __init__ +api-1 | Connection._handle_dbapi_exception_noconnection( +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 2450, in _handle_dbapi_exception_noconnection +api-1 | raise sqlalchemy_exception.with_traceback(exc_info[2]) from e +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | sqlalchemy.exc.OperationalError: (psycopg.OperationalError) connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | (Background on this error at: https://sqlalche.me/e/20/e3q8) +api-1 | entrypoint: database not ready (attempt 10), retrying in 3s +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | psycopg.OperationalError: connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | +api-1 | The above exception was the direct cause of the following exception: +api-1 | +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/bin/alembic", line 8, in +api-1 | sys.exit(main()) +api-1 | ^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1039, in main +api-1 | CommandLine(prog=prog).main(argv=argv) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1029, in main +api-1 | self.run_cmd(cfg, options) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 963, in run_cmd +api-1 | fn( +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/command.py", line 487, in upgrade +api-1 | script.run_env() +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/script/base.py", line 550, in run_env +api-1 | util.load_python_file(self.dir, "env.py") +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 114, in load_python_file +api-1 | module = load_module_py(module_id, path) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 132, in load_module_py +api-1 | spec.loader.exec_module(module) # type: ignore +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "", line 999, in exec_module +api-1 | File "", line 488, in _call_with_frames_removed +api-1 | File "/srv/alembic/env.py", line 47, in +api-1 | run_migrations_online() +api-1 | File "/srv/alembic/env.py", line 36, in run_migrations_online +api-1 | with connectable.connect() as connection: +api-1 | ^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3295, in connect +api-1 | return self._connection_cls(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 146, in __init__ +api-1 | Connection._handle_dbapi_exception_noconnection( +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 2450, in _handle_dbapi_exception_noconnection +api-1 | raise sqlalchemy_exception.with_traceback(exc_info[2]) from e +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | sqlalchemy.exc.OperationalError: (psycopg.OperationalError) connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | (Background on this error at: https://sqlalche.me/e/20/e3q8) +api-1 | entrypoint: database not ready (attempt 11), retrying in 3s +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | psycopg.OperationalError: connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | +api-1 | The above exception was the direct cause of the following exception: +api-1 | +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/bin/alembic", line 8, in +api-1 | sys.exit(main()) +api-1 | ^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1039, in main +api-1 | CommandLine(prog=prog).main(argv=argv) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1029, in main +api-1 | self.run_cmd(cfg, options) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 963, in run_cmd +api-1 | fn( +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/command.py", line 487, in upgrade +api-1 | script.run_env() +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/script/base.py", line 550, in run_env +api-1 | util.load_python_file(self.dir, "env.py") +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 114, in load_python_file +api-1 | module = load_module_py(module_id, path) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 132, in load_module_py +api-1 | spec.loader.exec_module(module) # type: ignore +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "", line 999, in exec_module +api-1 | File "", line 488, in _call_with_frames_removed +api-1 | File "/srv/alembic/env.py", line 47, in +api-1 | run_migrations_online() +api-1 | File "/srv/alembic/env.py", line 36, in run_migrations_online +api-1 | with connectable.connect() as connection: +api-1 | ^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3295, in connect +api-1 | return self._connection_cls(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 146, in __init__ +api-1 | Connection._handle_dbapi_exception_noconnection( +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 2450, in _handle_dbapi_exception_noconnection +api-1 | raise sqlalchemy_exception.with_traceback(exc_info[2]) from e +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | sqlalchemy.exc.OperationalError: (psycopg.OperationalError) connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | (Background on this error at: https://sqlalche.me/e/20/e3q8) +api-1 | entrypoint: database not ready (attempt 12), retrying in 3s +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | psycopg.OperationalError: connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | +api-1 | The above exception was the direct cause of the following exception: +api-1 | +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/bin/alembic", line 8, in +api-1 | sys.exit(main()) +api-1 | ^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1039, in main +api-1 | CommandLine(prog=prog).main(argv=argv) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1029, in main +api-1 | self.run_cmd(cfg, options) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 963, in run_cmd +api-1 | fn( +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/command.py", line 487, in upgrade +api-1 | script.run_env() +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/script/base.py", line 550, in run_env +api-1 | util.load_python_file(self.dir, "env.py") +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 114, in load_python_file +api-1 | module = load_module_py(module_id, path) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 132, in load_module_py +api-1 | spec.loader.exec_module(module) # type: ignore +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "", line 999, in exec_module +api-1 | File "", line 488, in _call_with_frames_removed +api-1 | File "/srv/alembic/env.py", line 47, in +api-1 | run_migrations_online() +api-1 | File "/srv/alembic/env.py", line 36, in run_migrations_online +api-1 | with connectable.connect() as connection: +api-1 | ^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3295, in connect +api-1 | return self._connection_cls(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 146, in __init__ +api-1 | Connection._handle_dbapi_exception_noconnection( +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 2450, in _handle_dbapi_exception_noconnection +api-1 | raise sqlalchemy_exception.with_traceback(exc_info[2]) from e +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | sqlalchemy.exc.OperationalError: (psycopg.OperationalError) connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | (Background on this error at: https://sqlalche.me/e/20/e3q8) +api-1 | entrypoint: database not ready (attempt 13), retrying in 3s +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | psycopg.OperationalError: connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | +api-1 | The above exception was the direct cause of the following exception: +api-1 | +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/bin/alembic", line 8, in +api-1 | sys.exit(main()) +api-1 | ^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1039, in main +api-1 | CommandLine(prog=prog).main(argv=argv) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1029, in main +api-1 | self.run_cmd(cfg, options) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 963, in run_cmd +api-1 | fn( +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/command.py", line 487, in upgrade +api-1 | script.run_env() +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/script/base.py", line 550, in run_env +api-1 | util.load_python_file(self.dir, "env.py") +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 114, in load_python_file +api-1 | module = load_module_py(module_id, path) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 132, in load_module_py +api-1 | spec.loader.exec_module(module) # type: ignore +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "", line 999, in exec_module +api-1 | File "", line 488, in _call_with_frames_removed +api-1 | File "/srv/alembic/env.py", line 47, in +api-1 | run_migrations_online() +api-1 | File "/srv/alembic/env.py", line 36, in run_migrations_online +api-1 | with connectable.connect() as connection: +api-1 | ^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3295, in connect +api-1 | return self._connection_cls(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 146, in __init__ +api-1 | Connection._handle_dbapi_exception_noconnection( +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 2450, in _handle_dbapi_exception_noconnection +api-1 | raise sqlalchemy_exception.with_traceback(exc_info[2]) from e +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | sqlalchemy.exc.OperationalError: (psycopg.OperationalError) connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | (Background on this error at: https://sqlalche.me/e/20/e3q8) +api-1 | entrypoint: database not ready (attempt 14), retrying in 3s +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | psycopg.OperationalError: connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | +api-1 | The above exception was the direct cause of the following exception: +api-1 | +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/bin/alembic", line 8, in +api-1 | sys.exit(main()) +api-1 | ^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1039, in main +api-1 | CommandLine(prog=prog).main(argv=argv) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1029, in main +api-1 | self.run_cmd(cfg, options) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 963, in run_cmd +api-1 | fn( +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/command.py", line 487, in upgrade +api-1 | script.run_env() +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/script/base.py", line 550, in run_env +api-1 | util.load_python_file(self.dir, "env.py") +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 114, in load_python_file +api-1 | module = load_module_py(module_id, path) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 132, in load_module_py +api-1 | spec.loader.exec_module(module) # type: ignore +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "", line 999, in exec_module +api-1 | File "", line 488, in _call_with_frames_removed +api-1 | File "/srv/alembic/env.py", line 47, in +api-1 | run_migrations_online() +api-1 | File "/srv/alembic/env.py", line 36, in run_migrations_online +api-1 | with connectable.connect() as connection: +api-1 | ^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3295, in connect +api-1 | return self._connection_cls(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 146, in __init__ +api-1 | Connection._handle_dbapi_exception_noconnection( +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 2450, in _handle_dbapi_exception_noconnection +api-1 | raise sqlalchemy_exception.with_traceback(exc_info[2]) from e +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | sqlalchemy.exc.OperationalError: (psycopg.OperationalError) connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | (Background on this error at: https://sqlalche.me/e/20/e3q8) +api-1 | entrypoint: database migration failed after 15 attempts +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | psycopg.OperationalError: connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | +api-1 | The above exception was the direct cause of the following exception: +api-1 | +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/bin/alembic", line 8, in +api-1 | sys.exit(main()) +api-1 | ^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1039, in main +api-1 | CommandLine(prog=prog).main(argv=argv) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1029, in main +api-1 | self.run_cmd(cfg, options) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 963, in run_cmd +api-1 | fn( +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/command.py", line 487, in upgrade +api-1 | script.run_env() +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/script/base.py", line 550, in run_env +api-1 | util.load_python_file(self.dir, "env.py") +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 114, in load_python_file +api-1 | module = load_module_py(module_id, path) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 132, in load_module_py +api-1 | spec.loader.exec_module(module) # type: ignore +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "", line 999, in exec_module +api-1 | File "", line 488, in _call_with_frames_removed +api-1 | File "/srv/alembic/env.py", line 47, in +api-1 | run_migrations_online() +api-1 | File "/srv/alembic/env.py", line 36, in run_migrations_online +api-1 | with connectable.connect() as connection: +api-1 | ^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3295, in connect +api-1 | return self._connection_cls(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 146, in __init__ +api-1 | Connection._handle_dbapi_exception_noconnection( +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 2450, in _handle_dbapi_exception_noconnection +api-1 | raise sqlalchemy_exception.with_traceback(exc_info[2]) from e +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | sqlalchemy.exc.OperationalError: (psycopg.OperationalError) connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | (Background on this error at: https://sqlalche.me/e/20/e3q8) +api-1 | entrypoint: database not ready (attempt 1), retrying in 3s +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | psycopg.OperationalError: connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | +api-1 | The above exception was the direct cause of the following exception: +api-1 | +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/bin/alembic", line 8, in +api-1 | sys.exit(main()) +api-1 | ^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1039, in main +api-1 | CommandLine(prog=prog).main(argv=argv) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1029, in main +api-1 | self.run_cmd(cfg, options) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 963, in run_cmd +api-1 | fn( +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/command.py", line 487, in upgrade +api-1 | script.run_env() +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/script/base.py", line 550, in run_env +api-1 | util.load_python_file(self.dir, "env.py") +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 114, in load_python_file +api-1 | module = load_module_py(module_id, path) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 132, in load_module_py +api-1 | spec.loader.exec_module(module) # type: ignore +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "", line 999, in exec_module +api-1 | File "", line 488, in _call_with_frames_removed +api-1 | File "/srv/alembic/env.py", line 47, in +api-1 | run_migrations_online() +api-1 | File "/srv/alembic/env.py", line 36, in run_migrations_online +api-1 | with connectable.connect() as connection: +api-1 | ^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3295, in connect +api-1 | return self._connection_cls(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 146, in __init__ +api-1 | Connection._handle_dbapi_exception_noconnection( +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 2450, in _handle_dbapi_exception_noconnection +api-1 | raise sqlalchemy_exception.with_traceback(exc_info[2]) from e +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | sqlalchemy.exc.OperationalError: (psycopg.OperationalError) connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | (Background on this error at: https://sqlalche.me/e/20/e3q8) +api-1 | entrypoint: database not ready (attempt 2), retrying in 3s +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | psycopg.OperationalError: connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | +api-1 | The above exception was the direct cause of the following exception: +api-1 | +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/bin/alembic", line 8, in +api-1 | sys.exit(main()) +api-1 | ^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1039, in main +api-1 | CommandLine(prog=prog).main(argv=argv) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1029, in main +api-1 | self.run_cmd(cfg, options) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 963, in run_cmd +api-1 | fn( +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/command.py", line 487, in upgrade +api-1 | script.run_env() +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/script/base.py", line 550, in run_env +api-1 | util.load_python_file(self.dir, "env.py") +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 114, in load_python_file +api-1 | module = load_module_py(module_id, path) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 132, in load_module_py +api-1 | spec.loader.exec_module(module) # type: ignore +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "", line 999, in exec_module +api-1 | File "", line 488, in _call_with_frames_removed +api-1 | File "/srv/alembic/env.py", line 47, in +api-1 | run_migrations_online() +api-1 | File "/srv/alembic/env.py", line 36, in run_migrations_online +api-1 | with connectable.connect() as connection: +api-1 | ^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3295, in connect +api-1 | return self._connection_cls(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 146, in __init__ +api-1 | Connection._handle_dbapi_exception_noconnection( +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 2450, in _handle_dbapi_exception_noconnection +api-1 | raise sqlalchemy_exception.with_traceback(exc_info[2]) from e +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | sqlalchemy.exc.OperationalError: (psycopg.OperationalError) connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | (Background on this error at: https://sqlalche.me/e/20/e3q8) +api-1 | entrypoint: database not ready (attempt 3), retrying in 3s +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | psycopg.OperationalError: connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | +api-1 | The above exception was the direct cause of the following exception: +api-1 | +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/bin/alembic", line 8, in +api-1 | sys.exit(main()) +api-1 | ^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1039, in main +api-1 | CommandLine(prog=prog).main(argv=argv) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1029, in main +api-1 | self.run_cmd(cfg, options) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 963, in run_cmd +api-1 | fn( +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/command.py", line 487, in upgrade +api-1 | script.run_env() +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/script/base.py", line 550, in run_env +api-1 | util.load_python_file(self.dir, "env.py") +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 114, in load_python_file +api-1 | module = load_module_py(module_id, path) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 132, in load_module_py +api-1 | spec.loader.exec_module(module) # type: ignore +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "", line 999, in exec_module +api-1 | File "", line 488, in _call_with_frames_removed +api-1 | File "/srv/alembic/env.py", line 47, in +api-1 | run_migrations_online() +api-1 | File "/srv/alembic/env.py", line 36, in run_migrations_online +api-1 | with connectable.connect() as connection: +api-1 | ^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3295, in connect +api-1 | return self._connection_cls(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 146, in __init__ +api-1 | Connection._handle_dbapi_exception_noconnection( +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 2450, in _handle_dbapi_exception_noconnection +api-1 | raise sqlalchemy_exception.with_traceback(exc_info[2]) from e +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | sqlalchemy.exc.OperationalError: (psycopg.OperationalError) connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | (Background on this error at: https://sqlalche.me/e/20/e3q8) +api-1 | entrypoint: database not ready (attempt 4), retrying in 3s +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | psycopg.OperationalError: connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | +api-1 | The above exception was the direct cause of the following exception: +api-1 | +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/bin/alembic", line 8, in +api-1 | sys.exit(main()) +api-1 | ^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1039, in main +api-1 | CommandLine(prog=prog).main(argv=argv) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1029, in main +api-1 | self.run_cmd(cfg, options) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 963, in run_cmd +api-1 | fn( +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/command.py", line 487, in upgrade +api-1 | script.run_env() +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/script/base.py", line 550, in run_env +api-1 | util.load_python_file(self.dir, "env.py") +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 114, in load_python_file +api-1 | module = load_module_py(module_id, path) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 132, in load_module_py +api-1 | spec.loader.exec_module(module) # type: ignore +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "", line 999, in exec_module +api-1 | File "", line 488, in _call_with_frames_removed +api-1 | File "/srv/alembic/env.py", line 47, in +api-1 | run_migrations_online() +api-1 | File "/srv/alembic/env.py", line 36, in run_migrations_online +api-1 | with connectable.connect() as connection: +api-1 | ^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3295, in connect +api-1 | return self._connection_cls(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 146, in __init__ +api-1 | Connection._handle_dbapi_exception_noconnection( +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 2450, in _handle_dbapi_exception_noconnection +api-1 | raise sqlalchemy_exception.with_traceback(exc_info[2]) from e +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | sqlalchemy.exc.OperationalError: (psycopg.OperationalError) connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | (Background on this error at: https://sqlalche.me/e/20/e3q8) +api-1 | entrypoint: database not ready (attempt 5), retrying in 3s +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | psycopg.OperationalError: connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | +api-1 | The above exception was the direct cause of the following exception: +api-1 | +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/bin/alembic", line 8, in +api-1 | sys.exit(main()) +api-1 | ^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1039, in main +api-1 | CommandLine(prog=prog).main(argv=argv) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1029, in main +api-1 | self.run_cmd(cfg, options) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 963, in run_cmd +api-1 | fn( +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/command.py", line 487, in upgrade +api-1 | script.run_env() +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/script/base.py", line 550, in run_env +api-1 | util.load_python_file(self.dir, "env.py") +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 114, in load_python_file +api-1 | module = load_module_py(module_id, path) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 132, in load_module_py +api-1 | spec.loader.exec_module(module) # type: ignore +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "", line 999, in exec_module +api-1 | File "", line 488, in _call_with_frames_removed +api-1 | File "/srv/alembic/env.py", line 47, in +api-1 | run_migrations_online() +api-1 | File "/srv/alembic/env.py", line 36, in run_migrations_online +api-1 | with connectable.connect() as connection: +api-1 | ^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3295, in connect +api-1 | return self._connection_cls(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 146, in __init__ +api-1 | Connection._handle_dbapi_exception_noconnection( +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 2450, in _handle_dbapi_exception_noconnection +api-1 | raise sqlalchemy_exception.with_traceback(exc_info[2]) from e +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | sqlalchemy.exc.OperationalError: (psycopg.OperationalError) connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | (Background on this error at: https://sqlalche.me/e/20/e3q8) +api-1 | entrypoint: database not ready (attempt 6), retrying in 3s +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | psycopg.OperationalError: connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | +api-1 | The above exception was the direct cause of the following exception: +api-1 | +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/bin/alembic", line 8, in +api-1 | sys.exit(main()) +api-1 | ^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1039, in main +api-1 | CommandLine(prog=prog).main(argv=argv) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1029, in main +api-1 | self.run_cmd(cfg, options) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 963, in run_cmd +api-1 | fn( +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/command.py", line 487, in upgrade +api-1 | script.run_env() +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/script/base.py", line 550, in run_env +api-1 | util.load_python_file(self.dir, "env.py") +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 114, in load_python_file +api-1 | module = load_module_py(module_id, path) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 132, in load_module_py +api-1 | spec.loader.exec_module(module) # type: ignore +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "", line 999, in exec_module +api-1 | File "", line 488, in _call_with_frames_removed +api-1 | File "/srv/alembic/env.py", line 47, in +api-1 | run_migrations_online() +api-1 | File "/srv/alembic/env.py", line 36, in run_migrations_online +api-1 | with connectable.connect() as connection: +api-1 | ^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3295, in connect +api-1 | return self._connection_cls(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 146, in __init__ +api-1 | Connection._handle_dbapi_exception_noconnection( +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 2450, in _handle_dbapi_exception_noconnection +api-1 | raise sqlalchemy_exception.with_traceback(exc_info[2]) from e +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | sqlalchemy.exc.OperationalError: (psycopg.OperationalError) connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | (Background on this error at: https://sqlalche.me/e/20/e3q8) +api-1 | entrypoint: database not ready (attempt 7), retrying in 3s +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | psycopg.OperationalError: connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | +api-1 | The above exception was the direct cause of the following exception: +api-1 | +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/bin/alembic", line 8, in +api-1 | sys.exit(main()) +api-1 | ^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1039, in main +api-1 | CommandLine(prog=prog).main(argv=argv) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1029, in main +api-1 | self.run_cmd(cfg, options) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 963, in run_cmd +api-1 | fn( +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/command.py", line 487, in upgrade +api-1 | script.run_env() +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/script/base.py", line 550, in run_env +api-1 | util.load_python_file(self.dir, "env.py") +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 114, in load_python_file +api-1 | module = load_module_py(module_id, path) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 132, in load_module_py +api-1 | spec.loader.exec_module(module) # type: ignore +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "", line 999, in exec_module +api-1 | File "", line 488, in _call_with_frames_removed +api-1 | File "/srv/alembic/env.py", line 47, in +api-1 | run_migrations_online() +api-1 | File "/srv/alembic/env.py", line 36, in run_migrations_online +api-1 | with connectable.connect() as connection: +api-1 | ^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3295, in connect +api-1 | return self._connection_cls(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 146, in __init__ +api-1 | Connection._handle_dbapi_exception_noconnection( +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 2450, in _handle_dbapi_exception_noconnection +api-1 | raise sqlalchemy_exception.with_traceback(exc_info[2]) from e +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | sqlalchemy.exc.OperationalError: (psycopg.OperationalError) connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | (Background on this error at: https://sqlalche.me/e/20/e3q8) +api-1 | entrypoint: database not ready (attempt 8), retrying in 3s +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | psycopg.OperationalError: connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | +api-1 | The above exception was the direct cause of the following exception: +api-1 | +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/bin/alembic", line 8, in +api-1 | sys.exit(main()) +api-1 | ^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1039, in main +api-1 | CommandLine(prog=prog).main(argv=argv) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1029, in main +api-1 | self.run_cmd(cfg, options) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 963, in run_cmd +api-1 | fn( +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/command.py", line 487, in upgrade +api-1 | script.run_env() +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/script/base.py", line 550, in run_env +api-1 | util.load_python_file(self.dir, "env.py") +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 114, in load_python_file +api-1 | module = load_module_py(module_id, path) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 132, in load_module_py +api-1 | spec.loader.exec_module(module) # type: ignore +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "", line 999, in exec_module +api-1 | File "", line 488, in _call_with_frames_removed +api-1 | File "/srv/alembic/env.py", line 47, in +api-1 | run_migrations_online() +api-1 | File "/srv/alembic/env.py", line 36, in run_migrations_online +api-1 | with connectable.connect() as connection: +api-1 | ^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3295, in connect +api-1 | return self._connection_cls(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 146, in __init__ +api-1 | Connection._handle_dbapi_exception_noconnection( +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 2450, in _handle_dbapi_exception_noconnection +api-1 | raise sqlalchemy_exception.with_traceback(exc_info[2]) from e +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | sqlalchemy.exc.OperationalError: (psycopg.OperationalError) connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | (Background on this error at: https://sqlalche.me/e/20/e3q8) +api-1 | entrypoint: database not ready (attempt 9), retrying in 3s +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | psycopg.OperationalError: connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | +api-1 | The above exception was the direct cause of the following exception: +api-1 | +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/bin/alembic", line 8, in +api-1 | sys.exit(main()) +api-1 | ^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1039, in main +api-1 | CommandLine(prog=prog).main(argv=argv) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1029, in main +api-1 | self.run_cmd(cfg, options) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 963, in run_cmd +api-1 | fn( +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/command.py", line 487, in upgrade +api-1 | script.run_env() +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/script/base.py", line 550, in run_env +api-1 | util.load_python_file(self.dir, "env.py") +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 114, in load_python_file +api-1 | module = load_module_py(module_id, path) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 132, in load_module_py +api-1 | spec.loader.exec_module(module) # type: ignore +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "", line 999, in exec_module +api-1 | File "", line 488, in _call_with_frames_removed +api-1 | File "/srv/alembic/env.py", line 47, in +api-1 | run_migrations_online() +api-1 | File "/srv/alembic/env.py", line 36, in run_migrations_online +api-1 | with connectable.connect() as connection: +api-1 | ^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3295, in connect +api-1 | return self._connection_cls(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 146, in __init__ +api-1 | Connection._handle_dbapi_exception_noconnection( +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 2450, in _handle_dbapi_exception_noconnection +api-1 | raise sqlalchemy_exception.with_traceback(exc_info[2]) from e +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | sqlalchemy.exc.OperationalError: (psycopg.OperationalError) connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | (Background on this error at: https://sqlalche.me/e/20/e3q8) +api-1 | entrypoint: database not ready (attempt 10), retrying in 3s +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | psycopg.OperationalError: connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | +api-1 | The above exception was the direct cause of the following exception: +api-1 | +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/bin/alembic", line 8, in +api-1 | sys.exit(main()) +api-1 | ^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1039, in main +api-1 | CommandLine(prog=prog).main(argv=argv) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1029, in main +api-1 | self.run_cmd(cfg, options) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 963, in run_cmd +api-1 | fn( +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/command.py", line 487, in upgrade +api-1 | script.run_env() +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/script/base.py", line 550, in run_env +api-1 | util.load_python_file(self.dir, "env.py") +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 114, in load_python_file +api-1 | module = load_module_py(module_id, path) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 132, in load_module_py +api-1 | spec.loader.exec_module(module) # type: ignore +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "", line 999, in exec_module +api-1 | File "", line 488, in _call_with_frames_removed +api-1 | File "/srv/alembic/env.py", line 47, in +api-1 | run_migrations_online() +api-1 | File "/srv/alembic/env.py", line 36, in run_migrations_online +api-1 | with connectable.connect() as connection: +api-1 | ^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3295, in connect +api-1 | return self._connection_cls(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 146, in __init__ +api-1 | Connection._handle_dbapi_exception_noconnection( +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 2450, in _handle_dbapi_exception_noconnection +api-1 | raise sqlalchemy_exception.with_traceback(exc_info[2]) from e +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | sqlalchemy.exc.OperationalError: (psycopg.OperationalError) connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | (Background on this error at: https://sqlalche.me/e/20/e3q8) +api-1 | entrypoint: database not ready (attempt 11), retrying in 3s +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | psycopg.OperationalError: connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | +api-1 | The above exception was the direct cause of the following exception: +api-1 | +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/bin/alembic", line 8, in +api-1 | sys.exit(main()) +api-1 | ^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1039, in main +api-1 | CommandLine(prog=prog).main(argv=argv) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1029, in main +api-1 | self.run_cmd(cfg, options) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 963, in run_cmd +api-1 | fn( +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/command.py", line 487, in upgrade +api-1 | script.run_env() +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/script/base.py", line 550, in run_env +api-1 | util.load_python_file(self.dir, "env.py") +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 114, in load_python_file +api-1 | module = load_module_py(module_id, path) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 132, in load_module_py +api-1 | spec.loader.exec_module(module) # type: ignore +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "", line 999, in exec_module +api-1 | File "", line 488, in _call_with_frames_removed +api-1 | File "/srv/alembic/env.py", line 47, in +api-1 | run_migrations_online() +api-1 | File "/srv/alembic/env.py", line 36, in run_migrations_online +api-1 | with connectable.connect() as connection: +api-1 | ^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3295, in connect +api-1 | return self._connection_cls(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 146, in __init__ +api-1 | Connection._handle_dbapi_exception_noconnection( +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 2450, in _handle_dbapi_exception_noconnection +api-1 | raise sqlalchemy_exception.with_traceback(exc_info[2]) from e +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | sqlalchemy.exc.OperationalError: (psycopg.OperationalError) connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | (Background on this error at: https://sqlalche.me/e/20/e3q8) +api-1 | entrypoint: database not ready (attempt 12), retrying in 3s +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | psycopg.OperationalError: connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | +api-1 | The above exception was the direct cause of the following exception: +api-1 | +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/bin/alembic", line 8, in +api-1 | sys.exit(main()) +api-1 | ^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1039, in main +api-1 | CommandLine(prog=prog).main(argv=argv) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1029, in main +api-1 | self.run_cmd(cfg, options) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 963, in run_cmd +api-1 | fn( +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/command.py", line 487, in upgrade +api-1 | script.run_env() +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/script/base.py", line 550, in run_env +api-1 | util.load_python_file(self.dir, "env.py") +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 114, in load_python_file +api-1 | module = load_module_py(module_id, path) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 132, in load_module_py +api-1 | spec.loader.exec_module(module) # type: ignore +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "", line 999, in exec_module +api-1 | File "", line 488, in _call_with_frames_removed +api-1 | File "/srv/alembic/env.py", line 47, in +api-1 | run_migrations_online() +api-1 | File "/srv/alembic/env.py", line 36, in run_migrations_online +api-1 | with connectable.connect() as connection: +api-1 | ^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3295, in connect +api-1 | return self._connection_cls(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 146, in __init__ +api-1 | Connection._handle_dbapi_exception_noconnection( +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 2450, in _handle_dbapi_exception_noconnection +api-1 | raise sqlalchemy_exception.with_traceback(exc_info[2]) from e +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | sqlalchemy.exc.OperationalError: (psycopg.OperationalError) connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | (Background on this error at: https://sqlalche.me/e/20/e3q8) +api-1 | entrypoint: database not ready (attempt 13), retrying in 3s +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | psycopg.OperationalError: connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | +api-1 | The above exception was the direct cause of the following exception: +api-1 | +api-1 | Traceback (most recent call last): +api-1 | File "/opt/venv/bin/alembic", line 8, in +api-1 | sys.exit(main()) +api-1 | ^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1039, in main +api-1 | CommandLine(prog=prog).main(argv=argv) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 1029, in main +api-1 | self.run_cmd(cfg, options) +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/config.py", line 963, in run_cmd +api-1 | fn( +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/command.py", line 487, in upgrade +api-1 | script.run_env() +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/script/base.py", line 550, in run_env +api-1 | util.load_python_file(self.dir, "env.py") +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 114, in load_python_file +api-1 | module = load_module_py(module_id, path) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 132, in load_module_py +api-1 | spec.loader.exec_module(module) # type: ignore +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "", line 999, in exec_module +api-1 | File "", line 488, in _call_with_frames_removed +api-1 | File "/srv/alembic/env.py", line 47, in +api-1 | run_migrations_online() +api-1 | File "/srv/alembic/env.py", line 36, in run_migrations_online +api-1 | with connectable.connect() as connection: +api-1 | ^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3295, in connect +api-1 | return self._connection_cls(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 146, in __init__ +api-1 | Connection._handle_dbapi_exception_noconnection( +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 2450, in _handle_dbapi_exception_noconnection +api-1 | raise sqlalchemy_exception.with_traceback(exc_info[2]) from e +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 144, in __init__ +api-1 | self._dbapi_connection = engine.raw_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3319, in raw_connection +api-1 | return self.pool.connect() +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 448, in connect +api-1 | return _ConnectionFairy._checkout(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1290, in _checkout +api-1 | fairy = _ConnectionRecord.checkout(pool) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout +api-1 | rec = pool._do_get() +api-1 | ^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 307, in _do_get +api-1 | return self._create_connection() +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection +api-1 | return _ConnectionRecord(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__ +api-1 | self.__connect() +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect +api-1 | with util.safe_reraise(): +api-1 | ^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__ +api-1 | raise exc_value.with_traceback(exc_tb) +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect +api-1 | self.dbapi_connection = connection = pool._invoke_creator(self) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 667, in connect +api-1 | return dialect.connect(*cargs_tup, **cparams) +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 630, in connect +api-1 | return self.loaded_dbapi.connect(*cargs, **cparams) # type: ignore[no-any-return] # NOQA: E501 +api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +api-1 | File "/opt/venv/lib/python3.12/site-packages/psycopg/connection.py", line 126, in connect +api-1 | raise last_ex.with_traceback(None) +api-1 | sqlalchemy.exc.OperationalError: (psycopg.OperationalError) connection failed: connection to server at "172.30.0.3", port 5432 failed: FATAL: password authentication failed for user "pharma" +api-1 | (Background on this error at: https://sqlalche.me/e/20/e3q8) +api-1 | entrypoint: database not ready (attempt 14), retrying in 3s diff --git a/.caddy.log b/.caddy.log new file mode 100644 index 0000000..e69de29 diff --git a/.db.log b/.db.log new file mode 100644 index 0000000..d0c2a6f --- /dev/null +++ b/.db.log @@ -0,0 +1,189 @@ +db-1 | +db-1 | PostgreSQL Database directory appears to contain a database; Skipping initialization +db-1 | +db-1 | 2026-09-20 05:16:57.152 UTC [1] LOG: starting PostgreSQL 16.15 on x86_64-pc-linux-musl, compiled by gcc (Alpine 15.2.0) 15.2.0, 64-bit +db-1 | 2026-09-20 05:16:57.152 UTC [1] LOG: listening on IPv4 address "0.0.0.0", port 5432 +db-1 | 2026-09-20 05:16:57.152 UTC [1] LOG: listening on IPv6 address "::", port 5432 +db-1 | 2026-09-20 05:16:57.155 UTC [1] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432" +db-1 | 2026-09-20 05:16:57.168 UTC [29] LOG: database system was shut down at 2026-09-20 05:16:55 UTC +db-1 | 2026-09-20 05:16:57.180 UTC [1] LOG: database system is ready to accept connections +db-1 | 2026-09-20 05:17:03.978 UTC [39] FATAL: password authentication failed for user "pharma" +db-1 | 2026-09-20 05:17:03.978 UTC [39] DETAIL: Connection matched file "/var/lib/postgresql/data/pg_hba.conf" line 128: "host all all all scram-sha-256" +db-1 | 2026-09-20 05:17:08.432 UTC [48] FATAL: password authentication failed for user "pharma" +db-1 | 2026-09-20 05:17:08.432 UTC [48] DETAIL: Connection matched file "/var/lib/postgresql/data/pg_hba.conf" line 128: "host all all all scram-sha-256" +db-1 | 2026-09-20 05:17:12.951 UTC [57] FATAL: password authentication failed for user "pharma" +db-1 | 2026-09-20 05:17:12.951 UTC [57] DETAIL: Connection matched file "/var/lib/postgresql/data/pg_hba.conf" line 128: "host all all all scram-sha-256" +db-1 | 2026-09-20 05:17:17.458 UTC [65] FATAL: password authentication failed for user "pharma" +db-1 | 2026-09-20 05:17:17.458 UTC [65] DETAIL: Connection matched file "/var/lib/postgresql/data/pg_hba.conf" line 128: "host all all all scram-sha-256" +db-1 | 2026-09-20 05:17:21.947 UTC [66] FATAL: password authentication failed for user "pharma" +db-1 | 2026-09-20 05:17:21.947 UTC [66] DETAIL: Connection matched file "/var/lib/postgresql/data/pg_hba.conf" line 128: "host all all all scram-sha-256" +db-1 | 2026-09-20 05:17:26.331 UTC [74] FATAL: password authentication failed for user "pharma" +db-1 | 2026-09-20 05:17:26.331 UTC [74] DETAIL: Connection matched file "/var/lib/postgresql/data/pg_hba.conf" line 128: "host all all all scram-sha-256" +db-1 | 2026-09-20 05:17:30.747 UTC [83] FATAL: password authentication failed for user "pharma" +db-1 | 2026-09-20 05:17:30.747 UTC [83] DETAIL: Connection matched file "/var/lib/postgresql/data/pg_hba.conf" line 128: "host all all all scram-sha-256" +db-1 | 2026-09-20 05:17:35.138 UTC [90] FATAL: password authentication failed for user "pharma" +db-1 | 2026-09-20 05:17:35.138 UTC [90] DETAIL: Connection matched file "/var/lib/postgresql/data/pg_hba.conf" line 128: "host all all all scram-sha-256" +db-1 | 2026-09-20 05:17:39.636 UTC [98] FATAL: password authentication failed for user "pharma" +db-1 | 2026-09-20 05:17:39.636 UTC [98] DETAIL: Connection matched file "/var/lib/postgresql/data/pg_hba.conf" line 128: "host all all all scram-sha-256" +db-1 | 2026-09-20 05:17:44.035 UTC [107] FATAL: password authentication failed for user "pharma" +db-1 | 2026-09-20 05:17:44.035 UTC [107] DETAIL: Connection matched file "/var/lib/postgresql/data/pg_hba.conf" line 128: "host all all all scram-sha-256" +db-1 | 2026-09-20 05:17:48.411 UTC [115] FATAL: password authentication failed for user "pharma" +db-1 | 2026-09-20 05:17:48.411 UTC [115] DETAIL: Connection matched file "/var/lib/postgresql/data/pg_hba.conf" line 128: "host all all all scram-sha-256" +db-1 | 2026-09-20 05:17:52.721 UTC [116] FATAL: password authentication failed for user "pharma" +db-1 | 2026-09-20 05:17:52.721 UTC [116] DETAIL: Connection matched file "/var/lib/postgresql/data/pg_hba.conf" line 128: "host all all all scram-sha-256" +db-1 | 2026-09-20 05:17:57.257 UTC [125] FATAL: password authentication failed for user "pharma" +db-1 | 2026-09-20 05:17:57.257 UTC [125] DETAIL: Connection matched file "/var/lib/postgresql/data/pg_hba.conf" line 128: "host all all all scram-sha-256" +db-1 | 2026-09-20 05:18:01.900 UTC [133] FATAL: password authentication failed for user "pharma" +db-1 | 2026-09-20 05:18:01.900 UTC [133] DETAIL: Connection matched file "/var/lib/postgresql/data/pg_hba.conf" line 128: "host all all all scram-sha-256" +db-1 | 2026-09-20 05:18:06.319 UTC [141] FATAL: password authentication failed for user "pharma" +db-1 | 2026-09-20 05:18:06.319 UTC [141] DETAIL: Connection matched file "/var/lib/postgresql/data/pg_hba.conf" line 128: "host all all all scram-sha-256" +db-1 | 2026-09-20 05:18:08.113 UTC [149] FATAL: password authentication failed for user "pharma" +db-1 | 2026-09-20 05:18:08.113 UTC [149] DETAIL: Connection matched file "/var/lib/postgresql/data/pg_hba.conf" line 128: "host all all all scram-sha-256" +db-1 | 2026-09-20 05:18:12.666 UTC [151] FATAL: password authentication failed for user "pharma" +db-1 | 2026-09-20 05:18:12.666 UTC [151] DETAIL: Connection matched file "/var/lib/postgresql/data/pg_hba.conf" line 128: "host all all all scram-sha-256" +db-1 | 2026-09-20 05:18:17.184 UTC [159] FATAL: password authentication failed for user "pharma" +db-1 | 2026-09-20 05:18:17.184 UTC [159] DETAIL: Connection matched file "/var/lib/postgresql/data/pg_hba.conf" line 128: "host all all all scram-sha-256" +db-1 | 2026-09-20 05:18:21.706 UTC [167] FATAL: password authentication failed for user "pharma" +db-1 | 2026-09-20 05:18:21.706 UTC [167] DETAIL: Connection matched file "/var/lib/postgresql/data/pg_hba.conf" line 128: "host all all all scram-sha-256" +db-1 | 2026-09-20 05:18:26.211 UTC [175] FATAL: password authentication failed for user "pharma" +db-1 | 2026-09-20 05:18:26.211 UTC [175] DETAIL: Connection matched file "/var/lib/postgresql/data/pg_hba.conf" line 128: "host all all all scram-sha-256" +db-1 | 2026-09-20 05:18:30.708 UTC [184] FATAL: password authentication failed for user "pharma" +db-1 | 2026-09-20 05:18:30.708 UTC [184] DETAIL: Connection matched file "/var/lib/postgresql/data/pg_hba.conf" line 128: "host all all all scram-sha-256" +db-1 | 2026-09-20 05:18:35.184 UTC [192] FATAL: password authentication failed for user "pharma" +db-1 | 2026-09-20 05:18:35.184 UTC [192] DETAIL: Connection matched file "/var/lib/postgresql/data/pg_hba.conf" line 128: "host all all all scram-sha-256" +db-1 | 2026-09-20 05:18:39.738 UTC [199] FATAL: password authentication failed for user "pharma" +db-1 | 2026-09-20 05:18:39.738 UTC [199] DETAIL: Connection matched file "/var/lib/postgresql/data/pg_hba.conf" line 128: "host all all all scram-sha-256" +db-1 | 2026-09-20 05:18:44.293 UTC [208] FATAL: password authentication failed for user "pharma" +db-1 | 2026-09-20 05:18:44.293 UTC [208] DETAIL: Connection matched file "/var/lib/postgresql/data/pg_hba.conf" line 128: "host all all all scram-sha-256" +db-1 | 2026-09-20 05:18:48.925 UTC [216] FATAL: password authentication failed for user "pharma" +db-1 | 2026-09-20 05:18:48.925 UTC [216] DETAIL: Connection matched file "/var/lib/postgresql/data/pg_hba.conf" line 128: "host all all all scram-sha-256" +db-1 | 2026-09-20 05:18:53.406 UTC [217] FATAL: password authentication failed for user "pharma" +db-1 | 2026-09-20 05:18:53.406 UTC [217] DETAIL: Connection matched file "/var/lib/postgresql/data/pg_hba.conf" line 128: "host all all all scram-sha-256" +db-1 | 2026-09-20 05:18:58.007 UTC [225] FATAL: password authentication failed for user "pharma" +db-1 | 2026-09-20 05:18:58.007 UTC [225] DETAIL: Connection matched file "/var/lib/postgresql/data/pg_hba.conf" line 128: "host all all all scram-sha-256" +db-1 | 2026-09-20 05:19:02.969 UTC [234] FATAL: password authentication failed for user "pharma" +db-1 | 2026-09-20 05:19:02.969 UTC [234] DETAIL: Connection matched file "/var/lib/postgresql/data/pg_hba.conf" line 128: "host all all all scram-sha-256" +db-1 | 2026-09-20 05:19:07.554 UTC [242] FATAL: password authentication failed for user "pharma" +db-1 | 2026-09-20 05:19:07.554 UTC [242] DETAIL: Connection matched file "/var/lib/postgresql/data/pg_hba.conf" line 128: "host all all all scram-sha-256" +db-1 | 2026-09-20 05:19:12.083 UTC [249] FATAL: password authentication failed for user "pharma" +db-1 | 2026-09-20 05:19:12.083 UTC [249] DETAIL: Connection matched file "/var/lib/postgresql/data/pg_hba.conf" line 128: "host all all all scram-sha-256" +db-1 | 2026-09-20 05:19:14.060 UTC [258] FATAL: password authentication failed for user "pharma" +db-1 | 2026-09-20 05:19:14.060 UTC [258] DETAIL: Connection matched file "/var/lib/postgresql/data/pg_hba.conf" line 128: "host all all all scram-sha-256" +db-1 | 2026-09-20 05:19:18.491 UTC [259] FATAL: password authentication failed for user "pharma" +db-1 | 2026-09-20 05:19:18.491 UTC [259] DETAIL: Connection matched file "/var/lib/postgresql/data/pg_hba.conf" line 128: "host all all all scram-sha-256" +db-1 | 2026-09-20 05:19:23.016 UTC [267] FATAL: password authentication failed for user "pharma" +db-1 | 2026-09-20 05:19:23.016 UTC [267] DETAIL: Connection matched file "/var/lib/postgresql/data/pg_hba.conf" line 128: "host all all all scram-sha-256" +db-1 | 2026-09-20 05:19:27.632 UTC [276] FATAL: password authentication failed for user "pharma" +db-1 | 2026-09-20 05:19:27.632 UTC [276] DETAIL: Connection matched file "/var/lib/postgresql/data/pg_hba.conf" line 128: "host all all all scram-sha-256" +db-1 | 2026-09-20 05:19:32.147 UTC [284] FATAL: password authentication failed for user "pharma" +db-1 | 2026-09-20 05:19:32.147 UTC [284] DETAIL: Connection matched file "/var/lib/postgresql/data/pg_hba.conf" line 128: "host all all all scram-sha-256" +db-1 | 2026-09-20 05:19:36.600 UTC [292] FATAL: password authentication failed for user "pharma" +db-1 | 2026-09-20 05:19:36.600 UTC [292] DETAIL: Connection matched file "/var/lib/postgresql/data/pg_hba.conf" line 128: "host all all all scram-sha-256" +db-1 | 2026-09-20 05:19:41.020 UTC [299] FATAL: password authentication failed for user "pharma" +db-1 | 2026-09-20 05:19:41.020 UTC [299] DETAIL: Connection matched file "/var/lib/postgresql/data/pg_hba.conf" line 128: "host all all all scram-sha-256" +db-1 | 2026-09-20 05:19:45.624 UTC [308] FATAL: password authentication failed for user "pharma" +db-1 | 2026-09-20 05:19:45.624 UTC [308] DETAIL: Connection matched file "/var/lib/postgresql/data/pg_hba.conf" line 128: "host all all all scram-sha-256" +db-1 | 2026-09-20 05:19:50.089 UTC [316] FATAL: password authentication failed for user "pharma" +db-1 | 2026-09-20 05:19:50.089 UTC [316] DETAIL: Connection matched file "/var/lib/postgresql/data/pg_hba.conf" line 128: "host all all all scram-sha-256" +db-1 | 2026-09-20 05:19:54.570 UTC [317] FATAL: password authentication failed for user "pharma" +db-1 | 2026-09-20 05:19:54.570 UTC [317] DETAIL: Connection matched file "/var/lib/postgresql/data/pg_hba.conf" line 128: "host all all all scram-sha-256" +db-1 | 2026-09-20 05:19:59.098 UTC [326] FATAL: password authentication failed for user "pharma" +db-1 | 2026-09-20 05:19:59.098 UTC [326] DETAIL: Connection matched file "/var/lib/postgresql/data/pg_hba.conf" line 128: "host all all all scram-sha-256" +db-1 | 2026-09-20 05:20:04.277 UTC [334] FATAL: password authentication failed for user "pharma" +db-1 | 2026-09-20 05:20:04.277 UTC [334] DETAIL: Connection matched file "/var/lib/postgresql/data/pg_hba.conf" line 128: "host all all all scram-sha-256" +db-1 | 2026-09-20 05:20:08.934 UTC [342] FATAL: password authentication failed for user "pharma" +db-1 | 2026-09-20 05:20:08.934 UTC [342] DETAIL: Connection matched file "/var/lib/postgresql/data/pg_hba.conf" line 128: "host all all all scram-sha-256" +db-1 | 2026-09-20 05:20:13.495 UTC [351] FATAL: password authentication failed for user "pharma" +db-1 | 2026-09-20 05:20:13.495 UTC [351] DETAIL: Connection matched file "/var/lib/postgresql/data/pg_hba.conf" line 128: "host all all all scram-sha-256" +db-1 | 2026-09-20 05:20:18.039 UTC [360] FATAL: password authentication failed for user "pharma" +db-1 | 2026-09-20 05:20:18.039 UTC [360] DETAIL: Connection matched file "/var/lib/postgresql/data/pg_hba.conf" line 128: "host all all all scram-sha-256" +db-1 | 2026-09-20 05:20:19.980 UTC [361] FATAL: password authentication failed for user "pharma" +db-1 | 2026-09-20 05:20:19.980 UTC [361] DETAIL: Connection matched file "/var/lib/postgresql/data/pg_hba.conf" line 128: "host all all all scram-sha-256" +db-1 | 2026-09-20 05:20:24.501 UTC [368] FATAL: password authentication failed for user "pharma" +db-1 | 2026-09-20 05:20:24.501 UTC [368] DETAIL: Connection matched file "/var/lib/postgresql/data/pg_hba.conf" line 128: "host all all all scram-sha-256" +db-1 | 2026-09-20 05:20:29.097 UTC [377] FATAL: password authentication failed for user "pharma" +db-1 | 2026-09-20 05:20:29.097 UTC [377] DETAIL: Connection matched file "/var/lib/postgresql/data/pg_hba.conf" line 128: "host all all all scram-sha-256" +db-1 | 2026-09-20 05:20:33.618 UTC [384] FATAL: password authentication failed for user "pharma" +db-1 | 2026-09-20 05:20:33.618 UTC [384] DETAIL: Connection matched file "/var/lib/postgresql/data/pg_hba.conf" line 128: "host all all all scram-sha-256" +db-1 | 2026-09-20 05:20:38.088 UTC [391] FATAL: password authentication failed for user "pharma" +db-1 | 2026-09-20 05:20:38.088 UTC [391] DETAIL: Connection matched file "/var/lib/postgresql/data/pg_hba.conf" line 128: "host all all all scram-sha-256" +db-1 | 2026-09-20 05:20:42.608 UTC [400] FATAL: password authentication failed for user "pharma" +db-1 | 2026-09-20 05:20:42.608 UTC [400] DETAIL: Connection matched file "/var/lib/postgresql/data/pg_hba.conf" line 128: "host all all all scram-sha-256" +db-1 | 2026-09-20 05:20:47.153 UTC [407] FATAL: password authentication failed for user "pharma" +db-1 | 2026-09-20 05:20:47.153 UTC [407] DETAIL: Connection matched file "/var/lib/postgresql/data/pg_hba.conf" line 128: "host all all all scram-sha-256" +db-1 | 2026-09-20 05:20:51.566 UTC [414] FATAL: password authentication failed for user "pharma" +db-1 | 2026-09-20 05:20:51.566 UTC [414] DETAIL: Connection matched file "/var/lib/postgresql/data/pg_hba.conf" line 128: "host all all all scram-sha-256" +db-1 | 2026-09-20 05:20:56.011 UTC [422] FATAL: password authentication failed for user "pharma" +db-1 | 2026-09-20 05:20:56.011 UTC [422] DETAIL: Connection matched file "/var/lib/postgresql/data/pg_hba.conf" line 128: "host all all all scram-sha-256" +db-1 | 2026-09-20 05:21:00.533 UTC [424] FATAL: password authentication failed for user "pharma" +db-1 | 2026-09-20 05:21:00.533 UTC [424] DETAIL: Connection matched file "/var/lib/postgresql/data/pg_hba.conf" line 128: "host all all all scram-sha-256" +db-1 | 2026-09-20 05:21:04.927 UTC [432] FATAL: password authentication failed for user "pharma" +db-1 | 2026-09-20 05:21:04.927 UTC [432] DETAIL: Connection matched file "/var/lib/postgresql/data/pg_hba.conf" line 128: "host all all all scram-sha-256" +db-1 | 2026-09-20 05:21:09.385 UTC [440] FATAL: password authentication failed for user "pharma" +db-1 | 2026-09-20 05:21:09.385 UTC [440] DETAIL: Connection matched file "/var/lib/postgresql/data/pg_hba.conf" line 128: "host all all all scram-sha-256" +db-1 | 2026-09-20 05:21:13.801 UTC [448] FATAL: password authentication failed for user "pharma" +db-1 | 2026-09-20 05:21:13.801 UTC [448] DETAIL: Connection matched file "/var/lib/postgresql/data/pg_hba.conf" line 128: "host all all all scram-sha-256" +db-1 | 2026-09-20 05:21:18.263 UTC [455] FATAL: password authentication failed for user "pharma" +db-1 | 2026-09-20 05:21:18.263 UTC [455] DETAIL: Connection matched file "/var/lib/postgresql/data/pg_hba.conf" line 128: "host all all all scram-sha-256" +db-1 | 2026-09-20 05:21:22.685 UTC [463] FATAL: password authentication failed for user "pharma" +db-1 | 2026-09-20 05:21:22.685 UTC [463] DETAIL: Connection matched file "/var/lib/postgresql/data/pg_hba.conf" line 128: "host all all all scram-sha-256" +db-1 | 2026-09-20 05:21:24.557 UTC [464] FATAL: password authentication failed for user "pharma" +db-1 | 2026-09-20 05:21:24.557 UTC [464] DETAIL: Connection matched file "/var/lib/postgresql/data/pg_hba.conf" line 128: "host all all all scram-sha-256" +db-1 | 2026-09-20 05:21:29.007 UTC [473] FATAL: password authentication failed for user "pharma" +db-1 | 2026-09-20 05:21:29.007 UTC [473] DETAIL: Connection matched file "/var/lib/postgresql/data/pg_hba.conf" line 128: "host all all all scram-sha-256" +db-1 | 2026-09-20 05:21:33.429 UTC [481] FATAL: password authentication failed for user "pharma" +db-1 | 2026-09-20 05:21:33.429 UTC [481] DETAIL: Connection matched file "/var/lib/postgresql/data/pg_hba.conf" line 128: "host all all all scram-sha-256" +db-1 | 2026-09-20 05:21:37.901 UTC [488] FATAL: password authentication failed for user "pharma" +db-1 | 2026-09-20 05:21:37.901 UTC [488] DETAIL: Connection matched file "/var/lib/postgresql/data/pg_hba.conf" line 128: "host all all all scram-sha-256" +db-1 | 2026-09-20 05:21:42.449 UTC [497] FATAL: password authentication failed for user "pharma" +db-1 | 2026-09-20 05:21:42.449 UTC [497] DETAIL: Connection matched file "/var/lib/postgresql/data/pg_hba.conf" line 128: "host all all all scram-sha-256" +db-1 | 2026-09-20 05:21:47.008 UTC [504] FATAL: password authentication failed for user "pharma" +db-1 | 2026-09-20 05:21:47.008 UTC [504] DETAIL: Connection matched file "/var/lib/postgresql/data/pg_hba.conf" line 128: "host all all all scram-sha-256" +db-1 | 2026-09-20 05:21:51.513 UTC [505] FATAL: password authentication failed for user "pharma" +db-1 | 2026-09-20 05:21:51.513 UTC [505] DETAIL: Connection matched file "/var/lib/postgresql/data/pg_hba.conf" line 128: "host all all all scram-sha-256" +db-1 | 2026-09-20 05:21:56.017 UTC [512] FATAL: password authentication failed for user "pharma" +db-1 | 2026-09-20 05:21:56.017 UTC [512] DETAIL: Connection matched file "/var/lib/postgresql/data/pg_hba.conf" line 128: "host all all all scram-sha-256" +db-1 | 2026-09-20 05:21:57.266 UTC [27] LOG: checkpoint starting: time +db-1 | 2026-09-20 05:21:57.282 UTC [27] LOG: checkpoint complete: wrote 3 buffers (0.0%); 0 WAL file(s) added, 0 removed, 0 recycled; write=0.006 s, sync=0.002 s, total=0.017 s; sync files=2, longest=0.001 s, average=0.001 s; distance=0 kB, estimate=0 kB; lsn=0/2FAD240, redo lsn=0/2FAD208 +db-1 | 2026-09-20 05:22:00.528 UTC [521] FATAL: password authentication failed for user "pharma" +db-1 | 2026-09-20 05:22:00.528 UTC [521] DETAIL: Connection matched file "/var/lib/postgresql/data/pg_hba.conf" line 128: "host all all all scram-sha-256" +db-1 | 2026-09-20 05:22:05.322 UTC [528] FATAL: password authentication failed for user "pharma" +db-1 | 2026-09-20 05:22:05.322 UTC [528] DETAIL: Connection matched file "/var/lib/postgresql/data/pg_hba.conf" line 128: "host all all all scram-sha-256" +db-1 | 2026-09-20 05:22:09.877 UTC [536] FATAL: password authentication failed for user "pharma" +db-1 | 2026-09-20 05:22:09.877 UTC [536] DETAIL: Connection matched file "/var/lib/postgresql/data/pg_hba.conf" line 128: "host all all all scram-sha-256" +db-1 | 2026-09-20 05:22:14.407 UTC [546] FATAL: password authentication failed for user "pharma" +db-1 | 2026-09-20 05:22:14.407 UTC [546] DETAIL: Connection matched file "/var/lib/postgresql/data/pg_hba.conf" line 128: "host all all all scram-sha-256" +db-1 | 2026-09-20 05:22:18.960 UTC [554] FATAL: password authentication failed for user "pharma" +db-1 | 2026-09-20 05:22:18.960 UTC [554] DETAIL: Connection matched file "/var/lib/postgresql/data/pg_hba.conf" line 128: "host all all all scram-sha-256" +db-1 | 2026-09-20 05:22:23.616 UTC [562] FATAL: password authentication failed for user "pharma" +db-1 | 2026-09-20 05:22:23.616 UTC [562] DETAIL: Connection matched file "/var/lib/postgresql/data/pg_hba.conf" line 128: "host all all all scram-sha-256" +db-1 | 2026-09-20 05:22:28.170 UTC [571] FATAL: password authentication failed for user "pharma" +db-1 | 2026-09-20 05:22:28.170 UTC [571] DETAIL: Connection matched file "/var/lib/postgresql/data/pg_hba.conf" line 128: "host all all all scram-sha-256" +db-1 | 2026-09-20 05:22:30.183 UTC [572] FATAL: password authentication failed for user "pharma" +db-1 | 2026-09-20 05:22:30.183 UTC [572] DETAIL: Connection matched file "/var/lib/postgresql/data/pg_hba.conf" line 128: "host all all all scram-sha-256" +db-1 | 2026-09-20 05:22:34.947 UTC [580] FATAL: password authentication failed for user "pharma" +db-1 | 2026-09-20 05:22:34.947 UTC [580] DETAIL: Connection matched file "/var/lib/postgresql/data/pg_hba.conf" line 128: "host all all all scram-sha-256" +db-1 | 2026-09-20 05:22:39.534 UTC [588] FATAL: password authentication failed for user "pharma" +db-1 | 2026-09-20 05:22:39.534 UTC [588] DETAIL: Connection matched file "/var/lib/postgresql/data/pg_hba.conf" line 128: "host all all all scram-sha-256" +db-1 | 2026-09-20 05:22:44.011 UTC [597] FATAL: password authentication failed for user "pharma" +db-1 | 2026-09-20 05:22:44.011 UTC [597] DETAIL: Connection matched file "/var/lib/postgresql/data/pg_hba.conf" line 128: "host all all all scram-sha-256" +db-1 | 2026-09-20 05:22:48.506 UTC [605] FATAL: password authentication failed for user "pharma" +db-1 | 2026-09-20 05:22:48.506 UTC [605] DETAIL: Connection matched file "/var/lib/postgresql/data/pg_hba.conf" line 128: "host all all all scram-sha-256" +db-1 | 2026-09-20 05:22:52.937 UTC [613] FATAL: password authentication failed for user "pharma" +db-1 | 2026-09-20 05:22:52.937 UTC [613] DETAIL: Connection matched file "/var/lib/postgresql/data/pg_hba.conf" line 128: "host all all all scram-sha-256" +db-1 | 2026-09-20 05:22:57.483 UTC [615] FATAL: password authentication failed for user "pharma" +db-1 | 2026-09-20 05:22:57.483 UTC [615] DETAIL: Connection matched file "/var/lib/postgresql/data/pg_hba.conf" line 128: "host all all all scram-sha-256" +db-1 | 2026-09-20 05:23:02.188 UTC [623] FATAL: password authentication failed for user "pharma" +db-1 | 2026-09-20 05:23:02.188 UTC [623] DETAIL: Connection matched file "/var/lib/postgresql/data/pg_hba.conf" line 128: "host all all all scram-sha-256" +db-1 | 2026-09-20 05:23:06.771 UTC [631] FATAL: password authentication failed for user "pharma" +db-1 | 2026-09-20 05:23:06.771 UTC [631] DETAIL: Connection matched file "/var/lib/postgresql/data/pg_hba.conf" line 128: "host all all all scram-sha-256" +db-1 | 2026-09-20 05:23:11.318 UTC [639] FATAL: password authentication failed for user "pharma" +db-1 | 2026-09-20 05:23:11.318 UTC [639] DETAIL: Connection matched file "/var/lib/postgresql/data/pg_hba.conf" line 128: "host all all all scram-sha-256" +db-1 | 2026-09-20 05:23:15.871 UTC [647] FATAL: password authentication failed for user "pharma" +db-1 | 2026-09-20 05:23:15.871 UTC [647] DETAIL: Connection matched file "/var/lib/postgresql/data/pg_hba.conf" line 128: "host all all all scram-sha-256" +db-1 | 2026-09-20 05:23:20.308 UTC [655] FATAL: password authentication failed for user "pharma" +db-1 | 2026-09-20 05:23:20.308 UTC [655] DETAIL: Connection matched file "/var/lib/postgresql/data/pg_hba.conf" line 128: "host all all all scram-sha-256" +db-1 | 2026-09-20 05:23:24.775 UTC [664] FATAL: password authentication failed for user "pharma" +db-1 | 2026-09-20 05:23:24.775 UTC [664] DETAIL: Connection matched file "/var/lib/postgresql/data/pg_hba.conf" line 128: "host all all all scram-sha-256" +db-1 | 2026-09-20 05:23:29.185 UTC [672] FATAL: password authentication failed for user "pharma" +db-1 | 2026-09-20 05:23:29.185 UTC [672] DETAIL: Connection matched file "/var/lib/postgresql/data/pg_hba.conf" line 128: "host all all all scram-sha-256" diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..000a423 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,23 @@ +.git +.gitignore +.env +.venv +venv +web +tests +storage +*.pdf +*.csv +openapi.json +README.md +Makefile +docker-compose*.yml +Dockerfile +.dockerignore +**/__pycache__ +**/*.py[cod] +*.egg-info +.pytest_cache +.ruff_cache +.coverage +htmlcov diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..4dff009 --- /dev/null +++ b/.env.example @@ -0,0 +1,30 @@ +# Copy to .env — it is git-ignored, never commit it. +# These defaults are for local development. On a server run `make deploy` — it fixes the +# production values and free ports for you (see README, "Quick start with Docker"). + +DATABASE_URL=postgresql+asyncpg://pharma:pharma@127.0.0.1:5432/pharma +SECRET_KEY=replace-with-a-64-char-random-string +ENVIRONMENT=development +DEBUG=true +PDF_STORAGE_PATH=./storage/pdf + +# --- Docker Compose (database container; must match DATABASE_URL above) ------ +POSTGRES_USER=pharma +POSTGRES_PASSWORD=pharma +POSTGRES_DB=pharma + +# --- Production --------------------------------------------------------------- +# Change these before deploying with `docker compose up -d --build`: +# ENVIRONMENT=production +# DEBUG=false +# POSTGRES_PASSWORD= +# SECRET_KEY=<64+ random chars: python -c "import secrets; print(secrets.token_urlsafe(64))"> +# DOMAIN= (localhost = local TLS) +# CORS_ORIGINS=["https://celtic.upskalor.com","https://www.celtic.upskalor.com","http://localhost:5173","http://localhost:3000"] +# A production start refuses a placeholder or under-32-character SECRET_KEY. +# +# Behind an existing reverse proxy that already owns ports 80/443? Serve plain HTTP on +# another host port and let that proxy terminate TLS: +# DOMAIN=:80 +# HTTP_PORT=2000 +# HTTPS_PORT=2443 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..38c7135 --- /dev/null +++ b/.gitignore @@ -0,0 +1,13 @@ +__pycache__/ +*.py[cod] +*.egg-info/ +.venv/ +venv/ +.env +.pytest_cache/ +.ruff_cache/ +storage/ +*.pdf +.coverage +htmlcov/ +.DS_Store diff --git a/AREA_COVERED.csv b/AREA_COVERED.csv new file mode 100644 index 0000000..1ac4470 --- /dev/null +++ b/AREA_COVERED.csv @@ -0,0 +1,26 @@ +NAME,HEADQUARTER,MONTH,SALE STATUS,AREA TO COVER,SALE OBJECTIVE,STATUS +,,,,,, +,,,,,, +,,,,,, +,,,,,, +,,,,,, +,,,,,, +,,,,,, +,,,,,, +,,,,,, +,,,,,, +,,,,,, +,,,,,, +,,,,,, +,,,,,, +,,,,,, +,,,,,, +,,,,,, +,,,,,, +,,,,,, +,,,,,, +,,,,,, +,,,,,, +,,,,,, +,,,,,, +,,,,,, diff --git a/CORE_Dr._CALL_CONVERSION.csv b/CORE_Dr._CALL_CONVERSION.csv new file mode 100644 index 0000000..5272dab --- /dev/null +++ b/CORE_Dr._CALL_CONVERSION.csv @@ -0,0 +1,26 @@ +NAME,HEADQUARTER,MONTH,DOCTOR NAME,DATE OF VISIT,PRODUCT TARGETED,STATUS +,,,,,, +,,,,,, +,,,,,, +,,,,,, +,,,,,, +,,,,,, +,,,,,, +,,,,,, +,,,,,, +,,,,,, +,,,,,, +,,,,,, +,,,,,, +,,,,,, +,,,,,, +,,,,,, +,,,,,, +,,,,,, +,,,,,, +,,,,,, +,,,,,, +,,,,,, +,,,,,, +,,,,,, +,,,,,, diff --git a/Caddyfile b/Caddyfile new file mode 100644 index 0000000..1e46c15 --- /dev/null +++ b/Caddyfile @@ -0,0 +1,44 @@ +{$DOMAIN} { + encode gzip + + # Security headers. HSTS is deliberately left commented until the domain is + # confirmed — turning it on before you are certain about HTTPS locks browsers in. + header { + X-Content-Type-Options nosniff + X-Frame-Options DENY + Referrer-Policy strict-origin-when-cross-origin + # Strict-Transport-Security "max-age=31536000; includeSubDomains" + -Server + } + + # API and API documentation stay behind the FastAPI service. Everything else + # is the React single-page application served by the lightweight web container. + handle /api/* { + reverse_proxy api:8000 + } + handle /docs* { + reverse_proxy api:8000 + } + handle /redoc* { + reverse_proxy api:8000 + } + handle /openapi.json { + reverse_proxy api:8000 + } + handle /health { + reverse_proxy api:8000 + } + # Hashed build files never change, so they may be cached for a year. The app shell + # (index.html) must be re-checked every time, or a user keeps running the old + # version after a deploy until they hard-refresh. + handle /assets/* { + reverse_proxy web:80 { + header_down Cache-Control "public, max-age=31536000, immutable" + } + } + handle { + reverse_proxy web:80 { + header_down Cache-Control "no-cache" + } + } +} diff --git a/Daily_Call_Report.csv b/Daily_Call_Report.csv new file mode 100644 index 0000000..421d5c5 --- /dev/null +++ b/Daily_Call_Report.csv @@ -0,0 +1,11 @@ +NAME,HEADQUARTER,DATE,MONTH,DOCTOR SR. NO.,DR. NAME,QUALIFICATION,PRODUCT PROMOTE,PRODUCT SAMPLE,REMARKS,CHEMIST SR. NO.,NAME OF THE CHEMIST,POB,STOCKIST VISIT,ORDER +,,,,1,,,,,,1,,,, +,,,,2,,,,,,2,,,, +,,,,3,,,,,,3,,,, +,,,,4,,,,,,4,,,, +,,,,5,,,,,,5,,,, +,,,,6,,,,,,,,,, +,,,,7,,,,,,,,,, +,,,,8,,,,,,,,,, +,,,,9,,,,,,,,,, +,,,,10,,,,,,,,,, diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..ac034c1 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,65 @@ +# syntax=docker/dockerfile:1 + +# ---- build stage: resolve and install the Python dependencies into a venv ---- +FROM python:3.12-slim AS builder + +ENV PIP_NO_CACHE_DIR=1 PIP_DISABLE_PIP_VERSION_CHECK=1 +RUN python -m venv /opt/venv +ENV PATH="/opt/venv/bin:$PATH" + +WORKDIR /build +COPY pyproject.toml ./ +COPY app ./app +# Install the dependencies only. The application itself runs from /srv/app, so the +# copy pip just installed into site-packages is removed to avoid a shadow copy. +RUN pip install . && pip uninstall -y pharma-field-force + +# ---- runtime stage ---- +FROM python:3.12-slim + +# WeasyPrint's native libraries and the fonts the PDF forms name: Liberation Sans/Serif +# (metric-compatible with the Arial/Times of the printed company forms), Carlito (the +# Calibri look-alike) and DejaVu as the last-resort fallback. +# Pinned here so a missing library shows up at build time, not at the first PDF. +RUN apt-get update && apt-get install -y --no-install-recommends \ + libpango-1.0-0 \ + libpangoft2-1.0-0 \ + libharfbuzz0b \ + fontconfig \ + fonts-dejavu-core \ + fonts-liberation \ + fonts-crosextra-carlito \ + curl \ + && rm -rf /var/lib/apt/lists/* + +ENV PATH="/opt/venv/bin:$PATH" \ + PYTHONUNBUFFERED=1 \ + PYTHONDONTWRITEBYTECODE=1 \ + ENVIRONMENT=production \ + PDF_STORAGE_PATH=/srv/storage/pdf \ + WEB_CONCURRENCY=2 + +COPY --from=builder /opt/venv /opt/venv + +WORKDIR /srv +COPY app ./app +COPY alembic ./alembic +COPY alembic.ini ./ +COPY scripts ./scripts + +RUN useradd --create-home --uid 1000 appuser \ + && mkdir -p /srv/storage/pdf \ + && chown -R appuser:appuser /srv/storage \ + && chmod +x /srv/scripts/docker-entrypoint.sh +USER appuser + +# Fail the image build if the PDF engine cannot load (missing system library). +RUN python -c "import weasyprint; weasyprint.HTML(string='

ok

').write_pdf()" + +EXPOSE 8000 +HEALTHCHECK --interval=30s --timeout=5s --start-period=40s --retries=3 \ + CMD curl -fsS http://localhost:8000/health || exit 1 + +ENTRYPOINT ["/srv/scripts/docker-entrypoint.sh"] +CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000", \ + "--proxy-headers", "--forwarded-allow-ips", "*"] diff --git a/FIELD_ACTIVITY_REPORT.csv b/FIELD_ACTIVITY_REPORT.csv new file mode 100644 index 0000000..0a5ab98 --- /dev/null +++ b/FIELD_ACTIVITY_REPORT.csv @@ -0,0 +1,26 @@ +NAME,HEADQUARTER,MONTH,DATE,STATION WORKED,NO. OF DOCTORS CALLED,NO. OF CHEMISTS/PDS CALLED,DOCTOR CALL AVG,CHEMIST CALL AVG +,,,,,,,, +,,,,,,,, +,,,,,,,, +,,,,,,,, +,,,,,,,, +,,,,,,,, +,,,,,,,, +,,,,,,,, +,,,,,,,, +,,,,,,,, +,,,,,,,, +,,,,,,,, +,,,,,,,, +,,,,,,,, +,,,,,,,, +,,,,,,,, +,,,,,,,, +,,,,,,,, +,,,,,,,, +,,,,,,,, +,,,,,,,, +,,,,,,,, +,,,,,,,, +,,,,,,,, +,,,,,,,, diff --git a/Fare_Chart.csv b/Fare_Chart.csv new file mode 100644 index 0000000..a8c9ad1 --- /dev/null +++ b/Fare_Chart.csv @@ -0,0 +1,26 @@ +NAME,HEADQUARTER,SL. NO.,DATE,FROM,TO,KILOMETERS (KM) +,,1,,,, +,,2,,,, +,,3,,,, +,,4,,,, +,,5,,,, +,,6,,,, +,,7,,,, +,,8,,,, +,,9,,,, +,,10,,,, +,,11,,,, +,,12,,,, +,,13,,,, +,,14,,,, +,,15,,,, +,,16,,,, +,,17,,,, +,,18,,,, +,,19,,,, +,,20,,,, +,,21,,,, +,,22,,,, +,,23,,,, +,,24,,,, +,,25,,,, diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..19a5a21 --- /dev/null +++ b/Makefile @@ -0,0 +1,66 @@ +.PHONY: help install dev migrate revision seed test test-unit test-e2e lint fmt up down logs harden dev-up dev-db setup deploy status + +help: + @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-14s\033[0m %s\n", $$1, $$2}' + +install: ## Install runtime + dev dependencies + pip install -e ".[dev]" + +dev: ## Run the API with auto-reload + uvicorn app.main:app --reload --host 0.0.0.0 --port 8000 + +migrate: ## Apply all migrations + alembic upgrade head + +revision: ## Autogenerate a migration: make revision m="add product table" + alembic revision --autogenerate -m "$(m)" + +seed: ## Seed the minimum MVP system (1 company, 1 HQ, GM/AM/MR, 15 doctors, 5 chemists) + python -m scripts.seed + +test: ## Run the whole suite (needs Postgres) + pytest -q + +test-unit: ## State machine and pure logic only — no database needed + pytest tests/unit -q + +test-e2e: ## The 13-step acceptance test plus the negative-scope tests + pytest tests/e2e -q + +lint: ## Check style + ruff check app tests + +fmt: ## Fix style + ruff check --fix app tests && ruff format app tests + +setup: ## Create/refresh .env for this machine (secrets, free ports) — safe to re-run + ./scripts/setup.sh + +deploy: setup ## setup + build + start + wait until the API is healthy + docker compose up -d --build + @for i in $$(seq 1 30); do \ + docker compose exec -T api curl -fsS http://localhost:8000/health >/dev/null 2>&1 && \ + { echo "API healthy"; $(MAKE) --no-print-directory status; exit 0; }; sleep 2; done; \ + echo "API did not become healthy: docker compose logs api"; exit 1 + +status: ## Show containers and the URL the site answers on + @docker compose ps --format 'table {{.Name}}\t{{.Status}}\t{{.Ports}}' + @echo "site: http://localhost:$$(grep -E '^HTTP_PORT=' .env 2>/dev/null | cut -d= -f2 | grep . || echo 80)" + +up: ## Start the production stack (needs .env — see .env.example) + docker compose up -d --build + +dev-up: ## Start the whole stack with DB and API published on localhost + docker compose -f docker-compose.yml -f docker-compose.dev.yml up -d --build + +dev-db: ## Start only PostgreSQL on localhost (host-run API and tests) + docker compose -f docker-compose.yml -f docker-compose.dev.yml up -d db + +down: ## Stop the stack + docker compose down + +logs: ## Tail API logs + docker compose logs -f api + +harden: ## Apply the append-only audit-log grants (run once, as superuser) + psql "$${ADMIN_DATABASE_URL:?set ADMIN_DATABASE_URL}" -f scripts/harden_audit.sql diff --git a/PRODUCTION.md b/PRODUCTION.md new file mode 100644 index 0000000..1de880c --- /dev/null +++ b/PRODUCTION.md @@ -0,0 +1,364 @@ +# Production guide + +How to deploy, secure, operate and recover the Celtic Life Science field-force system on a +single server. This is the operator's document; `README.md` is the developer's. + +Every command below was run against this codebase's Docker stack unless it is marked +**untested**. + +## Contents + +1. [What you are deploying](#1-what-you-are-deploying) +2. [Requirements](#2-requirements) +3. [First deployment](#3-first-deployment) +4. [Creating the real users](#4-creating-the-real-users) +5. [Loading reference data](#5-loading-reference-data) +6. [Configuration](#6-configuration) +7. [Domain, HTTPS and reverse proxies](#7-domain-https-and-reverse-proxies) +8. [Security checklist](#8-security-checklist) +9. [Backups and restore](#9-backups-and-restore) +10. [Updating and rolling back](#10-updating-and-rolling-back) +11. [Monitoring and logs](#11-monitoring-and-logs) +12. [Runbook](#12-runbook) +13. [Go-live checklist](#13-go-live-checklist) +14. [Known limitations](#14-known-limitations) + +--- + +## 1. What you are deploying + +``` + browser ──HTTPS──▶ caddy ──/api /docs /health──▶ api (FastAPI, uvicorn) ──▶ db (PostgreSQL 16) + │ │ + └──everything else──▶ web └─▶ pdfstore volume (approved DCR PDFs) + (static React build) +``` + +| Service | Image | Role | +|---|---|---| +| `caddy` | `caddy:2-alpine` | The only thing that publishes ports. TLS (Let's Encrypt), gzip, security headers, routing. | +| `api` | built from `Dockerfile` | FastAPI app and PDF rendering (WeasyPrint). Non-root, **read-only filesystem**, all capabilities dropped. Runs `alembic upgrade head` on start. | +| `web` | built from `web/Dockerfile` | The React app, built at image-build time and served as static files. | +| `db` | `postgres:16-alpine` | Internal network only. Data in the `pgdata` volume. | + +Persistent state lives in exactly two volumes: **`pgdata`** (the database) and **`pdfstore`** +(approved DCR PDFs). `caddydata` holds certificates. Everything else is rebuilt from the code. + +Roles: MR (medical representative), AM (area manager), GM (general manager), ADMIN. The MR +files daily call reports and company forms, the AM approves, the GM has read access across +territories, the ADMIN maintains people, organisation and master data. + +## 2. Requirements + +- A Linux server with **Docker Engine and the Compose plugin** (`docker compose version`). + 1 vCPU / 2 GB RAM / 20 GB disk is enough for one company and a few dozen users. +- `git`, `make`, `python3` (used by `scripts/setup.sh` to generate secrets; `openssl` is the fallback). +- For HTTPS with a real domain: a DNS `A` record pointing at the server, and ports 80 and 443 free + and reachable from the internet. +- Outbound internet access at build time (base images, `apt`, `pip`, `npm`). + +## 3. First deployment + +```bash +git clone pharma-web-celtic && cd pharma-web-celtic # or copy this folder +DOMAIN=app.example.com make deploy # omit DOMAIN if you only have an IP address +``` + +`make deploy` runs `scripts/setup.sh`, then `docker compose up -d --build`, then waits for the +API to report healthy. It is safe to re-run. `setup.sh`: + +- creates `.env` from `.env.example` when missing (**`.env` is never committed and is not part of this repository**); +- generates a 64-character `SECRET_KEY` when missing or a placeholder; +- sets `ENVIRONMENT=production` and `DEBUG=false`; +- generates `POSTGRES_PASSWORD` for a **new** database only — an existing database keeps its password; +- picks the ports: 80/443 when free, otherwise plain HTTP on the first free port from 2000 (HTTPS side 2443) and tells you which. + +Verify: + +```bash +make status +curl -s http://localhost:/health +# {"status":"ok","environment":"production","pdf_engine":"weasyprint"} +``` + +`pdf_engine` must say `weasyprint`. In production the API refuses to start if WeasyPrint's +system libraries are missing or `SECRET_KEY` is a placeholder or shorter than 32 characters, +so a bad image fails loudly at boot rather than producing broken PDFs later. + +> **Running this next to another copy on the same machine.** Compose derives the project name +> from the folder name, and volumes are named after it (`_pgdata`). Two folders with +> the same name share volumes and fight over ports. Set `COMPOSE_PROJECT_NAME=` +> in the environment (or `.env`) before the first `make deploy` of the second copy. + +## 4. Creating the real users + +There is no "create first admin" command. (An Administrator can reset any user's password, email and employee code from **Users → Edit**; users cannot change their own.) +The only way to obtain a first administrator is the seed script, which creates demo accounts +that all share one well-known password (`ChangeMe123!`, in `scripts/seed.py`). Treat that as a +short-lived bootstrap and do the following **before the server is reachable by anyone else** +(firewall closed, or on a private network): + +1. Seed once: `docker compose exec api python -m scripts.seed` + (creates the company row, one headquarters `BBSR`, four demo users `adm001 / gm001 / am001 / + mr001 @acmepharma.in`, 15 sample doctors and 5 chemists. Idempotent.) +2. Sign in as `adm001@acmepharma.in`. +3. **Setup → Organisation**: create the real headquarters. **Setup → People**: create the real + users, one of them an **Administrator**, each with a strong password. Passwords cannot be + changed later from the app, so choose them as final and hand them over securely. +4. Sign out, sign in as the **new** administrator, open **Users** and **deactivate all four demo + accounts** (deactivation also revokes their sessions). Verify `adm001` can no longer sign in. +5. Assign an Area Manager to each headquarters, then assign doctors and chemists to MRs + (**Setup → Assignments**). + +If you would rather not keep the demo doctors, chemists and the `BBSR` headquarters, deactivate +them from **Doctors & Chemists** / leave them unassigned. + +## 5. Loading reference data + +**Stock / Products list** — the Products page reads the `stock_inventory` table. It is created +**and filled (26 products from `stock.csv`) by the migration** `h8d4f0a6c3e5`, so it is there +after the first start with nothing to do. Administrators can add, edit and delete products from +the Products page. + +**Sales Projection and Sales & Stock product lists** — the Sales Projection form needs its +product list (name and PTS) in the database, and the Sales & Stock Statement lists the same +products. Load them once with the **non-destructive** mode of the import script. The CSVs are +deliberately not part of the Docker image and the API container is read-only, so mount the two +files into a one-off container: + +```bash +docker compose run --rm --no-deps -T \ + -v "$PWD/sales_projection.csv:/srv/sales_projection.csv:ro" \ + -v "$PWD/Sales_and_Stock_Statement.csv:/srv/Sales_and_Stock_Statement.csv:ro" \ + api python -m scripts.import_csv_data --only-empty +``` + +`--only-empty` loads a table only if it has **no rows** and prints `skipped, already has N rows` +otherwise, so it can be re-run safely. **Never run the script without `--only-empty` on a +database that holds real data** — the plain form deletes every form table before loading. + +## 6. Configuration + +Only variables listed in `docker-compose.yml` reach the API container. Set them in `.env`. + +| Variable | Default | Purpose | +|---|---|---| +| `SECRET_KEY` | *(required)* | JWT signing key, 64+ random characters. Changing it signs everyone out. | +| `POSTGRES_PASSWORD` | *(required)* | Database password. See [rotation](#12-runbook). | +| `POSTGRES_USER`, `POSTGRES_DB` | `pharma`, `pharma` | Database user and name. | +| `ENVIRONMENT` | `production` | `production` enables the boot-time safety checks. | +| `DEBUG` | `false` | Keep `false`. | +| `DOMAIN` | `localhost` | Host name Caddy serves; `:80` means plain HTTP (behind another proxy / no TLS). | +| `HTTP_PORT`, `HTTPS_PORT` | `80`, `443` | Host ports Caddy publishes. | +| `APP_TIMEZONE` | `Asia/Kolkata` | Business timezone. "Today" and the visit-time check use it, not the server's UTC clock. (Set under `api.environment:` in `docker-compose.yml` to change it.) | +| `BACKDATING_WINDOW_DAYS` | `7` | How many days back an MR may file a report. | +| `SUBMISSION_DEADLINE_DAYS` | `1` | A report for day D must be submitted by end of D + this many days. | +| `WEB_CONCURRENCY` | `2` | uvicorn worker processes. | +| `RUN_MIGRATIONS` | `1` | Set `0` on the `api` service to skip migrations at start. | + +Other application settings (`app/config/settings.py`) — the letterhead printed on PDFs +(`PDF_COMPANY_NAME`, `_ADDRESS`, `_WEBSITE`, `_EMAIL`, `_PHONE`), `ACCESS_TOKEN_EXPIRE_MINUTES` +(15), `REFRESH_TOKEN_EXPIRE_DAYS` (7), `LOGIN_MAX_FAILED_ATTEMPTS` (10) — are **not** passed +through by the shipped compose file. To change one, add it under `api.environment:` in +`docker-compose.yml` and run `docker compose up -d`. The defaults already carry Celtic's details. + +## 7. Domain, HTTPS and reverse proxies + +| Situation | Result | +|---|---| +| Ports 80/443 free and `DOMAIN=app.example.com` (DNS already pointing here) | Caddy obtains and renews a Let's Encrypt certificate itself. | +| Ports 80/443 free, no domain | `DOMAIN=localhost`: HTTPS with a self-signed certificate (browser warning). | +| 80/443 owned by another service | `DOMAIN=:80` on `HTTP_PORT` (e.g. 2000). Put your existing proxy in front. | + +Existing nginx terminating TLS in front of Caddy: + +```nginx +server { + server_name app.example.com; + listen 443 ssl; # + your certificate directives + location / { + proxy_pass http://127.0.0.1:2000; # the HTTP_PORT chosen by setup.sh + proxy_set_header Host $host; + proxy_set_header X-Forwarded-Proto $scheme; + proxy_set_header X-Forwarded-For $remote_addr; + } +} +``` + +Block the published port from the internet when a proxy on the same host fronts it +(`sudo ufw deny 2000/tcp`; the proxy still reaches `127.0.0.1:2000`). + +Once HTTPS works on the real domain, enable HSTS: uncomment the +`Strict-Transport-Security` line in `Caddyfile` and `docker compose up -d`. Do not enable it +earlier — it locks browsers into HTTPS for a year. + +## 8. Security checklist + +- [ ] `.env` is `chmod 600`, owned by the deploy user, and is **not** in any repository or backup that leaves the server unencrypted. +- [ ] `SECRET_KEY` and `POSTGRES_PASSWORD` are generated values (`setup.sh` does this). `setup.sh` warns if the database still uses the default `pharma` password — rotate it. +- [ ] The four demo accounts are **deactivated** ([section 4](#4-creating-the-real-users)). +- [ ] Only ports 80/443 (or your proxy) are open. The database and API are not published; do not use `docker-compose.dev.yml` on a server — it publishes them. +- [ ] HTTPS on the real domain, then HSTS enabled. +- [ ] The host is patched, SSH is key-only, and `docker` group membership is limited to operators. +- [ ] Backups run and a restore has been **rehearsed** ([section 9](#9-backups-and-restore)). +- [ ] Decide about the public API docs: `/docs`, `/redoc` and `/openapi.json` are **reachable by anyone** through Caddy in the shipped configuration (they list every endpoint, though not data). To hide them, delete the corresponding `handle` blocks in `Caddyfile` and `docker compose up -d`. +- [ ] Someone reads the API logs for repeated `401`s (accounts lock after 10 failed sign-ins). + +What the containers already enforce: API runs as a non-root user on a read-only filesystem with +all Linux capabilities dropped and `no-new-privileges`; the database is unreachable from outside +the compose network; Caddy sends `X-Content-Type-Options`, `X-Frame-Options: DENY` and a strict +`Referrer-Policy`, and hides the server banner; JSON logs rotate at 10 MB × 5 files per service. + +**Audit log hardening (optional, not enabled by default).** `scripts/harden_audit.sql` creates a +`pharma_app` role that can insert into and read `audit_log` but never update or delete it. The +shipped compose file connects with a single owner role that also runs migrations, so enabling it +means splitting credentials: run migrations with the owner role (set `RUN_MIGRATIONS=0` on `api` +and run `alembic upgrade head` in a one-off container) and point the running API's +`DATABASE_URL` at `pharma_app`, after changing that role's placeholder password in the script. +This flow is **untested** in this repository — rehearse it on a staging copy first. + +## 9. Backups and restore + +What to back up: the **database** (`pg_dump`) and the **`pdfstore` volume**. Everything else is +code or regenerable. Take a backup **before every update**. + +**Database backup** (verified): + +```bash +set -a; . ./.env; set +a +docker compose exec -T db pg_dump -U "$POSTGRES_USER" -Fc "$POSTGRES_DB" > backup-$(date +%F).dump +``` + +**PDF store backup:** + +```bash +docker run --rm -v "$(basename "$PWD")_pdfstore:/data:ro" -v "$PWD:/backup" alpine \ + tar czf /backup/pdfstore-$(date +%F).tgz -C /data . +``` + +(Adjust the volume name if you set `COMPOSE_PROJECT_NAME`; list volumes with `docker volume ls`.) + +**Nightly cron** (as the deploy user, `crontab -e`; copy the dumps off the server too): + +```cron +15 2 * * * cd /opt/pharma-web-celtic && set -a && . ./.env && set +a && docker compose exec -T db pg_dump -U "$POSTGRES_USER" -Fc "$POSTGRES_DB" > /var/backups/pharma/db-$(date +\%F).dump && find /var/backups/pharma -name 'db-*.dump' -mtime +30 -delete +``` + +**Restore rehearsal** — restores into a *scratch* database so nothing live is touched (verified): + +```bash +set -a; . ./.env; set +a +docker compose exec -T db createdb -U "$POSTGRES_USER" restore_check +docker compose exec -T db pg_restore -U "$POSTGRES_USER" -d restore_check --no-owner < backup-YYYY-MM-DD.dump +docker compose exec -T db psql -U "$POSTGRES_USER" -d restore_check \ + -c 'select count(*) from "user"' -c 'select count(*) from stock_inventory' +docker compose exec -T db dropdb -U "$POSTGRES_USER" restore_check +``` + +**Real disaster recovery** (empty server, backup in hand): deploy as in section 3, then +`docker compose stop api`, restore into the empty database +(`pg_restore -U … -d "$POSTGRES_DB" --clean --if-exists --no-owner < backup.dump`), restore the +PDF archive into the `pdfstore` volume, then `docker compose up -d`. Use the same `SECRET_KEY` +if you want existing sessions to survive; otherwise users simply sign in again. + +## 10. Updating and rolling back + +```bash +# 1. back up (section 9) +# 2. get the new code +git pull # or replace the folder contents +# 3. rebuild and restart — migrations run automatically on api start +make deploy +make status +``` + +The API image is rebuilt, so `pip`/`apt`/`npm` need network access. Compose recreates only what +changed; the database and volumes are untouched. Check `docker compose logs api | grep alembic` +to see which migrations ran. + +**Rollback:** restore the previous code, and if the new release added migrations, step the schema +back first, using the **new** image (it knows those revisions): + +```bash +docker compose exec api alembic downgrade -1 # once per migration to undo; check with: alembic current +# then deploy the previous code: git checkout && make deploy +``` + +If in doubt, restore the pre-update database backup instead — it is always the safe path. + +## 11. Monitoring and logs + +- **Health:** `GET /health` → `{"status":"ok", ..., "pdf_engine":"weasyprint"}`. Docker health + checks run on `api` and `db`; `docker compose ps` shows `(healthy)`. Point an external uptime + monitor at `https:///health`. +- **Logs:** `docker compose logs -f api` (also `caddy`, `db`, `web`). Rotated automatically. +- **Disk:** watch the Docker data directory (`docker system df`); the `pgdata` and `pdfstore` + volumes only grow. +- **Errors:** no error tracker is wired in. Add Sentry or similar if you need alerting on 500s. + +## 12. Runbook + +| Task | Command | +|---|---| +| Status / URL | `make status` | +| Restart the API | `docker compose restart api` | +| Stop everything (data kept) | `docker compose down` | +| **Delete all data** | `docker compose down -v` — **never** on a live system | +| Open a database shell | `docker compose exec db psql -U "$POSTGRES_USER" "$POSTGRES_DB"` | +| Unlock a user (10 failed sign-ins) | `UPDATE "user" SET failed_login_attempts = 0 WHERE email = '…';` in the shell above | +| Rotate `SECRET_KEY` | edit `.env`, `docker compose up -d` — everyone must sign in again | +| Rotate the database password | see below | + +**Rotating the database password** — the database keeps the password it was created with, so +changing `.env` alone would lock the API out: + +```bash +NEW=$(python3 -c "import secrets;print(secrets.token_urlsafe(24))") +docker compose exec db psql -U pharma -d pharma -c "ALTER USER pharma PASSWORD '$NEW';" +sed -i "s|^POSTGRES_PASSWORD=.*|POSTGRES_PASSWORD=$NEW|" .env +docker compose up -d +``` + +**Common failures** + +| Symptom | Cause / fix | +|---|---| +| `make deploy` says `set POSTGRES_PASSWORD in .env` | Run `make setup` (or `./scripts/setup.sh`). | +| API restarts in a loop, log says `SECRET_KEY must be a random value` | `.env` has a placeholder key; run `make setup`. | +| API log: `WeasyPrint system libraries are required` | The image was built without Pango/fonts; rebuild with `docker compose build --no-cache api`. | +| Caddy cannot bind port 80/443 | Another service owns them; run `make setup` (it moves Caddy to a free port) and put a proxy in front. | +| API cannot connect after editing `.env` | The database still has the old password — see rotation above. | +| A page shows *"This didn't load — Request failed (500)"* | `docker compose logs api` shows the cause; after an update check the migration ran (`alembic current`). | +| PDFs look plain-text | The API logged the WeasyPrint fallback warning; the image is missing native libraries. | + +## 13. Go-live checklist + +1. `make deploy` finishes and `/health` reports `weasyprint`. +2. Real headquarters and users created; **all demo accounts deactivated** (section 4). +3. Reference data loaded (section 5): Products page shows 26 products; Sales Projection shows the + product list. +4. One end-to-end pass with real accounts: MR files a DCR → AM approves → PDF downloads and + opens; each company form downloads a PDF that matches the printed original. +5. HTTPS works on the final domain; HSTS enabled. +6. Firewall: only 80/443 (or the proxy) open. +7. First backup taken **and a restore rehearsed**; cron installed. +8. Uptime monitor pointed at `/health`; someone owns reading the logs. +9. Business rules confirmed with the client: the back-dating window and submission deadline + (`BACKDATING_WINDOW_DAYS`, `SUBMISSION_DEADLINE_DAYS`) are shipped assumptions. + +## 14. Known limitations + +- **Users cannot change their own password.** Only an Administrator can, from **Users → Edit** + (also email and employee code). A reset signs that user out everywhere and clears a lockout, + but an access token already issued stays valid until it expires (15 minutes). If the last + Administrator password is lost, create a new admin with a one-off script (see `scripts/`) — + there is no self-service recovery and no email flow. +- **Company-form approval is per form, not per row.** Tour plan, standard tour plan and fare chart + each have one approval state, stored on the server (`form_approval`): the MR sends a form that has + rows, the Area Manager approves it, and the PDF signature shows that name. Any change to the rows + withdraws the approval. The signature is decided by the server, never by the browser. +- **Audit-log immutability is opt-in** (section 8) and untested with the shipped compose file. +- **No built-in alerting or error tracking**; only health checks and logs. +- **Single server, single database.** There is no high availability; recovery time is "restore the + latest backup". That is the deliberate trade-off for this size of deployment. +- The test suite needs a reachable PostgreSQL; some tests under `tests/unit` do too. diff --git a/README.md b/README.md new file mode 100644 index 0000000..36b3d89 --- /dev/null +++ b/README.md @@ -0,0 +1,470 @@ +# Pharma Field-Force Reporting + +> **Deploying to a server?** Use [PRODUCTION.md](PRODUCTION.md) — the operator's guide (first deployment, real users, backups, updates, runbook). This README is for development. + +Field-force reporting for a pharmaceutical sales team (Celtic Life Science Pvt Ltd): Medical Representatives (MRs) file **Daily Call Reports**, Area Managers (AMs) review and approve them (the General Manager has a read-only overview), and approved reports are locked and rendered as PDFs. Alongside the DCR, the system manages the company's paper forms — tour plans, fare charts, stock statements and more — and prints each one on its own PDF layout. + +- **Backend:** FastAPI · SQLAlchemy 2 (async) · PostgreSQL 16 · Alembic +- **PDFs:** Jinja2 templates rendered by WeasyPrint +- **Web app:** React 18 + TypeScript (Vite), Celtic-branded, served by Caddy +- **Deployment:** Docker Compose on a single VPS, automatic HTTPS via Caddy + +Deliberately **not** in scope: HR, payroll, attendance, distributor management, GPS, offline mode. + +## Contents + +1. [Features](#features) +2. [Quick start with Docker](#quick-start-with-docker) — incl. VPS over SSH, ports, operations +3. [Local development](#local-development) +4. [Configuration](#configuration) +5. [Roles and permissions](#roles-and-permissions) +6. [The approval workflow](#the-approval-workflow) +7. [Company forms and PDFs](#company-forms-and-pdfs) +8. [API overview](#api-overview) +9. [Project layout](#project-layout) +10. [Design decisions](#design-decisions) +11. [Testing](#testing) +12. [Production checklist](#production-checklist) +13. [Known limitations](#known-limitations) +14. [Troubleshooting](#troubleshooting) + +--- + +## Features + +| Area | What it does | +|---|---| +| Daily Call Reports | MR records doctor and chemist calls per day; one report per MR per date | +| Approval workflow | `DRAFT → PENDING_AM → APPROVED`, with a return-for-correction loop (the Area Manager is the final approver); approved reports are immutable | +| Audit trail | Append-only log of every state change; approval history is a view over it | +| PDFs | Approved DCRs are stored as PDFs; company forms download as PDFs on demand | +| Company forms | Ten form tables (tour plan, fare chart, stock statement, …) with per-form PDF layouts | +| Masters | Users, headquarters, AM↔HQ mapping, doctors, chemists, products, with MR assignments | +| Security | JWT with refresh-token rotation, argon2 password hashing, role **and** scope checks | + +--- + +## Quick start with Docker + +Requires Docker with the Compose plugin. On any machine — laptop, or a VPS over SSH: + +```bash +git clone pharma-web-celtic && cd pharma-web-celtic +make deploy # = ./scripts/setup.sh + docker compose up -d --build + wait until healthy +``` + +`make deploy` is safe to re-run; it is also how you update after `git pull`. The setup step (`scripts/setup.sh`) prepares `.env` for you: + +- creates `.env` from `.env.example` if it is missing; +- generates a strong `SECRET_KEY` (if missing or a placeholder), and sets `ENVIRONMENT=production`, `DEBUG=false`; +- generates `POSTGRES_PASSWORD` for a **new** database (an existing database keeps its password — see [Rotating the database password](#rotating-the-database-password)); +- **picks free ports**: if 80/443 are free, Caddy serves your `DOMAIN` with automatic HTTPS; if another service already owns them, it switches to plain HTTP on the first free host port from 2000 (HTTPS side from 2443) and tells you which. + +Then load the demo data once (skip this if the database already has users): + +```bash +docker compose exec api python -m scripts.seed +``` + +Check it: + +```bash +make status # containers, ports and the site URL +curl http://localhost:/health # {"status":"ok", ... "pdf_engine":"weasyprint"} +``` + +### Deploying on a VPS over SSH + +```bash +ssh user@your-vps +sudo apt-get install -y docker.io docker-compose-v2 git # or Docker's official install script +git clone pharma-web-celtic && cd pharma-web-celtic +DOMAIN=app.example.com make deploy # omit DOMAIN if you only have an IP address +``` + +Which case applies is decided by what is listening on the server: + +| Situation | What `setup.sh` does | How users reach it | +|---|---|---| +| Ports 80/443 free, real `DOMAIN` (DNS already points at the server) | Caddy takes 80/443 | `https://app.example.com` — certificate is automatic | +| Ports 80/443 free, no domain | `DOMAIN=localhost` | `https://` with a self-signed certificate warning | +| **80/443 already used** by another service | `DOMAIN=:80`, next free `HTTP_PORT` (e.g. `2000`) | `http://:2000`, or put your existing proxy in front (below) | + +Open the chosen port in the firewall only if you want direct access (`sudo ufw allow 2000/tcp`); if a proxy on the same host fronts it, block it instead (`sudo ufw deny 2000/tcp` — the proxy still reaches it on `127.0.0.1`). + +**Existing nginx in front** (terminating TLS on 80/443): + +```nginx +server { + server_name app.example.com; + listen 443 ssl; # + your certificate directives + location / { + proxy_pass http://127.0.0.1:2000; # the HTTP_PORT chosen by setup.sh + proxy_set_header Host $host; + proxy_set_header X-Forwarded-Proto $scheme; + proxy_set_header X-Forwarded-For $remote_addr; + } +} +``` + +**Choosing ports yourself:** edit `.env` (`HTTP_PORT`, `HTTPS_PORT`, `DOMAIN`) and run `docker compose up -d`. `setup.sh` keeps ports your own containers already use and only moves them when something else holds them. + +### Day-to-day operations + +```bash +docker compose logs -f api # API logs (also: web, caddy, db) +docker compose ps # status +make deploy # after git pull: rebuild and restart +docker compose down # stop (data volumes are kept) +docker compose down -v # stop AND DELETE the database and PDFs — never on a live system +docker compose exec db pg_dump -U pharma pharma > backup-$(date +%F).sql # database backup +``` + +### Rotating the database password + +The database keeps the password it was created with; changing `POSTGRES_PASSWORD` in `.env` alone would lock the API out. To rotate (needed if `setup.sh` warned about a default password): + +```bash +NEW=$(python3 -c "import secrets;print(secrets.token_urlsafe(24))") +docker compose exec db psql -U pharma -d pharma -c "ALTER USER pharma PASSWORD '$NEW';" +sed -i "s|^POSTGRES_PASSWORD=.*|POSTGRES_PASSWORD=$NEW|" .env +docker compose up -d +``` + +### What the stack contains + +| Service | Image | Notes | +|---|---|---| +| `caddy` | `caddy:2-alpine` | The only service publishing ports; routes `/api`, `/docs`, `/health` to the API and everything else to the web app | +| `api` | built from `Dockerfile` | Non-root, read-only filesystem, runs `alembic upgrade head` on start | +| `web` | built from `web/Dockerfile` | Static React build served by Caddy | +| `db` | `postgres:16-alpine` | Internal network only; data in the `pgdata` volume | + +Things worth knowing: + +- Compose refuses to start without `POSTGRES_PASSWORD` and `SECRET_KEY` (`make setup` fills them in). +- In `ENVIRONMENT=production` the API refuses to boot if WeasyPrint's system libraries are missing or `SECRET_KEY` is a placeholder / under 32 characters. `GET /health` reports `"pdf_engine": "weasyprint"`. +- Set `RUN_MIGRATIONS=0` on the `api` service to skip the start-up migration. +- The database and API are **not** published to the host. To reach the database from the host (tests, `psql`) use the development overlay: `DB_PORT=5433 make dev-db` publishes it on `127.0.0.1:5433` only. +- Volumes to back up: `pgdata` (use `pg_dump`) and `pdfstore` (approved DCR PDFs). +- The seed creates demo accounts that share one well-known password (see `scripts/seed.py`). **Change every password before real use.** + +--- + +## Local development + +Prerequisites: Python 3.11+, Node.js 20+, Docker (for PostgreSQL). + +```bash +# 1. Python environment +python -m venv .venv && source .venv/bin/activate # Windows: .\.venv\Scripts\Activate.ps1 +pip install -e ".[dev]" + +# 2. Settings +cp .env.example .env # development defaults; DATABASE_URL already points at localhost:5432 + +# 3. PostgreSQL on localhost:5432 (also creates the pharma_test database) +make dev-db # port taken? DB_PORT=5433 make dev-db, and use 5433 in DATABASE_URL + +# 4. Schema and demo data +alembic upgrade head +python -m scripts.seed + +# 5. API (http://localhost:8000, docs at /docs) +uvicorn app.main:app --reload + +# 6. Web app (http://localhost:5173, proxies /api to port 8000) +cd web && npm install && npm run dev +``` + +`make dev-up` starts the whole stack in containers with the database (`DB_PORT`, default 5432) and API (`API_PORT`, default 8000) published on `127.0.0.1` only. Run `make help` for all targets. + +**PDF rendering on a dev machine:** WeasyPrint needs Pango and HarfBuzz (`apt install libpango-1.0-0 libpangoft2-1.0-0 libharfbuzz0b fonts-dejavu-core fonts-liberation fonts-crosextra-carlito` on Debian/Ubuntu). Without them the app still runs but produces plain-text PDFs and logs a warning; use the Docker image to see the real layout. + +Seeded accounts (`scripts/seed.py`): `adm001@acmepharma.in` (System Admin), `gm001@acmepharma.in` (GM), `am001@acmepharma.in` (AM), `mr001@acmepharma.in` (MR) — one company, one headquarters (BBSR), 15 doctors (3 core) and 5 chemists assigned to the MR. + +--- + +## Configuration + +All settings come from environment variables (or `.env`); nothing secret lives in code. See `app/config/settings.py`. + +**Deployment (read by Docker Compose)** + +| Variable | Default | Purpose | +|---|---|---| +| `POSTGRES_USER` / `POSTGRES_DB` | `pharma` | Database credentials and name | +| `POSTGRES_PASSWORD` | *required* | Database password | +| `SECRET_KEY` | *required* | JWT signing key — 64+ random characters | +| `DOMAIN` | `localhost` | Host name Caddy serves and obtains a certificate for (`:80` = plain HTTP, see below) | +| `HTTP_PORT` / `HTTPS_PORT` | `80` / `443` | Host ports Caddy publishes (`setup.sh` picks free ones) | +| `ENVIRONMENT` | `production` | `production` enables the start-up safety checks | +| `WEB_CONCURRENCY` | `2` | Uvicorn worker processes | + +**Application** + +| Variable | Default | Purpose | +|---|---|---| +| `DATABASE_URL` | local Postgres | `postgresql+asyncpg://…` (Alembic derives a `psycopg` URL from it) | +| `PDF_STORAGE_PATH` | `./storage/pdf` | Where approved DCR PDFs are written | +| `CORS_ORIGINS` | localhost dev origins | Allowed browser origins | +| `DEBUG` / `DB_ECHO` | `false` | Verbose logging / SQL echo | +| `PDF_COMPANY_NAME`, `_ADDRESS`, `_WEBSITE`, `_EMAIL`, `_PHONE` | Celtic details | Letterhead on every PDF | + +**Business rules** — settings rather than constants, so they change without a code change: + +| Variable | Default | Rule | +|---|---|---| +| `BACKDATING_WINDOW_DAYS` | `7` | How many days back an MR may file | +| `SUBMISSION_DEADLINE_DAYS` | `1` | Report for date D must be submitted by end of D+N | +| `MIN_RETURN_REASON_LENGTH` | `10` | Minimum length of a manager's return reason | +| `ACCESS_TOKEN_EXPIRE_MINUTES` | `15` | Access-token life | +| `REFRESH_TOKEN_EXPIRE_DAYS` | `7` | Refresh-token life | +| `LOGIN_MAX_FAILED_ATTEMPTS` | `10` | Failed logins before lockout | + +--- + +## Web application + +A React 18 + TypeScript (Vite) single-page app in `web/`, styled as a minimal SaaS console: sidebar navigation with the Celtic logo, a top bar with the user menu, cards, tables with search and filters, side drawers for forms, toast notifications, and loading / empty / error states on every screen. It works down to phone width (the sidebar becomes a slide-in menu) and remembers whether the sidebar is collapsed. + +``` +web/src/ +├── main.tsx, App.tsx Entry point; role-aware route table and sign-in gate +├── api/ client.ts (fetch, token refresh, downloads) · index.ts (all endpoints) +├── lib/ router (hash-based), session (auth context), navigation, formatting +├── hooks/useAsync.ts Data loading with loading / error / reload state +├── components/ +│ ├── ui/ Button, Card, Badge, Field, DataTable, Tabs, Modal/drawer, Toast, Icon, … +│ ├── layout/ AppShell, Sidebar, Topbar +│ └── reports/ StatusBadge, WorkflowTracker, ApprovalTimeline, VisitList, AddVisitForm, ReviewPanel +├── pages/ Login, Dashboard, Directory, Products, Profile +│ ├── reports/ list, new, detail (with review actions) +│ ├── forms/ company forms: table, row drawer, approval state +│ └── admin/ Setup (tabs) and Users +└── styles/ tokens.css · base.css · layout.css · components.css +``` + +Screens are role-aware: MR / AM / GM get a dashboard with counts and a "waiting on you" queue; the Administrator gets an organisation overview. Routes use hash URLs (`#/reports/`), so every screen is linkable and the back button works behind any static file server. To add a page, create it under `pages/`, add a route in `App.tsx` and a menu entry in `lib/navigation.ts`. + +### Branding and theme + +The UI uses the Celtic logo and the colours taken from it. + +| Token | Value | Used for | +|---|---|---| +| Brand blue | `#285AA8` (dark `#23509A`) | Primary buttons, links, active navigation, sign-in panel | +| Brand orange | `#E95C00` | Small accents (sign-in panel highlight, logo star) | +| Brand grey | `#808080` | The logo's dot; text and borders use a neutral grey scale | + +- The logo is `web/public/celtic-logo.svg`; it is shown in the sidebar, on the sign-in page and as the browser-tab icon. Replace that one file to change it everywhere in the web app. +- All colours, radii, shadows and sizes are CSS variables in `web/src/styles/tokens.css` — change `--brand-*` there to re-theme the whole app. Status colours (green approved, amber in review, red returned) are semantic and intentionally not brand-coloured. +- The PDF letterhead is text (company details from the `PDF_COMPANY_*` settings) and shares its own stylesheet in `app/pdf/templates/base.html`. + +--- + +## Roles and permissions + +| Role | Can do | +|---|---| +| **MR** | File and edit own DCRs while `DRAFT`/`RETURNED`; submit; edit company forms | +| **AM** | Review DCRs of own headquarters: approve or return; sees only the approval forms (Tour Plan, Standard Tour Plan, Fare Chart) | +| **GM** | Read-only: view reports, users and headquarters across the company; no approval step | +| **ADMIN** | Provision users, headquarters and masters. **Cannot approve or read report content** | + +Permissions are checked in two separate layers, because most RBAC bugs live in the gap between them: + +```python +# Layer 1 — WHAT may this role do? +current_user: User = Depends(require_role(Role.MR)) + +# Layer 2 — WHOSE data may this specific user touch? +await assert_can_view_dcr(db, current_user, dcr) +``` + +"AM" is a role; "AM *of this headquarters*" is a scope. Both are mandatory on scoped endpoints, and each has a negative test asserting **403** — not 404 or an empty 200 — so a scope bug cannot hide behind an ambiguous response. + +The System Administrator can never approve: `ADMIN` matches no transition in the state machine, so the audit trail stays evidence that a manager made the decision. + +--- + +## The approval workflow + +``` +DRAFT ──submit(MR)──► PENDING_AM ──approve(AM)──► APPROVED (terminal, immutable) + ▲ │ + │ └──return(AM)──┐ + └──────submit(MR)───── RETURNED ◄───────┘ +``` + +- `RETURNED` records who returned it in the `returned_by_role` column. There is no General Manager stage; the GM is a read-only role. +- `APPROVED` is both "finally approved" and "locked": immutability is a property of the state, enforced in one guard, so there is no window where a report is approved but still editable. +- Managers change state and add comments; they never edit another person's call rows. +- Returning a report requires a reason (`MIN_RETURN_REASON_LENGTH`). + +The whole workflow is `app/approvals/state_machine.py`, a table of transitions with the role allowed to make each one. + +--- + +## Company forms and PDFs + +The `csv_data` module exposes the company's paper forms as editable tables, importable from the CSV files in the repository root. + +| Form | Table | Layout highlights | +|---|---|---| +| Standard Tour Plan ¹ | `standard_tour_plan` | Route places, place count | +| Tour Plan ¹ | `tour_plan` | Date/from/to, POB total, stockist-visit count | +| Fare Chart ¹ | `fare_chart` | Travel log with total kilometers | +| Area Covered | `area_covered` | Area coverage and sale objectives | +| Core Doctor Call Conversion | `core_dr_call_conversion` | Doctor follow-up with status summary | +| Field Activity Report | `field_activity_report` | Daily activity, totals and call averages | +| Sales and Stock Statement | `sales_and_stock_statement` | Opening/receipt/sale/closing with value totals | +| Sales Projection | `sales_projection` | Landscape, product-wise projection | +| Weekly Report | `weekly_report` | One page per saved report | +| Daily Call Report (CSV) | `daily_call_report_csv` | Doctor and chemist sections (not exposed in the UI) | + +¹ *Approval forms* — the AM can only see these, and their PDF carries the AM approval signature line. + +**Approval forms are per MR.** Tour Plan, Standard Tour Plan and Fare Chart rows belong to the MR who entered them (`owner_user_id`), each MR sees and numbers only their own, and the approval (`form_approval`) is kept per form *and* MR. A request goes only to the Area Manager who currently manages that MR's headquarters: any other Area Manager gets a 403 and never sees it in their list, and an MR whose headquarters has no Area Manager cannot send a form. Editing an MR's rows withdraws only that MR's approval. An admin fills a form in on behalf of one chosen MR and can never approve. + +**Monthly download.** Forms with a month (Sales Projection, Weekly Report, Field Activity Report, Core Doctor Call Conversion, Area Covered, Sales and Stock Statement) get a Month selector. The table and the PDF (`GET /csv-data/{form}/pdf?month=November`) then cover that month only; a month with no rows is refused rather than printed blank. + +**How PDFs are built.** The DCR (`dcr.html`) extends the stylesheet `app/pdf/templates/base.html`. The company forms do **not**: each is a copy of the company's printed form — same letterhead, title, column headings, column proportions, number of ruled lines and signature block — built from `app/pdf/templates/forms/_form_base.html` plus one small template per form. `app/pdf/forms.py` decides what each form prints (headings, widths, how many blank lines); stored rows fill the lines from the top, and rows beyond the printed length continue on the next page with the header repeated. Fonts: Liberation Sans/Serif and Carlito (the Arial / Times / Calibri look-alikes of the printed forms), with DejaVu as fallback. + +- `GET /api/v1/csv-data/{table}/pdf` prints **every stored row**; `…/rows/{id}/pdf` prints one row. +- Blank numbered lines pad each form to its printed length; longer data is never truncated. +- Identity fields (name, headquarter, month) are gathered from all rows, and for an MR always reflect the logged-in account. + +**Importing data.** `python -m scripts.import_csv_data` loads the CSV files from the repo root. It **replaces** the contents of every form table — never run it against a database holding real data — use `python -m scripts.import_csv_data --only-empty` instead, which loads only tables that have no rows (e.g. the product lists) and never deletes anything. It is deliberately not part of container start-up, and the CSVs are not in the Docker image. + +--- + +## API overview + +Base path `/api/v1`; interactive documentation at `/docs` and `/redoc`, schema at `/openapi.json`. + +| Module | Prefix | Purpose | +|---|---|---| +| auth | `/auth` | Login, refresh (rotating tokens), logout, current user | +| users | `/users` | User administration and the MR profile | +| organization | `/headquarters` | Headquarters and AM↔HQ mapping | +| doctors, chemists | `/doctors`, `/chemists` | Masters and MR assignment | +| products | `/products` | Product master and stock inventory list | +| reports | `/dcr` | DCR CRUD, calls, submit / return / approve, PDF | +| audit | `/audit` | Read access to the audit log | +| csv_data | `/csv-data` | Company form tables, rows and PDFs | + +Errors use one envelope: `{"error": {"code": "…", "message": "…", "details": {…}}}`. + +--- + +## Project layout + +``` +app/ +├── main.py App factory, error envelope, CORS, production preflight +├── config/ Pydantic settings +├── database/ Engine, session, declarative base, model registry +├── common/ Enums, exceptions, base repository, helpers +├── auth/ JWT, argon2, refresh rotation, permission dependencies +├── users/ organization/ doctors/ chemists/ products/ Masters +├── reports/ DailyCallReport, DoctorCall, ChemistCall ← core domain +├── approvals/ The state machine ← the rules live here +├── audit/ Append-only log +├── csv_data/ Company form tables and their endpoints +├── pdf/ service.py, forms.py, templates/ (base, dcr, forms/*) +└── api/v1/ Router mount point +alembic/ Migrations +scripts/ seed, CSV import, audit hardening SQL, container entrypoint +web/ React application (its own Dockerfile) — see "Web application" +tests/ unit/, integration/, e2e/ +``` + +Domain modules share the same file set, so a new module is a copy of a folder: `models.py` (ORM), `schemas.py` (Pydantic), `service.py` (business rules, transactions, audit calls) and `router.py` (HTTP only). + +--- + +## Design decisions + +**Database-enforced constraints.** Under concurrency only the database can guarantee these, so they are constraints, not just service checks: + +```sql +-- One report per MR per calendar day +ALTER TABLE daily_call_report ADD CONSTRAINT uq_dcr_mr_date UNIQUE (mr_user_id, report_date); + +-- No duplicate doctor call within one report +ALTER TABLE doctor_call ADD CONSTRAINT uq_call_dcr_doctor UNIQUE (dcr_id, doctor_id); + +-- Exactly one active Area Manager per headquarters +CREATE UNIQUE INDEX uq_active_am_per_hq ON am_headquarters (headquarters_id) + WHERE effective_to IS NULL; +``` + +`tests/integration/test_db_constraints.py` proves each rejects the bad case *and* permits the good one. + +**Tables deliberately not created.** The original brief listed 28 tables; the core domain uses far fewer: + +| Not created | Instead | +|---|---| +| `role` | `user.role` enum — four fixed roles; a lookup table adds a join to every request | +| `mr_profile`, `area_manager_profile` | Merged into `user` | +| `area_territory` | Merged into `headquarters` — the HQ *is* the territory | +| `mr_assignment` | `user.headquarters_id` — an MR has exactly one HQ | +| `core_doctor_conversion` | `doctor.is_core_doctor` + `doctor_call.conversion_status` | +| `comments` | `audit_log.comment` — every comment attaches to a state change | +| `approval_history` | A filtered query over `audit_log` — one source of truth | + +**Single-VPS deployment.** No Kubernetes, message broker or microservices: one company and a handful of MRs do not need them, and each extra piece is something to operate. + +--- + +## Testing + +Tests run against a real PostgreSQL database — never SQLite. The system relies on partial unique indexes, composite uniques and `jsonb`, which SQLite does not implement the same way. + +```bash +make dev-db # starts Postgres and creates pharma_test +export TEST_DATABASE_URL=postgresql+asyncpg://pharma:@localhost:5432/pharma_test +pytest -q # everything +pytest tests/unit -q # state machine, PDF layouts — see note below +``` + +`tests/unit` is mostly pure logic (state machine, form PDF view-models and rendering), but a couple of tests there use the database. `make lint` runs ruff. + +--- + +## Production checklist + +1. **Set a real `SECRET_KEY`** (64 random characters) and `POSTGRES_PASSWORD`, from a secrets manager — never in the repo. +2. **Run `scripts/harden_audit.sql`** once as a superuser to make `audit_log` genuinely append-only (revokes UPDATE/DELETE from the app role, plus a trigger as a backstop). Then connect the API as the `pharma_app` role it creates. +3. **Change every seeded password**, or do not seed at all and create real users. +4. **Set `DOMAIN`** to the real host name and, once HTTPS is confirmed, enable the commented HSTS header in `Caddyfile`. +5. **Confirm the blocking business rules** marked in code as `A1`–`A16` / `Q1`–`Q9`; the shipped defaults are assumptions, not decisions. +6. **Back up** `pgdata` and `pdfstore`, and **test a restore** — an untested backup is not a backup. +7. **Point an error tracker (e.g. Sentry) at the app** so production 500s surface as errors. + +--- + +## Known limitations + +- **Company-form approval is per form, not per row.** The tour plan, standard tour plan and fare chart each have one server-stored approval state (`draft → pending → approved`). The MR sends a form that has rows, the Area Manager approves it, and the PDF signature is decided by the server. Any change to the rows withdraws the approval. +- **`web/node_modules` and `web/dist` are committed** to the repository (with stale build output) and should be untracked; Docker builds the app from source. +- The test suite needs a reachable PostgreSQL; some tests under `tests/unit` also need it. + +--- + +## Troubleshooting + +| Symptom | Fix | +|---|---| +| `required variable POSTGRES_PASSWORD is missing` | Create `.env` from `.env.example` and fill it in | +| API exits with `SECRET_KEY must be a random value…` | Set a `SECRET_KEY` of 32+ random characters | +| API exits with `WeasyPrint system libraries are required` | Use the provided image, or install Pango/HarfBuzz and DejaVu fonts | +| PDFs are plain text | WeasyPrint is unavailable (`/health` shows `"pdf_engine": "fallback"`) | +| `no pq wrapper available` from Alembic | `pip install --upgrade --force-reinstall "psycopg[binary]"` | +| Web build in Docker fails on `esbuild` | A host `node_modules` leaked in; check `web/.dockerignore` | +| `npm run build` fails with `tsc: Permission denied` | The committed `web/node_modules` has lost its executable bits. Delete it and run `npm ci` (or build through Docker, which does this) | +| `failed to bind host port 0.0.0.0:80 … address already in use` | Another service owns 80/443. Run `make setup` (or `make deploy`): it switches to free ports. Manually: `DOMAIN=:80`, `HTTP_PORT=2000`, `HTTPS_PORT=2443` in `.env` | +| `password authentication failed` after editing `POSTGRES_PASSWORD` | The database keeps its original password — see *Rotating the database password* | +| API container unhealthy / restarting | `docker compose logs api`: a weak `SECRET_KEY` or missing WeasyPrint stops a production start on purpose | +| Port 5432 in use during `make dev-db` | Set `DB_PORT` (e.g. `DB_PORT=5433`) and adjust `TEST_DATABASE_URL` | diff --git a/STANDARD_TOUR_PLAN.csv b/STANDARD_TOUR_PLAN.csv new file mode 100644 index 0000000..1095f51 --- /dev/null +++ b/STANDARD_TOUR_PLAN.csv @@ -0,0 +1,26 @@ +NAME,HEADQUARTER,SL. NO.,PLACE +,,1, +,,2, +,,3, +,,4, +,,5, +,,6, +,,7, +,,8, +,,9, +,,10, +,,11, +,,12, +,,13, +,,14, +,,15, +,,16, +,,17, +,,18, +,,19, +,,20, +,,21, +,,22, +,,23, +,,24, +,,25, diff --git a/Sales_and_Stock_Statement.csv b/Sales_and_Stock_Statement.csv new file mode 100644 index 0000000..8c5de4b --- /dev/null +++ b/Sales_and_Stock_Statement.csv @@ -0,0 +1,27 @@ +NAME,HEADQUARTER,DATE,MONTH,SL. NO.,NAME OF THE PRODUCT,OPENING,RECEIPT,SALE,CLOSING,VALUE IN PTS +,,,,1,Intezole-PD,,,,, +,,,,2,Intezole-RD,,,,, +,,,,3,Intezole-EL,,,,, +,,,,4,Intezole-ED,,,,, +,,,,5,Intezole-P40,,,,, +,,,,6,Fenmonac-P,,,,, +,,,,7,Fenmonac-SP,,,,, +,,,,8,Fenmonac-MR,,,,, +,,,,9,Penorenz-MR-4,,,,, +,,,,10,Celvadox-CV,,,,, +,,,,11,Amoclodax-CV-625,,,,, +,,,,12,Infezox-O,,,,, +,,,,13,Febrivance-Plus,,,,, +,,,,14,Hiferglobin-XT,,,,, +,,,,15,Vivacellix-360,,,,, +,,,,16,Healthovance-super,,,,, +,,,,17,Healthovance-Q10,,,,, +,,,,18,Megavance-Forte,,,,, +,,,,19,Bontra-Strong,,,,, +,,,,20,Bontra-max+,,,,, +,,,,21,Weakover,,,,, +,,,,22,Bellyfully,,,,, +,,,,23,Tummysure,,,,, +,,,,24,Viscosynth,,,,, +,,,,25,Hiferglobin-Red+,,,,, +,,,,26,Lypopink-Adv,,,,, diff --git a/TOUR_PLAN.csv b/TOUR_PLAN.csv new file mode 100644 index 0000000..6a9246d --- /dev/null +++ b/TOUR_PLAN.csv @@ -0,0 +1,26 @@ +NAME,HEADQUARTER,SL. NO.,DATE,FROM,TO,POB,STOCKIEST VISIT +,,1,,,,, +,,2,,,,, +,,3,,,,, +,,4,,,,, +,,5,,,,, +,,6,,,,, +,,7,,,,, +,,8,,,,, +,,9,,,,, +,,10,,,,, +,,11,,,,, +,,12,,,,, +,,13,,,,, +,,14,,,,, +,,15,,,,, +,,16,,,,, +,,17,,,,, +,,18,,,,, +,,19,,,,, +,,20,,,,, +,,21,,,,, +,,22,,,,, +,,23,,,,, +,,24,,,,, +,,25,,,,, diff --git a/Weekly_Report.csv b/Weekly_Report.csv new file mode 100644 index 0000000..1a5d689 --- /dev/null +++ b/Weekly_Report.csv @@ -0,0 +1,2 @@ +EMPLOYEE NAME,DATE,HEADQUARTER,MONTH,NO. OF DAYS WORKED,NO. OF DOCTOR CALLED,NO. OF CHEMIST CALLED,POB BOOKED,SECONDARY SALES,POB OBJECTIVE,SECONDARY OBJECTIVE,PRODUCT - OFFER SCHEME BOOKED,PRODUCT - OFFER SCHEME OBJECTIVE +,,,,,,,,,,,, diff --git a/alembic.ini b/alembic.ini new file mode 100644 index 0000000..567c56b --- /dev/null +++ b/alembic.ini @@ -0,0 +1,39 @@ +[alembic] +script_location = alembic +prepend_sys_path = . +version_path_separator = os +# sqlalchemy.url is supplied at runtime from app.config.settings — never hard-code it here. + +[loggers] +keys = root,sqlalchemy,alembic + +[handlers] +keys = console + +[formatters] +keys = generic + +[logger_root] +level = WARN +handlers = console +qualname = + +[logger_sqlalchemy] +level = WARN +handlers = +qualname = sqlalchemy.engine + +[logger_alembic] +level = INFO +handlers = +qualname = alembic + +[handler_console] +class = StreamHandler +args = (sys.stderr,) +level = NOTSET +formatter = generic + +[formatter_generic] +format = %(levelname)-5.5s [%(name)s] %(message)s +datefmt = %H:%M:%S diff --git a/alembic/env.py b/alembic/env.py new file mode 100644 index 0000000..3fc24b2 --- /dev/null +++ b/alembic/env.py @@ -0,0 +1,47 @@ +from logging.config import fileConfig + +from alembic import context +from sqlalchemy import engine_from_config, pool + +from app.config.settings import settings +from app.database.all_models import Base # noqa: F401 - registers every model + +config = context.config +config.set_main_option("sqlalchemy.url", settings.sync_database_url) + +if config.config_file_name is not None: + fileConfig(config.config_file_name) + +target_metadata = Base.metadata + + +def run_migrations_offline() -> None: + context.configure( + url=settings.sync_database_url, + target_metadata=target_metadata, + literal_binds=True, + dialect_opts={"paramstyle": "named"}, + compare_type=True, + ) + with context.begin_transaction(): + context.run_migrations() + + +def run_migrations_online() -> None: + connectable = engine_from_config( + config.get_section(config.config_ini_section, {}), + prefix="sqlalchemy.", + poolclass=pool.NullPool, + ) + with connectable.connect() as connection: + context.configure( + connection=connection, target_metadata=target_metadata, compare_type=True + ) + with context.begin_transaction(): + context.run_migrations() + + +if context.is_offline_mode(): + run_migrations_offline() +else: + run_migrations_online() diff --git a/alembic/script.py.mako b/alembic/script.py.mako new file mode 100644 index 0000000..49a7df2 --- /dev/null +++ b/alembic/script.py.mako @@ -0,0 +1,24 @@ +"""${message} + +Revision ID: ${up_revision} +Revises: ${down_revision | comma,n} +Create Date: ${create_date} +""" +from collections.abc import Sequence + +from alembic import op +import sqlalchemy as sa +${imports if imports else ""} + +revision: str = ${repr(up_revision)} +down_revision: str | None = ${repr(down_revision)} +branch_labels: str | Sequence[str] | None = ${repr(branch_labels)} +depends_on: str | Sequence[str] | None = ${repr(depends_on)} + + +def upgrade() -> None: + ${upgrades if upgrades else "pass"} + + +def downgrade() -> None: + ${downgrades if downgrades else "pass"} diff --git a/alembic/versions/a40386dcf76c_initial_mvp_schema.py b/alembic/versions/a40386dcf76c_initial_mvp_schema.py new file mode 100644 index 0000000..0a2ea32 --- /dev/null +++ b/alembic/versions/a40386dcf76c_initial_mvp_schema.py @@ -0,0 +1,241 @@ +"""initial MVP schema + +Revision ID: a40386dcf76c +Revises: +Create Date: 2026-09-10 13:54:30.431676 +""" +from collections.abc import Sequence + +from alembic import op +import sqlalchemy as sa +from sqlalchemy.dialects import postgresql + +revision: str = 'a40386dcf76c' +down_revision: str | None = None +branch_labels: str | Sequence[str] | None = None +depends_on: str | Sequence[str] | None = None + + +def upgrade() -> None: + # ### commands auto generated by Alembic - please adjust! ### + op.create_table('company', + sa.Column('name', sa.String(length=200), nullable=False), + sa.Column('address', sa.String(length=500), nullable=True), + sa.Column('is_active', sa.Boolean(), nullable=False), + sa.Column('id', sa.UUID(), nullable=False), + sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=False), + sa.Column('updated_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=False), + sa.PrimaryKeyConstraint('id') + ) + op.create_table('headquarters', + sa.Column('company_id', sa.UUID(), nullable=False), + sa.Column('code', sa.String(length=20), nullable=False), + sa.Column('name', sa.String(length=200), nullable=False), + sa.Column('district', sa.String(length=100), nullable=True), + sa.Column('state', sa.String(length=100), nullable=True), + sa.Column('is_active', sa.Boolean(), nullable=False), + sa.Column('id', sa.UUID(), nullable=False), + sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=False), + sa.Column('updated_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=False), + sa.ForeignKeyConstraint(['company_id'], ['company.id'], ondelete='RESTRICT'), + sa.PrimaryKeyConstraint('id'), + sa.UniqueConstraint('company_id', 'code', name='uq_hq_company_code') + ) + op.create_table('chemist', + sa.Column('headquarters_id', sa.UUID(), nullable=False), + sa.Column('name', sa.String(length=200), nullable=False), + sa.Column('shop_address', sa.String(length=500), nullable=False), + sa.Column('contact_number', sa.String(length=20), nullable=True), + sa.Column('is_active', sa.Boolean(), nullable=False), + sa.Column('id', sa.UUID(), nullable=False), + sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=False), + sa.Column('updated_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=False), + sa.ForeignKeyConstraint(['headquarters_id'], ['headquarters.id'], ondelete='RESTRICT'), + sa.PrimaryKeyConstraint('id'), + sa.UniqueConstraint('headquarters_id', 'name', 'shop_address', name='uq_chemist_hq_name_shop') + ) + op.create_table('doctor', + sa.Column('headquarters_id', sa.UUID(), nullable=False), + sa.Column('name', sa.String(length=200), nullable=False), + sa.Column('speciality', sa.String(length=100), nullable=True), + sa.Column('qualification', sa.String(length=100), nullable=True), + sa.Column('clinic_address', sa.String(length=500), nullable=False), + sa.Column('contact_number', sa.String(length=20), nullable=True), + sa.Column('is_core_doctor', sa.Boolean(), nullable=False), + sa.Column('is_active', sa.Boolean(), nullable=False), + sa.Column('id', sa.UUID(), nullable=False), + sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=False), + sa.Column('updated_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=False), + sa.ForeignKeyConstraint(['headquarters_id'], ['headquarters.id'], ondelete='RESTRICT'), + sa.PrimaryKeyConstraint('id'), + sa.UniqueConstraint('headquarters_id', 'name', 'clinic_address', name='uq_doctor_hq_name_clinic') + ) + op.create_table('user', + sa.Column('company_id', sa.UUID(), nullable=False), + sa.Column('email', sa.String(length=255), nullable=False), + sa.Column('password_hash', sa.String(length=255), nullable=False), + sa.Column('full_name', sa.String(length=200), nullable=False), + sa.Column('employee_code', sa.String(length=50), nullable=False), + sa.Column('phone', sa.String(length=20), nullable=True), + sa.Column('role', sa.Enum('ADMIN', 'GM', 'AM', 'MR', name='role_enum', native_enum=False, length=10), nullable=False), + sa.Column('headquarters_id', sa.UUID(), nullable=True), + sa.Column('is_active', sa.Boolean(), nullable=False), + sa.Column('failed_login_attempts', sa.Integer(), nullable=False), + sa.Column('id', sa.UUID(), nullable=False), + sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=False), + sa.Column('updated_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=False), + sa.CheckConstraint("(role = 'MR' AND headquarters_id IS NOT NULL) OR (role <> 'MR' AND headquarters_id IS NULL)", name='ck_user_mr_requires_hq'), + sa.ForeignKeyConstraint(['company_id'], ['company.id'], ondelete='RESTRICT'), + sa.ForeignKeyConstraint(['headquarters_id'], ['headquarters.id'], ondelete='RESTRICT'), + sa.PrimaryKeyConstraint('id'), + sa.UniqueConstraint('company_id', 'email', name='uq_user_company_email'), + sa.UniqueConstraint('company_id', 'employee_code', name='uq_user_company_empcode') + ) + op.create_table('am_headquarters', + sa.Column('area_manager_user_id', sa.UUID(), nullable=False), + sa.Column('headquarters_id', sa.UUID(), nullable=False), + sa.Column('effective_from', sa.Date(), nullable=False), + sa.Column('effective_to', sa.Date(), nullable=True), + sa.Column('id', sa.UUID(), nullable=False), + sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=False), + sa.Column('updated_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=False), + sa.ForeignKeyConstraint(['area_manager_user_id'], ['user.id'], ondelete='RESTRICT'), + sa.ForeignKeyConstraint(['headquarters_id'], ['headquarters.id'], ondelete='RESTRICT'), + sa.PrimaryKeyConstraint('id') + ) + op.create_index('uq_active_am_per_hq', 'am_headquarters', ['headquarters_id'], unique=True, postgresql_where=sa.text('effective_to IS NULL')) + op.create_table('audit_log', + sa.Column('actor_user_id', sa.UUID(), nullable=False), + sa.Column('entity_type', sa.Enum('USER', 'HEADQUARTERS', 'DOCTOR', 'CHEMIST', 'DCR', name='entity_type_enum', native_enum=False, length=30), nullable=False), + sa.Column('entity_id', sa.UUID(), nullable=False), + sa.Column('action', sa.Enum('CREATE', 'UPDATE', 'DELETE', 'SUBMIT', 'FORWARD', 'RETURN', 'APPROVE', 'ASSIGN', 'LOGIN', 'DEACTIVATE', name='audit_action_enum', native_enum=False, length=20), nullable=False), + sa.Column('before_data', postgresql.JSONB(astext_type=sa.Text()), nullable=True), + sa.Column('after_data', postgresql.JSONB(astext_type=sa.Text()), nullable=True), + sa.Column('comment', sa.Text(), nullable=True), + sa.Column('ip_address', sa.String(length=45), nullable=True), + sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=False), + sa.Column('id', sa.UUID(), nullable=False), + sa.ForeignKeyConstraint(['actor_user_id'], ['user.id'], ondelete='RESTRICT'), + sa.PrimaryKeyConstraint('id') + ) + op.create_index(op.f('ix_audit_log_created_at'), 'audit_log', ['created_at'], unique=False) + op.create_index(op.f('ix_audit_log_entity_id'), 'audit_log', ['entity_id'], unique=False) + op.create_index(op.f('ix_audit_log_entity_type'), 'audit_log', ['entity_type'], unique=False) + op.create_table('chemist_assignment', + sa.Column('chemist_id', sa.UUID(), nullable=False), + sa.Column('mr_user_id', sa.UUID(), nullable=False), + sa.Column('effective_from', sa.Date(), nullable=False), + sa.Column('effective_to', sa.Date(), nullable=True), + sa.Column('id', sa.UUID(), nullable=False), + sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=False), + sa.Column('updated_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=False), + sa.ForeignKeyConstraint(['chemist_id'], ['chemist.id'], ondelete='CASCADE'), + sa.ForeignKeyConstraint(['mr_user_id'], ['user.id'], ondelete='RESTRICT'), + sa.PrimaryKeyConstraint('id') + ) + op.create_index('uq_active_chemist_assignment', 'chemist_assignment', ['chemist_id'], unique=True, postgresql_where=sa.text('effective_to IS NULL')) + op.create_table('daily_call_report', + sa.Column('mr_user_id', sa.UUID(), nullable=False), + sa.Column('headquarters_id', sa.UUID(), nullable=False), + sa.Column('report_date', sa.Date(), nullable=False), + sa.Column('status', sa.Enum('DRAFT', 'PENDING_AM', 'PENDING_GM', 'RETURNED', 'APPROVED', name='dcr_status_enum', native_enum=False, length=20), nullable=False), + sa.Column('current_am_user_id', sa.UUID(), nullable=True), + sa.Column('current_gm_user_id', sa.UUID(), nullable=True), + sa.Column('mr_remarks', sa.Text(), nullable=True), + sa.Column('return_reason', sa.Text(), nullable=True), + sa.Column('returned_by_role', sa.Enum('ADMIN', 'GM', 'AM', 'MR', name='role_enum', native_enum=False, length=10), nullable=True), + sa.Column('submitted_at', sa.DateTime(timezone=True), nullable=True), + sa.Column('approved_at', sa.DateTime(timezone=True), nullable=True), + sa.Column('pdf_path', sa.String(length=500), nullable=True), + sa.Column('id', sa.UUID(), nullable=False), + sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=False), + sa.Column('updated_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=False), + sa.CheckConstraint("(status = 'APPROVED' AND approved_at IS NOT NULL) OR (status <> 'APPROVED' AND approved_at IS NULL)", name='ck_dcr_approved_at'), + sa.ForeignKeyConstraint(['current_am_user_id'], ['user.id'], ondelete='RESTRICT'), + sa.ForeignKeyConstraint(['current_gm_user_id'], ['user.id'], ondelete='RESTRICT'), + sa.ForeignKeyConstraint(['headquarters_id'], ['headquarters.id'], ondelete='RESTRICT'), + sa.ForeignKeyConstraint(['mr_user_id'], ['user.id'], ondelete='RESTRICT'), + sa.PrimaryKeyConstraint('id'), + sa.UniqueConstraint('mr_user_id', 'report_date', name='uq_dcr_mr_date') + ) + op.create_table('doctor_assignment', + sa.Column('doctor_id', sa.UUID(), nullable=False), + sa.Column('mr_user_id', sa.UUID(), nullable=False), + sa.Column('effective_from', sa.Date(), nullable=False), + sa.Column('effective_to', sa.Date(), nullable=True), + sa.Column('id', sa.UUID(), nullable=False), + sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=False), + sa.Column('updated_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=False), + sa.ForeignKeyConstraint(['doctor_id'], ['doctor.id'], ondelete='CASCADE'), + sa.ForeignKeyConstraint(['mr_user_id'], ['user.id'], ondelete='RESTRICT'), + sa.PrimaryKeyConstraint('id') + ) + op.create_index('uq_active_doctor_assignment', 'doctor_assignment', ['doctor_id'], unique=True, postgresql_where=sa.text('effective_to IS NULL')) + op.create_table('refresh_token', + sa.Column('user_id', sa.UUID(), nullable=False), + sa.Column('token_hash', sa.String(length=64), nullable=False), + sa.Column('expires_at', sa.DateTime(timezone=True), nullable=False), + sa.Column('revoked', sa.Boolean(), nullable=False), + sa.Column('id', sa.UUID(), nullable=False), + sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=False), + sa.Column('updated_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=False), + sa.ForeignKeyConstraint(['user_id'], ['user.id'], ondelete='CASCADE'), + sa.PrimaryKeyConstraint('id') + ) + op.create_index(op.f('ix_refresh_token_token_hash'), 'refresh_token', ['token_hash'], unique=True) + op.create_index(op.f('ix_refresh_token_user_id'), 'refresh_token', ['user_id'], unique=False) + op.create_table('chemist_call', + sa.Column('dcr_id', sa.UUID(), nullable=False), + sa.Column('chemist_id', sa.UUID(), nullable=False), + sa.Column('visit_time', sa.Time(), nullable=False), + sa.Column('remarks', sa.Text(), nullable=True), + sa.Column('id', sa.UUID(), nullable=False), + sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=False), + sa.Column('updated_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=False), + sa.ForeignKeyConstraint(['chemist_id'], ['chemist.id'], ondelete='RESTRICT'), + sa.ForeignKeyConstraint(['dcr_id'], ['daily_call_report.id'], ondelete='CASCADE'), + sa.PrimaryKeyConstraint('id'), + sa.UniqueConstraint('dcr_id', 'chemist_id', name='uq_call_dcr_chemist') + ) + op.create_table('doctor_call', + sa.Column('dcr_id', sa.UUID(), nullable=False), + sa.Column('doctor_id', sa.UUID(), nullable=False), + sa.Column('visit_time', sa.Time(), nullable=False), + sa.Column('call_outcome', sa.Enum('MET', 'NOT_AVAILABLE', 'RESCHEDULED', name='call_outcome_enum', native_enum=False, length=20), nullable=False), + sa.Column('conversion_status', sa.Enum('NOT_STARTED', 'IN_PROGRESS', 'CONVERTED', 'LOST', name='conversion_status_enum', native_enum=False, length=20), nullable=True), + sa.Column('remarks', sa.Text(), nullable=True), + sa.Column('id', sa.UUID(), nullable=False), + sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=False), + sa.Column('updated_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=False), + sa.ForeignKeyConstraint(['dcr_id'], ['daily_call_report.id'], ondelete='CASCADE'), + sa.ForeignKeyConstraint(['doctor_id'], ['doctor.id'], ondelete='RESTRICT'), + sa.PrimaryKeyConstraint('id'), + sa.UniqueConstraint('dcr_id', 'doctor_id', name='uq_call_dcr_doctor') + ) + # ### end Alembic commands ### + + +def downgrade() -> None: + # ### commands auto generated by Alembic - please adjust! ### + op.drop_table('doctor_call') + op.drop_table('chemist_call') + op.drop_index(op.f('ix_refresh_token_user_id'), table_name='refresh_token') + op.drop_index(op.f('ix_refresh_token_token_hash'), table_name='refresh_token') + op.drop_table('refresh_token') + op.drop_index('uq_active_doctor_assignment', table_name='doctor_assignment', postgresql_where=sa.text('effective_to IS NULL')) + op.drop_table('doctor_assignment') + op.drop_table('daily_call_report') + op.drop_index('uq_active_chemist_assignment', table_name='chemist_assignment', postgresql_where=sa.text('effective_to IS NULL')) + op.drop_table('chemist_assignment') + op.drop_index(op.f('ix_audit_log_entity_type'), table_name='audit_log') + op.drop_index(op.f('ix_audit_log_entity_id'), table_name='audit_log') + op.drop_index(op.f('ix_audit_log_created_at'), table_name='audit_log') + op.drop_table('audit_log') + op.drop_index('uq_active_am_per_hq', table_name='am_headquarters', postgresql_where=sa.text('effective_to IS NULL')) + op.drop_table('am_headquarters') + op.drop_table('user') + op.drop_table('doctor') + op.drop_table('chemist') + op.drop_table('headquarters') + op.drop_table('company') + # ### end Alembic commands ### diff --git a/alembic/versions/b71d4c22a917_am_final_approval_and_product_master.py b/alembic/versions/b71d4c22a917_am_final_approval_and_product_master.py new file mode 100644 index 0000000..4c0bbed --- /dev/null +++ b/alembic/versions/b71d4c22a917_am_final_approval_and_product_master.py @@ -0,0 +1,54 @@ +"""make AM the final approver and add the product master + +Revision ID: b71d4c22a917 +Revises: a40386dcf76c +Create Date: 2026-09-17 +""" + +from collections.abc import Sequence + +import sqlalchemy as sa + +from alembic import op + +revision: str = "b71d4c22a917" +down_revision: str | None = "a40386dcf76c" +branch_labels: str | Sequence[str] | None = None +depends_on: str | Sequence[str] | None = None + + +def upgrade() -> None: + # Native enums are deliberately disabled in the initial schema. Existing reports + # that were waiting for GM are returned to the AM queue for a final decision. + op.execute("UPDATE daily_call_report SET status = 'PENDING_AM' WHERE status = 'PENDING_GM'") + op.create_table( + "product", + sa.Column("company_id", sa.UUID(), nullable=False), + sa.Column("name", sa.String(length=200), nullable=False), + sa.Column("pack", sa.String(length=100), nullable=True), + sa.Column("unit", sa.String(length=50), nullable=True), + sa.Column("is_active", sa.Boolean(), nullable=False, server_default=sa.true()), + sa.Column("id", sa.UUID(), nullable=False), + sa.Column( + "created_at", + sa.DateTime(timezone=True), + server_default=sa.text("now()"), + nullable=False, + ), + sa.Column( + "updated_at", + sa.DateTime(timezone=True), + server_default=sa.text("now()"), + nullable=False, + ), + sa.ForeignKeyConstraint(["company_id"], ["company.id"], ondelete="RESTRICT"), + sa.PrimaryKeyConstraint("id"), + sa.UniqueConstraint("company_id", "name", name="uq_product_company_name"), + ) + + +def downgrade() -> None: + op.drop_table("product") + # A downgrade cannot safely reinstate the former GM queue assignment. Reopen the + # reports in the old AM queue rather than fabricating a GM approval decision. + op.execute("UPDATE daily_call_report SET status = 'PENDING_AM' WHERE status = 'PENDING_AM'") diff --git a/alembic/versions/c2e7f5b1a9d4_add_csv_import_rows.py b/alembic/versions/c2e7f5b1a9d4_add_csv_import_rows.py new file mode 100644 index 0000000..833de98 --- /dev/null +++ b/alembic/versions/c2e7f5b1a9d4_add_csv_import_rows.py @@ -0,0 +1,33 @@ +"""store non-MVP CSV source rows + +Revision ID: c2e7f5b1a9d4 +Revises: b71d4c22a917 +Create Date: 2026-09-18 +""" + +from collections.abc import Sequence + +import sqlalchemy as sa + +from alembic import op + +revision: str = "c2e7f5b1a9d4" +down_revision: str | None = "b71d4c22a917" +branch_labels: str | Sequence[str] | None = None +depends_on: str | Sequence[str] | None = None + + +def upgrade() -> None: + op.create_table( + "csv_import_row", + sa.Column("id", sa.UUID(), nullable=False), + sa.Column("source_file", sa.String(length=255), nullable=False), + sa.Column("row_number", sa.Integer(), nullable=False), + sa.Column("data", sa.JSON(), nullable=False), + sa.PrimaryKeyConstraint("id"), + sa.UniqueConstraint("source_file", "row_number", name="uq_csv_import_file_row"), + ) + + +def downgrade() -> None: + op.drop_table("csv_import_row") \ No newline at end of file diff --git a/alembic/versions/d4f8a6c2e1b0_split_csv_import_table.py b/alembic/versions/d4f8a6c2e1b0_split_csv_import_table.py new file mode 100644 index 0000000..28a7678 --- /dev/null +++ b/alembic/versions/d4f8a6c2e1b0_split_csv_import_table.py @@ -0,0 +1,57 @@ +"""replace the old single CSV table with individual CSV tables + +Revision ID: d4f8a6c2e1b0 +Revises: c2e7f5b1a9d4 +Create Date: 2026-09-18 +""" + +import sqlalchemy as sa + +from collections.abc import Sequence + +from alembic import op + +revision: str = "d4f8a6c2e1b0" +down_revision: str | None = "c2e7f5b1a9d4" +branch_labels: str | Sequence[str] | None = None +depends_on: str | Sequence[str] | None = None + +TABLE_COLUMNS = { + "weekly_report": ["employee_name", "report_date", "headquarter", "month", "no_of_days_worked", "no_of_doctor_called", "no_of_chemist_called", "pob_booked", "secondary_sales", "pob_objective", "secondary_objective", "product_offer_scheme_booked", "product_offer_scheme_objective"], + "field_activity_report": ["name", "headquarter", "month", "report_date", "station_worked", "no_of_doctors_called", "no_of_chemists_pds_called", "doctor_call_avg", "chemist_call_avg"], + "fare_chart": ["name", "headquarter", "serial_no", "report_date", "from_location", "to_location", "kilometers_km"], + "daily_call_report_csv": ["name", "headquarter", "report_date", "month", "doctor_sr_no", "doctor_name", "qualification", "product_promote", "product_sample", "remarks", "chemist_sr_no", "chemist_name", "pob", "stockist_visit", "order_value"], + "core_dr_call_conversion": ["name", "headquarter", "month", "doctor_name", "date_of_visit", "product_targeted", "status"], + "area_covered": ["name", "headquarter", "month", "sale_status", "area_to_cover", "sale_objective", "status"], + "sales_and_stock_statement": ["name", "headquarter", "report_date", "month", "serial_no", "product_name", "opening", "receipt", "sale", "closing", "value_in_pts"], + "tour_plan": ["name", "headquarter", "serial_no", "report_date", "from_location", "to_location", "pob", "stockiest_visit"], + "standard_tour_plan": ["name", "headquarter", "serial_no", "place"], + "sales_projection": ["serial_no", "product_name", "pts", "secondary_qty", "value", "closing", "secondary_value", "aug_sales", "value_2"], +} + + +def upgrade() -> None: + op.drop_table("csv_import_row") + for table_name, columns in TABLE_COLUMNS.items(): + op.create_table( + table_name, + sa.Column("id", sa.UUID(), nullable=False), + sa.Column("source_row_number", sa.Integer(), nullable=False), + *(sa.Column(column, sa.Text(), nullable=True) for column in columns), + sa.PrimaryKeyConstraint("id"), + sa.UniqueConstraint("source_row_number", name=f"uq_{table_name}_source_row"), + ) + + +def downgrade() -> None: + for table_name in reversed(TABLE_COLUMNS): + op.drop_table(table_name) + op.create_table( + "csv_import_row", + sa.Column("id", sa.UUID(), nullable=False), + sa.Column("source_file", sa.String(length=255), nullable=False), + sa.Column("row_number", sa.Integer(), nullable=False), + sa.Column("data", sa.JSON(), nullable=False), + sa.PrimaryKeyConstraint("id"), + sa.UniqueConstraint("source_file", "row_number", name="uq_csv_import_file_row"), + ) \ No newline at end of file diff --git a/alembic/versions/e5a1c7d9f3b2_add_sales_projection_table.py b/alembic/versions/e5a1c7d9f3b2_add_sales_projection_table.py new file mode 100644 index 0000000..0404bf8 --- /dev/null +++ b/alembic/versions/e5a1c7d9f3b2_add_sales_projection_table.py @@ -0,0 +1,43 @@ +"""add the sales projection CSV table + +Revision ID: e5a1c7d9f3b2 +Revises: d4f8a6c2e1b0 +Create Date: 2026-09-18 +""" + +from collections.abc import Sequence + +import sqlalchemy as sa + +from alembic import op + +revision: str = "e5a1c7d9f3b2" +down_revision: str | None = "d4f8a6c2e1b0" +branch_labels: str | Sequence[str] | None = None +depends_on: str | Sequence[str] | None = None + + +def upgrade() -> None: + # A pre-migration local table may exist with the old product-master schema. + # The CSV is the canonical source, so recreate it using the shared CSV-table shape. + op.execute("DROP TABLE IF EXISTS sales_projection") + op.create_table( + "sales_projection", + sa.Column("id", sa.UUID(), nullable=False), + sa.Column("source_row_number", sa.Integer(), nullable=False), + sa.Column("serial_no", sa.Text(), nullable=True), + sa.Column("product_name", sa.Text(), nullable=True), + sa.Column("pts", sa.Text(), nullable=True), + sa.Column("secondary_qty", sa.Text(), nullable=True), + sa.Column("value", sa.Text(), nullable=True), + sa.Column("closing", sa.Text(), nullable=True), + sa.Column("secondary_value", sa.Text(), nullable=True), + sa.Column("aug_sales", sa.Text(), nullable=True), + sa.Column("value_2", sa.Text(), nullable=True), + sa.PrimaryKeyConstraint("id"), + sa.UniqueConstraint("source_row_number", name="uq_sales_projection_source_row"), + ) + + +def downgrade() -> None: + op.drop_table("sales_projection") \ No newline at end of file diff --git a/alembic/versions/f6b2d8e4a1c3_add_sales_projection_identity.py b/alembic/versions/f6b2d8e4a1c3_add_sales_projection_identity.py new file mode 100644 index 0000000..7800f10 --- /dev/null +++ b/alembic/versions/f6b2d8e4a1c3_add_sales_projection_identity.py @@ -0,0 +1,35 @@ +"""add account identity fields to sales projection + +Revision ID: f6b2d8e4a1c3 +Revises: e5a1c7d9f3b2 +Create Date: 2026-09-18 +""" + +from collections.abc import Sequence + +import sqlalchemy as sa + +from alembic import op + +revision: str = "f6b2d8e4a1c3" +down_revision: str | None = "e5a1c7d9f3b2" +branch_labels: str | Sequence[str] | None = None +depends_on: str | Sequence[str] | None = None + + +def upgrade() -> None: + op.add_column("sales_projection", sa.Column("name", sa.Text(), nullable=True)) + op.add_column("sales_projection", sa.Column("headquarter", sa.Text(), nullable=True)) + op.execute( + '''UPDATE "sales_projection" AS projection + SET name = account.full_name, + headquarter = headquarters.name + FROM "user" AS account + LEFT JOIN headquarters ON headquarters.id = account.headquarters_id + WHERE account.role = 'MR' ''' + ) + + +def downgrade() -> None: + op.drop_column("sales_projection", "headquarter") + op.drop_column("sales_projection", "name") \ No newline at end of file diff --git a/alembic/versions/g7c3e9f5b2d4_add_sales_projection_date_month.py b/alembic/versions/g7c3e9f5b2d4_add_sales_projection_date_month.py new file mode 100644 index 0000000..8534cf7 --- /dev/null +++ b/alembic/versions/g7c3e9f5b2d4_add_sales_projection_date_month.py @@ -0,0 +1,27 @@ +"""add date and month fields to sales projection + +Revision ID: g7c3e9f5b2d4 +Revises: f6b2d8e4a1c3 +Create Date: 2026-09-19 +""" + +from collections.abc import Sequence + +import sqlalchemy as sa + +from alembic import op + +revision: str = "g7c3e9f5b2d4" +down_revision: str | None = "f6b2d8e4a1c3" +branch_labels: str | Sequence[str] | None = None +depends_on: str | Sequence[str] | None = None + + +def upgrade() -> None: + op.add_column("sales_projection", sa.Column("report_date", sa.Text(), nullable=True)) + op.add_column("sales_projection", sa.Column("month", sa.Text(), nullable=True)) + + +def downgrade() -> None: + op.drop_column("sales_projection", "month") + op.drop_column("sales_projection", "report_date") \ No newline at end of file diff --git a/alembic/versions/h8d4f0a6c3e5_add_stock_inventory.py b/alembic/versions/h8d4f0a6c3e5_add_stock_inventory.py new file mode 100644 index 0000000..d608edc --- /dev/null +++ b/alembic/versions/h8d4f0a6c3e5_add_stock_inventory.py @@ -0,0 +1,82 @@ +"""add the stock inventory table behind the Products page and load stock.csv + +The Products page (GET /products/stock-inventory) reads ``stock_inventory``, which no +migration created — the endpoint returned 500 on any database built from migrations. +The rows are the company's product / pack / quantity list (stock.csv). They are inlined +here because the CSV files are not part of the Docker image. + +Revision ID: h8d4f0a6c3e5 +Revises: g7c3e9f5b2d4 +Create Date: 2026-09-20 +""" + +from collections.abc import Sequence + +import sqlalchemy as sa + +from alembic import op + +revision: str = "h8d4f0a6c3e5" +down_revision: str | None = "g7c3e9f5b2d4" +branch_labels: str | Sequence[str] | None = None +depends_on: str | Sequence[str] | None = None + +# (serial_no, product_name, pack, quantity, unit) — straight from stock.csv +STOCK_ROWS = [ + (1, 'INTEZOLE-PD', '10X10 CAP', '10+2', None), + (2, 'INTEZOLE-RD', '10X10 CAP', '10+2', None), + (3, 'INTEZOLE-EL', '10X10 CAP', '10+2', None), + (4, 'INTEZOLE-ED', '10X10 CAP', '10+2', None), + (5, 'INTEZOLE-P40', '10X10 TAB', '10+1', None), + (6, 'FENMONAC-P', '10X10 TAB', '10+1', None), + (7, 'FENMONAC-SP', '10X10 TAB', '10+1', None), + (8, 'FENMONAC-MR', '10X10 TAB', '10+1', None), + (9, 'PENORENZ-MR 4', '10X10 TAB', '10+1', None), + (10, 'CELVADOX-CV', '10X1X10 TAB', 'NA', None), + (11, 'AMOCLADOV-CV 625', '10X1X10 TAB', '10+1', None), + (12, 'INFEZOX-O', '10X10 TAB', '9+1', None), + (13, 'FEBRIVANCE-PLUS', '10X10 TAB', '10+2', None), + (14, 'HIFERGLOBIN-XT', '10X10 TAB', '9+1', None), + (15, 'VIVACELLIX-360', '10X10 TAB', 'NA', None), + (16, 'HEALTHOVANCE-SUPER', '10X10 TAB', '9+1', None), + (17, 'HEALTHOVANCE-Q10', '10X10 TAB', 'NA', None), + (18, 'MEGAVANCE-FORTE', '10X1X10CAP', '10+2', None), + (19, 'BONETRA-STRONG', '10X1X10CAP', '9+1', None), + (20, 'BONETRA-MAX+', '10X1X10CAP', '9+1', None), + (21, 'WEAKOVER', '200ML SYRUP', '11+1', None), + (22, 'BELLYFULLY', '200ML SYRUP', '11+1', None), + (23, 'TUMMY SURE', '200ML SYRUP', '14+1', None), + (24, 'VISCOSYNTH', '200ML SYRUP', '11+1', None), + (25, 'HIFERGLOBIN-RED+', '200ML SYRUP', '14+1', None), + (26, 'LYPOPINK-ADV', '200ML SYRUP', 'NA', None), +] + + +def upgrade() -> None: + stock = op.create_table( + "stock_inventory", + sa.Column("id", sa.Integer(), sa.Identity(), primary_key=True), + sa.Column("serial_no", sa.Integer(), nullable=False), + sa.Column("product_name", sa.Text(), nullable=False), + sa.Column("pack", sa.Text(), nullable=True), + sa.Column("quantity", sa.Text(), nullable=True), + sa.Column("unit", sa.Text(), nullable=True), + sa.UniqueConstraint("serial_no", name="uq_stock_inventory_serial_no"), + ) + op.bulk_insert( + stock, + [ + { + "serial_no": serial_no, + "product_name": product_name, + "pack": pack, + "quantity": quantity, + "unit": unit, + } + for serial_no, product_name, pack, quantity, unit in STOCK_ROWS + ], + ) + + +def downgrade() -> None: + op.drop_table("stock_inventory") diff --git a/alembic/versions/i9e5a1b7d4f6_remove_general_manager_approval.py b/alembic/versions/i9e5a1b7d4f6_remove_general_manager_approval.py new file mode 100644 index 0000000..4c8432b --- /dev/null +++ b/alembic/versions/i9e5a1b7d4f6_remove_general_manager_approval.py @@ -0,0 +1,28 @@ +"""remove the General Manager approval stage + +The Area Manager is the final approver: PENDING_AM -> APPROVED | RETURNED. Any report +still sitting in the retired PENDING_GM status goes back to the Area Manager's queue. +Historical audit rows (including FORWARD) are left untouched. + +Revision ID: i9e5a1b7d4f6 +Revises: h8d4f0a6c3e5 +Create Date: 2026-09-21 +""" + +from collections.abc import Sequence + +from alembic import op + +revision: str = "i9e5a1b7d4f6" +down_revision: str | None = "h8d4f0a6c3e5" +branch_labels: str | Sequence[str] | None = None +depends_on: str | Sequence[str] | None = None + + +def upgrade() -> None: + op.execute("UPDATE daily_call_report SET status = 'PENDING_AM' WHERE status = 'PENDING_GM'") + + +def downgrade() -> None: + # Nothing to restore: the GM stage no longer exists in the code. + pass diff --git a/alembic/versions/j0f6b2c8e5a7_daily_call_report_form_fields.py b/alembic/versions/j0f6b2c8e5a7_daily_call_report_form_fields.py new file mode 100644 index 0000000..6cea0ec --- /dev/null +++ b/alembic/versions/j0f6b2c8e5a7_daily_call_report_form_fields.py @@ -0,0 +1,37 @@ +"""capture the printed Daily Call Report's extra fields + +Doctor visits gain PRODUCT PROMOTE / PRODUCT SAMPLE, chemist visits gain POB, and the +report gains STOCKIST VISIT / ORDER, so the approved PDF can reproduce the paper form. +All nullable: existing reports are unaffected. + +Revision ID: j0f6b2c8e5a7 +Revises: i9e5a1b7d4f6 +Create Date: 2026-09-21 +""" + +from collections.abc import Sequence + +import sqlalchemy as sa + +from alembic import op + +revision: str = "j0f6b2c8e5a7" +down_revision: str | None = "i9e5a1b7d4f6" +branch_labels: str | Sequence[str] | None = None +depends_on: str | Sequence[str] | None = None + + +def upgrade() -> None: + op.add_column("doctor_call", sa.Column("product_promote", sa.String(length=200), nullable=True)) + op.add_column("doctor_call", sa.Column("product_sample", sa.String(length=200), nullable=True)) + op.add_column("chemist_call", sa.Column("pob", sa.String(length=100), nullable=True)) + op.add_column("daily_call_report", sa.Column("stockist_visit", sa.String(length=200), nullable=True)) + op.add_column("daily_call_report", sa.Column("order_value", sa.String(length=100), nullable=True)) + + +def downgrade() -> None: + op.drop_column("daily_call_report", "order_value") + op.drop_column("daily_call_report", "stockist_visit") + op.drop_column("chemist_call", "pob") + op.drop_column("doctor_call", "product_sample") + op.drop_column("doctor_call", "product_promote") diff --git a/alembic/versions/k1a7c3d9f6b8_form_approval_state.py b/alembic/versions/k1a7c3d9f6b8_form_approval_state.py new file mode 100644 index 0000000..19162cc --- /dev/null +++ b/alembic/versions/k1a7c3d9f6b8_form_approval_state.py @@ -0,0 +1,37 @@ +"""store company-form approvals on the server + +Until now the "approved / pending" state of the tour plan, standard tour plan and fare +chart lived in each browser's local storage: an Area Manager's approval was invisible to +the MR, and the PDF signature was whatever the browser sent. It is now a table. + +Revision ID: k1a7c3d9f6b8 +Revises: j0f6b2c8e5a7 +Create Date: 2026-09-21 +""" + +from collections.abc import Sequence + +import sqlalchemy as sa + +from alembic import op + +revision: str = "k1a7c3d9f6b8" +down_revision: str | None = "j0f6b2c8e5a7" +branch_labels: str | Sequence[str] | None = None +depends_on: str | Sequence[str] | None = None + + +def upgrade() -> None: + op.create_table( + "form_approval", + sa.Column("table_name", sa.String(length=64), primary_key=True), + sa.Column("status", sa.String(length=10), nullable=False, server_default="draft"), + sa.Column("requested_by_user_id", sa.UUID(), sa.ForeignKey("user.id", ondelete="SET NULL"), nullable=True), + sa.Column("approved_by_user_id", sa.UUID(), sa.ForeignKey("user.id", ondelete="SET NULL"), nullable=True), + sa.Column("approved_by_name", sa.String(length=200), nullable=True), + sa.Column("updated_at", sa.DateTime(timezone=True), server_default=sa.text("now()"), nullable=False), + ) + + +def downgrade() -> None: + op.drop_table("form_approval") diff --git a/alembic/versions/l2b8d4e0a7c9_per_mr_form_approvals.py b/alembic/versions/l2b8d4e0a7c9_per_mr_form_approvals.py new file mode 100644 index 0000000..cbeb0e9 --- /dev/null +++ b/alembic/versions/l2b8d4e0a7c9_per_mr_form_approvals.py @@ -0,0 +1,77 @@ +"""company forms belong to one MR, and so does their approval + +The tour plan, standard tour plan and fare chart were one shared table with one shared +approval, so any Area Manager could sign for any MR. Each row now records its owner (the MR), +and an approval is kept per (form, MR) so it can only be requested from, and signed by, the +Area Manager who manages that MR's headquarters. + +Revision ID: l2b8d4e0a7c9 +Revises: k1a7c3d9f6b8 +Create Date: 2026-09-21 +""" + +from collections.abc import Sequence + +import sqlalchemy as sa + +from alembic import op + +revision: str = "l2b8d4e0a7c9" +down_revision: str | None = "k1a7c3d9f6b8" +branch_labels: str | Sequence[str] | None = None +depends_on: str | Sequence[str] | None = None + +OWNED = ("tour_plan", "standard_tour_plan", "fare_chart") + + +def upgrade() -> None: + op.add_column("form_approval", sa.Column("owner_user_id", sa.UUID(), nullable=True)) + # The MR who sent a form for approval is the one whose data it was. + op.execute("UPDATE form_approval SET owner_user_id = requested_by_user_id") + op.execute("DELETE FROM form_approval WHERE owner_user_id IS NULL") + op.drop_constraint("form_approval_pkey", "form_approval", type_="primary") + op.alter_column("form_approval", "owner_user_id", nullable=False) + op.create_primary_key("form_approval_pkey", "form_approval", ["table_name", "owner_user_id"]) + op.create_foreign_key( + "fk_form_approval_owner", "form_approval", "user", ["owner_user_id"], ["id"], ondelete="CASCADE" + ) + + for table in OWNED: + op.add_column(table, sa.Column("owner_user_id", sa.UUID(), sa.ForeignKey("user.id", ondelete="SET NULL"), nullable=True)) + op.create_index(f"ix_{table}_owner", table, ["owner_user_id"]) + # Rows that existed belong to the MR who put the form up for approval, with that MR's identity. + op.execute( + f'''UPDATE "{table}" t + SET owner_user_id = a.owner_user_id, name = u.full_name, headquarter = h.name + FROM form_approval a + JOIN "user" u ON u.id = a.owner_user_id + LEFT JOIN headquarters h ON h.id = u.headquarters_id + WHERE a.table_name = '{table}' ''' + ) + + # An approval by an Area Manager who does not manage the MR's headquarters was never valid: + # send it back to the right one. + op.execute( + '''UPDATE form_approval a + SET status = 'pending', approved_by_user_id = NULL, approved_by_name = NULL + FROM "user" u + WHERE u.id = a.owner_user_id AND a.status = 'approved' + AND NOT EXISTS ( + SELECT 1 FROM am_headquarters m + WHERE m.headquarters_id = u.headquarters_id AND m.effective_to IS NULL + AND m.area_manager_user_id = a.approved_by_user_id)''' + ) + + +def downgrade() -> None: + for table in OWNED: + op.drop_index(f"ix_{table}_owner", table_name=table) + op.drop_column(table, "owner_user_id") + op.drop_constraint("fk_form_approval_owner", "form_approval", type_="foreignkey") + op.drop_constraint("form_approval_pkey", "form_approval", type_="primary") + op.execute( + "DELETE FROM form_approval a USING form_approval b " + "WHERE a.table_name = b.table_name AND a.ctid < b.ctid" + ) + op.drop_column("form_approval", "owner_user_id") + op.create_primary_key("form_approval_pkey", "form_approval", ["table_name"]) diff --git a/app/__init__.py b/app/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/app/api/__init__.py b/app/api/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/app/api/v1/__init__.py b/app/api/v1/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/app/api/v1/router.py b/app/api/v1/router.py new file mode 100644 index 0000000..b9fc382 --- /dev/null +++ b/app/api/v1/router.py @@ -0,0 +1,28 @@ +"""Mount point for every v1 module router. + +Versioning matters here because of the Phase-3 mobile app: an installed app cannot be +force-updated, so v1 must stay frozen once it ships and breaking changes go to v2. +""" + +from fastapi import APIRouter + +from app.audit.router import router as audit_router +from app.auth.router import router as auth_router +from app.chemists.router import router as chemists_router +from app.csv_data.router import router as csv_data_router +from app.doctors.router import router as doctors_router +from app.organization.router import router as organization_router +from app.products.router import router as products_router +from app.reports.router import router as reports_router +from app.users.router import router as users_router + +api_router = APIRouter() +api_router.include_router(auth_router) +api_router.include_router(users_router) +api_router.include_router(organization_router) +api_router.include_router(doctors_router) +api_router.include_router(chemists_router) +api_router.include_router(csv_data_router) +api_router.include_router(products_router) +api_router.include_router(reports_router) +api_router.include_router(audit_router) diff --git a/app/approvals/__init__.py b/app/approvals/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/app/approvals/state_machine.py b/app/approvals/state_machine.py new file mode 100644 index 0000000..ad7836d --- /dev/null +++ b/app/approvals/state_machine.py @@ -0,0 +1,84 @@ +"""The approval workflow for the revised business requirement. + + DRAFT --submit(MR)--> PENDING_AM + RETURNED --submit(MR)--> PENDING_AM + PENDING_AM --approve(AM)--> APPROVED (terminal, immutable) + PENDING_AM --return(AM)--> RETURNED + +The Area Manager is the final approver; there is no General Manager stage. +""" + +from dataclasses import dataclass + +from app.common.enums import EDITABLE_STATUSES, DCRStatus, Role, WorkflowAction +from app.common.exceptions import ForbiddenError, InvalidStateTransitionError + + +@dataclass(frozen=True) +class Transition: + from_status: DCRStatus + action: WorkflowAction + to_status: DCRStatus + allowed_role: Role + requires_reason: bool = False + + +TRANSITIONS: tuple[Transition, ...] = ( + Transition(DCRStatus.DRAFT, WorkflowAction.SUBMIT, DCRStatus.PENDING_AM, Role.MR), + Transition(DCRStatus.RETURNED, WorkflowAction.SUBMIT, DCRStatus.PENDING_AM, Role.MR), + Transition(DCRStatus.PENDING_AM, WorkflowAction.APPROVE, DCRStatus.APPROVED, Role.AM), + Transition( + DCRStatus.PENDING_AM, WorkflowAction.RETURN, DCRStatus.RETURNED, Role.AM, + requires_reason=True, + ), +) + +_INDEX: dict[tuple[DCRStatus, WorkflowAction], Transition] = { + (t.from_status, t.action): t for t in TRANSITIONS +} + + +def find_transition(status: DCRStatus, action: WorkflowAction) -> Transition | None: + return _INDEX.get((status, action)) + + +def assert_transition(status: DCRStatus, action: WorkflowAction, role: Role) -> Transition: + """Validate a requested move and return the transition to apply. + + Raises InvalidStateTransitionError (409) if the move does not exist from this + status, and ForbiddenError (403) if it exists but this role may not make it. + ADMIN never matches any transition — SEC-2: the System Administrator can never + approve a report. + """ + transition = find_transition(status, action) + if transition is None: + raise InvalidStateTransitionError( + f"Cannot {action.value.lower()} a report in status {status.value}", + { + "current_status": status.value, + "attempted_action": action.value, + "allowed_actions": sorted( + t.action.value for t in TRANSITIONS if t.from_status == status + ), + }, + ) + if transition.allowed_role != role: + raise ForbiddenError( + f"Role {role.value} may not {action.value.lower()} this report", + {"required_role": transition.allowed_role.value, "your_role": role.value}, + ) + return transition + + +def assert_editable(status: DCRStatus) -> None: + """V9/V10 — report data may only change in DRAFT or RETURNED.""" + if status not in EDITABLE_STATUSES: + from app.common.exceptions import ReportLockedError + + raise ReportLockedError( + f"A report in status {status.value} cannot be modified", + { + "current_status": status.value, + "editable_statuses": sorted(s.value for s in EDITABLE_STATUSES), + }, + ) diff --git a/app/audit/__init__.py b/app/audit/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/app/audit/models.py b/app/audit/models.py new file mode 100644 index 0000000..00f211b --- /dev/null +++ b/app/audit/models.py @@ -0,0 +1,46 @@ +"""Append-only audit log. + +`approval_history` and `comments` were NOT created as separate tables (report §13.2). +Approval history is a filtered query over this table; every comment in this system +attaches to a state change, so it lives in `audit_log.comment`. + +SEC-3: the application must never be granted UPDATE or DELETE on this table. See +`scripts/harden_audit.sql`. +""" + +import uuid +from datetime import datetime +from typing import Any + +from sqlalchemy import DateTime, Enum, ForeignKey, String, Text, func +from sqlalchemy.dialects.postgresql import JSONB +from sqlalchemy.dialects.postgresql import UUID as PGUUID +from sqlalchemy.orm import Mapped, mapped_column + +from app.common.enums import AuditAction, EntityType +from app.database.base import Base, UUIDMixin + + +class AuditLog(Base, UUIDMixin): + __tablename__ = "audit_log" + + actor_user_id: Mapped[uuid.UUID] = mapped_column( + PGUUID(as_uuid=True), ForeignKey("user.id", ondelete="RESTRICT"), nullable=False + ) + entity_type: Mapped[EntityType] = mapped_column( + Enum(EntityType, name="entity_type_enum", native_enum=False, length=30), + nullable=False, + index=True, + ) + entity_id: Mapped[uuid.UUID] = mapped_column(PGUUID(as_uuid=True), nullable=False, index=True) + action: Mapped[AuditAction] = mapped_column( + Enum(AuditAction, name="audit_action_enum", native_enum=False, length=20), nullable=False + ) + before_data: Mapped[dict[str, Any] | None] = mapped_column(JSONB) + after_data: Mapped[dict[str, Any] | None] = mapped_column(JSONB) + #: The manager's reason — business context no automatic row-versioner can capture. + comment: Mapped[str | None] = mapped_column(Text) + ip_address: Mapped[str | None] = mapped_column(String(45)) + created_at: Mapped[datetime] = mapped_column( + DateTime(timezone=True), server_default=func.now(), nullable=False, index=True + ) diff --git a/app/audit/router.py b/app/audit/router.py new file mode 100644 index 0000000..69f7959 --- /dev/null +++ b/app/audit/router.py @@ -0,0 +1,68 @@ +import uuid + +from fastapi import APIRouter, Depends, Query +from sqlalchemy.ext.asyncio import AsyncSession + +from app.audit.schemas import ApprovalHistoryItem, AuditLogRead +from app.audit.service import AuditService +from app.auth.dependencies import assert_can_view_dcr, get_current_user +from app.common.enums import EntityType, Role +from app.common.exceptions import NotFoundError +from app.database.session import get_db +from app.reports.repository import DCRRepository +from app.users.models import User + +router = APIRouter(prefix="/audit", tags=["audit"]) + + +@router.get("", response_model=list[AuditLogRead]) +async def get_audit_history( + entity_type: EntityType = Query(...), + entity_id: uuid.UUID = Query(...), + current_user: User = Depends(get_current_user), + db: AsyncSession = Depends(get_db), +): + """Scoped audit history. + + For a report, the caller must be able to view the report itself — the audit log is + not a side door around the data-scope rules. + """ + if entity_type == EntityType.DCR: + dcr = await DCRRepository(db).get(entity_id) + if dcr is None: + raise NotFoundError("Report not found") + await assert_can_view_dcr(db, current_user, dcr) + elif current_user.role not in (Role.ADMIN, Role.GM): + from app.common.exceptions import ForbiddenError + + raise ForbiddenError("Only ADMIN or GM may read non-report audit history") + + return await AuditService(db).history_for(entity_type, entity_id) + + +@router.get("/dcr/{dcr_id}/approval-history", response_model=list[ApprovalHistoryItem]) +async def approval_history( + dcr_id: uuid.UUID, + current_user: User = Depends(get_current_user), + db: AsyncSession = Depends(get_db), +) -> list[ApprovalHistoryItem]: + """"Approval history" is a filtered view over audit_log, not a second table.""" + dcr = await DCRRepository(db).get(dcr_id) + if dcr is None: + raise NotFoundError("Report not found") + await assert_can_view_dcr(db, current_user, dcr) + + entries = await AuditService(db).approval_history_for(dcr_id) + items: list[ApprovalHistoryItem] = [] + for entry in entries: + actor = await db.get(User, entry.actor_user_id) + items.append( + ApprovalHistoryItem( + action=entry.action, + actor_name=actor.full_name if actor else "Unknown", + actor_role=actor.role.value if actor else "-", + comment=entry.comment, + at=entry.created_at, + ) + ) + return items diff --git a/app/audit/schemas.py b/app/audit/schemas.py new file mode 100644 index 0000000..48cc7ab --- /dev/null +++ b/app/audit/schemas.py @@ -0,0 +1,32 @@ +import uuid +from datetime import datetime +from typing import Any + +from pydantic import BaseModel, ConfigDict + +from app.common.enums import AuditAction, EntityType + + +class AuditLogRead(BaseModel): + model_config = ConfigDict(from_attributes=True) + + id: uuid.UUID + actor_user_id: uuid.UUID + entity_type: EntityType + entity_id: uuid.UUID + action: AuditAction + comment: str | None + before_data: dict[str, Any] | None + after_data: dict[str, Any] | None + ip_address: str | None + created_at: datetime + + +class ApprovalHistoryItem(BaseModel): + """The approval trail as shown on S7 and printed in the PDF.""" + + action: AuditAction + actor_name: str + actor_role: str + comment: str | None + at: datetime diff --git a/app/audit/service.py b/app/audit/service.py new file mode 100644 index 0000000..1afd643 --- /dev/null +++ b/app/audit/service.py @@ -0,0 +1,80 @@ +"""Explicit, application-level audit logging. + +Deliberately NOT automatic row-versioning (report §14.3 C4): an automatic versioner +records *what* changed but cannot record *why* — and the manager's return reason is +the single most important thing in this audit trail. + +Every `log()` call happens inside the caller's transaction, so a state change and its +audit row commit together or not at all (V12). +""" + +import uuid +from typing import Any + +from sqlalchemy import select +from sqlalchemy.ext.asyncio import AsyncSession + +from app.audit.models import AuditLog +from app.common.enums import AuditAction, EntityType + + +class AuditService: + def __init__(self, db: AsyncSession) -> None: + self.db = db + + async def log( + self, + *, + actor_user_id: uuid.UUID, + entity_type: EntityType, + entity_id: uuid.UUID, + action: AuditAction, + before: dict[str, Any] | None = None, + after: dict[str, Any] | None = None, + comment: str | None = None, + ip_address: str | None = None, + ) -> AuditLog: + entry = AuditLog( + actor_user_id=actor_user_id, + entity_type=entity_type, + entity_id=entity_id, + action=action, + before_data=before, + after_data=after, + comment=comment, + ip_address=ip_address, + ) + self.db.add(entry) + # Flush, not commit — the caller owns the transaction boundary. + await self.db.flush() + return entry + + async def history_for( + self, entity_type: EntityType, entity_id: uuid.UUID + ) -> list[AuditLog]: + stmt = ( + select(AuditLog) + .where(AuditLog.entity_type == entity_type, AuditLog.entity_id == entity_id) + .order_by(AuditLog.created_at.asc()) + ) + return list((await self.db.execute(stmt)).scalars().all()) + + async def approval_history_for(self, dcr_id: uuid.UUID) -> list[AuditLog]: + """"Approval history" is a FILTERED QUERY, not a second table (report §13.2).""" + workflow_actions = [ + AuditAction.CREATE, + AuditAction.SUBMIT, + AuditAction.FORWARD, + AuditAction.RETURN, + AuditAction.APPROVE, + ] + stmt = ( + select(AuditLog) + .where( + AuditLog.entity_type == EntityType.DCR, + AuditLog.entity_id == dcr_id, + AuditLog.action.in_(workflow_actions), + ) + .order_by(AuditLog.created_at.asc()) + ) + return list((await self.db.execute(stmt)).scalars().all()) diff --git a/app/auth/__init__.py b/app/auth/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/app/auth/dependencies.py b/app/auth/dependencies.py new file mode 100644 index 0000000..053dad3 --- /dev/null +++ b/app/auth/dependencies.py @@ -0,0 +1,111 @@ +"""The permission core — two layers. + +Layer 1 (`require_role`) answers "WHAT may this role do?". +Layer 2 (`assert_can_*`) answers "WHOSE data may this specific user touch?". + +Most RBAC bugs live in the gap between those two questions: "AM" is a role, but +"AM *of this headquarters*" is a scope. Both checks are mandatory on scoped +endpoints, and every one has a negative test asserting 403 (X1-X3). +""" + +import uuid + +from fastapi import Depends, Request +from fastapi.security import HTTPAuthorizationCredentials, HTTPBearer +from sqlalchemy import select +from sqlalchemy.ext.asyncio import AsyncSession + +from app.auth.security import decode_access_token +from app.common.enums import Role +from app.common.exceptions import ForbiddenError, UnauthorizedError +from app.database.session import get_db +from app.organization.models import AMHeadquarters +from app.users.models import User + +bearer_scheme = HTTPBearer(auto_error=False) + + +async def get_current_user( + credentials: HTTPAuthorizationCredentials | None = Depends(bearer_scheme), + db: AsyncSession = Depends(get_db), +) -> User: + if credentials is None: + raise UnauthorizedError("Missing bearer token") + + payload = decode_access_token(credentials.credentials) + try: + user_id = uuid.UUID(payload["sub"]) + except (KeyError, ValueError) as exc: + raise UnauthorizedError("Malformed token subject") from exc + + user = await db.get(User, user_id) + if user is None: + raise UnauthorizedError("User no longer exists") + # SEC-5: checked on EVERY request, not only at login. + if not user.is_active: + raise UnauthorizedError("User account is deactivated") + return user + + +def require_role(*allowed: Role): + """Layer 1. Usage: `user: User = Depends(require_role(Role.MR))`.""" + + async def _check(user: User = Depends(get_current_user)) -> User: + if user.role not in allowed: + raise ForbiddenError( + "Role not permitted for this action", + {"your_role": user.role.value, "required": [r.value for r in allowed]}, + ) + return user + + return _check + + +async def active_hq_ids_for_am(db: AsyncSession, am_user_id: uuid.UUID) -> set[uuid.UUID]: + """Headquarters this Area Manager currently manages (`effective_to IS NULL`).""" + stmt = select(AMHeadquarters.headquarters_id).where( + AMHeadquarters.area_manager_user_id == am_user_id, + AMHeadquarters.effective_to.is_(None), + ) + return set((await db.execute(stmt)).scalars().all()) + + +async def visible_hq_ids(db: AsyncSession, user: User) -> set[uuid.UUID] | None: + """Headquarters the user may see. `None` means "all" (GM and ADMIN).""" + if user.role in (Role.GM, Role.ADMIN): + return None + if user.role == Role.AM: + return await active_hq_ids_for_am(db, user.id) + if user.role == Role.MR: + return {user.headquarters_id} if user.headquarters_id else set() + return set() + + +async def assert_can_view_hq(db: AsyncSession, user: User, headquarters_id: uuid.UUID) -> None: + allowed = await visible_hq_ids(db, user) + if allowed is None or headquarters_id in allowed: + return + raise ForbiddenError("Headquarters outside your data scope") + + +async def assert_can_view_dcr(db: AsyncSession, user: User, dcr) -> None: + """Layer 2 for reports. + + ADMIN may inspect report content for support and administration, but cannot act on + reports because every transition endpoint still requires the AM role. + """ + if user.role in (Role.GM, Role.ADMIN): + return + if user.role == Role.MR and dcr.mr_user_id == user.id: + return + if user.role == Role.AM: + if dcr.headquarters_id in await active_hq_ids_for_am(db, user.id): + return + raise ForbiddenError("Report outside your data scope") + + +def client_ip(request: Request) -> str | None: + forwarded = request.headers.get("x-forwarded-for") + if forwarded: + return forwarded.split(",")[0].strip() + return request.client.host if request.client else None diff --git a/app/auth/models.py b/app/auth/models.py new file mode 100644 index 0000000..03d8d7e --- /dev/null +++ b/app/auth/models.py @@ -0,0 +1,26 @@ +"""Server-side refresh tokens. + +Stored server-side (not stateless) precisely so they can be REVOKED — a departing MR +must lose access immediately (SEC-5). +""" + +import uuid +from datetime import datetime + +from sqlalchemy import Boolean, DateTime, ForeignKey, String +from sqlalchemy.dialects.postgresql import UUID as PGUUID +from sqlalchemy.orm import Mapped, mapped_column + +from app.database.base import Base, TimestampMixin, UUIDMixin + + +class RefreshToken(Base, UUIDMixin, TimestampMixin): + __tablename__ = "refresh_token" + + user_id: Mapped[uuid.UUID] = mapped_column( + PGUUID(as_uuid=True), ForeignKey("user.id", ondelete="CASCADE"), nullable=False, index=True + ) + #: SHA-256 of the token — a database leak must not yield usable tokens. + token_hash: Mapped[str] = mapped_column(String(64), nullable=False, unique=True, index=True) + expires_at: Mapped[datetime] = mapped_column(DateTime(timezone=True), nullable=False) + revoked: Mapped[bool] = mapped_column(Boolean, default=False, nullable=False) diff --git a/app/auth/router.py b/app/auth/router.py new file mode 100644 index 0000000..cf634a5 --- /dev/null +++ b/app/auth/router.py @@ -0,0 +1,34 @@ +from fastapi import APIRouter, Depends, Request, status +from sqlalchemy.ext.asyncio import AsyncSession + +from app.auth.dependencies import client_ip, get_current_user +from app.auth.schemas import CurrentUser, LoginRequest, RefreshRequest, TokenPair +from app.auth.service import AuthService +from app.database.session import get_db +from app.users.models import User + +router = APIRouter(prefix="/auth", tags=["auth"]) + + +@router.post("/login", response_model=TokenPair) +async def login( + payload: LoginRequest, request: Request, db: AsyncSession = Depends(get_db) +) -> TokenPair: + return await AuthService(db).login(payload.email, payload.password, client_ip(request)) + + +@router.post("/refresh", response_model=TokenPair) +async def refresh(payload: RefreshRequest, db: AsyncSession = Depends(get_db)) -> TokenPair: + return await AuthService(db).refresh(payload.refresh_token) + + +@router.post("/logout", status_code=status.HTTP_204_NO_CONTENT) +async def logout( + current_user: User = Depends(get_current_user), db: AsyncSession = Depends(get_db) +) -> None: + await AuthService(db).logout(current_user.id) + + +@router.get("/me", response_model=CurrentUser) +async def me(current_user: User = Depends(get_current_user)) -> User: + return current_user diff --git a/app/auth/schemas.py b/app/auth/schemas.py new file mode 100644 index 0000000..66b2be0 --- /dev/null +++ b/app/auth/schemas.py @@ -0,0 +1,33 @@ +import uuid + +from pydantic import BaseModel, ConfigDict, EmailStr, Field + +from app.common.enums import Role + + +class LoginRequest(BaseModel): + email: EmailStr + password: str = Field(min_length=1) + + +class TokenPair(BaseModel): + access_token: str + refresh_token: str + token_type: str = "bearer" + expires_in: int + + +class RefreshRequest(BaseModel): + refresh_token: str + + +class CurrentUser(BaseModel): + model_config = ConfigDict(from_attributes=True) + + id: uuid.UUID + email: str + full_name: str + employee_code: str + role: Role + headquarters_id: uuid.UUID | None + is_active: bool diff --git a/app/auth/security.py b/app/auth/security.py new file mode 100644 index 0000000..5062e55 --- /dev/null +++ b/app/auth/security.py @@ -0,0 +1,65 @@ +"""Password hashing and JWT encoding/decoding.""" + +import hashlib +import secrets +import uuid +from datetime import UTC, datetime, timedelta +from typing import Any + +from argon2 import PasswordHasher +from argon2.exceptions import VerificationError, VerifyMismatchError +from jose import JWTError, jwt + +from app.common.exceptions import UnauthorizedError +from app.config.settings import settings + +_hasher = PasswordHasher() + + +def utcnow() -> datetime: + return datetime.now(UTC) + + +def hash_password(plain: str) -> str: + return _hasher.hash(plain) + + +def verify_password(plain: str, hashed: str) -> bool: + try: + _hasher.verify(hashed, plain) + return True + except (VerifyMismatchError, VerificationError): + return False + + +def create_access_token(user_id: uuid.UUID, role: str) -> str: + now = utcnow() + payload: dict[str, Any] = { + "sub": str(user_id), + "role": role, + "type": "access", + "iat": now, + "exp": now + timedelta(minutes=settings.ACCESS_TOKEN_EXPIRE_MINUTES), + "jti": secrets.token_urlsafe(16), + } + return jwt.encode(payload, settings.SECRET_KEY, algorithm=settings.JWT_ALGORITHM) + + +def decode_access_token(token: str) -> dict[str, Any]: + try: + payload = jwt.decode(token, settings.SECRET_KEY, algorithms=[settings.JWT_ALGORITHM]) + except JWTError as exc: + raise UnauthorizedError("Invalid or expired token") from exc + if payload.get("type") != "access": + raise UnauthorizedError("Wrong token type") + return payload + + +def generate_refresh_token() -> tuple[str, str]: + """Return (plaintext_token, sha256_hash). Only the hash is stored.""" + raw = secrets.token_urlsafe(48) + return raw, hash_refresh_token(raw) + + +def hash_refresh_token(raw: str) -> str: + return hashlib.sha256(raw.encode()).hexdigest() diff --git a/app/auth/service.py b/app/auth/service.py new file mode 100644 index 0000000..7f0055a --- /dev/null +++ b/app/auth/service.py @@ -0,0 +1,100 @@ +import uuid +from datetime import timedelta + +from sqlalchemy import select +from sqlalchemy.ext.asyncio import AsyncSession + +from app.audit.service import AuditService +from app.auth.models import RefreshToken +from app.auth.schemas import TokenPair +from app.auth.security import ( + create_access_token, + generate_refresh_token, + hash_refresh_token, + utcnow, + verify_password, +) +from app.common.enums import AuditAction, EntityType +from app.common.exceptions import UnauthorizedError +from app.config.settings import settings +from app.users.models import User + + +class AuthService: + def __init__(self, db: AsyncSession) -> None: + self.db = db + self.audit = AuditService(db) + + async def login(self, email: str, password: str, ip: str | None = None) -> TokenPair: + stmt = select(User).where(User.email == email) + user = (await self.db.execute(stmt)).scalar_one_or_none() + + # Same message for unknown user and wrong password — do not leak which. + if user is None or not verify_password(password, user.password_hash): + if user is not None: + user.failed_login_attempts += 1 + await self.db.commit() + raise UnauthorizedError("Invalid email or password") + + if not user.is_active: + raise UnauthorizedError("User account is deactivated") + + # SEC-10 — lock out after repeated failures. + if user.failed_login_attempts >= settings.LOGIN_MAX_FAILED_ATTEMPTS: + raise UnauthorizedError("Account locked after too many failed attempts") + + user.failed_login_attempts = 0 + await self.audit.log( + actor_user_id=user.id, + entity_type=EntityType.USER, + entity_id=user.id, + action=AuditAction.LOGIN, + ip_address=ip, + ) + pair = await self._issue_tokens(user) + await self.db.commit() + return pair + + async def refresh(self, raw_token: str) -> TokenPair: + token_hash = hash_refresh_token(raw_token) + stmt = select(RefreshToken).where(RefreshToken.token_hash == token_hash) + stored = (await self.db.execute(stmt)).scalar_one_or_none() + + if stored is None or stored.revoked or stored.expires_at < utcnow(): + raise UnauthorizedError("Invalid or expired refresh token") + + user = await self.db.get(User, stored.user_id) + if user is None or not user.is_active: + raise UnauthorizedError("User no longer active") + + # Rotate: the presented token is burned as the new one is issued. + stored.revoked = True + pair = await self._issue_tokens(user) + await self.db.commit() + return pair + + async def logout(self, user_id: uuid.UUID) -> None: + """Revoke every refresh token for this user.""" + stmt = select(RefreshToken).where( + RefreshToken.user_id == user_id, RefreshToken.revoked.is_(False) + ) + for token in (await self.db.execute(stmt)).scalars().all(): + token.revoked = True + await self.db.commit() + + async def _issue_tokens(self, user: User) -> TokenPair: + access = create_access_token(user.id, user.role.value) + raw_refresh, refresh_hash = generate_refresh_token() + self.db.add( + RefreshToken( + user_id=user.id, + token_hash=refresh_hash, + expires_at=utcnow() + timedelta(days=settings.REFRESH_TOKEN_EXPIRE_DAYS), + ) + ) + await self.db.flush() + return TokenPair( + access_token=access, + refresh_token=raw_refresh, + expires_in=settings.ACCESS_TOKEN_EXPIRE_MINUTES * 60, + ) diff --git a/app/chemists/__init__.py b/app/chemists/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/app/chemists/models.py b/app/chemists/models.py new file mode 100644 index 0000000..912fcd9 --- /dev/null +++ b/app/chemists/models.py @@ -0,0 +1,52 @@ +"""Chemist master data and chemist → MR assignment (same shape as doctors).""" + +import uuid +from datetime import date + +from sqlalchemy import Boolean, Date, ForeignKey, Index, String, UniqueConstraint, text +from sqlalchemy.dialects.postgresql import UUID as PGUUID +from sqlalchemy.orm import Mapped, mapped_column, relationship + +from app.database.base import Base, TimestampMixin, UUIDMixin + + +class Chemist(Base, UUIDMixin, TimestampMixin): + __tablename__ = "chemist" + __table_args__ = ( + UniqueConstraint( + "headquarters_id", "name", "shop_address", name="uq_chemist_hq_name_shop" + ), + ) + + headquarters_id: Mapped[uuid.UUID] = mapped_column( + PGUUID(as_uuid=True), ForeignKey("headquarters.id", ondelete="RESTRICT"), nullable=False + ) + name: Mapped[str] = mapped_column(String(200), nullable=False) + shop_address: Mapped[str] = mapped_column(String(500), nullable=False) + contact_number: Mapped[str | None] = mapped_column(String(20)) + is_active: Mapped[bool] = mapped_column(Boolean, default=True, nullable=False) + + assignments: Mapped[list["ChemistAssignment"]] = relationship(back_populates="chemist") + + +class ChemistAssignment(Base, UUIDMixin, TimestampMixin): + __tablename__ = "chemist_assignment" + __table_args__ = ( + Index( + "uq_active_chemist_assignment", + "chemist_id", + unique=True, + postgresql_where=text("effective_to IS NULL"), + ), + ) + + chemist_id: Mapped[uuid.UUID] = mapped_column( + PGUUID(as_uuid=True), ForeignKey("chemist.id", ondelete="CASCADE"), nullable=False + ) + mr_user_id: Mapped[uuid.UUID] = mapped_column( + PGUUID(as_uuid=True), ForeignKey("user.id", ondelete="RESTRICT"), nullable=False + ) + effective_from: Mapped[date] = mapped_column(Date, nullable=False) + effective_to: Mapped[date | None] = mapped_column(Date) + + chemist: Mapped["Chemist"] = relationship(back_populates="assignments") diff --git a/app/chemists/router.py b/app/chemists/router.py new file mode 100644 index 0000000..05abe2d --- /dev/null +++ b/app/chemists/router.py @@ -0,0 +1,62 @@ +import uuid + +from fastapi import APIRouter, Depends, Request, status +from sqlalchemy.ext.asyncio import AsyncSession + +from app.auth.dependencies import client_ip, get_current_user, require_role +from app.chemists.models import Chemist +from app.chemists.schemas import ChemistCreate, ChemistRead, ChemistUpdate +from app.chemists.service import ChemistService +from app.common.enums import Role +from app.database.session import get_db +from app.doctors.schemas import AssignToMR +from app.users.models import User + +router = APIRouter(prefix="/chemists", tags=["chemists"]) + + +@router.get("", response_model=list[ChemistRead]) +async def list_chemists( + current_user: User = Depends(get_current_user), db: AsyncSession = Depends(get_db) +) -> list[Chemist]: + return await ChemistService(db).list_for(current_user) + + +@router.post("", response_model=ChemistRead, status_code=status.HTTP_201_CREATED) +async def create_chemist( + payload: ChemistCreate, + request: Request, + current_user: User = Depends(require_role(Role.ADMIN)), + db: AsyncSession = Depends(get_db), +) -> Chemist: + return await ChemistService(db).create(payload, current_user, client_ip(request)) + + +@router.patch("/{chemist_id}", response_model=ChemistRead) +async def update_chemist( + chemist_id: uuid.UUID, + payload: ChemistUpdate, + request: Request, + current_user: User = Depends(require_role(Role.ADMIN)), + db: AsyncSession = Depends(get_db), +) -> Chemist: + return await ChemistService(db).update(chemist_id, payload, current_user, client_ip(request)) + + +@router.post("/{chemist_id}/assign", status_code=status.HTTP_201_CREATED) +async def assign_chemist( + chemist_id: uuid.UUID, + payload: AssignToMR, + request: Request, + current_user: User = Depends(require_role(Role.ADMIN, Role.GM, Role.AM)), + db: AsyncSession = Depends(get_db), +): + assignment = await ChemistService(db).assign_to_mr( + chemist_id, payload.mr_user_id, payload.effective_from, current_user, client_ip(request) + ) + return { + "id": assignment.id, + "chemist_id": assignment.chemist_id, + "mr_user_id": assignment.mr_user_id, + "effective_from": assignment.effective_from, + } diff --git a/app/chemists/schemas.py b/app/chemists/schemas.py new file mode 100644 index 0000000..92e7feb --- /dev/null +++ b/app/chemists/schemas.py @@ -0,0 +1,28 @@ +import uuid + +from pydantic import BaseModel, ConfigDict, Field + + +class ChemistCreate(BaseModel): + headquarters_id: uuid.UUID + name: str = Field(min_length=2, max_length=200) + shop_address: str = Field(min_length=2, max_length=500) + contact_number: str | None = Field(default=None, max_length=20) + + +class ChemistUpdate(BaseModel): + name: str | None = Field(default=None, min_length=2, max_length=200) + shop_address: str | None = Field(default=None, min_length=2, max_length=500) + contact_number: str | None = Field(default=None, max_length=20) + is_active: bool | None = None + + +class ChemistRead(BaseModel): + model_config = ConfigDict(from_attributes=True) + + id: uuid.UUID + headquarters_id: uuid.UUID + name: str + shop_address: str + contact_number: str | None + is_active: bool diff --git a/app/chemists/service.py b/app/chemists/service.py new file mode 100644 index 0000000..fcfa1b6 --- /dev/null +++ b/app/chemists/service.py @@ -0,0 +1,143 @@ +import uuid +from datetime import date + +from sqlalchemy import select +from sqlalchemy.exc import IntegrityError +from sqlalchemy.ext.asyncio import AsyncSession + +from app.audit.service import AuditService +from app.auth.dependencies import assert_can_view_hq, visible_hq_ids +from app.chemists.models import Chemist, ChemistAssignment +from app.chemists.schemas import ChemistCreate, ChemistUpdate +from app.common.enums import AuditAction, EntityType, Role +from app.common.exceptions import ConflictError, NotFoundError, ValidationError +from app.common.utils import snapshot +from app.users.models import User + +_AUDIT_FIELDS = ["name", "shop_address", "contact_number", "is_active"] + + +class ChemistService: + def __init__(self, db: AsyncSession) -> None: + self.db = db + self.audit = AuditService(db) + + async def create(self, data: ChemistCreate, actor: User, ip: str | None = None) -> Chemist: + await assert_can_view_hq(self.db, actor, data.headquarters_id) + + chemist = Chemist(**data.model_dump()) + self.db.add(chemist) + try: + await self.db.flush() + except IntegrityError as exc: + await self.db.rollback() + raise ConflictError( + "A chemist with this name already exists at this address in this headquarters", + {"cause": "uq_chemist_hq_name_shop"}, + ) from exc + + await self.audit.log( + actor_user_id=actor.id, + entity_type=EntityType.CHEMIST, + entity_id=chemist.id, + action=AuditAction.CREATE, + after=snapshot(chemist, _AUDIT_FIELDS), + ip_address=ip, + ) + await self.db.commit() + return chemist + + async def update( + self, chemist_id: uuid.UUID, data: ChemistUpdate, actor: User, ip: str | None = None + ) -> Chemist: + chemist = await self.db.get(Chemist, chemist_id) + if chemist is None: + raise NotFoundError("Chemist not found") + await assert_can_view_hq(self.db, actor, chemist.headquarters_id) + + before = snapshot(chemist, _AUDIT_FIELDS) + for field, value in data.model_dump(exclude_unset=True).items(): + setattr(chemist, field, value) + + await self.audit.log( + actor_user_id=actor.id, + entity_type=EntityType.CHEMIST, + entity_id=chemist.id, + action=AuditAction.UPDATE, + before=before, + after=snapshot(chemist, _AUDIT_FIELDS), + ip_address=ip, + ) + await self.db.commit() + return chemist + + async def list_for(self, actor: User) -> list[Chemist]: + if actor.role == Role.MR: + stmt = ( + select(Chemist) + .join(ChemistAssignment, ChemistAssignment.chemist_id == Chemist.id) + .where( + ChemistAssignment.mr_user_id == actor.id, + ChemistAssignment.effective_to.is_(None), + Chemist.is_active.is_(True), + ) + .order_by(Chemist.name) + ) + return list((await self.db.execute(stmt)).scalars().all()) + + allowed = await visible_hq_ids(self.db, actor) + stmt = select(Chemist).order_by(Chemist.name) + if allowed is not None: + stmt = stmt.where(Chemist.headquarters_id.in_(allowed or [None])) + return list((await self.db.execute(stmt)).scalars().all()) + + async def assign_to_mr( + self, + chemist_id: uuid.UUID, + mr_user_id: uuid.UUID, + effective_from: date | None, + actor: User, + ip: str | None = None, + ) -> ChemistAssignment: + chemist = await self.db.get(Chemist, chemist_id) + if chemist is None: + raise NotFoundError("Chemist not found") + await assert_can_view_hq(self.db, actor, chemist.headquarters_id) + + mr = await self.db.get(User, mr_user_id) + if mr is None: + raise NotFoundError("MR not found") + if mr.role != Role.MR: + raise ValidationError("Chemists can only be assigned to an MR") + if mr.headquarters_id != chemist.headquarters_id: + raise ValidationError("MR and chemist belong to different headquarters") + + start = effective_from or date.today() + existing = ( + await self.db.execute( + select(ChemistAssignment).where( + ChemistAssignment.chemist_id == chemist_id, + ChemistAssignment.effective_to.is_(None), + ) + ) + ).scalars().all() + for row in existing: + if row.mr_user_id == mr_user_id: + return row + row.effective_to = start + await self.db.flush() + + assignment = ChemistAssignment( + chemist_id=chemist_id, mr_user_id=mr_user_id, effective_from=start + ) + self.db.add(assignment) + await self.audit.log( + actor_user_id=actor.id, + entity_type=EntityType.CHEMIST, + entity_id=chemist_id, + action=AuditAction.ASSIGN, + after={"mr_user_id": str(mr_user_id), "effective_from": start.isoformat()}, + ip_address=ip, + ) + await self.db.commit() + return assignment diff --git a/app/common/__init__.py b/app/common/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/app/common/enums.py b/app/common/enums.py new file mode 100644 index 0000000..02631aa --- /dev/null +++ b/app/common/enums.py @@ -0,0 +1,83 @@ +"""Domain enumerations. + +Roles are a fixed enum on `user.role`, not a `role` table — with 4 roles that never +change at runtime a lookup table adds a join to every request and buys nothing. +(See report §13.2.) +""" + +from enum import StrEnum + + +class Role(StrEnum): + """Operational roles (MR/AM/GM) plus the technical ADMIN role. + + ADMIN sits OUTSIDE the business hierarchy. It provisions users and masters but + can never approve a report or read report content (report §8, SEC-2). + """ + + ADMIN = "ADMIN" + GM = "GM" + AM = "AM" + MR = "MR" + + +class DCRStatus(StrEnum): + """MR submits, the Area Manager approves or returns it. + + `RETURNED` captures the correction loop, and `APPROVED` remains terminal and + immutable. There is no General Manager step. + """ + + DRAFT = "DRAFT" + PENDING_AM = "PENDING_AM" + RETURNED = "RETURNED" + APPROVED = "APPROVED" + + +#: Statuses in which the owning MR may still change report data (V9). +EDITABLE_STATUSES: frozenset[DCRStatus] = frozenset( + {DCRStatus.DRAFT, DCRStatus.RETURNED} +) + + +class WorkflowAction(StrEnum): + SUBMIT = "SUBMIT" + RETURN = "RETURN" + APPROVE = "APPROVE" + + +class CallOutcome(StrEnum): + MET = "MET" + NOT_AVAILABLE = "NOT_AVAILABLE" + RESCHEDULED = "RESCHEDULED" + + +class ConversionStatus(StrEnum): + """Core-doctor conversion. Stored as a column on doctor_call, not a table.""" + + NOT_STARTED = "NOT_STARTED" + IN_PROGRESS = "IN_PROGRESS" + CONVERTED = "CONVERTED" + LOST = "LOST" + + +class AuditAction(StrEnum): + CREATE = "CREATE" + UPDATE = "UPDATE" + DELETE = "DELETE" + SUBMIT = "SUBMIT" + FORWARD = "FORWARD" + RETURN = "RETURN" + APPROVE = "APPROVE" + ASSIGN = "ASSIGN" + LOGIN = "LOGIN" + DEACTIVATE = "DEACTIVATE" + + +class EntityType(StrEnum): + USER = "user" + HEADQUARTERS = "headquarters" + DOCTOR = "doctor" + CHEMIST = "chemist" + DCR = "dcr" + PRODUCT = "product" diff --git a/app/common/exceptions.py b/app/common/exceptions.py new file mode 100644 index 0000000..9644c9b --- /dev/null +++ b/app/common/exceptions.py @@ -0,0 +1,67 @@ +"""Application error hierarchy → one consistent JSON error envelope.""" + +from typing import Any + + +class AppError(Exception): + """Base for every error the application raises deliberately.""" + + status_code: int = 400 + code: str = "APP_ERROR" + + def __init__(self, message: str, details: dict[str, Any] | None = None) -> None: + self.message = message + self.details = details or {} + super().__init__(message) + + def to_dict(self) -> dict[str, Any]: + return { + "error": { + "code": self.code, + "message": self.message, + "details": self.details, + } + } + + +class NotFoundError(AppError): + status_code = 404 + code = "NOT_FOUND" + + +class ForbiddenError(AppError): + """Raised for both role failures and data-scope failures. + + Deliberately 403 and not 404: the negative-scope tests (X1-X3) assert 403, so a + scope bug cannot hide behind an ambiguous "not found". + """ + + status_code = 403 + code = "FORBIDDEN" + + +class UnauthorizedError(AppError): + status_code = 401 + code = "UNAUTHORIZED" + + +class ConflictError(AppError): + status_code = 409 + code = "CONFLICT" + + +class ValidationError(AppError): + status_code = 422 + code = "VALIDATION_ERROR" + + +class InvalidStateTransitionError(AppError): + status_code = 409 + code = "INVALID_STATE_TRANSITION" + + +class ReportLockedError(AppError): + """V10 — an APPROVED report can never be modified by any role.""" + + status_code = 409 + code = "REPORT_LOCKED" diff --git a/app/common/repository.py b/app/common/repository.py new file mode 100644 index 0000000..47e38fb --- /dev/null +++ b/app/common/repository.py @@ -0,0 +1,35 @@ +"""Generic data-access base. Repositories hold queries only — never business rules.""" + +import uuid +from typing import Generic, TypeVar + +from sqlalchemy import select +from sqlalchemy.ext.asyncio import AsyncSession + +from app.common.exceptions import NotFoundError +from app.database.base import Base + +ModelT = TypeVar("ModelT", bound=Base) + + +class BaseRepository(Generic[ModelT]): + model: type[ModelT] + + def __init__(self, db: AsyncSession) -> None: + self.db = db + + async def get(self, entity_id: uuid.UUID) -> ModelT | None: + return await self.db.get(self.model, entity_id) + + async def get_or_404(self, entity_id: uuid.UUID) -> ModelT: + entity = await self.get(entity_id) + if entity is None: + raise NotFoundError(f"{self.model.__name__} not found", {"id": str(entity_id)}) + return entity + + async def list_all(self) -> list[ModelT]: + return list((await self.db.execute(select(self.model))).scalars().all()) + + def add(self, entity: ModelT) -> ModelT: + self.db.add(entity) + return entity diff --git a/app/common/utils.py b/app/common/utils.py new file mode 100644 index 0000000..3c12a63 --- /dev/null +++ b/app/common/utils.py @@ -0,0 +1,45 @@ +"""Small shared helpers.""" + +import uuid +from datetime import UTC, date, datetime, time +from typing import Any +from zoneinfo import ZoneInfo + +from sqlalchemy import inspect + + +def utcnow() -> datetime: + return datetime.now(UTC) + + +def local_now() -> datetime: + """Current time in the company's timezone (`APP_TIMEZONE`), timezone-aware.""" + from app.config.settings import settings + + return datetime.now(ZoneInfo(settings.APP_TIMEZONE)) + + +def local_today() -> date: + """Today's date in the company's timezone — the server clock runs on UTC.""" + return local_now().date() + + +def _jsonable(value: Any) -> Any: + if isinstance(value, uuid.UUID): + return str(value) + if isinstance(value, datetime | date | time): + return value.isoformat() + if hasattr(value, "value"): # StrEnum and friends + return value.value + return value + + +def snapshot(instance: Any, fields: list[str] | None = None) -> dict[str, Any]: + """Serialise an ORM instance's column values for the audit log's JSONB columns. + + Only loaded column attributes are read, so this never triggers lazy IO inside a + transaction that is about to commit. + """ + mapper = inspect(instance).mapper + names = fields or [c.key for c in mapper.column_attrs] + return {name: _jsonable(getattr(instance, name, None)) for name in names} diff --git a/app/config/__init__.py b/app/config/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/app/config/settings.py b/app/config/settings.py new file mode 100644 index 0000000..a7d1792 --- /dev/null +++ b/app/config/settings.py @@ -0,0 +1,67 @@ +"""Application settings. Everything comes from the environment — no secrets in code.""" + +from functools import lru_cache + +from pydantic import Field +from pydantic_settings import BaseSettings, SettingsConfigDict + + +class Settings(BaseSettings): + model_config = SettingsConfigDict( + env_file=".env", env_file_encoding="utf-8", extra="ignore" + ) + + # --- Application --------------------------------------------------- + APP_NAME: str = "Celtic Life Science Pvt Ltd" + PDF_COMPANY_NAME: str = "CELTIC LIFE SCIENCE PVT LTD" + PDF_COMPANY_ADDRESS: str = "PLOT NO -D/3, KHARVEL NAGAR, UNIT-3, BHUBANESWAR ODISHA-751001" + PDF_COMPANY_WEBSITE: str = "www.celticlifescience.com" + PDF_COMPANY_EMAIL: str = "info@celticlifescience.com" + PDF_COMPANY_PHONE: str = "9090024999" + API_V1_PREFIX: str = "/api/v1" + ENVIRONMENT: str = "development" + DEBUG: bool = False + + # --- Database ------------------------------------------------------ + DATABASE_URL: str = "postgresql+asyncpg://pharma:pharma@localhost:5432/pharma" + DB_ECHO: bool = False + + # --- Authentication ------------------------------------------------ + # SECRET_KEY MUST be overridden in production. + SECRET_KEY: str = "change-me-in-production-this-is-not-a-secret" + JWT_ALGORITHM: str = "HS256" + ACCESS_TOKEN_EXPIRE_MINUTES: int = 15 + REFRESH_TOKEN_EXPIRE_DAYS: int = 7 + LOGIN_MAX_FAILED_ATTEMPTS: int = 10 + + # Business timezone: "today" and visit-time checks use this, not the server's UTC clock. + APP_TIMEZONE: str = "Asia/Kolkata" + + # --- Business rules (see report §21 — confirm with client) ---------- + # A10 / Q8: how many days back an MR may file a report. + BACKDATING_WINDOW_DAYS: int = Field(default=7, ge=0, le=90) + # A16 / Q9: report for date D must be submitted by end of D + this many days. + SUBMISSION_DEADLINE_DAYS: int = Field(default=1, ge=0, le=30) + # V8: minimum length of a manager's return reason. + MIN_RETURN_REASON_LENGTH: int = 10 + + # --- Storage ------------------------------------------------------- + PDF_STORAGE_PATH: str = "./storage/pdf" + + # --- CORS ---------------------------------------------------------- + CORS_ORIGINS: list[str] = Field( + default_factory=lambda: ["https://celtic.upskalor.com", "https://www.celtic.upskalor.com", "http://localhost:5173", "http://localhost:3000"] + ) + + @property + def sync_database_url(self) -> str: + """Alembic runs synchronously through psycopg, not the async API driver.""" + return self.DATABASE_URL.replace("+asyncpg", "+psycopg") + + +@lru_cache +def get_settings() -> Settings: + return Settings() + + +settings = get_settings() diff --git a/app/csv_data/approval.py b/app/csv_data/approval.py new file mode 100644 index 0000000..1829bbf --- /dev/null +++ b/app/csv_data/approval.py @@ -0,0 +1,140 @@ +"""Approval workflow for the company forms that carry an Area Manager signature. + + draft --request(MR)--> pending --approve(AM)--> approved + pending / approved --any change to the rows--> draft (a signature never covers edited data) + +Every MR has their own copy of each form, so approval is per (form, MR). The request goes to the Area +Manager who manages that MR's headquarters, and nobody else can approve it. Only a form that has +rows can be sent, and only a form that has been sent can be approved. +""" + +import uuid + +from sqlalchemy import select, text +from sqlalchemy.ext.asyncio import AsyncSession + +from app.auth.dependencies import active_hq_ids_for_am +from app.common.enums import Role +from app.common.exceptions import ConflictError, ForbiddenError, NotFoundError, ValidationError +from app.csv_data.models import FormApproval +from app.organization.models import AMHeadquarters, Headquarters +from app.users.models import User + +APPROVAL_TABLES = {"standard_tour_plan", "tour_plan", "fare_chart"} + + +async def owners_in_scope(db: AsyncSession, user: User) -> list[User]: + """The MRs whose forms this user may see: themselves, the MRs of their headquarters, or (admin) all.""" + stmt = select(User).where(User.role == Role.MR, User.is_active.is_(True)).order_by(User.full_name) + if user.role == Role.MR: + stmt = stmt.where(User.id == user.id) + elif user.role == Role.AM: + stmt = stmt.where(User.headquarters_id.in_(await active_hq_ids_for_am(db, user.id))) + elif user.role != Role.ADMIN: + return [] + return list((await db.execute(stmt)).scalars()) + + +async def assigned_area_manager(db: AsyncSession, owner: User) -> uuid.UUID | None: + if owner.headquarters_id is None: + return None + stmt = select(AMHeadquarters.area_manager_user_id).where( + AMHeadquarters.headquarters_id == owner.headquarters_id, AMHeadquarters.effective_to.is_(None) + ) + return (await db.execute(stmt)).scalars().first() + + +async def assert_owner_in_scope(db: AsyncSession, user: User, owner_id: uuid.UUID) -> User: + """The MR `owner_id`, if `user` is allowed to see their forms; anything else is refused.""" + for owner in await owners_in_scope(db, user): + if owner.id == owner_id: + return owner + if user.role == Role.ADMIN or (await db.get(User, owner_id)) is None: + raise NotFoundError("Medical representative not found", {"id": str(owner_id)}) + raise ForbiddenError("This form belongs to a medical representative outside your headquarters") + + +async def get_approval(db: AsyncSession, table_name: str, owner_id: uuid.UUID) -> FormApproval | None: + return await db.get(FormApproval, (table_name, owner_id)) + + +async def _get_or_create(db: AsyncSession, table_name: str, owner_id: uuid.UUID) -> FormApproval: + row = await get_approval(db, table_name, owner_id) + if row is None: + row = FormApproval(table_name=table_name, owner_user_id=owner_id, status="draft") + db.add(row) + await db.flush() + return row + + +async def list_approvals(db: AsyncSession, user: User) -> list[tuple[FormApproval, User, str | None]]: + """(approval, MR, headquarters name) for what `user` can see. + + An MR always gets all three forms ("draft" until they act); an Area Manager or admin only + gets forms that have been sent, since a draft is nothing for them to act on. + """ + owners = {o.id: o for o in await owners_in_scope(db, user)} + hq_names = {h.id: h.name for h in (await db.execute(select(Headquarters))).scalars()} + existing = { + (r.table_name, r.owner_user_id): r + for r in (await db.execute(select(FormApproval).where(FormApproval.owner_user_id.in_(owners)))).scalars() + } + out: list[tuple[FormApproval, User, str | None]] = [] + if user.role == Role.MR: + for name in sorted(APPROVAL_TABLES): + out.append((existing.get((name, user.id)) or FormApproval(table_name=name, owner_user_id=user.id, status="draft"), user, hq_names.get(user.headquarters_id))) + return out + for (name, owner_id), row in sorted(existing.items()): + if row.status != "draft": + out.append((row, owners[owner_id], hq_names.get(owners[owner_id].headquarters_id))) + return out + + +async def _row_count(db: AsyncSession, table_name: str, owner_id: uuid.UUID) -> int: + # table_name is only ever one of the fixed APPROVAL_TABLES, never user input. + return ( + await db.execute(text(f'SELECT COUNT(*) FROM "{table_name}" WHERE owner_user_id = :o'), {"o": owner_id}) + ).scalar_one() + + +async def request_approval(db: AsyncSession, table_name: str, actor: User) -> FormApproval: + if await assigned_area_manager(db, actor) is None: + raise ValidationError("No Area Manager is assigned to your headquarters yet. Ask the administrator to assign one.") + row = await _get_or_create(db, table_name, actor.id) + if row.status == "pending": + return row # already with the Area Manager — a second click changes nothing + if row.status == "approved": + raise ConflictError("This form is already approved. Change a row to send it again.") + if await _row_count(db, table_name, actor.id) == 0: + raise ValidationError("Add at least one row before sending the form for approval") + row.status = "pending" + row.requested_by_user_id = actor.id + await db.commit() + await db.refresh(row) + return row + + +async def approve(db: AsyncSession, table_name: str, owner_id: uuid.UUID, actor: User) -> FormApproval: + await assert_owner_in_scope(db, actor, owner_id) # only the Area Manager assigned to this MR's headquarters + row = await _get_or_create(db, table_name, owner_id) + if row.status == "approved": + return row # a double click + if row.status != "pending" or await _row_count(db, table_name, owner_id) == 0: + raise ConflictError("Nothing is waiting for approval on this form") + row.status = "approved" + row.approved_by_user_id = actor.id + row.approved_by_name = actor.full_name + await db.commit() + await db.refresh(row) + return row + + +async def invalidate(db: AsyncSession, table_name: str, owner_id: uuid.UUID | None) -> None: + """The MR's rows changed: any earlier approval no longer applies. The caller commits.""" + if table_name not in APPROVAL_TABLES or owner_id is None: + return + row = await get_approval(db, table_name, owner_id) + if row is not None and row.status != "draft": + row.status = "draft" + row.approved_by_user_id = None + row.approved_by_name = None diff --git a/app/csv_data/config.py b/app/csv_data/config.py new file mode 100644 index 0000000..3cbef86 --- /dev/null +++ b/app/csv_data/config.py @@ -0,0 +1,27 @@ +"""Allow-listed imported CSV tables and their database columns.""" + +TABLES: dict[str, tuple[str, ...]] = { + "sales_projection": ("name", "headquarter", "report_date", "month", "serial_no", "product_name", "pts", "secondary_qty", "value", "closing", "secondary_value", "aug_sales", "value_2"), + "weekly_report": ("employee_name", "report_date", "headquarter", "month", "no_of_days_worked", "no_of_doctor_called", "no_of_chemist_called", "pob_booked", "secondary_sales", "pob_objective", "secondary_objective", "product_offer_scheme_booked", "product_offer_scheme_objective"), + "field_activity_report": ("name", "headquarter", "month", "report_date", "station_worked", "no_of_doctors_called", "no_of_chemists_pds_called", "doctor_call_avg", "chemist_call_avg"), + "fare_chart": ("name", "headquarter", "serial_no", "report_date", "from_location", "to_location", "kilometers_km"), + "daily_call_report_csv": ("name", "headquarter", "report_date", "month", "doctor_sr_no", "doctor_name", "qualification", "product_promote", "product_sample", "remarks", "chemist_sr_no", "chemist_name", "pob", "stockist_visit", "order_value"), + "core_dr_call_conversion": ("name", "headquarter", "month", "doctor_name", "date_of_visit", "product_targeted", "status"), + "area_covered": ("name", "headquarter", "month", "sale_status", "area_to_cover", "sale_objective", "status"), + "sales_and_stock_statement": ("name", "headquarter", "report_date", "month", "serial_no", "product_name", "opening", "receipt", "sale", "closing", "value_in_pts"), + "tour_plan": ("name", "headquarter", "serial_no", "report_date", "from_location", "to_location", "pob", "stockiest_visit"), + "standard_tour_plan": ("name", "headquarter", "serial_no", "place"), +} + +CSV_LABELS = { + "weekly_report": "Weekly Report", + "field_activity_report": "Field Activity Report", + "fare_chart": "Fare Chart", + "daily_call_report_csv": "Daily Call Report CSV", + "core_dr_call_conversion": "Core Doctor Call Conversion", + "area_covered": "Area Covered", + "sales_and_stock_statement": "Sales and Stock Statement", + "tour_plan": "Tour Plan", + "standard_tour_plan": "Standard Tour Plan", + "sales_projection": "Sales Projection", +} \ No newline at end of file diff --git a/app/csv_data/models.py b/app/csv_data/models.py new file mode 100644 index 0000000..ae0b4f3 --- /dev/null +++ b/app/csv_data/models.py @@ -0,0 +1,37 @@ +"""Approval state of the company forms that carry an Area Manager signature.""" + +import uuid +from datetime import datetime + +from sqlalchemy import DateTime, ForeignKey, String, func +from sqlalchemy.dialects.postgresql import UUID as PGUUID +from sqlalchemy.orm import Mapped, mapped_column + +from app.database.base import Base + +#: draft = not sent yet, pending = the MR asked for approval, approved = the Area Manager signed. +FORM_APPROVAL_STATUSES = ("draft", "pending", "approved") + + +class FormApproval(Base): + """One row per (approval form, MR): each MR's tour plan, standard tour plan and fare chart is approved on its own.""" + + __tablename__ = "form_approval" + + table_name: Mapped[str] = mapped_column(String(64), primary_key=True) + #: The MR whose rows these are. + owner_user_id: Mapped[uuid.UUID] = mapped_column( + PGUUID(as_uuid=True), ForeignKey("user.id", ondelete="CASCADE"), primary_key=True + ) + status: Mapped[str] = mapped_column(String(10), nullable=False, default="draft", server_default="draft") + requested_by_user_id: Mapped[uuid.UUID | None] = mapped_column( + PGUUID(as_uuid=True), ForeignKey("user.id", ondelete="SET NULL") + ) + approved_by_user_id: Mapped[uuid.UUID | None] = mapped_column( + PGUUID(as_uuid=True), ForeignKey("user.id", ondelete="SET NULL") + ) + #: The name printed on the PDF. A snapshot, so renaming the user never rewrites a signature. + approved_by_name: Mapped[str | None] = mapped_column(String(200)) + updated_at: Mapped[datetime] = mapped_column( + DateTime(timezone=True), server_default=func.now(), onupdate=func.now(), nullable=False + ) diff --git a/app/csv_data/router.py b/app/csv_data/router.py new file mode 100644 index 0000000..96b7ddd --- /dev/null +++ b/app/csv_data/router.py @@ -0,0 +1,493 @@ +import re +import uuid +from collections.abc import Iterable +from zoneinfo import ZoneInfo + +from fastapi import APIRouter, Body, Depends, Query, status +from fastapi.responses import Response +from sqlalchemy import select, text +from sqlalchemy.ext.asyncio import AsyncSession + +from app.auth.dependencies import require_role +from app.common.enums import Role +from app.common.exceptions import ConflictError, ForbiddenError, NotFoundError, ValidationError +from app.config.settings import settings +from app.csv_data import approval as approvals +from app.csv_data.config import CSV_LABELS, TABLES +from app.database.session import get_db +from app.users.models import User +from app.organization.models import Headquarters + +router = APIRouter(prefix="/csv-data", tags=["CSV data"]) +SERIAL_COLUMNS = {"serial_no", "doctor_sr_no", "chemist_sr_no"} +IDENTITY_COLUMNS = {"name", "employee_name", "headquarter"} +APPROVAL_TABLES = approvals.APPROVAL_TABLES +HIDDEN_TABLES = {"daily_call_report_csv"} +#: Forms where every row belongs to one MR (and is approved by that MR's Area Manager). +OWNED_TABLES = APPROVAL_TABLES + + +def _table(table_name: str) -> tuple[str, ...]: + if table_name not in TABLES: + raise NotFoundError("CSV table not found", {"table": table_name}) + return TABLES[table_name] + + +def _clean_payload(table_name: str, payload: dict[str, object]) -> dict[str, str | None]: + columns = _table(table_name) + unknown = set(payload) - set(columns) + if unknown: + raise ValidationError("Unknown CSV column", {"columns": sorted(unknown)}) + return {column: None if payload.get(column) is None else str(payload.get(column, "")) for column in columns} + + +def _has_user_data(table_name: str, values: dict[str, str | None]) -> bool: + return any(value and column not in SERIAL_COLUMNS for column, value in values.items()) + + +async def _reject_repeat( + table_name: str, values: dict[str, str | None], db: AsyncSession, owner_id: uuid.UUID | None = None +) -> None: + """A row identical to one already in the form is a repeat (a double click), not new data.""" + compared = [c for c in _table(table_name) if c not in SERIAL_COLUMNS] + conditions = " AND ".join(f"COALESCE(\"{c}\", '') = :c_{i}" for i, c in enumerate(compared)) + params: dict[str, object] = {f"c_{i}": (values.get(c) or "") for i, c in enumerate(compared)} + if owner_id is not None: + conditions += " AND owner_user_id = :owner" + params["owner"] = owner_id + if (await db.execute(text(f'SELECT 1 FROM "{table_name}" WHERE {conditions} LIMIT 1'), params)).first(): + raise ConflictError("An identical row already exists in this form") + + +async def _renumber_rows(table_name: str, db: AsyncSession) -> None: + columns = _table(table_name) + # An MR's own form is numbered 1, 2, 3… whoever else has rows in the same table. + partition = "PARTITION BY owner_user_id " if table_name in OWNED_TABLES else "" + serial_updates = "" + for column in columns: + if column in SERIAL_COLUMNS: + serial_updates += f', "{column}" = numbered.serial::text' + await db.execute( + text( + f'''WITH numbered AS ( + SELECT id, + ROW_NUMBER() OVER (ORDER BY source_row_number, id) AS row_number, + ROW_NUMBER() OVER ({partition}ORDER BY source_row_number, id) AS serial + FROM "{table_name}" + ) + UPDATE "{table_name}" AS target + SET source_row_number = numbered.row_number{serial_updates} + FROM numbered + WHERE target.id = numbered.id''' + ) + ) + + +async def _apply_mr_identity( + values: dict[str, str | None], subject: User | None, db: AsyncSession +) -> dict[str, str | None]: + """Fill NAME / HEADQUARTER from the MR the row is for (the signed-in MR, or the one an admin picked).""" + if subject is None or subject.role != Role.MR: + return values + headquarters_name = None + if subject.headquarters_id: + headquarters = await db.get(Headquarters, subject.headquarters_id) + headquarters_name = headquarters.name if headquarters else None + for column in values: + if column in {"name", "employee_name"}: + values[column] = subject.full_name + elif column == "headquarter": + values[column] = headquarters_name + return values + + +async def _present_rows_for_user( + rows: list[dict[str, object]], current_user: User, db: AsyncSession +) -> list[dict[str, object]]: + """Show account identity from the session without changing imported data. + + Admins must see the source values and every row. MRs use the imported rows as + their working data, but identity columns must always reflect the logged-in MR. + """ + if current_user.role != Role.MR: + return rows + + headquarters_name = None + if current_user.headquarters_id: + headquarters = await db.get(Headquarters, current_user.headquarters_id) + headquarters_name = headquarters.name if headquarters else None + + presented: list[dict[str, object]] = [] + for row in rows: + item = dict(row) + if "name" in item: + item["name"] = current_user.full_name + if "employee_name" in item: + item["employee_name"] = current_user.full_name + if "headquarter" in item: + item["headquarter"] = headquarters_name or "" + presented.append(item) + return presented + + +async def _apply_sales_projection_product( + values: dict[str, str | None], db: AsyncSession, current_user: User | None = None +) -> dict[str, str | None]: + if values.get("product_name") is None: + return values + if current_user is not None and current_user.role == Role.ADMIN: + # Admin maintains the product list itself: any product name and PTS may be entered. + if not (values.get("product_name") or "").strip(): + raise ValidationError("Enter a product name") + return values + result = await db.execute( + text( + 'SELECT pts FROM "sales_projection" ' + 'WHERE product_name = :product_name LIMIT 1' + ), + {"product_name": values["product_name"]}, + ) + pts = result.scalar_one_or_none() + if pts is None: + raise ValidationError( + "Choose a product from the Sales Projection product list", + {"product_name": values["product_name"]}, + ) + values["pts"] = str(pts) + return values + + +def _select(table_name: str, columns: Iterable[str]) -> str: + selected = ", ".join(f'"{column}"' for column in columns) + return f'SELECT id, source_row_number, {selected} FROM "{table_name}"' + + +async def _owner_condition( + table_name: str, current_user: User, db: AsyncSession, owner_id: uuid.UUID | None +) -> tuple[list[str], dict[str, object]]: + """Limit an approval form's rows to the MRs this user may see: an MR sees only their own, + an Area Manager only the MRs of their headquarters, an admin anyone (or one chosen MR).""" + if table_name not in OWNED_TABLES: + return [], {} + if current_user.role == Role.MR: + if owner_id not in (None, current_user.id): + raise ForbiddenError("You can only see your own forms") + return ["owner_user_id = :owner"], {"owner": current_user.id} + if owner_id is not None: + await approvals.assert_owner_in_scope(db, current_user, owner_id) + return ["owner_user_id = :owner"], {"owner": owner_id} + if current_user.role == Role.AM: + return ["owner_user_id = ANY(:owners)"], {"owners": [o.id for o in await approvals.owners_in_scope(db, current_user)]} + return [], {} + + +async def _row_owner(table_name: str, row_id: uuid.UUID, current_user: User, db: AsyncSession) -> uuid.UUID | None: + """Who owns this row, after checking `current_user` is allowed to touch it.""" + if table_name not in OWNED_TABLES: + return None + found = (await db.execute(text(f'SELECT owner_user_id FROM "{table_name}" WHERE id = :id'), {"id": row_id})).first() + if found is None: + raise NotFoundError("CSV row not found", {"id": str(row_id)}) + owner_id = found[0] + if current_user.role == Role.MR and owner_id != current_user.id: + raise ForbiddenError("This row belongs to another medical representative") + if current_user.role == Role.AM: + if owner_id is None: + raise ForbiddenError("This row is outside your headquarters") + await approvals.assert_owner_in_scope(db, current_user, owner_id) + return owner_id + + +def _month_filter(table_name: str, month: str | None) -> tuple[list[str], dict[str, object]]: + if not month or not month.strip(): + return [], {} + if "month" not in _table(table_name): + raise ValidationError("This form has no month to filter by", {"table": table_name}) + return ["lower(btrim(COALESCE(\"month\", ''))) = :month"], {"month": month.strip().lower()} + + +async def _load_rows( + table_name: str, db: AsyncSession, current_user: User, owner_id: uuid.UUID | None = None, month: str | None = None +) -> list[dict[str, object]]: + columns = _table(table_name) + conditions, params = await _owner_condition(table_name, current_user, db, owner_id) + more, extra = _month_filter(table_name, month) + where = f" WHERE {' AND '.join(conditions + more)}" if conditions or more else "" + result = await db.execute(text(f"{_select(table_name, columns)}{where} ORDER BY source_row_number"), {**params, **extra}) + return await _present_rows_for_user([dict(row) for row in result.mappings().all()], current_user, db) + + +def _available_csv_tables(current_user: User) -> list[str]: + visible = [name for name in TABLES if name not in HIDDEN_TABLES] + if current_user.role == Role.AM: + return [name for name in visible if name in APPROVAL_TABLES] + return visible + + +def _ensure_table_access(table_name: str, current_user: User) -> None: + if table_name in HIDDEN_TABLES: + raise ForbiddenError("This CSV form is not available for export.", {"table": table_name}) + if current_user.role == Role.AM and table_name not in APPROVAL_TABLES: + raise ForbiddenError("Area Manager can only access approval forms.", {"table": table_name}) + + +@router.get("/tables") +async def list_csv_tables(current_user: User = Depends(require_role(Role.MR, Role.ADMIN, Role.AM))) -> list[dict[str, object]]: + return [{"name": name, "label": CSV_LABELS[name], "columns": list(TABLES[name])} for name in _available_csv_tables(current_user)] + + +async def _signature( + table_name: str, owner_id: uuid.UUID | None, db: AsyncSession +) -> tuple[str | None, str | None, str | None]: + """(status, approver name, approval date/time) for the PDF's signature — decided here, never by the browser. + + It is the approval of the one MR whose rows the PDF holds; a PDF mixing several MRs is never signed.""" + if table_name not in APPROVAL_TABLES: + return None, None, None + row = await approvals.get_approval(db, table_name, owner_id) if owner_id else None + if row is None or row.status != "approved": + return "pending", None, None + when = row.updated_at.astimezone(ZoneInfo(settings.APP_TIMEZONE)).strftime("%d/%m/%Y %H:%M") if row.updated_at else None + return "approved", row.approved_by_name, when + + +def _approval_out(row, owner: User, headquarters_name: str | None = None) -> dict[str, object]: + return { + "table_name": row.table_name, + "owner_user_id": str(owner.id), + "owner_name": owner.full_name, + "headquarters_name": headquarters_name, + "status": row.status, + "approved_by_name": row.approved_by_name, + "updated_at": row.updated_at.isoformat() if row.updated_at else None, + } + + +async def _hq_name(db: AsyncSession, user: User) -> str | None: + headquarters = await db.get(Headquarters, user.headquarters_id) if user.headquarters_id else None + return headquarters.name if headquarters else None + + +def _approval_table(table_name: str) -> str: + if table_name not in APPROVAL_TABLES: + raise NotFoundError("This form has no approval step", {"table": table_name}) + return table_name + + +@router.get("/approvals") +async def list_form_approvals( + db: AsyncSession = Depends(get_db), + current_user: User = Depends(require_role(Role.MR, Role.ADMIN, Role.AM)), +) -> list[dict[str, object]]: + """Approval state of the forms that carry an Area Manager signature, limited to the MRs this user may see.""" + return [_approval_out(r, owner, hq) for r, owner, hq in await approvals.list_approvals(db, current_user)] + + +@router.get("/owners") +async def list_form_owners( + db: AsyncSession = Depends(get_db), + current_user: User = Depends(require_role(Role.MR, Role.ADMIN, Role.AM)), +) -> list[dict[str, object]]: + """The medical representatives whose forms this user may open.""" + hq = {h.id: h.name for h in (await db.execute(select(Headquarters))).scalars()} + return [ + {"id": str(o.id), "name": o.full_name, "employee_code": o.employee_code, "headquarters_name": hq.get(o.headquarters_id)} + for o in await approvals.owners_in_scope(db, current_user) + ] + + +@router.post("/{table_name}/approval/request") +async def request_form_approval( + table_name: str, + db: AsyncSession = Depends(get_db), + current_user: User = Depends(require_role(Role.MR)), +) -> dict[str, object]: + """The MR sends a form to the Area Manager.""" + row = await approvals.request_approval(db, _approval_table(table_name), current_user) + return _approval_out(row, current_user, await _hq_name(db, current_user)) + + +@router.post("/{table_name}/approval/approve") +async def approve_form( + table_name: str, + owner_id: uuid.UUID = Query(description="The MR whose form is being approved"), + db: AsyncSession = Depends(get_db), + current_user: User = Depends(require_role(Role.AM)), +) -> dict[str, object]: + """The Area Manager signs an MR's form — only the one who manages that MR's headquarters.""" + row = await approvals.approve(db, _approval_table(table_name), owner_id, current_user) + owner = await db.get(User, owner_id) + return _approval_out(row, owner, await _hq_name(db, owner)) + + +@router.get("/{table_name}/rows") +async def list_csv_rows( + table_name: str, + owner_id: uuid.UUID | None = None, + db: AsyncSession = Depends(get_db), + current_user: User = Depends(require_role(Role.MR, Role.ADMIN, Role.AM)), +) -> list[dict[str, object]]: + _ensure_table_access(table_name, current_user) + return await _load_rows(table_name, db, current_user, owner_id) + + +@router.post("/{table_name}/rows", status_code=status.HTTP_201_CREATED) +async def create_csv_row( + table_name: str, + payload: dict[str, object] = Body(...), + owner_id: uuid.UUID | None = None, + db: AsyncSession = Depends(get_db), + current_user: User = Depends(require_role(Role.MR, Role.ADMIN)), +) -> dict[str, object]: + columns = _table(table_name) + values = _clean_payload(table_name, payload) + owner: User | None = None + if table_name in OWNED_TABLES: + if current_user.role == Role.MR: + owner = current_user + elif owner_id is None: + raise ValidationError("Choose which medical representative this row is for") + else: + owner = await approvals.assert_owner_in_scope(db, current_user, owner_id) + values = await _apply_mr_identity(values, owner or current_user, db) + if table_name == "sales_projection": + values = await _apply_sales_projection_product(values, db, current_user) + if not _has_user_data(table_name, values): + raise ValidationError("Add at least one value before creating a row") + await _reject_repeat(table_name, values, db, owner.id if owner else None) + next_row = (await db.execute(text(f'SELECT COALESCE(MAX(source_row_number), 0) + 1 FROM "{table_name}"'))).scalar_one() + for column in columns: + if column in SERIAL_COLUMNS: + values[column] = str(next_row) + extra_ids, extra_params = (["owner_user_id"], [":owner_user_id"]) if owner else ([], []) + identifiers = ", ".join(["id", "source_row_number", *extra_ids, *[f'"{column}"' for column in columns]]) + parameters = ", ".join([":id", ":source_row_number", *extra_params, *[f":{column}" for column in columns]]) + values.update(id=uuid.uuid4(), source_row_number=next_row) + if owner: + values["owner_user_id"] = owner.id + result = await db.execute(text(f'INSERT INTO "{table_name}" ({identifiers}) VALUES ({parameters}) RETURNING id'), values) + row_id = result.scalar_one() + await _renumber_rows(table_name, db) + await approvals.invalidate(db, table_name, owner.id if owner else None) + await db.commit() + return await _get_row(table_name, row_id, db) + + +@router.patch("/{table_name}/rows/{row_id}") +async def update_csv_row(table_name: str, row_id: uuid.UUID, payload: dict[str, object] = Body(...), db: AsyncSession = Depends(get_db), current_user: User = Depends(require_role(Role.MR, Role.ADMIN))) -> dict[str, object]: + values = _clean_payload(table_name, payload) + row_owner = await _row_owner(table_name, row_id, current_user, db) + values = await _apply_mr_identity(values, current_user, db) + if table_name == "sales_projection": + values = await _apply_sales_projection_product(values, db, current_user) + changes = {column: value for column, value in values.items() if column in payload} + if not changes: + raise ValidationError("At least one CSV column is required") + if not _has_user_data(table_name, {**values, **changes}): + raise ValidationError("A row must contain at least one value") + changes = {column: value for column, value in changes.items() if column not in SERIAL_COLUMNS} + if not changes: + raise ValidationError("Serial numbers are generated automatically") + assignments = ", ".join(f'"{column}" = :{column}' for column in changes) + result = await db.execute(text(f'UPDATE "{table_name}" SET {assignments} WHERE id = :id RETURNING id'), {**changes, "id": row_id}) + if result.scalar_one_or_none() is None: + raise NotFoundError("CSV row not found", {"id": str(row_id)}) + await approvals.invalidate(db, table_name, row_owner) + await db.commit() + return await _get_row(table_name, row_id, db) + + +@router.delete("/{table_name}/rows/{row_id}", status_code=status.HTTP_204_NO_CONTENT) +async def delete_csv_row(table_name: str, row_id: uuid.UUID, db: AsyncSession = Depends(get_db), current_user: User = Depends(require_role(Role.MR, Role.ADMIN))) -> None: + _table(table_name) + row_owner = await _row_owner(table_name, row_id, current_user, db) + result = await db.execute(text(f'DELETE FROM "{table_name}" WHERE id = :id'), {"id": row_id}) + if result.rowcount == 0: + raise NotFoundError("CSV row not found", {"id": str(row_id)}) + await _renumber_rows(table_name, db) + await approvals.invalidate(db, table_name, row_owner) + await db.commit() + + +async def _get_row(table_name: str, row_id: uuid.UUID, db: AsyncSession) -> dict[str, object]: + columns = _table(table_name) + result = await db.execute(text(f'{_select(table_name, columns)} WHERE id = :id'), {"id": row_id}) + row = result.mappings().one_or_none() + if row is None: + raise NotFoundError("CSV row not found", {"id": str(row_id)}) + return dict(row) + + +def _pdf_bytes( + table_name: str, + table_label: str, + row: dict[str, object], + approval_status: str | None = None, + am_name: str | None = None, + approved_at: str | None = None, +) -> bytes: + from app.pdf.service import csv_table_pdf_bytes + return csv_table_pdf_bytes( + table_name, + table_label, + _table(table_name), + [row], + approval_status, + am_name, + approved_at=approved_at, + ) + + +@router.get("/{table_name}/rows/{row_id}/pdf") +async def download_csv_row_pdf( + table_name: str, + row_id: uuid.UUID, + db: AsyncSession = Depends(get_db), + current_user: User = Depends(require_role(Role.MR, Role.ADMIN, Role.AM)), +) -> Response: + _ensure_table_access(table_name, current_user) + row_owner = await _row_owner(table_name, row_id, current_user, db) + row = await _get_row(table_name, row_id, db) + row = (await _present_rows_for_user([row], current_user, db))[0] + approval_status, am_name, approved_at = await _signature(table_name, row_owner, db) + return Response( + _pdf_bytes(table_name, CSV_LABELS[table_name], row, approval_status, am_name, approved_at), + media_type="application/pdf", + headers={"Content-Disposition": f'attachment; filename="{table_name}-{row_id}.pdf"'}, + ) + + +@router.get("/{table_name}/pdf") +async def download_csv_table_pdfs( + table_name: str, + owner_id: uuid.UUID | None = None, + month: str | None = None, + db: AsyncSession = Depends(get_db), + current_user: User = Depends(require_role(Role.MR, Role.ADMIN, Role.AM)), +) -> Response: + """The whole form, or only one month of it (for the forms that have a month).""" + _ensure_table_access(table_name, current_user) + columns = _table(table_name) + rows = await _load_rows(table_name, db, current_user, owner_id, month) + if month and month.strip() and not rows: + raise NotFoundError(f"There are no rows for {month.strip()} in this form", {"month": month}) + # The signature is that of the single MR whose rows these are; a PDF of several MRs is unsigned. + subject = current_user.id if current_user.role == Role.MR else owner_id + approval_status, am_name, approved_at = await _signature(table_name, subject, db) + from app.pdf.service import csv_table_pdf_bytes + suffix = re.sub(r"[^a-z]", "", month.lower()) if month else "" + filename = f"{table_name}-{suffix}.pdf" if suffix else f"{table_name}.pdf" + pdf = csv_table_pdf_bytes( + table_name, + CSV_LABELS[table_name], + columns, + rows, + approval_status, + am_name, + approved_at=approved_at, + ) + return Response( + pdf, + media_type="application/pdf", + headers={"Content-Disposition": f'attachment; filename="{filename}"'}, + ) \ No newline at end of file diff --git a/app/database/__init__.py b/app/database/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/app/database/all_models.py b/app/database/all_models.py new file mode 100644 index 0000000..0677386 --- /dev/null +++ b/app/database/all_models.py @@ -0,0 +1,36 @@ +"""Single import point for every ORM model. + +Alembic autogenerate and SQLAlchemy's string-based relationship resolution both need +every mapper registered before use. Import this module, never individual model +modules, when you need "all of them". +""" + +from app.audit.models import AuditLog +from app.auth.models import RefreshToken +from app.chemists.models import Chemist, ChemistAssignment +from app.csv_data.models import FormApproval +from app.database.base import Base +from app.doctors.models import Doctor, DoctorAssignment +from app.organization.models import AMHeadquarters, Company, Headquarters +from app.products.models import Product +from app.reports.models import ChemistCall, DailyCallReport, DoctorCall +from app.users.models import User + +__all__ = [ + "Base", + "AuditLog", + "RefreshToken", + "Chemist", + "FormApproval", + "ChemistAssignment", + "Doctor", + "DoctorAssignment", + "AMHeadquarters", + "Company", + "Headquarters", + "ChemistCall", + "DailyCallReport", + "DoctorCall", + "User", + "Product", +] diff --git a/app/database/base.py b/app/database/base.py new file mode 100644 index 0000000..0c29780 --- /dev/null +++ b/app/database/base.py @@ -0,0 +1,30 @@ +"""Declarative base and shared column mixins.""" + +import uuid +from datetime import datetime + +from sqlalchemy import DateTime, func +from sqlalchemy.dialects.postgresql import UUID as PGUUID +from sqlalchemy.orm import DeclarativeBase, Mapped, mapped_column + + +class Base(DeclarativeBase): + pass + + +class UUIDMixin: + id: Mapped[uuid.UUID] = mapped_column( + PGUUID(as_uuid=True), primary_key=True, default=uuid.uuid4 + ) + + +class TimestampMixin: + created_at: Mapped[datetime] = mapped_column( + DateTime(timezone=True), server_default=func.now(), nullable=False + ) + updated_at: Mapped[datetime] = mapped_column( + DateTime(timezone=True), + server_default=func.now(), + onupdate=func.now(), + nullable=False, + ) diff --git a/app/database/session.py b/app/database/session.py new file mode 100644 index 0000000..f2d554b --- /dev/null +++ b/app/database/session.py @@ -0,0 +1,34 @@ +"""Engine, session factory and the `get_db` request dependency. + +One transaction per request: the dependency opens a session, the service layer +commits on success, and any escaping exception rolls the whole request back — so a +state change and its audit row can never be persisted separately. +""" + +from collections.abc import AsyncGenerator + +from sqlalchemy.ext.asyncio import AsyncSession, async_sessionmaker, create_async_engine + +from app.config.settings import settings + +engine = create_async_engine( + settings.DATABASE_URL, + echo=settings.DB_ECHO, + pool_pre_ping=True, +) + +AsyncSessionLocal = async_sessionmaker( + bind=engine, + class_=AsyncSession, + expire_on_commit=False, + autoflush=False, +) + + +async def get_db() -> AsyncGenerator[AsyncSession, None]: + async with AsyncSessionLocal() as session: + try: + yield session + except Exception: + await session.rollback() + raise diff --git a/app/doctors/__init__.py b/app/doctors/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/app/doctors/models.py b/app/doctors/models.py new file mode 100644 index 0000000..858202c --- /dev/null +++ b/app/doctors/models.py @@ -0,0 +1,65 @@ +"""Doctor master data and doctor → MR assignment. + +Master data belongs to a HEADQUARTERS, not to an MR (A2). Assignment is a separate, +dated table so that when an MR leaves, the doctor list survives. + +`core_doctor_conversion` was not created as a table (report §13.2): it would store +one enum per call, which is a column — `doctor.is_core_doctor` + +`doctor_call.conversion_status`. +""" + +import uuid +from datetime import date + +from sqlalchemy import Boolean, Date, ForeignKey, Index, String, UniqueConstraint, text +from sqlalchemy.dialects.postgresql import UUID as PGUUID +from sqlalchemy.orm import Mapped, mapped_column, relationship + +from app.database.base import Base, TimestampMixin, UUIDMixin + + +class Doctor(Base, UUIDMixin, TimestampMixin): + __tablename__ = "doctor" + __table_args__ = ( + # Deduplication guard: two MRs must not create two records for one doctor. + UniqueConstraint( + "headquarters_id", "name", "clinic_address", name="uq_doctor_hq_name_clinic" + ), + ) + + headquarters_id: Mapped[uuid.UUID] = mapped_column( + PGUUID(as_uuid=True), ForeignKey("headquarters.id", ondelete="RESTRICT"), nullable=False + ) + name: Mapped[str] = mapped_column(String(200), nullable=False) + speciality: Mapped[str | None] = mapped_column(String(100)) + qualification: Mapped[str | None] = mapped_column(String(100)) + clinic_address: Mapped[str] = mapped_column(String(500), nullable=False) + contact_number: Mapped[str | None] = mapped_column(String(20)) + #: Core doctors are the high-value targets tracked for conversion. + is_core_doctor: Mapped[bool] = mapped_column(Boolean, default=False, nullable=False) + is_active: Mapped[bool] = mapped_column(Boolean, default=True, nullable=False) + + assignments: Mapped[list["DoctorAssignment"]] = relationship(back_populates="doctor") + + +class DoctorAssignment(Base, UUIDMixin, TimestampMixin): + __tablename__ = "doctor_assignment" + __table_args__ = ( + Index( + "uq_active_doctor_assignment", + "doctor_id", + unique=True, + postgresql_where=text("effective_to IS NULL"), + ), + ) + + doctor_id: Mapped[uuid.UUID] = mapped_column( + PGUUID(as_uuid=True), ForeignKey("doctor.id", ondelete="CASCADE"), nullable=False + ) + mr_user_id: Mapped[uuid.UUID] = mapped_column( + PGUUID(as_uuid=True), ForeignKey("user.id", ondelete="RESTRICT"), nullable=False + ) + effective_from: Mapped[date] = mapped_column(Date, nullable=False) + effective_to: Mapped[date | None] = mapped_column(Date) + + doctor: Mapped["Doctor"] = relationship(back_populates="assignments") diff --git a/app/doctors/router.py b/app/doctors/router.py new file mode 100644 index 0000000..f7533dd --- /dev/null +++ b/app/doctors/router.py @@ -0,0 +1,64 @@ +import uuid + +from fastapi import APIRouter, Depends, Request, status +from sqlalchemy.ext.asyncio import AsyncSession + +from app.auth.dependencies import client_ip, get_current_user, require_role +from app.common.enums import Role +from app.database.session import get_db +from app.doctors.models import Doctor +from app.doctors.schemas import AssignToMR, DoctorCreate, DoctorRead, DoctorUpdate +from app.doctors.service import DoctorService +from app.users.models import User + +router = APIRouter(prefix="/doctors", tags=["doctors"]) + + +@router.get("", response_model=list[DoctorRead]) +async def list_doctors( + current_user: User = Depends(get_current_user), db: AsyncSession = Depends(get_db) +) -> list[Doctor]: + """S5 — an MR gets only their assigned doctors; managers get their HQ scope.""" + return await DoctorService(db).list_for(current_user) + + +@router.post("", response_model=DoctorRead, status_code=status.HTTP_201_CREATED) +async def create_doctor( + payload: DoctorCreate, + request: Request, + current_user: User = Depends(require_role(Role.ADMIN)), + db: AsyncSession = Depends(get_db), +) -> Doctor: + """Only an Administrator can create a doctor (MR, AM and GM cannot).""" + return await DoctorService(db).create(payload, current_user, client_ip(request)) + + +@router.patch("/{doctor_id}", response_model=DoctorRead) +async def update_doctor( + doctor_id: uuid.UUID, + payload: DoctorUpdate, + request: Request, + current_user: User = Depends(require_role(Role.ADMIN)), + db: AsyncSession = Depends(get_db), +) -> Doctor: + return await DoctorService(db).update(doctor_id, payload, current_user, client_ip(request)) + + +@router.post("/{doctor_id}/assign", status_code=status.HTTP_201_CREATED) +async def assign_doctor( + doctor_id: uuid.UUID, + payload: AssignToMR, + request: Request, + current_user: User = Depends(require_role(Role.ADMIN, Role.GM, Role.AM)), + db: AsyncSession = Depends(get_db), +): + """An AM may assign only within their own headquarters — enforced by data scope.""" + assignment = await DoctorService(db).assign_to_mr( + doctor_id, payload.mr_user_id, payload.effective_from, current_user, client_ip(request) + ) + return { + "id": assignment.id, + "doctor_id": assignment.doctor_id, + "mr_user_id": assignment.mr_user_id, + "effective_from": assignment.effective_from, + } diff --git a/app/doctors/schemas.py b/app/doctors/schemas.py new file mode 100644 index 0000000..9d95795 --- /dev/null +++ b/app/doctors/schemas.py @@ -0,0 +1,43 @@ +import uuid +from datetime import date + +from pydantic import BaseModel, ConfigDict, Field + + +class DoctorCreate(BaseModel): + headquarters_id: uuid.UUID + name: str = Field(min_length=2, max_length=200) + clinic_address: str = Field(min_length=2, max_length=500) + speciality: str | None = Field(default=None, max_length=100) + qualification: str | None = Field(default=None, max_length=100) + contact_number: str | None = Field(default=None, max_length=20) + is_core_doctor: bool = False + + +class DoctorUpdate(BaseModel): + name: str | None = Field(default=None, min_length=2, max_length=200) + clinic_address: str | None = Field(default=None, min_length=2, max_length=500) + speciality: str | None = Field(default=None, max_length=100) + qualification: str | None = Field(default=None, max_length=100) + contact_number: str | None = Field(default=None, max_length=20) + is_core_doctor: bool | None = None + is_active: bool | None = None + + +class DoctorRead(BaseModel): + model_config = ConfigDict(from_attributes=True) + + id: uuid.UUID + headquarters_id: uuid.UUID + name: str + clinic_address: str + speciality: str | None + qualification: str | None + contact_number: str | None + is_core_doctor: bool + is_active: bool + + +class AssignToMR(BaseModel): + mr_user_id: uuid.UUID + effective_from: date | None = None diff --git a/app/doctors/service.py b/app/doctors/service.py new file mode 100644 index 0000000..fcd552b --- /dev/null +++ b/app/doctors/service.py @@ -0,0 +1,152 @@ +import uuid +from datetime import date + +from sqlalchemy import select +from sqlalchemy.exc import IntegrityError +from sqlalchemy.ext.asyncio import AsyncSession + +from app.audit.service import AuditService +from app.auth.dependencies import assert_can_view_hq, visible_hq_ids +from app.common.enums import AuditAction, EntityType, Role +from app.common.exceptions import ConflictError, NotFoundError, ValidationError +from app.common.utils import snapshot +from app.doctors.models import Doctor, DoctorAssignment +from app.doctors.schemas import DoctorCreate, DoctorUpdate +from app.users.models import User + +_AUDIT_FIELDS = ["name", "clinic_address", "speciality", "is_core_doctor", "is_active"] + + +class DoctorService: + def __init__(self, db: AsyncSession) -> None: + self.db = db + self.audit = AuditService(db) + + async def create(self, data: DoctorCreate, actor: User, ip: str | None = None) -> Doctor: + # A2/A3 — masters are owned by ADMIN/GM. An MR cannot create a doctor. + await assert_can_view_hq(self.db, actor, data.headquarters_id) + + doctor = Doctor(**data.model_dump()) + self.db.add(doctor) + try: + await self.db.flush() + except IntegrityError as exc: + await self.db.rollback() + raise ConflictError( + "A doctor with this name already exists at this clinic in this headquarters", + {"cause": "uq_doctor_hq_name_clinic"}, + ) from exc + + await self.audit.log( + actor_user_id=actor.id, + entity_type=EntityType.DOCTOR, + entity_id=doctor.id, + action=AuditAction.CREATE, + after=snapshot(doctor, _AUDIT_FIELDS), + ip_address=ip, + ) + await self.db.commit() + return doctor + + async def update( + self, doctor_id: uuid.UUID, data: DoctorUpdate, actor: User, ip: str | None = None + ) -> Doctor: + doctor = await self.db.get(Doctor, doctor_id) + if doctor is None: + raise NotFoundError("Doctor not found") + await assert_can_view_hq(self.db, actor, doctor.headquarters_id) + + before = snapshot(doctor, _AUDIT_FIELDS) + for field, value in data.model_dump(exclude_unset=True).items(): + setattr(doctor, field, value) + + await self.audit.log( + actor_user_id=actor.id, + entity_type=EntityType.DOCTOR, + entity_id=doctor.id, + action=AuditAction.UPDATE, + before=before, + after=snapshot(doctor, _AUDIT_FIELDS), + ip_address=ip, + ) + await self.db.commit() + return doctor + + async def list_for(self, actor: User) -> list[Doctor]: + """An MR sees ONLY doctors currently assigned to them (R5).""" + if actor.role == Role.MR: + stmt = ( + select(Doctor) + .join(DoctorAssignment, DoctorAssignment.doctor_id == Doctor.id) + .where( + DoctorAssignment.mr_user_id == actor.id, + DoctorAssignment.effective_to.is_(None), + Doctor.is_active.is_(True), + ) + .order_by(Doctor.name) + ) + return list((await self.db.execute(stmt)).scalars().all()) + + allowed = await visible_hq_ids(self.db, actor) + stmt = select(Doctor).order_by(Doctor.name) + if allowed is not None: + stmt = stmt.where(Doctor.headquarters_id.in_(allowed or [None])) + return list((await self.db.execute(stmt)).scalars().all()) + + async def assign_to_mr( + self, + doctor_id: uuid.UUID, + mr_user_id: uuid.UUID, + effective_from: date | None, + actor: User, + ip: str | None = None, + ) -> DoctorAssignment: + doctor = await self.db.get(Doctor, doctor_id) + if doctor is None: + raise NotFoundError("Doctor not found") + await assert_can_view_hq(self.db, actor, doctor.headquarters_id) + + mr = await self.db.get(User, mr_user_id) + if mr is None: + raise NotFoundError("MR not found") + if mr.role != Role.MR: + raise ValidationError("Doctors can only be assigned to an MR") + # An MR may only be given doctors from their own headquarters. + if mr.headquarters_id != doctor.headquarters_id: + raise ValidationError( + "MR and doctor belong to different headquarters", + { + "mr_headquarters_id": str(mr.headquarters_id), + "doctor_headquarters_id": str(doctor.headquarters_id), + }, + ) + + start = effective_from or date.today() + existing = ( + await self.db.execute( + select(DoctorAssignment).where( + DoctorAssignment.doctor_id == doctor_id, + DoctorAssignment.effective_to.is_(None), + ) + ) + ).scalars().all() + for row in existing: + if row.mr_user_id == mr_user_id: + return row + row.effective_to = start + await self.db.flush() + + assignment = DoctorAssignment( + doctor_id=doctor_id, mr_user_id=mr_user_id, effective_from=start + ) + self.db.add(assignment) + await self.audit.log( + actor_user_id=actor.id, + entity_type=EntityType.DOCTOR, + entity_id=doctor_id, + action=AuditAction.ASSIGN, + after={"mr_user_id": str(mr_user_id), "effective_from": start.isoformat()}, + ip_address=ip, + ) + await self.db.commit() + return assignment diff --git a/app/main.py b/app/main.py new file mode 100644 index 0000000..320a5a2 --- /dev/null +++ b/app/main.py @@ -0,0 +1,113 @@ +"""Application factory: router mount, middleware, exception handlers.""" + +import logging +from collections.abc import AsyncIterator +from contextlib import asynccontextmanager + +from fastapi import FastAPI, Request +from fastapi.encoders import jsonable_encoder +from fastapi.exceptions import RequestValidationError +from fastapi.middleware.cors import CORSMiddleware +from fastapi.responses import JSONResponse + +from app.api.v1.router import api_router +from app.common.exceptions import AppError +from app.config.settings import settings +from app.database import all_models # noqa: F401 - registers every mapper +from app.pdf.service import pdf_engine_ready + +logging.basicConfig( + level=logging.DEBUG if settings.DEBUG else logging.INFO, + format="%(asctime)s %(levelname)s %(name)s %(message)s", +) + + +logger = logging.getLogger(__name__) + + +def _preflight() -> None: + """Refuse to start a production instance that would silently misbehave.""" + production = settings.ENVIRONMENT.lower() == "production" + if not pdf_engine_ready(): + if production: + raise RuntimeError("WeasyPrint system libraries are required in production") + logger.warning("WeasyPrint is unavailable: PDFs will be plain text, not the form layout.") + weak_key = settings.SECRET_KEY.startswith("change-me") or len(settings.SECRET_KEY) < 32 + if production and weak_key: + raise RuntimeError("SECRET_KEY must be a random value of at least 32 characters") + + +@asynccontextmanager +async def lifespan(_: FastAPI) -> AsyncIterator[None]: + _preflight() + yield + + +def create_app() -> FastAPI: + app = FastAPI( + lifespan=lifespan, + title=settings.APP_NAME, + version="0.1.0", + description=( + "Pharmaceutical field-force reporting — MVP. " + "Daily Call Reports with AM final approval, GM monitoring, " + "locked PDFs and audit trails." + ), + docs_url="/docs", + redoc_url="/redoc", + openapi_url="/openapi.json", + ) + + app.add_middleware( + CORSMiddleware, + allow_origins=settings.CORS_ORIGINS, + allow_credentials=True, + allow_methods=["*"], + allow_headers=["*"], + ) + + # ---- one consistent error envelope ------------------------------- + @app.exception_handler(AppError) + async def app_error_handler(_: Request, exc: AppError) -> JSONResponse: + return JSONResponse(status_code=exc.status_code, content=exc.to_dict()) + + @app.exception_handler(RequestValidationError) + async def validation_handler(_: Request, exc: RequestValidationError) -> JSONResponse: + # Pydantic puts the original exception object in `ctx`, which is not JSON + # serialisable — strip it, or the error handler itself becomes a 500. + errors = [ + {k: v for k, v in error.items() if k != "ctx"} + | ( + {"reason": str(error["ctx"].get("error"))} + if isinstance(error.get("ctx"), dict) and "error" in error["ctx"] + else {} + ) + for error in exc.errors() + ] + return JSONResponse( + status_code=422, + content=jsonable_encoder( + { + "error": { + "code": "VALIDATION_ERROR", + "message": "Request payload failed validation", + "details": {"errors": errors}, + } + } + ), + ) + + app.include_router(api_router, prefix=settings.API_V1_PREFIX) + + @app.get("/health", tags=["meta"]) + async def health() -> dict[str, str]: + return { + "status": "ok", + "environment": settings.ENVIRONMENT, + "pdf_engine": "weasyprint" if pdf_engine_ready() else "fallback", + } + + return app + + +app = create_app() diff --git a/app/organization/__init__.py b/app/organization/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/app/organization/models.py b/app/organization/models.py new file mode 100644 index 0000000..917ec9f --- /dev/null +++ b/app/organization/models.py @@ -0,0 +1,85 @@ +"""Company, Headquarters and the Area-Manager ↔ Headquarters mapping. + +Design notes (report §13.2): +- `area_territory` was merged into `headquarters` — the brief states HQ *is* the + territory, and two tables for one concept invites drift. +- An MR's Area Manager is DERIVED through the headquarters, not stored on the MR. + An HQ handover therefore re-points every MR in that HQ with no data migration. +""" + +import uuid +from datetime import date + +from sqlalchemy import Date, ForeignKey, Index, String, UniqueConstraint, text +from sqlalchemy.dialects.postgresql import UUID as PGUUID +from sqlalchemy.orm import Mapped, mapped_column, relationship + +from app.database.base import Base, TimestampMixin, UUIDMixin + + +class Company(Base, UUIDMixin, TimestampMixin): + """Tenant root. Single company in the MVP (A17), but `company_id` is carried on + every table so multi-tenancy needs no migration later.""" + + __tablename__ = "company" + + name: Mapped[str] = mapped_column(String(200), nullable=False) + address: Mapped[str | None] = mapped_column(String(500)) + is_active: Mapped[bool] = mapped_column(default=True, nullable=False) + + headquarters: Mapped[list["Headquarters"]] = relationship(back_populates="company") + + +class Headquarters(Base, UUIDMixin, TimestampMixin): + """A territory/location. NOT a login role (R8).""" + + __tablename__ = "headquarters" + __table_args__ = ( + UniqueConstraint("company_id", "code", name="uq_hq_company_code"), + ) + + company_id: Mapped[uuid.UUID] = mapped_column( + PGUUID(as_uuid=True), ForeignKey("company.id", ondelete="RESTRICT"), nullable=False + ) + code: Mapped[str] = mapped_column(String(20), nullable=False) + name: Mapped[str] = mapped_column(String(200), nullable=False) + district: Mapped[str | None] = mapped_column(String(100)) + state: Mapped[str | None] = mapped_column(String(100)) + is_active: Mapped[bool] = mapped_column(default=True, nullable=False) + + company: Mapped["Company"] = relationship(back_populates="headquarters") + am_mappings: Mapped[list["AMHeadquarters"]] = relationship( + back_populates="headquarters" + ) + + +class AMHeadquarters(Base, UUIDMixin, TimestampMixin): + """Which Area Manager currently manages which headquarters. + + `effective_to IS NULL` means "current". A partial unique index guarantees at most + one active Area Manager per headquarters at any time. + """ + + __tablename__ = "am_headquarters" + __table_args__ = ( + Index( + "uq_active_am_per_hq", + "headquarters_id", + unique=True, + postgresql_where=text("effective_to IS NULL"), + ), + ) + + area_manager_user_id: Mapped[uuid.UUID] = mapped_column( + PGUUID(as_uuid=True), ForeignKey("user.id", ondelete="RESTRICT"), nullable=False + ) + headquarters_id: Mapped[uuid.UUID] = mapped_column( + PGUUID(as_uuid=True), + ForeignKey("headquarters.id", ondelete="RESTRICT"), + nullable=False, + ) + effective_from: Mapped[date] = mapped_column(Date, nullable=False) + effective_to: Mapped[date | None] = mapped_column(Date) + + headquarters: Mapped["Headquarters"] = relationship(back_populates="am_mappings") + area_manager: Mapped["User"] = relationship() # noqa: F821 diff --git a/app/organization/router.py b/app/organization/router.py new file mode 100644 index 0000000..c6e484a --- /dev/null +++ b/app/organization/router.py @@ -0,0 +1,88 @@ +import uuid + +from fastapi import APIRouter, Depends, Request, status +from sqlalchemy.ext.asyncio import AsyncSession + +from app.auth.dependencies import client_ip, get_current_user, require_role +from app.common.enums import Role +from app.database.session import get_db +from app.organization.models import Headquarters +from app.organization.schemas import ( + AMHeadquartersRead, + AssignAreaManager, + HeadquartersCreate, + HeadquartersRead, + SetAreaManagerHeadquarters, +) +from app.organization.service import OrganizationService +from app.users.models import User + +router = APIRouter(prefix="/headquarters", tags=["organization"]) + + +@router.get("", response_model=list[HeadquartersRead]) +async def list_headquarters( + current_user: User = Depends(get_current_user), db: AsyncSession = Depends(get_db) +) -> list[Headquarters]: + """Scoped: an MR sees their own HQ, an AM sees theirs, GM/Admin see all.""" + return await OrganizationService(db).list_headquarters(current_user) + + +@router.get("/area-managers", response_model=list[AMHeadquartersRead]) +async def list_area_manager_mappings( + current_user: User = Depends(require_role(Role.ADMIN, Role.GM)), + db: AsyncSession = Depends(get_db), +): + """Which Area Manager currently manages which headquarters (one row per pair).""" + return await OrganizationService(db).list_area_manager_mappings(current_user) + + +@router.put("/area-managers/{area_manager_user_id}", response_model=list[AMHeadquartersRead]) +async def set_area_manager_headquarters( + area_manager_user_id: uuid.UUID, + payload: SetAreaManagerHeadquarters, + request: Request, + current_user: User = Depends(require_role(Role.ADMIN)), + db: AsyncSession = Depends(get_db), +): + """Replace the set of headquarters an Area Manager manages (any number).""" + return await OrganizationService(db).set_area_manager_headquarters( + area_manager_user_id, + payload.headquarters_ids, + payload.effective_from, + current_user, + client_ip(request), + ) + + +@router.post("", response_model=HeadquartersRead, status_code=status.HTTP_201_CREATED) +async def create_headquarters( + payload: HeadquartersCreate, + request: Request, + current_user: User = Depends(require_role(Role.ADMIN)), + db: AsyncSession = Depends(get_db), +) -> Headquarters: + return await OrganizationService(db).create_headquarters( + payload, current_user, client_ip(request) + ) + + +@router.post( + "/{headquarters_id}/area-manager", + response_model=AMHeadquartersRead, + status_code=status.HTTP_201_CREATED, +) +async def assign_area_manager( + headquarters_id: uuid.UUID, + payload: AssignAreaManager, + request: Request, + current_user: User = Depends(require_role(Role.ADMIN)), + db: AsyncSession = Depends(get_db), +): + return await OrganizationService(db).assign_area_manager( + headquarters_id, + payload.area_manager_user_id, + payload.effective_from, + current_user, + client_ip(request), + ) diff --git a/app/organization/schemas.py b/app/organization/schemas.py new file mode 100644 index 0000000..f7a4e6f --- /dev/null +++ b/app/organization/schemas.py @@ -0,0 +1,59 @@ +import uuid +from datetime import date + +from pydantic import BaseModel, ConfigDict, Field + + +class CompanyCreate(BaseModel): + name: str = Field(min_length=2, max_length=200) + address: str | None = Field(default=None, max_length=500) + + +class CompanyRead(BaseModel): + model_config = ConfigDict(from_attributes=True) + + id: uuid.UUID + name: str + address: str | None + is_active: bool + + +class HeadquartersCreate(BaseModel): + code: str = Field(min_length=1, max_length=20) + name: str = Field(min_length=2, max_length=200) + district: str | None = Field(default=None, max_length=100) + state: str | None = Field(default=None, max_length=100) + + +class HeadquartersRead(BaseModel): + model_config = ConfigDict(from_attributes=True) + + id: uuid.UUID + company_id: uuid.UUID + code: str + name: str + district: str | None + state: str | None + is_active: bool + + +class AssignAreaManager(BaseModel): + area_manager_user_id: uuid.UUID + effective_from: date | None = None + + +class SetAreaManagerHeadquarters(BaseModel): + """The complete list of headquarters an Area Manager should manage (may be empty).""" + + headquarters_ids: list[uuid.UUID] = Field(default_factory=list, max_length=500) + effective_from: date | None = None + + +class AMHeadquartersRead(BaseModel): + model_config = ConfigDict(from_attributes=True) + + id: uuid.UUID + area_manager_user_id: uuid.UUID + headquarters_id: uuid.UUID + effective_from: date + effective_to: date | None diff --git a/app/organization/service.py b/app/organization/service.py new file mode 100644 index 0000000..49947ab --- /dev/null +++ b/app/organization/service.py @@ -0,0 +1,228 @@ +import uuid +from datetime import date + +from sqlalchemy import select +from sqlalchemy.exc import IntegrityError +from sqlalchemy.ext.asyncio import AsyncSession + +from app.audit.service import AuditService +from app.auth.dependencies import visible_hq_ids +from app.common.enums import AuditAction, EntityType, Role +from app.common.exceptions import ConflictError, NotFoundError, ValidationError +from app.organization.models import AMHeadquarters, Company, Headquarters +from app.organization.schemas import HeadquartersCreate +from app.users.models import User + + +class OrganizationService: + def __init__(self, db: AsyncSession) -> None: + self.db = db + self.audit = AuditService(db) + + async def create_headquarters( + self, data: HeadquartersCreate, actor: User, ip: str | None = None + ) -> Headquarters: + if await self.db.get(Company, actor.company_id) is None: + raise NotFoundError("Company not found") + + hq = Headquarters( + company_id=actor.company_id, + code=data.code.upper(), + name=data.name, + district=data.district, + state=data.state, + ) + self.db.add(hq) + try: + await self.db.flush() + except IntegrityError as exc: + await self.db.rollback() + raise ConflictError( + "A headquarters with this code already exists", {"code": data.code} + ) from exc + + await self.audit.log( + actor_user_id=actor.id, + entity_type=EntityType.HEADQUARTERS, + entity_id=hq.id, + action=AuditAction.CREATE, + after={"code": hq.code, "name": hq.name}, + ip_address=ip, + ) + await self.db.commit() + return hq + + async def list_headquarters(self, actor: User) -> list[Headquarters]: + allowed = await visible_hq_ids(self.db, actor) + stmt = select(Headquarters).where(Headquarters.company_id == actor.company_id) + if allowed is not None: + stmt = stmt.where(Headquarters.id.in_(allowed or [None])) + return list((await self.db.execute(stmt)).scalars().all()) + + async def list_area_manager_mappings(self, actor: User) -> list[AMHeadquarters]: + """Current (open) Area Manager to headquarters mappings, for display.""" + stmt = ( + select(AMHeadquarters) + .join(Headquarters, Headquarters.id == AMHeadquarters.headquarters_id) + .where( + Headquarters.company_id == actor.company_id, + AMHeadquarters.effective_to.is_(None), + ) + ) + return list((await self.db.execute(stmt)).scalars().all()) + + async def set_area_manager_headquarters( + self, + am_user_id: uuid.UUID, + headquarters_ids: list[uuid.UUID], + effective_from: date | None, + actor: User, + ip: str | None = None, + ) -> list[AMHeadquarters]: + """Make `headquarters_ids` exactly the set of headquarters this AM manages. + + Headquarters missing from the list are released, new ones are added. If a new + headquarters already has another AM, that mapping is closed first (one active AM + per headquarters stays true). An AM may manage any number of headquarters. + """ + manager = await self.db.get(User, am_user_id) + if manager is None or manager.company_id != actor.company_id: + raise NotFoundError("User not found") + if manager.role != Role.AM: + raise ValidationError( + "Only a user with the AM role can manage a headquarters", + {"user_role": manager.role.value}, + ) + + wanted = set(headquarters_ids) + if wanted: + found = set( + ( + await self.db.execute( + select(Headquarters.id).where( + Headquarters.id.in_(wanted), + Headquarters.company_id == actor.company_id, + ) + ) + ).scalars() + ) + if found != wanted: + raise NotFoundError("Headquarters not found") + + start = effective_from or date.today() + mine = { + row.headquarters_id: row + for row in ( + await self.db.execute( + select(AMHeadquarters).where( + AMHeadquarters.area_manager_user_id == am_user_id, + AMHeadquarters.effective_to.is_(None), + ) + ) + ).scalars() + } + + released = set(mine) - wanted + added = wanted - set(mine) + for hq_id in released: + mine[hq_id].effective_to = start + + if added: + for row in ( + await self.db.execute( + select(AMHeadquarters).where( + AMHeadquarters.headquarters_id.in_(added), + AMHeadquarters.effective_to.is_(None), + ) + ) + ).scalars(): + row.effective_to = start + await self.db.flush() + + for hq_id in added: + self.db.add( + AMHeadquarters( + area_manager_user_id=am_user_id, + headquarters_id=hq_id, + effective_from=start, + ) + ) + + if added or released: + await self.audit.log( + actor_user_id=actor.id, + entity_type=EntityType.USER, + entity_id=am_user_id, + action=AuditAction.ASSIGN, + before={"headquarters_ids": sorted(str(h) for h in mine)}, + after={"headquarters_ids": sorted(str(h) for h in wanted)}, + ip_address=ip, + ) + await self.db.commit() + return await self.list_area_manager_mappings_for(am_user_id) + + async def list_area_manager_mappings_for(self, am_user_id: uuid.UUID) -> list[AMHeadquarters]: + stmt = select(AMHeadquarters).where( + AMHeadquarters.area_manager_user_id == am_user_id, + AMHeadquarters.effective_to.is_(None), + ) + return list((await self.db.execute(stmt)).scalars().all()) + + async def assign_area_manager( + self, + headquarters_id: uuid.UUID, + am_user_id: uuid.UUID, + effective_from: date | None, + actor: User, + ip: str | None = None, + ) -> AMHeadquarters: + """Assign an AM to an HQ, closing any existing active mapping first. + + The partial unique index `uq_active_am_per_hq` is the real guarantee that only + one Area Manager is active per headquarters at a time. + """ + hq = await self.db.get(Headquarters, headquarters_id) + if hq is None: + raise NotFoundError("Headquarters not found") + + manager = await self.db.get(User, am_user_id) + if manager is None: + raise NotFoundError("User not found") + if manager.role != Role.AM: + raise ValidationError( + "Only a user with the AM role can manage a headquarters", + {"user_role": manager.role.value}, + ) + + start = effective_from or date.today() + + existing = ( + await self.db.execute( + select(AMHeadquarters).where( + AMHeadquarters.headquarters_id == headquarters_id, + AMHeadquarters.effective_to.is_(None), + ) + ) + ).scalars().all() + for row in existing: + if row.area_manager_user_id == am_user_id: + return row + row.effective_to = start + await self.db.flush() + + mapping = AMHeadquarters( + area_manager_user_id=am_user_id, + headquarters_id=headquarters_id, + effective_from=start, + ) + self.db.add(mapping) + await self.audit.log( + actor_user_id=actor.id, + entity_type=EntityType.HEADQUARTERS, + entity_id=headquarters_id, + action=AuditAction.ASSIGN, + after={"area_manager_user_id": str(am_user_id), "effective_from": start.isoformat()}, + ip_address=ip, + ) + await self.db.commit() + return mapping diff --git a/app/pdf/__init__.py b/app/pdf/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/app/pdf/forms.py b/app/pdf/forms.py new file mode 100644 index 0000000..c855c28 --- /dev/null +++ b/app/pdf/forms.py @@ -0,0 +1,453 @@ +"""View models for the company-form PDFs (tour plan, fare chart, sales & stock, ...). + +Pure Python — no WeasyPrint, no database — so every form's layout data can be unit +tested anywhere. ``build_form_context`` turns the stored rows of one CSV table into +the context its template under ``templates/forms/`` renders. + +Each form here is a copy of the company's printed form: the same title, the same +column headings in the same order, the same column proportions and the same number of +ruled lines. Stored rows fill those lines from the top; the rest stay blank for +handwriting, and rows beyond the printed length simply continue on the next page. +The templates own the look; this module owns *what* each form shows. +""" + +from __future__ import annotations + +from dataclasses import dataclass +from datetime import date + +DATE_FIELDS = {"report_date", "date_of_visit"} +APPROVAL_FORMS = {"standard_tour_plan", "tour_plan", "fare_chart"} +SERIAL = "#" # pseudo-field: the running "Sl.No." column +_ALIGN = {"left": "l", "center": "c", "right": "r"} + +Row = dict[str, object] +Meta = tuple[str, str] | None # (printed label, column) — None leaves the slot empty + + +@dataclass(frozen=True) +class Col: + header: str + field: str + width: float # percent of the table + align: str = "left" + + +@dataclass(frozen=True) +class FormSpec: + template: str + title: str + meta: tuple[tuple[Meta, Meta], ...] + columns: tuple[Col, ...] = () + min_rows: int = 25 + serial_field: str | None = None + serial_dot: bool = False # "1." (tour plan, fare chart) instead of "1" + table_width: float = 100 # percent of the printed width + full_letterhead: bool = True # address, web and phone lines under the company name + + +def _serial(header: str, width: float) -> Col: + return Col(header, SERIAL, width, "center") + + +_NAME_HQ = ((("NAME:", "name"), None), (("HEADQUARTER:", "headquarter"), None)) +_NAME_HQ_DATE_MONTH = ( + (("NAME:", "name"), ("Date:", "report_date")), + (("HEADQUARTER:", "headquarter"), ("Month:", "month")), +) +_NAME_HQ_MONTH = ( + (("NAME :", "name"), None), + (("HEADQUARTER:", "headquarter"), ("MONTH:", "month")), +) + +FORMS: dict[str, FormSpec] = { + "standard_tour_plan": FormSpec( + "standard_tour_plan", + "STANDARD TOUR PLAN", + _NAME_HQ, + (_serial("Sl.No.", 11.4), Col("PLACE", "place", 88.6, "center")), + serial_field="serial_no", + serial_dot=True, + table_width=83, + ), + "tour_plan": FormSpec( + "tour_plan", + "TOUR PLAN", + _NAME_HQ, + ( + _serial("Sl.No.", 9.4), + Col("Date", "report_date", 11.9, "center"), + Col("From", "from_location", 25.0), + Col("To", "to_location", 23.2), + Col("POB", "pob", 15.3, "center"), + Col("Stockiest Visit", "stockiest_visit", 15.2, "center"), + ), + serial_field="serial_no", + serial_dot=True, + ), + "fare_chart": FormSpec( + "fare_chart", + "FARE CHART", + _NAME_HQ, + ( + _serial("Sl.No.", 9.4), + Col("Date", "report_date", 15.3, "center"), + Col("From", "from_location", 30.2), + Col("To", "to_location", 27.1), + Col("Kilometers (KM)", "kilometers_km", 17.6, "center"), + ), + serial_field="serial_no", + serial_dot=True, + ), + "area_covered": FormSpec( + "area_covered", + "AREA COVERED", + _NAME_HQ_MONTH, + ( + Col("SALE STATUS", "sale_status", 34.0), + Col("AREA TO COVER", "area_to_cover", 24.3), + Col("SALE OBJECTIVE", "sale_objective", 20.8), + Col("STATUS", "status", 20.9, "center"), + ), + min_rows=28, + full_letterhead=False, + ), + "core_dr_call_conversion": FormSpec( + "core_dr_call_conversion", + "CORE Dr. CALL & CONVERSION", + _NAME_HQ_MONTH, + ( + Col("DOCTOR NAME", "doctor_name", 38.3), + Col("DATE OF VISIT", "date_of_visit", 14.7, "center"), + Col("PRODUCT TARGETED", "product_targeted", 30.4), + Col("STATUS", "status", 16.6, "center"), + ), + min_rows=28, + full_letterhead=False, + ), + "field_activity_report": FormSpec( + "field_activity_report", + "FIELD ACTIVITY REPORT", + _NAME_HQ_MONTH, + ( + Col("DATE", "report_date", 14.5, "center"), + Col("STATION WORKED", "station_worked", 36.6), + Col("NO. OF DOCTORS CALLED", "no_of_doctors_called", 19.8, "center"), + Col("NO. OF CHEMISTS/PDS CALLED", "no_of_chemists_pds_called", 29.1, "center"), + ), + min_rows=25, + table_width=83, + full_letterhead=False, + ), + "sales_and_stock_statement": FormSpec( + "sales_and_stock_statement", + "SALES AND STOCK STATEMENT", + _NAME_HQ_DATE_MONTH, + ( + _serial("Sl.No.", 7.0), + Col("Name of the Product", "product_name", 22.6), + Col("Opening", "opening", 15.0, "center"), + Col("Receipt", "receipt", 14.7, "center"), + Col("Sale", "sale", 15.0, "center"), + Col("Closing", "closing", 12.2, "center"), + Col("Value in PTS", "value_in_pts", 13.5, "center"), + ), + min_rows=26, + serial_field="serial_no", + ), + "sales_projection": FormSpec( + "sales_projection", + "SALES PROJECTION", + _NAME_HQ_MONTH, + ( + _serial("SL. No.", 7.1), + Col("NAME OF THE PRODUCT", "product_name", 22.7), + Col("PTS", "pts", 10.7, "center"), + Col("SEC. QTY", "secondary_qty", 9.1, "center"), + Col("VALUE", "value", 9.6, "center"), + Col("CLOSING", "closing", 11.6, "center"), + Col("SEC. VALUE", "secondary_value", 10.1, "center"), + Col("AUG. SALES", "aug_sales", 9.6, "center"), + Col("VALUE", "value_2", 9.5, "center"), + ), + min_rows=26, + serial_field="serial_no", + full_letterhead=False, + ), + "daily_call_report_csv": FormSpec( + "daily_call_report_csv", + "DAILY CALL REPORT", + _NAME_HQ_DATE_MONTH, + ), + "weekly_report": FormSpec( + "weekly_report", + "Weekly Report", + ( + (("EMPLOYEE NAME:", "employee_name"), ("DATE :", "report_date")), + (("HEADQUARTER :", "headquarter"), ("MONTH:", "month")), + ), + full_letterhead=False, + ), +} + +# Daily Call Report: a doctor-call table and a chemist-visit table share one stored row. +_DOCTOR_COLS = ( + _serial("SR. NO.", 8.6), + Col("DR. NAME", "doctor_name", 27.5), + Col("QUALIFICATION", "qualification", 14.9), + Col("PRODUCT PROMOTE", "product_promote", 14.6), + Col("PRODUCT SAMPLE", "product_sample", 18.2), + Col("REMARKS", "remarks", 16.2), +) +_DOCTOR_FIELDS = tuple(c.field for c in _DOCTOR_COLS if c.field != SERIAL) +_CHEMIST_COLS = ( + _serial("SR. NO.", 10.2), + Col("NAME OF THE CHEMIST", "chemist_name", 32.8), + Col("POB", "pob", 57.0), +) +_CHEMIST_FIELDS = tuple(c.field for c in _CHEMIST_COLS if c.field != SERIAL) + +_WEEKLY_SUMMARY = ( + ("No. of Days Worked", "no_of_days_worked"), + ("No. of Doctor Called", "no_of_doctor_called"), + ("No. of Chemist Called", "no_of_chemist_called"), + ("POB Booked", "pob_booked"), + ("Secondary Sales", "secondary_sales"), + ("POB Objective", "pob_objective"), + ("Secondary Objective", "secondary_objective"), +) +_WEEKLY_SCHEMES = ( + ("Product – Offer Scheme Booked", "product_offer_scheme_booked"), + ("Product – Offer Scheme Objective", "product_offer_scheme_objective"), +) + + +# --------------------------------------------------------------------- helpers +def _text(value: object) -> str: + return "" if value is None else str(value).strip() + + +def _display(field: str, value: object) -> str: + """Stored text as printed; ISO dates become dd/mm/yyyy, anything else is untouched.""" + text = _text(value) + if field in DATE_FIELDS and text: + try: + return date.fromisoformat(text[:10]).strftime("%d/%m/%Y") + except ValueError: + return text + return text + + +def _distinct(rows: list[Row], field: str) -> str: + """Every different stored value of a column, in order — never just the first row's.""" + seen: list[str] = [] + for row in rows: + value = _display(field, row.get(field)) + if value and value not in seen: + seen.append(value) + return ", ".join(seen) + + +def _has(row: Row, fields: tuple[str, ...]) -> bool: + return any(_text(row.get(field)) for field in fields) + + +def _grid( + cols: tuple[Col, ...], + rows: list[Row], + *, + min_rows: int, + serial_field: str | None = None, + serial_dot: bool = False, + table_width: float = 100, +) -> dict[str, object]: + """One printed table: header, stored rows, then blank ruled lines up to ``min_rows``.""" + suffix = "." if serial_dot else "" + body = [] + next_serial = 1 + for index in range(max(min_rows, len(rows))): + row = rows[index] if index < len(rows) else None + cells: list[str] = [] + for col in cols: + if col.field == SERIAL: + # A stored number wins (single-row PDFs keep their real serial); blank + # lines carry on counting from the last printed number. + number = _text(row.get(serial_field)) if row and serial_field else "" + number = number or str(next_serial) + next_serial = int(number) + 1 if number.isdigit() else next_serial + 1 + cells.append(number + suffix) + else: + cells.append(_display(col.field, row.get(col.field)) if row else "") + body.append({"cells": cells, "blank": row is None}) + return { + "headers": [c.header for c in cols], + "aligns": [_ALIGN[c.align] for c in cols], + "widths": [f"{c.width}%" for c in cols], + "rows": body, + "width": f"{table_width}%", + } + + +def _meta_rows( + meta: tuple[tuple[Meta, Meta], ...], rows: list[Row] +) -> list[list[tuple[str, str] | None]]: + return [ + [(slot[0], _distinct(rows, slot[1])) if slot else None for slot in pair] for pair in meta + ] + + +def approval_signature_line( + table_name: str, approval_status: str | None = None, am_name: str | None = None +) -> str: + if table_name not in APPROVAL_FORMS: + return "" + approved = (approval_status or "pending").lower() == "approved" + name = (am_name or "").strip() + return f"APPROVAL SIGNATURE: {name}" if approved and name else "APPROVAL SIGNATURE: PENDING" + + +# --------------------------------------------------------------------- builder +def build_form_context( + table_name: str, + label: str, + columns: tuple[str, ...], + rows: list[Row], + approval_status: str | None = None, + am_name: str | None = None, + approved_at: str | None = None, +) -> dict[str, object]: + """Everything a form template needs, for all stored rows of ``table_name``.""" + spec = FORMS.get(table_name) + grids: dict[str, dict[str, object]] = {} + extra: dict[str, object] = {} + + if spec is None: # unknown table: print every stored column generically + identity = {"name", "employee_name", "headquarter", "month"} + spec = FormSpec( + "generic", + label.upper(), + tuple( + ( + (f"{c.replace('_', ' ').upper()}:", c) if c in identity else None, + None, + ) + for c in columns + if c in identity + ), + ) + cols = tuple( + Col(c.replace("_", " ").upper(), c, 100 / max(1, len(columns))) + for c in columns + if c not in {"id", "source_row_number"} + ) + grids["main"] = _grid(cols, rows, min_rows=0) + elif spec.template == "daily_call_report_csv": + doctors = [r for r in rows if _has(r, _DOCTOR_FIELDS)] + chemists = [r for r in rows if _has(r, _CHEMIST_FIELDS)] + grids["doctors"] = _grid(_DOCTOR_COLS, doctors, min_rows=10, serial_field="doctor_sr_no") + grids["chemists"] = _grid( + _CHEMIST_COLS, chemists, min_rows=5, serial_field="chemist_sr_no", table_width=84 + ) + extra["stockist_visit"] = _distinct(rows, "stockist_visit") + extra["order_value"] = _distinct(rows, "order_value") + elif spec.template == "weekly_report": + extra["reports"] = [ + { + "meta_rows": _meta_rows(spec.meta, [r]), + "summary": [(lbl, _text(r.get(f))) for lbl, f in _WEEKLY_SUMMARY], + "schemes": [(lbl, _text(r.get(f))) for lbl, f in _WEEKLY_SCHEMES], + } + for r in rows or [{}] + ] + else: + grids["main"] = _grid( + spec.columns, + rows, + min_rows=spec.min_rows, + serial_field=spec.serial_field, + serial_dot=spec.serial_dot, + table_width=spec.table_width, + ) + if table_name == "field_activity_report": + extra["doctor_call_avg"] = _distinct(rows, "doctor_call_avg") + extra["chemist_call_avg"] = _distinct(rows, "chemist_call_avg") + + approval = None + if table_name in APPROVAL_FORMS: + line = approval_signature_line(table_name, approval_status, am_name) + value = line.split(": ", 1)[1] + approval = { + "line": line, "label": "APPROVAL SIGNATURE:", "value": value, + "when": approved_at if value != "PENDING" and approved_at else "", + # Once approved, the MR's own signature line carries their name too. + "mr_name": _distinct(rows, "name") if value != "PENDING" else "", + } + + if spec.template == "weekly_report": + meta: list[list[tuple[str, str] | None]] = [] + else: + meta = _meta_rows(spec.meta, rows) + + return { + "template": spec.template, + "label": label, + "title": spec.title, + "full_letterhead": spec.full_letterhead, + "title_suffix": next((s[1] for pair in meta for s in pair if s and s[1]), ""), + "meta_rows": meta, + "grids": grids, + "approval": approval, + **extra, + } + + +# ------------------------------------------------------------- the filed Daily Call Report +_OUTCOME_NOTE = {"NOT_AVAILABLE": "Not available", "RESCHEDULED": "Rescheduled"} + + +def _doctor_remarks(call) -> str: + """The remarks column; a visit that did not happen is flagged, since the form has no outcome column.""" + note = _OUTCOME_NOTE.get(getattr(call.call_outcome, "value", str(call.call_outcome)), "") + return ". ".join(part for part in (note, (call.remarks or "").strip()) if part) + + +def build_dcr_context(dcr, doctor_calls, chemist_calls, approval: dict[str, str] | None = None) -> dict[str, object]: + """The approved Daily Call Report, laid out exactly like the printed company form. + + Same template family, headings, column widths and number of ruled lines as the + ``daily_call_report_csv`` company form: 10 doctor lines and 5 chemist lines, filled + from the top in visit order; more visits simply continue on the next page. The only + additions are the signatures: the MR's name, and (once approved) the Area Manager's + approval signature with its date and time. + """ + doctors = [ + { + "doctor_name": c.doctor.name, + "qualification": c.doctor.qualification or "", + "product_promote": c.product_promote or "", + "product_sample": c.product_sample or "", + "remarks": _doctor_remarks(c), + } + for c in doctor_calls + ] + chemists = [{"chemist_name": c.chemist.name, "pob": c.pob or ""} for c in chemist_calls] + meta = [ + [("NAME:", dcr.mr.full_name), ("Date:", dcr.report_date.strftime("%d/%m/%Y"))], + [("HEADQUARTER:", dcr.headquarters.name), ("Month:", dcr.report_date.strftime("%B %Y"))], + ] + return { + "template": "dcr", + "label": "Daily Call Report", + "title": "DAILY CALL REPORT", + "title_suffix": f"{dcr.mr.full_name} — {dcr.report_date.strftime('%d/%m/%Y')}", + "full_letterhead": True, + "meta_rows": meta, + "grids": { + "doctors": _grid(_DOCTOR_COLS, doctors, min_rows=10), + "chemists": _grid(_CHEMIST_COLS, chemists, min_rows=5, table_width=84), + }, + "stockist_visit": dcr.stockist_visit or "", + "order_value": dcr.order_value or "", + "mr_signed": f"{dcr.mr.full_name} ({dcr.mr.employee_code})", + "approval": approval, # {"name": ..., "at": "dd/mm/yyyy HH:MM"} or None + } diff --git a/app/pdf/service.py b/app/pdf/service.py new file mode 100644 index 0000000..b44d661 --- /dev/null +++ b/app/pdf/service.py @@ -0,0 +1,236 @@ +"""Approved-report and company-form PDF generation. + +WeasyPrint (BSD-3-Clause) renders Jinja2 HTML templates, so every layout is plain +HTML/CSS that anyone on the team can edit. The approved Daily Call Report and every +company form (tour plan, fare chart, sales & stock, ...) extend +``templates/forms/_form_base.html``, because each is a copy of the company's printed form; +each has its own template (``dcr.html`` or one under ``templates/forms/``). What a form +shows is decided in ``app.pdf.forms``. + +WeasyPrint needs system libraries (Pango, HarfBuzz) and DejaVu fonts. They are pinned in +the Dockerfile. If they are genuinely absent (a bare dev machine, CI without the apt +step) the service falls back to a minimal built-in writer so the workflow still +completes and tests still run — and logs a loud warning, because that fallback +produces a plain-text PDF, not the designed layout. Production must have WeasyPrint; +``pdf_engine_ready()`` lets the health check and startup log say so. +""" + +import logging +import uuid +from html.parser import HTMLParser +from pathlib import Path +from zoneinfo import ZoneInfo + +from jinja2 import Environment, FileSystemLoader, select_autoescape +from sqlalchemy.ext.asyncio import AsyncSession + +from app.audit.service import AuditService +from app.common.enums import AuditAction, EntityType +from app.config.settings import settings +from app.pdf.forms import approval_signature_line, build_dcr_context, build_form_context +from app.reports.models import DailyCallReport +from app.users.models import User + +logger = logging.getLogger(__name__) + +_TEMPLATE_DIR = Path(__file__).parent / "templates" +_env = Environment( + loader=FileSystemLoader(_TEMPLATE_DIR), + autoescape=select_autoescape(["html"]), +) +_env.globals.update( + company_name=settings.PDF_COMPANY_NAME, + company_address=settings.PDF_COMPANY_ADDRESS, + company_website=settings.PDF_COMPANY_WEBSITE, + company_email=settings.PDF_COMPANY_EMAIL, + company_phone=settings.PDF_COMPANY_PHONE, +) + +try: # pragma: no cover - depends on system libraries + from weasyprint import HTML as _WeasyHTML + + WEASYPRINT_AVAILABLE = True +except Exception: # noqa: BLE001 - ImportError or OSError from missing libs + _WeasyHTML = None + WEASYPRINT_AVAILABLE = False + + +def pdf_engine_ready() -> bool: + """True when the designed (WeasyPrint) layout can be rendered.""" + return WEASYPRINT_AVAILABLE + + +def _minimal_pdf(text: str) -> bytes: + """Fallback renderer: a valid single-page PDF containing plain text. + + Used ONLY when WeasyPrint's system libraries are unavailable. It exists so the + approval workflow and its tests never depend on native libraries being present. + """ + lines = [ln[:95] for ln in text.splitlines()][:52] + content = ["BT", "/F1 9 Tf", "40 780 Td", "11 TL"] + for line in lines: + escaped = line.replace("\\", r"\\").replace("(", r"\(").replace(")", r"\)") + content.append(f"({escaped}) Tj T*") + content.append("ET") + stream = "\n".join(content).encode("latin-1", "replace") + + objects = [ + b"<< /Type /Catalog /Pages 2 0 R >>", + b"<< /Type /Pages /Kids [3 0 R] /Count 1 >>", + b"<< /Type /Page /Parent 2 0 R /MediaBox [0 0 595 842] " + b"/Resources << /Font << /F1 5 0 R >> >> /Contents 4 0 R >>", + b"<< /Length " + str(len(stream)).encode() + b" >>\nstream\n" + stream + b"\nendstream", + b"<< /Type /Font /Subtype /Type1 /BaseFont /Helvetica >>", + ] + + out = bytearray(b"%PDF-1.4\n") + offsets = [0] + for i, body in enumerate(objects, start=1): + offsets.append(len(out)) + out += f"{i} 0 obj\n".encode() + body + b"\nendobj\n" + + xref_pos = len(out) + out += f"xref\n0 {len(objects) + 1}\n".encode() + out += b"0000000000 65535 f \n" + for off in offsets[1:]: + out += f"{off:010d} 00000 n \n".encode() + out += ( + f"trailer\n<< /Size {len(objects) + 1} /Root 1 0 R >>\n" + f"startxref\n{xref_pos}\n%%EOF\n" + ).encode() + return bytes(out) + + +class _TextExtractor(HTMLParser): + """Flattens a rendered form to lines of text for the plain-text fallback.""" + + _SKIP = {"style", "title", "script"} + _BREAK = {"tr", "div", "h1", "h2", "p", "br", "table"} + + def __init__(self) -> None: + super().__init__() + self.parts: list[str] = [] + self._skipping = 0 + + def handle_starttag(self, tag: str, attrs: list) -> None: + if tag in self._SKIP: + self._skipping += 1 + + def handle_endtag(self, tag: str) -> None: + if tag in self._SKIP: + self._skipping -= 1 + elif tag in {"td", "th"}: + self.parts.append(" | ") + elif tag in self._BREAK: + self.parts.append("\n") + + def handle_data(self, data: str) -> None: + if not self._skipping and data.strip(): + self.parts.append(" ".join(data.split()) + " ") + + +def _html_to_text(html: str) -> str: + parser = _TextExtractor() + parser.feed(html) + lines = ("".join(parser.parts)).splitlines() + cleaned = (" ".join(line.split()).strip(" |") for line in lines) + return "\n".join(line for line in cleaned if line) + + +def _approval_signature_line( + table_name: str, + approval_status: str | None = None, + am_name: str | None = None, + am_role: str = "Area Manager", +) -> str: + return approval_signature_line(table_name, approval_status, am_name) + + +def csv_table_pdf_bytes( + table_name: str, + table_label: str, + columns: tuple[str, ...], + rows: list[dict[str, object]], + approval_status: str | None = None, + am_name: str | None = None, + am_role: str = "Area Manager", + approved_at: str | None = None, +) -> bytes: + """Render every stored row of an imported table on its own company-form layout.""" + context = build_form_context( + table_name, table_label, columns, rows, approval_status, am_name, approved_at + ) + html = _env.get_template(f"forms/{context['template']}.html").render(**context) + if WEASYPRINT_AVAILABLE: + return _WeasyHTML(string=html).write_pdf() + + logger.warning( + "WeasyPrint unavailable — using the plain-text fallback renderer for %s. " + "Install Pango/HarfBuzz (see Dockerfile) before production use.", + table_name, + ) + return _minimal_pdf(_html_to_text(html)) + + +def csv_pdf_bytes(table_label: str, row: dict[str, object]) -> bytes: + """Render one imported table row for the row-level PDF action.""" + columns = tuple(key for key in row if key not in {"id", "source_row_number"}) + return csv_table_pdf_bytes("row", table_label, columns, [row]) + + +class PDFService: + def __init__(self, db: AsyncSession) -> None: + self.db = db + self.audit = AuditService(db) + + async def _approval(self, dcr: DailyCallReport) -> dict[str, str] | None: + """Who approved the report and when, from the audit trail — the signature cannot be typed in.""" + if dcr.approved_at is None: + return None + approvals = [h for h in await self.audit.approval_history_for(dcr.id) if h.action == AuditAction.APPROVE] + if not approvals: + return None + approver = await self.db.get(User, approvals[-1].actor_user_id) + if approver is None: + return None + when = dcr.approved_at.astimezone(ZoneInfo(settings.APP_TIMEZONE)).strftime("%d/%m/%Y %H:%M") + return {"name": approver.full_name, "at": when} + + async def _context(self, dcr: DailyCallReport) -> dict: + return build_dcr_context( + dcr, + sorted(dcr.doctor_calls, key=lambda c: c.visit_time), + sorted(dcr.chemist_calls, key=lambda c: c.visit_time), + await self._approval(dcr), + ) + + async def render_bytes(self, dcr: DailyCallReport) -> bytes: + """The report as a PDF in the current layout — a pure function of the stored report.""" + context = await self._context(dcr) + html = _env.get_template("dcr.html").render(**context) + + if WEASYPRINT_AVAILABLE: + return _WeasyHTML(string=html).write_pdf() + + logger.warning( + "WeasyPrint unavailable — using the plain-text fallback renderer. " + "Install Pango/cairo (see Dockerfile) before production use." + ) + return _minimal_pdf(_env.get_template("dcr.txt").render(**context)) + + async def render_and_store(self, dcr: DailyCallReport, approver: User) -> str: + pdf_bytes = await self.render_bytes(dcr) + + directory = Path(settings.PDF_STORAGE_PATH) / str(dcr.report_date.year) + directory.mkdir(parents=True, exist_ok=True) + path = directory / f"DCR-{dcr.report_date.isoformat()}-{dcr.id}.pdf" + path.write_bytes(pdf_bytes) + + await self.audit.log( + actor_user_id=approver.id, + entity_type=EntityType.DCR, + entity_id=dcr.id, + action=AuditAction.UPDATE, + after={"pdf_generated": str(path)}, + ) + return str(path) diff --git a/app/pdf/templates/dcr.html b/app/pdf/templates/dcr.html new file mode 100644 index 0000000..64dd633 --- /dev/null +++ b/app/pdf/templates/dcr.html @@ -0,0 +1,46 @@ +{# The approved Daily Call Report — a copy of the company's printed form, filled in. #} +{% extends "forms/_form_base.html" %} +{% from "forms/_macros.html" import grid %} + +{% block form_styles %} + h1.title { margin: 6mm 0 3mm; font-size: 13pt; text-decoration: none; letter-spacing: .3px; } + table.grid th { height: 7.5mm; font-size: 9pt; } + table.grid td { font-size: 10pt; } + h2.section { margin: 6mm 0 1.5mm; text-align: center; font-size: 11pt; } + .visit { margin: 6mm 0 0 14mm; font-size: 10.5pt; line-height: 1.7; } + .visit b { display: inline-block; min-width: 30mm; } + table.dcr-sign { width: 100%; margin-top: 12mm; border-collapse: collapse; page-break-inside: avoid; } + table.dcr-sign td { vertical-align: top; padding: 0; } + table.dcr-sign td.mr { width: 52%; padding-left: 14mm; } + .sign-label { font-size: 10.5pt; font-weight: bold; } + .signed { display: inline-block; min-width: 62mm; margin-top: 4mm; padding-bottom: 1mm; border-bottom: .7pt solid #000; font-family: "Liberation Serif", "Times New Roman", serif; font-style: italic; font-size: 12pt; } + .signed-when { margin-top: 1.2mm; font-size: 8.5pt; } +{% endblock %} + +{% block form %} + {{ grid(grids.doctors, left=True) }} +

CHEMIST VISIT

+ {{ grid(grids.chemists, left=True) }} +
+
STOCKIST VISIT : {{ stockist_visit }}
+
ORDER : {{ order_value }}
+
+{% endblock %} + +{% block signature %} + + + + + +
+
MR Signature
+
{{ mr_signed }}
+
+ {% if approval %} +
APPROVAL SIGNATURE:
+
{{ approval.name }}
+
Area Manager · {{ approval.at }}
+ {% endif %} +
+{% endblock %} diff --git a/app/pdf/templates/dcr.txt b/app/pdf/templates/dcr.txt new file mode 100644 index 0000000..d91f275 --- /dev/null +++ b/app/pdf/templates/dcr.txt @@ -0,0 +1,19 @@ +{{ company_name }} +{{ company_address }} +Website: {{ company_website }} E-Mail: {{ company_email }} PHONE: {{ company_phone }} +DAILY CALL REPORT +{% for pair in meta_rows %}{% for slot in pair %}{% if slot %}{{ slot[0] }} {{ slot[1] }} {% endif %}{% endfor %} +{% endfor %} +SR.NO | DR. NAME | QUALIFICATION | PRODUCT PROMOTE | PRODUCT SAMPLE | REMARKS +{% for r in grids.doctors.rows %}{{ r.cells | join(' | ') }} +{% endfor %} +CHEMIST VISIT +SR.NO | NAME OF THE CHEMIST | POB +{% for r in grids.chemists.rows %}{{ r.cells | join(' | ') }} +{% endfor %} +STOCKIST VISIT : {{ stockist_visit }} +ORDER : {{ order_value }} + +MR Signature: {{ mr_signed }} +{% if approval %}APPROVAL SIGNATURE: {{ approval.name }} ({{ approval.at }}) +{% endif %} \ No newline at end of file diff --git a/app/pdf/templates/forms/_form_base.html b/app/pdf/templates/forms/_form_base.html new file mode 100644 index 0000000..a1f8469 --- /dev/null +++ b/app/pdf/templates/forms/_form_base.html @@ -0,0 +1,108 @@ +{# Base for every company form. Standalone on purpose: the forms copy the printed + originals and must not inherit the DCR report's look (base.html). #} +{% from "forms/_macros.html" import letterhead, meta_block, grid, sign_right, sign_approval %} + + + + + + {{ label }}{% if title_suffix %} — {{ title_suffix }}{% endif %} + + + + + {% block body %} + {{ letterhead(full_letterhead) }} +

{{ title }}

+ {{ meta_block(meta_rows) }} + {% block form %}{% endblock %} + {% block signature %}{{ sign_right() }}{% endblock %} + {% endblock %} + + + diff --git a/app/pdf/templates/forms/_macros.html b/app/pdf/templates/forms/_macros.html new file mode 100644 index 0000000..a4c9b6b --- /dev/null +++ b/app/pdf/templates/forms/_macros.html @@ -0,0 +1,56 @@ +{# Building blocks shared by the company-form PDFs. Each mirrors a part of the printed form. #} + +{% macro letterhead(full) %} +
+
{{ company_name }}
+ {% if full %} +
{{ company_address }}
+
Website: {{ company_website }} E-Mail:{{ company_email }}
+
PHONE: {{ company_phone }}
+ {% endif %} +
+{% endmacro %} + +{# NAME / HEADQUARTER on the left, DATE / MONTH on the right — empty slots stay empty. #} +{% macro meta_block(rows) %} +{% if rows %} + + {% for pair in rows %} + + {% for slot in pair %} + + {% endfor %} + + {% endfor %} +
{% if slot %}{{ slot[0] }} {{ slot[1] }}{% endif %}
+{% endif %} +{% endmacro %} + +{% macro grid(g, left=False) %} + + {% for w in g.widths %}{% endfor %} + + {% for h in g.headers %}{% endfor %} + + + {% for r in g.rows %} + {% for c in r.cells %}{% endfor %} + {% endfor %} + +
{{ h }}
{{ c }}
+{% endmacro %} + +{# "SIGNATURE" alone, low on the right — the sales / activity / call-report forms. #} +{% macro sign_right(text="SIGNATURE") %} +
{{ text }}
+{% endmacro %} + +{# Tour plan, standard tour plan and fare chart: MR signature plus the AM approval. #} +{% macro sign_approval(approval) %} + + + + + +
SIGNATURE: {{ approval.mr_name }}{{ approval.label }} {{ approval.value }}{% if approval.when %}
{{ approval.when }}
{% endif %}
+{% endmacro %} diff --git a/app/pdf/templates/forms/area_covered.html b/app/pdf/templates/forms/area_covered.html new file mode 100644 index 0000000..9fa3fe4 --- /dev/null +++ b/app/pdf/templates/forms/area_covered.html @@ -0,0 +1,11 @@ +{% extends "forms/_form_base.html" %} +{% from "forms/_macros.html" import grid %} + +{% block form_styles %} + h1.title { margin: 0 0 5mm; font-size: 10pt; } + table.grid th { font-family: "Liberation Sans", Arial, "DejaVu Sans", sans-serif; font-size: 10pt; } +{% endblock %} + +{% block form %} + {{ grid(grids.main) }} +{% endblock %} diff --git a/app/pdf/templates/forms/core_dr_call_conversion.html b/app/pdf/templates/forms/core_dr_call_conversion.html new file mode 100644 index 0000000..9fa3fe4 --- /dev/null +++ b/app/pdf/templates/forms/core_dr_call_conversion.html @@ -0,0 +1,11 @@ +{% extends "forms/_form_base.html" %} +{% from "forms/_macros.html" import grid %} + +{% block form_styles %} + h1.title { margin: 0 0 5mm; font-size: 10pt; } + table.grid th { font-family: "Liberation Sans", Arial, "DejaVu Sans", sans-serif; font-size: 10pt; } +{% endblock %} + +{% block form %} + {{ grid(grids.main) }} +{% endblock %} diff --git a/app/pdf/templates/forms/daily_call_report_csv.html b/app/pdf/templates/forms/daily_call_report_csv.html new file mode 100644 index 0000000..44a71b5 --- /dev/null +++ b/app/pdf/templates/forms/daily_call_report_csv.html @@ -0,0 +1,24 @@ +{% extends "forms/_form_base.html" %} +{% from "forms/_macros.html" import grid %} + +{% block form_styles %} + h1.title { margin: 6mm 0 3mm; font-size: 13pt; text-decoration: none; letter-spacing: .3px; } + table.grid th { height: 7.5mm; font-size: 9pt; } + table.grid td { font-size: 10pt; } + h2.section { margin: 6mm 0 1.5mm; text-align: center; font-size: 11pt; } + .visit { margin: 6mm 0 0 14mm; font-size: 10.5pt; line-height: 1.7; } + .visit b { display: inline-block; min-width: 30mm; } + .sign-left { margin: 12mm 0 0 14mm; font-size: 10.5pt; font-weight: bold; } +{% endblock %} + +{% block form %} + {{ grid(grids.doctors, left=True) }} +

CHEMIST VISIT

+ {{ grid(grids.chemists, left=True) }} +
+
STOCKIST VISIT : {{ stockist_visit }}
+
ORDER : {{ order_value }}
+
+{% endblock %} + +{% block signature %}
MR Signature
{% endblock %} diff --git a/app/pdf/templates/forms/fare_chart.html b/app/pdf/templates/forms/fare_chart.html new file mode 100644 index 0000000..2584119 --- /dev/null +++ b/app/pdf/templates/forms/fare_chart.html @@ -0,0 +1,8 @@ +{% extends "forms/_form_base.html" %} +{% from "forms/_macros.html" import grid, sign_approval %} + +{% block form %} + {{ grid(grids.main) }} +{% endblock %} + +{% block signature %}{{ sign_approval(approval) }}{% endblock %} diff --git a/app/pdf/templates/forms/field_activity_report.html b/app/pdf/templates/forms/field_activity_report.html new file mode 100644 index 0000000..eed13fe --- /dev/null +++ b/app/pdf/templates/forms/field_activity_report.html @@ -0,0 +1,20 @@ +{% extends "forms/_form_base.html" %} +{% from "forms/_macros.html" import grid, sign_right %} + +{% block form_styles %} + h1.title { margin: 0 0 5mm; font-size: 13pt; } + table.grid th { font-family: "Liberation Sans", Arial, "DejaVu Sans", sans-serif; font-size: 10pt; } + table.avg { width: 100%; margin-top: 7mm; border-collapse: collapse; } + table.avg td { padding: 0; font-family: "Liberation Sans", Arial, "DejaVu Sans", sans-serif; font-size: 9.5pt; font-weight: bold; white-space: nowrap; } + table.avg .ln { min-width: 44mm; } +{% endblock %} + +{% block form %} + {{ grid(grids.main) }} + + + + + +
DOCTOR CALL AVG {{ doctor_call_avg }}CHEMIST CALL AVG. {{ chemist_call_avg }}
+{% endblock %} diff --git a/app/pdf/templates/forms/generic.html b/app/pdf/templates/forms/generic.html new file mode 100644 index 0000000..76d40c1 --- /dev/null +++ b/app/pdf/templates/forms/generic.html @@ -0,0 +1,6 @@ +{% extends "forms/_form_base.html" %} +{% from "forms/_macros.html" import grid %} + +{% block form %} + {{ grid(grids.main) }} +{% endblock %} diff --git a/app/pdf/templates/forms/sales_and_stock_statement.html b/app/pdf/templates/forms/sales_and_stock_statement.html new file mode 100644 index 0000000..c041b19 --- /dev/null +++ b/app/pdf/templates/forms/sales_and_stock_statement.html @@ -0,0 +1,11 @@ +{% extends "forms/_form_base.html" %} +{% from "forms/_macros.html" import grid %} + +{% block form_styles %} + h1.title { font-size: 14pt; margin: 6mm 0 3mm; } + table.grid th { font-size: 11pt; } +{% endblock %} + +{% block form %} + {{ grid(grids.main) }} +{% endblock %} diff --git a/app/pdf/templates/forms/sales_projection.html b/app/pdf/templates/forms/sales_projection.html new file mode 100644 index 0000000..4f902be --- /dev/null +++ b/app/pdf/templates/forms/sales_projection.html @@ -0,0 +1,20 @@ +{% extends "forms/_form_base.html" %} +{% from "forms/_macros.html" import grid %} + +{# Arial throughout, title tucked directly under the company name — as printed. #} +{% block form_styles %} + .company .name { font-size: 20pt; } + h1.title { + margin: 0 0 4mm; + font-family: "Liberation Sans", Arial, "DejaVu Sans", sans-serif; + font-size: 14pt; + } + table.grid th, table.grid td { font-family: "Liberation Sans", Arial, "DejaVu Sans", sans-serif; } + table.grid th { height: 10mm; font-size: 9.5pt; } + table.grid td { font-size: 9.5pt; } + table.grid td:nth-child(2) { font-weight: bold; } +{% endblock %} + +{% block form %} + {{ grid(grids.main) }} +{% endblock %} diff --git a/app/pdf/templates/forms/standard_tour_plan.html b/app/pdf/templates/forms/standard_tour_plan.html new file mode 100644 index 0000000..401fc1b --- /dev/null +++ b/app/pdf/templates/forms/standard_tour_plan.html @@ -0,0 +1,8 @@ +{% extends "forms/_form_base.html" %} +{% from "forms/_macros.html" import grid, sign_approval %} + +{% block form %} + {{ grid(grids.main, left=True) }} +{% endblock %} + +{% block signature %}{{ sign_approval(approval) }}{% endblock %} diff --git a/app/pdf/templates/forms/tour_plan.html b/app/pdf/templates/forms/tour_plan.html new file mode 100644 index 0000000..2584119 --- /dev/null +++ b/app/pdf/templates/forms/tour_plan.html @@ -0,0 +1,8 @@ +{% extends "forms/_form_base.html" %} +{% from "forms/_macros.html" import grid, sign_approval %} + +{% block form %} + {{ grid(grids.main) }} +{% endblock %} + +{% block signature %}{{ sign_approval(approval) }}{% endblock %} diff --git a/app/pdf/templates/forms/weekly_report.html b/app/pdf/templates/forms/weekly_report.html new file mode 100644 index 0000000..a1cb588 --- /dev/null +++ b/app/pdf/templates/forms/weekly_report.html @@ -0,0 +1,64 @@ +{% extends "forms/_form_base.html" %} +{% from "forms/_macros.html" import letterhead, sign_right %} + +{# The weekly report is boxed: the whole page carries a border, as printed. #} +{% block page_box %}margin: 8mm; padding: 9mm 8mm 6mm; border: .8pt solid #000;{% endblock %} + +{% macro items(rows, label_width) %} + + {% for label, value in rows %} + + + + + + {% endfor %} +
o{{ label }}: {{ value }}
+{% endmacro %} + +{% block form_styles %} + .weekly + .weekly { page-break-before: always; } + .weekly h1.title { margin: 2mm 0 0; font-family: "Liberation Sans", Arial, "DejaVu Sans", sans-serif; font-size: 11pt; } + table.wmeta { width: 100%; margin: 9mm 0 7mm; border: .75pt solid #000; border-collapse: collapse; } + table.wmeta td { padding: 1.4mm 3mm; font-size: 10.5pt; } + table.wmeta td:first-child { width: 68%; } + .weekly h2 { + margin: 0 0 .6mm; + font-family: "Liberation Serif", "Times New Roman", "DejaVu Serif", serif; + font-size: 11.5pt; + } + .weekly h2.gap { margin-top: 2mm; } + table.items { width: 100%; margin: 0 0 4mm; border: .75pt solid #000; border-collapse: collapse; } + table.items td { + padding: .5mm 0; + font-family: "Liberation Serif", "Times New Roman", "DejaVu Serif", serif; + font-size: 11pt; + line-height: 1.25; + white-space: nowrap; + } + table.items tr:last-child td { padding-bottom: 2mm; } + table.items td.bul { width: 9mm; padding-left: 3mm; font-family: "Liberation Mono", "Courier New", monospace; } + table.items .ln { min-width: 60mm; text-align: left; height: 4.6mm; } + .weekly .sign-right { margin-top: 26mm; font-size: 10.5pt; } +{% endblock %} + +{% block body %} + {% for report in reports %} +
+ {{ letterhead(false) }} +

{{ title }}

+ + {% for pair in report.meta_rows %} + + {% for slot in pair %}{% endfor %} + + {% endfor %} +
{{ slot[0] }} {{ slot[1] }}
+

1. Work Summary & Sales Performance

+ {{ items(report.summary, "40mm") }} +

2. Additional Schemes & Projects

+ {{ items(report.schemes, "64mm") }} + {{ sign_right("Signature") }} +
+ {% endfor %} +{% endblock %} diff --git a/app/products/__init__.py b/app/products/__init__.py new file mode 100644 index 0000000..4f81b89 --- /dev/null +++ b/app/products/__init__.py @@ -0,0 +1 @@ +"""Product master domain.""" diff --git a/app/products/models.py b/app/products/models.py new file mode 100644 index 0000000..df94501 --- /dev/null +++ b/app/products/models.py @@ -0,0 +1,22 @@ +"""Company-owned product master used by every report that references a product.""" + +import uuid + +from sqlalchemy import Boolean, ForeignKey, String, UniqueConstraint +from sqlalchemy.dialects.postgresql import UUID as PGUUID +from sqlalchemy.orm import Mapped, mapped_column + +from app.database.base import Base, TimestampMixin, UUIDMixin + + +class Product(Base, UUIDMixin, TimestampMixin): + __tablename__ = "product" + __table_args__ = (UniqueConstraint("company_id", "name", name="uq_product_company_name"),) + + company_id: Mapped[uuid.UUID] = mapped_column( + PGUUID(as_uuid=True), ForeignKey("company.id", ondelete="RESTRICT"), nullable=False + ) + name: Mapped[str] = mapped_column(String(200), nullable=False) + pack: Mapped[str | None] = mapped_column(String(100)) + unit: Mapped[str | None] = mapped_column(String(50)) + is_active: Mapped[bool] = mapped_column(Boolean, default=True, nullable=False) diff --git a/app/products/router.py b/app/products/router.py new file mode 100644 index 0000000..a40da24 --- /dev/null +++ b/app/products/router.py @@ -0,0 +1,92 @@ +import uuid + +from fastapi import APIRouter, Depends, Request, status +from sqlalchemy.ext.asyncio import AsyncSession + +from app.auth.dependencies import client_ip, get_current_user, require_role +from app.common.enums import Role +from app.database.session import get_db +from app.products.models import Product +from app.products.schemas import ( + ProductCreate, + ProductRead, + ProductUpdate, + StockInventoryCreate, + StockInventoryRead, + StockInventoryUpdate, +) +from app.products.service import ProductService +from app.users.models import User + +router = APIRouter(prefix="/products", tags=["products"]) + + +@router.get("", response_model=list[ProductRead]) +async def list_products( + current_user: User = Depends(get_current_user), db: AsyncSession = Depends(get_db) +) -> list[Product]: + return await ProductService(db).list_for(current_user) + + +@router.get("/stock-inventory", response_model=list[StockInventoryRead]) +async def list_stock_inventory( + current_user: User = Depends(get_current_user), + db: AsyncSession = Depends(get_db), +) -> list[StockInventoryRead]: + return await ProductService(db).list_stock_inventory() + + +@router.post( + "/stock-inventory", response_model=StockInventoryRead, status_code=status.HTTP_201_CREATED +) +async def create_stock_item( + payload: StockInventoryCreate, + request: Request, + current_user: User = Depends(require_role(Role.ADMIN)), + db: AsyncSession = Depends(get_db), +) -> StockInventoryRead: + return await ProductService(db).create_stock_item(payload, current_user, client_ip(request)) + + +@router.patch("/stock-inventory/{item_id}", response_model=StockInventoryRead) +async def update_stock_item( + item_id: int, + payload: StockInventoryUpdate, + request: Request, + current_user: User = Depends(require_role(Role.ADMIN)), + db: AsyncSession = Depends(get_db), +) -> StockInventoryRead: + return await ProductService(db).update_stock_item( + item_id, payload, current_user, client_ip(request) + ) + + +@router.delete("/stock-inventory/{item_id}", status_code=status.HTTP_204_NO_CONTENT) +async def delete_stock_item( + item_id: int, + request: Request, + current_user: User = Depends(require_role(Role.ADMIN)), + db: AsyncSession = Depends(get_db), +) -> None: + await ProductService(db).delete_stock_item(item_id, current_user, client_ip(request)) + + +@router.post("", response_model=ProductRead, status_code=status.HTTP_201_CREATED) +async def create_product( + payload: ProductCreate, + request: Request, + current_user: User = Depends(require_role(Role.ADMIN)), + db: AsyncSession = Depends(get_db), +) -> Product: + return await ProductService(db).create(payload, current_user, client_ip(request)) + + +@router.patch("/{product_id}", response_model=ProductRead) +async def update_product( + product_id: uuid.UUID, + payload: ProductUpdate, + request: Request, + current_user: User = Depends(require_role(Role.ADMIN)), + db: AsyncSession = Depends(get_db), +) -> Product: + return await ProductService(db).update(product_id, payload, current_user, client_ip(request)) diff --git a/app/products/schemas.py b/app/products/schemas.py new file mode 100644 index 0000000..be90a0d --- /dev/null +++ b/app/products/schemas.py @@ -0,0 +1,50 @@ +import uuid + +from pydantic import BaseModel, ConfigDict, Field + + +class ProductCreate(BaseModel): + name: str = Field(min_length=2, max_length=200) + pack: str | None = Field(default=None, max_length=100) + unit: str | None = Field(default=None, max_length=50) + + +class ProductUpdate(BaseModel): + name: str | None = Field(default=None, min_length=2, max_length=200) + pack: str | None = Field(default=None, max_length=100) + unit: str | None = Field(default=None, max_length=50) + is_active: bool | None = None + + +class ProductRead(BaseModel): + model_config = ConfigDict(from_attributes=True) + + id: uuid.UUID + company_id: uuid.UUID + name: str + pack: str | None + unit: str | None + is_active: bool + + +class StockInventoryRead(BaseModel): + id: int + serial_no: int + product_name: str + pack: str | None + quantity: str | None + unit: str | None + + +class StockInventoryCreate(BaseModel): + product_name: str = Field(min_length=2, max_length=200) + pack: str | None = Field(default=None, max_length=100) + quantity: str | None = Field(default=None, max_length=50) + unit: str | None = Field(default=None, max_length=50) + + +class StockInventoryUpdate(BaseModel): + product_name: str | None = Field(default=None, min_length=2, max_length=200) + pack: str | None = Field(default=None, max_length=100) + quantity: str | None = Field(default=None, max_length=50) + unit: str | None = Field(default=None, max_length=50) diff --git a/app/products/service.py b/app/products/service.py new file mode 100644 index 0000000..e48a081 --- /dev/null +++ b/app/products/service.py @@ -0,0 +1,193 @@ +import uuid + +from sqlalchemy import select, text +from sqlalchemy.exc import IntegrityError +from sqlalchemy.ext.asyncio import AsyncSession + +from app.audit.service import AuditService +from app.common.enums import AuditAction, EntityType, Role +from app.common.exceptions import ConflictError, NotFoundError +from app.common.utils import snapshot +from app.products.models import Product +from app.products.schemas import ( + ProductCreate, + ProductUpdate, + StockInventoryCreate, + StockInventoryRead, + StockInventoryUpdate, +) +from app.users.models import User + +_AUDIT_FIELDS = ["name", "pack", "unit", "is_active"] + + +class ProductService: + def __init__(self, db: AsyncSession) -> None: + self.db, self.audit = db, AuditService(db) + + async def list_for(self, actor: User) -> list[Product]: + stmt = select(Product).where(Product.company_id == actor.company_id).order_by(Product.name) + if actor.role == Role.MR: + stmt = stmt.where(Product.is_active.is_(True)) + return list((await self.db.execute(stmt)).scalars().all()) + + async def list_stock_inventory(self) -> list[StockInventoryRead]: + result = await self.db.execute( + text( + """ + SELECT id, serial_no, product_name, pack, quantity, unit + FROM stock_inventory + ORDER BY serial_no + """ + ) + ) + return [StockInventoryRead.model_validate(row) for row in result.mappings()] + + async def _stock_row(self, item_id: int) -> StockInventoryRead: + result = await self.db.execute( + text( + "SELECT id, serial_no, product_name, pack, quantity, unit " + "FROM stock_inventory WHERE id = :id" + ), + {"id": item_id}, + ) + row = result.mappings().one_or_none() + if row is None: + raise NotFoundError("Stock item not found") + return StockInventoryRead.model_validate(row) + + async def _assert_stock_name_free(self, name: str, except_id: int | None = None) -> None: + """A product appears once in the stock list — this also absorbs a double-submitted form.""" + taken = ( + await self.db.execute( + text( + "SELECT 1 FROM stock_inventory WHERE lower(btrim(product_name)) = lower(btrim(:name)) " + "AND (CAST(:skip AS INTEGER) IS NULL OR id <> :skip) LIMIT 1" + ), + {"name": name, "skip": except_id}, + ) + ).first() + if taken: + raise ConflictError("This product is already in the stock list", {"product_name": name}) + + async def create_stock_item( + self, data: StockInventoryCreate, actor: User, ip: str | None = None + ) -> StockInventoryRead: + await self._assert_stock_name_free(data.product_name) + result = await self.db.execute( + text( + """ + INSERT INTO stock_inventory (serial_no, product_name, pack, quantity, unit) + VALUES ( + (SELECT COALESCE(MAX(serial_no), 0) + 1 FROM stock_inventory), + :product_name, :pack, :quantity, :unit + ) + RETURNING id + """ + ), + data.model_dump(), + ) + item = await self._stock_row(result.scalar_one()) + await self._audit_stock(actor, item, None, item.model_dump(), AuditAction.CREATE, ip) + await self.db.commit() + return item + + async def update_stock_item( + self, item_id: int, data: StockInventoryUpdate, actor: User, ip: str | None = None + ) -> StockInventoryRead: + before = await self._stock_row(item_id) + changes = data.model_dump(exclude_unset=True) + if changes.get("product_name") is None: + changes.pop("product_name", None) + if "product_name" in changes: + await self._assert_stock_name_free(changes["product_name"], except_id=item_id) + if changes: + assignments = ", ".join(f"{column} = :{column}" for column in changes) + await self.db.execute( + text(f"UPDATE stock_inventory SET {assignments} WHERE id = :id"), + {**changes, "id": item_id}, + ) + after = await self._stock_row(item_id) + await self._audit_stock( + actor, after, before.model_dump(), after.model_dump(), AuditAction.UPDATE, ip + ) + await self.db.commit() + return after + + async def delete_stock_item(self, item_id: int, actor: User, ip: str | None = None) -> None: + before = await self._stock_row(item_id) + await self.db.execute(text("DELETE FROM stock_inventory WHERE id = :id"), {"id": item_id}) + # keep the printed "No." column gap-free, like the company forms do + await self.db.execute( + text( + """ + WITH numbered AS ( + SELECT id, ROW_NUMBER() OVER (ORDER BY serial_no, id) AS n FROM stock_inventory + ) + UPDATE stock_inventory s SET serial_no = numbered.n + FROM numbered WHERE s.id = numbered.id AND s.serial_no <> numbered.n + """ + ) + ) + await self._audit_stock(actor, before, before.model_dump(), None, AuditAction.DELETE, ip) + await self.db.commit() + + async def _audit_stock(self, actor, item, before, after, action, ip) -> None: + # entity_id is a UUID column; stock rows use integer ids, so derive a stable UUID. + await self.audit.log( + actor_user_id=actor.id, + entity_type=EntityType.PRODUCT, + entity_id=uuid.uuid5(uuid.NAMESPACE_OID, f"stock_inventory:{item.id}"), + action=action, + before=before, + after=after, + ip_address=ip, + ) + + async def create(self, data: ProductCreate, actor: User, ip: str | None = None) -> Product: + product = Product(company_id=actor.company_id, **data.model_dump()) + self.db.add(product) + try: + await self.db.flush() + except IntegrityError as exc: + await self.db.rollback() + raise ConflictError( + "A product with this name already exists", {"cause": "uq_product_company_name"} + ) from exc + await self.audit.log( + actor_user_id=actor.id, + entity_type=EntityType.PRODUCT, + entity_id=product.id, + action=AuditAction.CREATE, + after=snapshot(product, _AUDIT_FIELDS), + ip_address=ip, + ) + await self.db.commit() + return product + + async def update( + self, product_id: uuid.UUID, data: ProductUpdate, actor: User, ip: str | None = None + ) -> Product: + product = await self.db.get(Product, product_id) + if product is None or product.company_id != actor.company_id: + raise NotFoundError("Product not found") + before = snapshot(product, _AUDIT_FIELDS) + for field, value in data.model_dump(exclude_unset=True).items(): + setattr(product, field, value) + await self.audit.log( + actor_user_id=actor.id, + entity_type=EntityType.PRODUCT, + entity_id=product.id, + action=AuditAction.UPDATE, + before=before, + after=snapshot(product, _AUDIT_FIELDS), + ip_address=ip, + ) + try: + await self.db.commit() + except IntegrityError as exc: + await self.db.rollback() + raise ConflictError( + "A product with this name already exists", {"cause": "uq_product_company_name"} + ) from exc + return product diff --git a/app/reports/__init__.py b/app/reports/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/app/reports/models.py b/app/reports/models.py new file mode 100644 index 0000000..de8a889 --- /dev/null +++ b/app/reports/models.py @@ -0,0 +1,144 @@ +"""The Daily Call Report and its call rows — the core artefact of the MVP.""" + +import uuid +from datetime import date, datetime, time + +from sqlalchemy import ( + CheckConstraint, + Date, + DateTime, + Enum, + ForeignKey, + String, + Text, + Time, + UniqueConstraint, +) +from sqlalchemy.dialects.postgresql import UUID as PGUUID +from sqlalchemy.orm import Mapped, mapped_column, relationship + +from app.common.enums import CallOutcome, ConversionStatus, DCRStatus, Role +from app.database.base import Base, TimestampMixin, UUIDMixin + + +class DailyCallReport(Base, UUIDMixin, TimestampMixin): + __tablename__ = "daily_call_report" + __table_args__ = ( + # V1 / A9 — ONE report per MR per calendar date. Enforced in the database and + # not only in the service, so a double-submit race cannot create two reports. + UniqueConstraint("mr_user_id", "report_date", name="uq_dcr_mr_date"), + # An approved report must carry its approval timestamp, and nothing else may. + CheckConstraint( + "(status = 'APPROVED' AND approved_at IS NOT NULL) " + "OR (status <> 'APPROVED' AND approved_at IS NULL)", + name="ck_dcr_approved_at", + ), + ) + + mr_user_id: Mapped[uuid.UUID] = mapped_column( + PGUUID(as_uuid=True), ForeignKey("user.id", ondelete="RESTRICT"), nullable=False + ) + #: SNAPSHOT of the MR's headquarters at creation time. If the MR is later + #: transferred, historical reports keep the HQ they were filed under (A1). + headquarters_id: Mapped[uuid.UUID] = mapped_column( + PGUUID(as_uuid=True), ForeignKey("headquarters.id", ondelete="RESTRICT"), nullable=False + ) + report_date: Mapped[date] = mapped_column(Date, nullable=False) + status: Mapped[DCRStatus] = mapped_column( + Enum(DCRStatus, name="dcr_status_enum", native_enum=False, length=20), + default=DCRStatus.DRAFT, + nullable=False, + ) + + #: SNAPSHOT of the reviewing AM / approving GM, so an HQ handover never rewrites + #: history (report §5.5). + current_am_user_id: Mapped[uuid.UUID | None] = mapped_column( + PGUUID(as_uuid=True), ForeignKey("user.id", ondelete="RESTRICT") + ) + current_gm_user_id: Mapped[uuid.UUID | None] = mapped_column( + PGUUID(as_uuid=True), ForeignKey("user.id", ondelete="RESTRICT") + ) + + mr_remarks: Mapped[str | None] = mapped_column(Text) + #: The printed form's "STOCKIST VISIT" and "ORDER" lines. + stockist_visit: Mapped[str | None] = mapped_column(String(200)) + order_value: Mapped[str | None] = mapped_column(String(100)) + return_reason: Mapped[str | None] = mapped_column(Text) + #: Which role sent it back — data, not a separate status (report §7.2). + returned_by_role: Mapped[Role | None] = mapped_column( + Enum(Role, name="role_enum", native_enum=False, length=10) + ) + + submitted_at: Mapped[datetime | None] = mapped_column(DateTime(timezone=True)) + approved_at: Mapped[datetime | None] = mapped_column(DateTime(timezone=True)) + pdf_path: Mapped[str | None] = mapped_column(String(500)) + + mr: Mapped["User"] = relationship(foreign_keys=[mr_user_id]) # noqa: F821 + headquarters: Mapped["Headquarters"] = relationship() # noqa: F821 + doctor_calls: Mapped[list["DoctorCall"]] = relationship( + back_populates="dcr", cascade="all, delete-orphan", lazy="selectin" + ) + chemist_calls: Mapped[list["ChemistCall"]] = relationship( + back_populates="dcr", cascade="all, delete-orphan", lazy="selectin" + ) + + @property + def is_locked(self) -> bool: + """APPROVED is the lock. There is no separate LOCKED status (report §7.2).""" + return self.status == DCRStatus.APPROVED + + +class DoctorCall(Base, UUIDMixin, TimestampMixin): + __tablename__ = "doctor_call" + __table_args__ = ( + # V5 / A11 — a doctor may appear only once per report. + UniqueConstraint("dcr_id", "doctor_id", name="uq_call_dcr_doctor"), + ) + + dcr_id: Mapped[uuid.UUID] = mapped_column( + PGUUID(as_uuid=True), + ForeignKey("daily_call_report.id", ondelete="CASCADE"), + nullable=False, + ) + doctor_id: Mapped[uuid.UUID] = mapped_column( + PGUUID(as_uuid=True), ForeignKey("doctor.id", ondelete="RESTRICT"), nullable=False + ) + visit_time: Mapped[time] = mapped_column(Time, nullable=False) + call_outcome: Mapped[CallOutcome] = mapped_column( + Enum(CallOutcome, name="call_outcome_enum", native_enum=False, length=20), + nullable=False, + ) + #: V7 — only permitted when the doctor is a core doctor. + conversion_status: Mapped[ConversionStatus | None] = mapped_column( + Enum(ConversionStatus, name="conversion_status_enum", native_enum=False, length=20) + ) + #: The printed form's "PRODUCT PROMOTE" and "PRODUCT SAMPLE" columns. + product_promote: Mapped[str | None] = mapped_column(String(200)) + product_sample: Mapped[str | None] = mapped_column(String(200)) + remarks: Mapped[str | None] = mapped_column(Text) + + dcr: Mapped["DailyCallReport"] = relationship(back_populates="doctor_calls") + doctor: Mapped["Doctor"] = relationship(lazy="selectin") # noqa: F821 + + +class ChemistCall(Base, UUIDMixin, TimestampMixin): + __tablename__ = "chemist_call" + __table_args__ = ( + UniqueConstraint("dcr_id", "chemist_id", name="uq_call_dcr_chemist"), + ) + + dcr_id: Mapped[uuid.UUID] = mapped_column( + PGUUID(as_uuid=True), + ForeignKey("daily_call_report.id", ondelete="CASCADE"), + nullable=False, + ) + chemist_id: Mapped[uuid.UUID] = mapped_column( + PGUUID(as_uuid=True), ForeignKey("chemist.id", ondelete="RESTRICT"), nullable=False + ) + visit_time: Mapped[time] = mapped_column(Time, nullable=False) + #: The printed form's "POB" column. + pob: Mapped[str | None] = mapped_column(String(100)) + remarks: Mapped[str | None] = mapped_column(Text) + + dcr: Mapped["DailyCallReport"] = relationship(back_populates="chemist_calls") + chemist: Mapped["Chemist"] = relationship(lazy="selectin") # noqa: F821 diff --git a/app/reports/repository.py b/app/reports/repository.py new file mode 100644 index 0000000..abc1165 --- /dev/null +++ b/app/reports/repository.py @@ -0,0 +1,99 @@ +import uuid +from datetime import date + +from sqlalchemy import func, select +from sqlalchemy.orm import selectinload + +from app.common.enums import DCRStatus +from app.common.repository import BaseRepository +from app.reports.models import ChemistCall, DailyCallReport, DoctorCall + + +class DCRRepository(BaseRepository[DailyCallReport]): + model = DailyCallReport + + async def get_full(self, dcr_id: uuid.UUID) -> DailyCallReport | None: + stmt = ( + select(DailyCallReport) + .where(DailyCallReport.id == dcr_id) + .options( + selectinload(DailyCallReport.doctor_calls).selectinload(DoctorCall.doctor), + selectinload(DailyCallReport.chemist_calls).selectinload(ChemistCall.chemist), + selectinload(DailyCallReport.mr), + selectinload(DailyCallReport.headquarters), + ) + # The session keeps objects after commit (expire_on_commit=False), so without this the + # report comes back with the call lists it had *before* an add or remove. + .execution_options(populate_existing=True) + ) + return (await self.db.execute(stmt)).scalar_one_or_none() + + async def get_for_date( + self, mr_user_id: uuid.UUID, report_date: date + ) -> DailyCallReport | None: + """V1 pre-check. The database unique constraint is the real guarantee.""" + stmt = select(DailyCallReport).where( + DailyCallReport.mr_user_id == mr_user_id, + DailyCallReport.report_date == report_date, + ) + return (await self.db.execute(stmt)).scalar_one_or_none() + + def _scoped( + self, + *, + mr_user_id: uuid.UUID | None, + hq_ids: set[uuid.UUID] | None, + status: DCRStatus | None, + date_from: date | None, + date_to: date | None, + ): + stmt = select(DailyCallReport) + if mr_user_id is not None: + stmt = stmt.where(DailyCallReport.mr_user_id == mr_user_id) + if hq_ids is not None: + # An empty scope must match nothing, not everything. + stmt = stmt.where(DailyCallReport.headquarters_id.in_(hq_ids or [None])) + if status is not None: + stmt = stmt.where(DailyCallReport.status == status) + if date_from is not None: + stmt = stmt.where(DailyCallReport.report_date >= date_from) + if date_to is not None: + stmt = stmt.where(DailyCallReport.report_date <= date_to) + return stmt + + async def list_scoped( + self, + *, + mr_user_id: uuid.UUID | None = None, + hq_ids: set[uuid.UUID] | None = None, + status: DCRStatus | None = None, + date_from: date | None = None, + date_to: date | None = None, + limit: int = 50, + offset: int = 0, + ) -> list[DailyCallReport]: + stmt = ( + self._scoped( + mr_user_id=mr_user_id, hq_ids=hq_ids, status=status, + date_from=date_from, date_to=date_to, + ) + .options( + selectinload(DailyCallReport.doctor_calls), + selectinload(DailyCallReport.chemist_calls), + selectinload(DailyCallReport.mr), + selectinload(DailyCallReport.headquarters), + ) + .order_by(DailyCallReport.created_at.desc(), DailyCallReport.report_date.desc()) + .limit(limit) + .offset(offset) + ) + return list((await self.db.execute(stmt)).scalars().all()) + + async def status_counts( + self, *, mr_user_id: uuid.UUID | None = None, hq_ids: set[uuid.UUID] | None = None + ) -> dict[str, int]: + stmt = self._scoped( + mr_user_id=mr_user_id, hq_ids=hq_ids, status=None, date_from=None, date_to=None + ).with_only_columns(DailyCallReport.status, func.count()).group_by(DailyCallReport.status) + rows = (await self.db.execute(stmt)).all() + return {str(status): count for status, count in rows} diff --git a/app/reports/router.py b/app/reports/router.py new file mode 100644 index 0000000..65b559a --- /dev/null +++ b/app/reports/router.py @@ -0,0 +1,204 @@ +import uuid +from datetime import date + +from fastapi import APIRouter, Depends, Query, Request, Response, status +from sqlalchemy.ext.asyncio import AsyncSession + +from app.auth.dependencies import client_ip, get_current_user, require_role +from app.common.enums import DCRStatus, Role +from app.common.exceptions import ValidationError +from app.database.session import get_db +from app.pdf.service import PDFService +from app.reports.schemas import ( + ApproveRequest, + ChemistCallCreate, + DCRCreate, + DCRListItem, + DCRRead, + DCRUpdate, + DoctorCallCreate, + ReturnRequest, + StatusCounts, +) +from app.reports.serializers import to_list_item, to_read +from app.reports.service import DCRService +from app.users.models import User + +router = APIRouter(prefix="/dcr", tags=["reports"]) + + +# ---------------------------------------------------------------- queries + + +@router.get("", response_model=list[DCRListItem]) +async def list_reports( + status_filter: DCRStatus | None = Query(default=None, alias="status"), + date_from: date | None = None, + date_to: date | None = None, + limit: int = Query(default=50, ge=1, le=200), + offset: int = Query(default=0, ge=0), + current_user: User = Depends(get_current_user), + db: AsyncSession = Depends(get_db), +) -> list[DCRListItem]: + """S2 (MR) and S6 (manager queue). Scope is applied in the service, never here.""" + reports = await DCRService(db).list_for( + current_user, + status=status_filter, + date_from=date_from, + date_to=date_to, + limit=limit, + offset=offset, + ) + return [to_list_item(r) for r in reports] + + +@router.get("/counts", response_model=StatusCounts) +async def status_counts( + current_user: User = Depends(get_current_user), db: AsyncSession = Depends(get_db) +) -> StatusCounts: + """Header counts — the deliberate, cheap replacement for the cut dashboards.""" + return StatusCounts(**await DCRService(db).counts_for(current_user)) + + +@router.get("/{dcr_id}", response_model=DCRRead) +async def get_report( + dcr_id: uuid.UUID, + current_user: User = Depends(get_current_user), + db: AsyncSession = Depends(get_db), +) -> DCRRead: + return to_read(await DCRService(db).get_for_view(dcr_id, current_user)) + + +@router.get("/{dcr_id}/pdf") +async def download_pdf( + dcr_id: uuid.UUID, + current_user: User = Depends(get_current_user), + db: AsyncSession = Depends(get_db), +) -> Response: + """SEC-7 — served through an authorised endpoint, never as a guessable static path.""" + dcr = await DCRService(db).get_for_view(dcr_id, current_user) + + if dcr.status != DCRStatus.APPROVED: + raise ValidationError( + "Only a finally approved report can be downloaded", + {"current_status": dcr.status.value}, + ) + # An approved report never changes, so it is rendered from its data each time: every download + # uses the current form layout, even for reports approved before the layout changed. + content = await PDFService(db).render_bytes(dcr) + + filename = f"DCR-{dcr.mr.employee_code}-{dcr.report_date.isoformat()}.pdf" + return Response( + content=content, + media_type="application/pdf", + headers={"Content-Disposition": f'attachment; filename="{filename}"'}, + ) + + +# --------------------------------------------------------------- commands + + +@router.post("", response_model=DCRRead, status_code=status.HTTP_201_CREATED) +async def create_report( + payload: DCRCreate, + request: Request, + current_user: User = Depends(require_role(Role.MR)), + db: AsyncSession = Depends(get_db), +) -> DCRRead: + return to_read(await DCRService(db).create(payload, current_user, client_ip(request))) + + +@router.patch("/{dcr_id}", response_model=DCRRead) +async def update_report( + dcr_id: uuid.UUID, + payload: DCRUpdate, + request: Request, + current_user: User = Depends(require_role(Role.MR)), + db: AsyncSession = Depends(get_db), +) -> DCRRead: + return to_read( + await DCRService(db).update_details( + dcr_id, payload.model_dump(exclude_unset=True), current_user, client_ip(request) + ) + ) + + +@router.post("/{dcr_id}/calls/doctor", response_model=DCRRead, status_code=201) +async def add_doctor_call( + dcr_id: uuid.UUID, + payload: DoctorCallCreate, + request: Request, + current_user: User = Depends(require_role(Role.MR)), + db: AsyncSession = Depends(get_db), +) -> DCRRead: + return to_read( + await DCRService(db).add_doctor_call(dcr_id, payload, current_user, client_ip(request)) + ) + + +@router.post("/{dcr_id}/calls/chemist", response_model=DCRRead, status_code=201) +async def add_chemist_call( + dcr_id: uuid.UUID, + payload: ChemistCallCreate, + request: Request, + current_user: User = Depends(require_role(Role.MR)), + db: AsyncSession = Depends(get_db), +) -> DCRRead: + return to_read( + await DCRService(db).add_chemist_call(dcr_id, payload, current_user, client_ip(request)) + ) + + +@router.delete("/{dcr_id}/calls/{call_id}", response_model=DCRRead) +async def delete_call( + dcr_id: uuid.UUID, + call_id: uuid.UUID, + request: Request, + current_user: User = Depends(require_role(Role.MR)), + db: AsyncSession = Depends(get_db), +) -> DCRRead: + return to_read( + await DCRService(db).delete_call(dcr_id, call_id, current_user, client_ip(request)) + ) + + +# ------------------------------------------------------------- transitions + + +@router.post("/{dcr_id}/submit", response_model=DCRRead) +async def submit( + dcr_id: uuid.UUID, + request: Request, + current_user: User = Depends(require_role(Role.MR)), + db: AsyncSession = Depends(get_db), +) -> DCRRead: + return to_read(await DCRService(db).submit(dcr_id, current_user, client_ip(request))) + + +@router.post("/{dcr_id}/return", response_model=DCRRead) +async def return_report( + dcr_id: uuid.UUID, + payload: ReturnRequest, + request: Request, + current_user: User = Depends(require_role(Role.AM)), + db: AsyncSession = Depends(get_db), +) -> DCRRead: + return to_read( + await DCRService(db).return_report( + dcr_id, payload.reason, current_user, client_ip(request) + ) + ) + + +@router.post("/{dcr_id}/approve", response_model=DCRRead) +async def approve( + dcr_id: uuid.UUID, + payload: ApproveRequest, + request: Request, + current_user: User = Depends(require_role(Role.AM)), + db: AsyncSession = Depends(get_db), +) -> DCRRead: + """Area Manager final approval (headquarters scope is enforced by the service).""" + return to_read( + await DCRService(db).approve(dcr_id, payload.comment, current_user, client_ip(request)) + ) diff --git a/app/reports/schemas.py b/app/reports/schemas.py new file mode 100644 index 0000000..0e9419e --- /dev/null +++ b/app/reports/schemas.py @@ -0,0 +1,126 @@ +import uuid +from datetime import date, datetime, time + +from pydantic import BaseModel, ConfigDict, Field + +from app.common.enums import CallOutcome, ConversionStatus, DCRStatus, Role +from app.config.settings import settings + + +class DoctorCallCreate(BaseModel): + doctor_id: uuid.UUID + visit_time: time + call_outcome: CallOutcome + #: V7 — accepted only when the doctor is flagged as a core doctor. + conversion_status: ConversionStatus | None = None + product_promote: str | None = Field(default=None, max_length=200) + product_sample: str | None = Field(default=None, max_length=200) + remarks: str | None = Field(default=None, max_length=2000) + + +class ChemistCallCreate(BaseModel): + chemist_id: uuid.UUID + visit_time: time + pob: str | None = Field(default=None, max_length=100) + remarks: str | None = Field(default=None, max_length=2000) + + +class DoctorCallRead(BaseModel): + model_config = ConfigDict(from_attributes=True) + + id: uuid.UUID + doctor_id: uuid.UUID + doctor_name: str + doctor_speciality: str | None + is_core_doctor: bool + visit_time: time + call_outcome: CallOutcome + conversion_status: ConversionStatus | None + product_promote: str | None + product_sample: str | None + remarks: str | None + + +class ChemistCallRead(BaseModel): + model_config = ConfigDict(from_attributes=True) + + id: uuid.UUID + chemist_id: uuid.UUID + chemist_name: str + visit_time: time + pob: str | None + remarks: str | None + + +class DCRCreate(BaseModel): + report_date: date + mr_remarks: str | None = Field(default=None, max_length=2000) + doctor_calls: list[DoctorCallCreate] = Field(default_factory=list) + chemist_calls: list[ChemistCallCreate] = Field(default_factory=list) + + +class DCRUpdate(BaseModel): + mr_remarks: str | None = Field(default=None, max_length=2000) + stockist_visit: str | None = Field(default=None, max_length=200) + order_value: str | None = Field(default=None, max_length=100) + + +class ReturnRequest(BaseModel): + """V8 — a manager must say WHY. This reason is what makes the audit trail useful.""" + + reason: str = Field(min_length=settings.MIN_RETURN_REASON_LENGTH, max_length=2000) + + +class ApproveRequest(BaseModel): + comment: str | None = Field(default=None, max_length=2000) + + +class DCRListItem(BaseModel): + """Row for S2/S6 — the list screens that replaced the cut dashboards.""" + + model_config = ConfigDict(from_attributes=True) + + id: uuid.UUID + report_date: date + status: DCRStatus + mr_user_id: uuid.UUID + mr_name: str + headquarters_id: uuid.UUID + headquarters_name: str + doctor_call_count: int + chemist_call_count: int + submitted_at: datetime | None + approved_at: datetime | None + returned_by_role: Role | None + + +class DCRRead(BaseModel): + model_config = ConfigDict(from_attributes=True) + + id: uuid.UUID + mr_user_id: uuid.UUID + mr_name: str + employee_code: str + headquarters_id: uuid.UUID + headquarters_name: str + report_date: date + status: DCRStatus + is_locked: bool + mr_remarks: str | None + stockist_visit: str | None + order_value: str | None + return_reason: str | None + returned_by_role: Role | None + submitted_at: datetime | None + approved_at: datetime | None + doctor_calls: list[DoctorCallRead] + chemist_calls: list[ChemistCallRead] + + +class StatusCounts(BaseModel): + """Header counts on the list screens — the cheap replacement for dashboards.""" + + DRAFT: int = 0 + PENDING_AM: int = 0 + RETURNED: int = 0 + APPROVED: int = 0 diff --git a/app/reports/serializers.py b/app/reports/serializers.py new file mode 100644 index 0000000..30bf8a1 --- /dev/null +++ b/app/reports/serializers.py @@ -0,0 +1,74 @@ +"""ORM → response-schema mapping for reports.""" + +from app.reports.models import DailyCallReport +from app.reports.schemas import ( + ChemistCallRead, + DCRListItem, + DCRRead, + DoctorCallRead, +) + + +def to_read(dcr: DailyCallReport) -> DCRRead: + return DCRRead( + id=dcr.id, + mr_user_id=dcr.mr_user_id, + mr_name=dcr.mr.full_name, + employee_code=dcr.mr.employee_code, + headquarters_id=dcr.headquarters_id, + headquarters_name=dcr.headquarters.name, + report_date=dcr.report_date, + status=dcr.status, + is_locked=dcr.is_locked, + mr_remarks=dcr.mr_remarks, + stockist_visit=dcr.stockist_visit, + order_value=dcr.order_value, + return_reason=dcr.return_reason, + returned_by_role=dcr.returned_by_role, + submitted_at=dcr.submitted_at, + approved_at=dcr.approved_at, + doctor_calls=[ + DoctorCallRead( + id=c.id, + doctor_id=c.doctor_id, + doctor_name=c.doctor.name, + doctor_speciality=c.doctor.speciality, + is_core_doctor=c.doctor.is_core_doctor, + visit_time=c.visit_time, + call_outcome=c.call_outcome, + conversion_status=c.conversion_status, + product_promote=c.product_promote, + product_sample=c.product_sample, + remarks=c.remarks, + ) + for c in sorted(dcr.doctor_calls, key=lambda x: x.visit_time) + ], + chemist_calls=[ + ChemistCallRead( + id=c.id, + chemist_id=c.chemist_id, + chemist_name=c.chemist.name, + visit_time=c.visit_time, + pob=c.pob, + remarks=c.remarks, + ) + for c in sorted(dcr.chemist_calls, key=lambda x: x.visit_time) + ], + ) + + +def to_list_item(dcr: DailyCallReport) -> DCRListItem: + return DCRListItem( + id=dcr.id, + report_date=dcr.report_date, + status=dcr.status, + mr_user_id=dcr.mr_user_id, + mr_name=dcr.mr.full_name, + headquarters_id=dcr.headquarters_id, + headquarters_name=dcr.headquarters.name, + doctor_call_count=len(dcr.doctor_calls), + chemist_call_count=len(dcr.chemist_calls), + submitted_at=dcr.submitted_at, + approved_at=dcr.approved_at, + returned_by_role=dcr.returned_by_role, + ) diff --git a/app/reports/service.py b/app/reports/service.py new file mode 100644 index 0000000..5b4afc0 --- /dev/null +++ b/app/reports/service.py @@ -0,0 +1,492 @@ +"""Daily Call Report business rules — validation rules V1-V12 all live here. + +Routers never contain rules; repositories never contain rules. This module is the +single place a reviewer needs to read to understand what the system enforces. +""" + +import uuid +from datetime import date, timedelta + +from sqlalchemy import select +from sqlalchemy.exc import IntegrityError +from sqlalchemy.ext.asyncio import AsyncSession + +from app.approvals.state_machine import assert_editable, assert_transition +from app.audit.service import AuditService +from app.auth.dependencies import assert_can_view_dcr, visible_hq_ids +from app.chemists.models import Chemist, ChemistAssignment +from app.common.enums import ( + AuditAction, + DCRStatus, + EntityType, + Role, + WorkflowAction, +) +from app.common.exceptions import ( + ConflictError, + NotFoundError, + ValidationError, +) +from app.common.utils import local_now, local_today, snapshot, utcnow +from app.config.settings import settings +from app.doctors.models import Doctor, DoctorAssignment +from app.reports.models import ChemistCall, DailyCallReport, DoctorCall +from app.reports.repository import DCRRepository +from app.reports.schemas import ChemistCallCreate, DCRCreate, DoctorCallCreate +from app.users.models import User + +#: Audit fields — the columns worth recording on a state change. +_AUDIT_FIELDS = [ + "status", + "report_date", + "mr_remarks", + "stockist_visit", + "order_value", + "return_reason", + "returned_by_role", + "submitted_at", + "approved_at", +] + + +def _clean(value: str | None) -> str | None: + """Trimmed text, with blank input stored as NULL.""" + value = (value or "").strip() + return value or None + + +class DCRService: + def __init__(self, db: AsyncSession) -> None: + self.db = db + self.repo = DCRRepository(db) + self.audit = AuditService(db) + + # ------------------------------------------------------------------ + # Validation helpers + # ------------------------------------------------------------------ + + def _validate_report_date(self, report_date: date) -> None: + today = local_today() + # V2 — no future reports. + if report_date > today: + raise ValidationError( + "Report date cannot be in the future", + {"report_date": report_date.isoformat(), "today": today.isoformat()}, + ) + # V3 / A10 / Q8 — back-dating window. + earliest = today - timedelta(days=settings.BACKDATING_WINDOW_DAYS) + if report_date < earliest: + raise ValidationError( + f"Report date is older than the {settings.BACKDATING_WINDOW_DAYS}-day " + "back-dating window", + {"report_date": report_date.isoformat(), "earliest_allowed": earliest.isoformat()}, + ) + + def _check_submission_deadline(self, report_date: date) -> None: + """A16 / Q9 — report for date D must be submitted by end of D + N days.""" + deadline = report_date + timedelta(days=settings.SUBMISSION_DEADLINE_DAYS) + if local_today() > deadline: + raise ValidationError( + "Submission deadline for this report date has passed", + {"report_date": report_date.isoformat(), "deadline": deadline.isoformat()}, + ) + + async def _assigned_doctor_ids(self, mr_user_id: uuid.UUID) -> set[uuid.UUID]: + stmt = select(DoctorAssignment.doctor_id).where( + DoctorAssignment.mr_user_id == mr_user_id, + DoctorAssignment.effective_to.is_(None), + ) + return set((await self.db.execute(stmt)).scalars().all()) + + async def _assigned_chemist_ids(self, mr_user_id: uuid.UUID) -> set[uuid.UUID]: + stmt = select(ChemistAssignment.chemist_id).where( + ChemistAssignment.mr_user_id == mr_user_id, + ChemistAssignment.effective_to.is_(None), + ) + return set((await self.db.execute(stmt)).scalars().all()) + + async def _build_doctor_call( + self, dcr: DailyCallReport, payload: DoctorCallCreate, assigned: set[uuid.UUID] + ) -> DoctorCall: + # V6 — only doctors currently assigned to this MR may be called. + if payload.doctor_id not in assigned: + raise ValidationError( + "Doctor is not assigned to this MR", + {"doctor_id": str(payload.doctor_id)}, + ) + doctor = await self.db.get(Doctor, payload.doctor_id) + if doctor is None: + raise NotFoundError("Doctor not found", {"doctor_id": str(payload.doctor_id)}) + # V7 — conversion status is meaningful only for core doctors. + if payload.conversion_status is not None and not doctor.is_core_doctor: + raise ValidationError( + "conversion_status may only be set for a core doctor", + {"doctor_id": str(doctor.id), "is_core_doctor": False}, + ) + return DoctorCall( + dcr_id=dcr.id, + doctor_id=payload.doctor_id, + visit_time=payload.visit_time, + call_outcome=payload.call_outcome, + conversion_status=payload.conversion_status, + product_promote=_clean(payload.product_promote), + product_sample=_clean(payload.product_sample), + remarks=payload.remarks, + ) + + async def _build_chemist_call( + self, dcr: DailyCallReport, payload: ChemistCallCreate, assigned: set[uuid.UUID] + ) -> ChemistCall: + if payload.chemist_id not in assigned: + raise ValidationError( + "Chemist is not assigned to this MR", {"chemist_id": str(payload.chemist_id)} + ) + if await self.db.get(Chemist, payload.chemist_id) is None: + raise NotFoundError("Chemist not found", {"chemist_id": str(payload.chemist_id)}) + return ChemistCall( + dcr_id=dcr.id, + chemist_id=payload.chemist_id, + visit_time=payload.visit_time, + pob=_clean(payload.pob), + remarks=payload.remarks, + ) + + # ------------------------------------------------------------------ + # Commands + # ------------------------------------------------------------------ + + async def create( + self, data: DCRCreate, actor: User, ip: str | None = None + ) -> DailyCallReport: + if actor.role != Role.MR or actor.headquarters_id is None: + raise ValidationError("Only an MR with a headquarters can create a report") + + self._validate_report_date(data.report_date) + + # V1 pre-check for a friendly 409; the unique constraint below is the guarantee. + if await self.repo.get_for_date(actor.id, data.report_date): + raise ConflictError( + "A report already exists for this date", + {"report_date": data.report_date.isoformat()}, + ) + + dcr = DailyCallReport( + id=uuid.uuid4(), + mr_user_id=actor.id, + headquarters_id=actor.headquarters_id, # snapshot (A1) + report_date=data.report_date, + status=DCRStatus.DRAFT, + mr_remarks=data.mr_remarks, + ) + self.db.add(dcr) + + doctor_ids = await self._assigned_doctor_ids(actor.id) + chemist_ids = await self._assigned_chemist_ids(actor.id) + + seen_doctors: set[uuid.UUID] = set() + for payload in data.doctor_calls: + if payload.doctor_id in seen_doctors: + raise ConflictError( + "Duplicate doctor call in the same report", + {"doctor_id": str(payload.doctor_id)}, + ) + seen_doctors.add(payload.doctor_id) + self.db.add(await self._build_doctor_call(dcr, payload, doctor_ids)) + + seen_chemists: set[uuid.UUID] = set() + for payload in data.chemist_calls: + if payload.chemist_id in seen_chemists: + raise ConflictError( + "Duplicate chemist call in the same report", + {"chemist_id": str(payload.chemist_id)}, + ) + seen_chemists.add(payload.chemist_id) + self.db.add(await self._build_chemist_call(dcr, payload, chemist_ids)) + + await self.audit.log( + actor_user_id=actor.id, + entity_type=EntityType.DCR, + entity_id=dcr.id, + action=AuditAction.CREATE, + after=snapshot(dcr, _AUDIT_FIELDS), + ip_address=ip, + ) + + try: + await self.db.commit() + except IntegrityError as exc: + await self.db.rollback() + raise ConflictError( + "A report already exists for this MR and date", {"cause": "uq_dcr_mr_date"} + ) from exc + + return await self.repo.get_full(dcr.id) + + async def update_details( + self, dcr_id: uuid.UUID, changes: dict[str, str | None], actor: User, ip: str | None = None + ) -> DailyCallReport: + """Change the report-level free text: MR remarks, stockist visit, order.""" + dcr = await self._get_owned_editable(dcr_id, actor) + before = snapshot(dcr, _AUDIT_FIELDS) + for field in ("mr_remarks", "stockist_visit", "order_value"): + if field in changes: + setattr(dcr, field, _clean(changes[field])) + await self.audit.log( + actor_user_id=actor.id, + entity_type=EntityType.DCR, + entity_id=dcr.id, + action=AuditAction.UPDATE, + before=before, + after=snapshot(dcr, _AUDIT_FIELDS), + ip_address=ip, + ) + await self.db.commit() + return await self.repo.get_full(dcr.id) + + async def add_doctor_call( + self, dcr_id: uuid.UUID, payload: DoctorCallCreate, actor: User, ip: str | None = None + ) -> DailyCallReport: + dcr = await self._get_owned_editable(dcr_id, actor) + assigned = await self._assigned_doctor_ids(actor.id) + call = await self._build_doctor_call(dcr, payload, assigned) + self._validate_visit_time(dcr, payload.visit_time) + self.db.add(call) + + # Flush the insert on its own so the unique-violation surfaces HERE, as a + # clean 409, rather than escaping from the audit flush or the final commit. + try: + await self.db.flush() + except IntegrityError as exc: + await self.db.rollback() + # V5 — the doctor is already on this report. + raise ConflictError( + "This doctor has already been called on this report", + {"doctor_id": str(payload.doctor_id), "cause": "uq_call_dcr_doctor"}, + ) from exc + + await self.audit.log( + actor_user_id=actor.id, + entity_type=EntityType.DCR, + entity_id=dcr.id, + action=AuditAction.UPDATE, + after={"added_doctor_call": str(payload.doctor_id)}, + ip_address=ip, + ) + await self.db.commit() + return await self.repo.get_full(dcr.id) + + async def add_chemist_call( + self, dcr_id: uuid.UUID, payload: ChemistCallCreate, actor: User, ip: str | None = None + ) -> DailyCallReport: + dcr = await self._get_owned_editable(dcr_id, actor) + assigned = await self._assigned_chemist_ids(actor.id) + call = await self._build_chemist_call(dcr, payload, assigned) + self._validate_visit_time(dcr, payload.visit_time) + self.db.add(call) + + try: + await self.db.flush() + except IntegrityError as exc: + await self.db.rollback() + raise ConflictError( + "This chemist has already been called on this report", + {"chemist_id": str(payload.chemist_id), "cause": "uq_call_dcr_chemist"}, + ) from exc + + await self.audit.log( + actor_user_id=actor.id, + entity_type=EntityType.DCR, + entity_id=dcr.id, + action=AuditAction.UPDATE, + after={"added_chemist_call": str(payload.chemist_id)}, + ip_address=ip, + ) + await self.db.commit() + return await self.repo.get_full(dcr.id) + + def _validate_visit_time(self, dcr: DailyCallReport, visit_time) -> None: + """V11 — a visit time on today's report cannot be in the future.""" + if dcr.report_date == local_today(): + # Visit times are entered in the company's local time (APP_TIMEZONE), so they + # must be compared with local "now" — not the server's UTC clock. + if visit_time > local_now().time() and settings.ENVIRONMENT == "production": + raise ValidationError( + "Visit time cannot be in the future", {"visit_time": str(visit_time)} + ) + + async def delete_call( + self, dcr_id: uuid.UUID, call_id: uuid.UUID, actor: User, ip: str | None = None + ) -> DailyCallReport: + dcr = await self._get_owned_editable(dcr_id, actor) + call = await self.db.get(DoctorCall, call_id) or await self.db.get(ChemistCall, call_id) + if call is None or call.dcr_id != dcr.id: + raise NotFoundError("Call not found on this report", {"call_id": str(call_id)}) + await self.db.delete(call) + await self.audit.log( + actor_user_id=actor.id, + entity_type=EntityType.DCR, + entity_id=dcr.id, + action=AuditAction.DELETE, + before={"removed_call": str(call_id)}, + ip_address=ip, + ) + await self.db.commit() + return await self.repo.get_full(dcr.id) + + # ------------------------------------------------------------------ + # Workflow transitions + # ------------------------------------------------------------------ + + async def submit( + self, dcr_id: uuid.UUID, actor: User, ip: str | None = None + ) -> DailyCallReport: + dcr = await self.repo.get_full(dcr_id) + if dcr is None: + raise NotFoundError("Report not found", {"id": str(dcr_id)}) + await assert_can_view_dcr(self.db, actor, dcr) + if dcr.mr_user_id != actor.id: + from app.common.exceptions import ForbiddenError + + raise ForbiddenError("Only the owning MR can submit this report") + + if dcr.status == DCRStatus.PENDING_AM: + return dcr # already submitted (a double click): nothing more to do + + transition = assert_transition(dcr.status, WorkflowAction.SUBMIT, actor.role) + + # V4 — at least one doctor call is required to submit. + if not dcr.doctor_calls: + raise ValidationError("A report must contain at least one doctor call to submit") + self._check_submission_deadline(dcr.report_date) + + before = snapshot(dcr, _AUDIT_FIELDS) + dcr.status = transition.to_status + dcr.submitted_at = utcnow() + dcr.return_reason = None + dcr.returned_by_role = None + dcr.current_am_user_id = await self._current_am_for_hq(dcr.headquarters_id) + + await self.audit.log( + actor_user_id=actor.id, + entity_type=EntityType.DCR, + entity_id=dcr.id, + action=AuditAction.SUBMIT, + before=before, + after=snapshot(dcr, _AUDIT_FIELDS), + ip_address=ip, + ) + await self.db.commit() + return await self.repo.get_full(dcr.id) + + async def return_report( + self, dcr_id: uuid.UUID, reason: str, actor: User, ip: str | None = None + ) -> DailyCallReport: + dcr = await self._get_in_scope(dcr_id, actor) + transition = assert_transition(dcr.status, WorkflowAction.RETURN, actor.role) + + before = snapshot(dcr, _AUDIT_FIELDS) + dcr.status = transition.to_status + dcr.return_reason = reason + dcr.returned_by_role = actor.role # data, not a separate status + + await self.audit.log( + actor_user_id=actor.id, + entity_type=EntityType.DCR, + entity_id=dcr.id, + action=AuditAction.RETURN, + before=before, + after=snapshot(dcr, _AUDIT_FIELDS), + comment=reason, + ip_address=ip, + ) + await self.db.commit() + return await self.repo.get_full(dcr.id) + + async def approve( + self, dcr_id: uuid.UUID, comment: str | None, actor: User, ip: str | None = None + ) -> DailyCallReport: + """Area Manager final approval. APPROVED is terminal and immutable.""" + dcr = await self._get_in_scope(dcr_id, actor) + if dcr.status == DCRStatus.APPROVED and actor.role == Role.AM: + return dcr # already approved (a double click): the report stays as it is + transition = assert_transition(dcr.status, WorkflowAction.APPROVE, actor.role) + + before = snapshot(dcr, _AUDIT_FIELDS) + dcr.status = transition.to_status + dcr.approved_at = utcnow() + + await self.audit.log( + actor_user_id=actor.id, + entity_type=EntityType.DCR, + entity_id=dcr.id, + action=AuditAction.APPROVE, + before=before, + after=snapshot(dcr, _AUDIT_FIELDS), + comment=comment, + ip_address=ip, + ) + + # PDF is generated synchronously — it takes about a second, and adding a task + # queue for one one-second job is infrastructure you must then operate. + from app.pdf.service import PDFService + + full = await self.repo.get_full(dcr.id) + dcr.pdf_path = await PDFService(self.db).render_and_store(full, approver=actor) + + await self.db.commit() + return await self.repo.get_full(dcr.id) + + # ------------------------------------------------------------------ + # Queries + # ------------------------------------------------------------------ + + async def get_for_view(self, dcr_id: uuid.UUID, actor: User) -> DailyCallReport: + dcr = await self.repo.get_full(dcr_id) + if dcr is None: + raise NotFoundError("Report not found", {"id": str(dcr_id)}) + await assert_can_view_dcr(self.db, actor, dcr) + return dcr + + async def list_for(self, actor: User, **filters) -> list[DailyCallReport]: + if actor.role == Role.MR: + return await self.repo.list_scoped(mr_user_id=actor.id, **filters) + hq_ids = await visible_hq_ids(self.db, actor) + return await self.repo.list_scoped(hq_ids=hq_ids, **filters) + + async def counts_for(self, actor: User) -> dict[str, int]: + if actor.role == Role.MR: + return await self.repo.status_counts(mr_user_id=actor.id) + return await self.repo.status_counts(hq_ids=await visible_hq_ids(self.db, actor)) + + # ------------------------------------------------------------------ + # Internals + # ------------------------------------------------------------------ + + async def _get_owned_editable(self, dcr_id: uuid.UUID, actor: User) -> DailyCallReport: + """Owner + editable-status guard for every data-changing operation (V9/V10).""" + dcr = await self.repo.get_full(dcr_id) + if dcr is None: + raise NotFoundError("Report not found", {"id": str(dcr_id)}) + await assert_can_view_dcr(self.db, actor, dcr) + if actor.role != Role.MR or dcr.mr_user_id != actor.id: + from app.common.exceptions import ForbiddenError + + raise ForbiddenError("Only the owning MR can modify report data") + assert_editable(dcr.status) + return dcr + + async def _get_in_scope(self, dcr_id: uuid.UUID, actor: User) -> DailyCallReport: + dcr = await self.repo.get_full(dcr_id) + if dcr is None: + raise NotFoundError("Report not found", {"id": str(dcr_id)}) + await assert_can_view_dcr(self.db, actor, dcr) + return dcr + + async def _current_am_for_hq(self, headquarters_id: uuid.UUID) -> uuid.UUID | None: + from app.organization.models import AMHeadquarters + + stmt = select(AMHeadquarters.area_manager_user_id).where( + AMHeadquarters.headquarters_id == headquarters_id, + AMHeadquarters.effective_to.is_(None), + ) + return (await self.db.execute(stmt)).scalars().first() diff --git a/app/users/__init__.py b/app/users/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/app/users/models.py b/app/users/models.py new file mode 100644 index 0000000..d8c0738 --- /dev/null +++ b/app/users/models.py @@ -0,0 +1,50 @@ +"""The single `user` table for every role. + +`mr_profile` and `area_manager_profile` were merged in (report §13.2): both would +have held the same columns as `user`, and the only MR-specific payload is +`headquarters_id`. +""" + +import uuid + +from sqlalchemy import Boolean, CheckConstraint, Enum, ForeignKey, String, UniqueConstraint +from sqlalchemy.dialects.postgresql import UUID as PGUUID +from sqlalchemy.orm import Mapped, mapped_column, relationship + +from app.common.enums import Role +from app.database.base import Base, TimestampMixin, UUIDMixin + + +class User(Base, UUIDMixin, TimestampMixin): + __tablename__ = "user" + __table_args__ = ( + UniqueConstraint("company_id", "email", name="uq_user_company_email"), + UniqueConstraint("company_id", "employee_code", name="uq_user_company_empcode"), + # An MR must have a headquarters; nobody else may have one (R4, R8). + CheckConstraint( + "(role = 'MR' AND headquarters_id IS NOT NULL) " + "OR (role <> 'MR' AND headquarters_id IS NULL)", + name="ck_user_mr_requires_hq", + ), + ) + + company_id: Mapped[uuid.UUID] = mapped_column( + PGUUID(as_uuid=True), ForeignKey("company.id", ondelete="RESTRICT"), nullable=False + ) + email: Mapped[str] = mapped_column(String(255), nullable=False) + password_hash: Mapped[str] = mapped_column(String(255), nullable=False) + full_name: Mapped[str] = mapped_column(String(200), nullable=False) + employee_code: Mapped[str] = mapped_column(String(50), nullable=False) + phone: Mapped[str | None] = mapped_column(String(20)) + role: Mapped[Role] = mapped_column( + Enum(Role, name="role_enum", native_enum=False, length=10), nullable=False + ) + #: MR only — the one headquarters this MR belongs to (R4). + headquarters_id: Mapped[uuid.UUID | None] = mapped_column( + PGUUID(as_uuid=True), ForeignKey("headquarters.id", ondelete="RESTRICT") + ) + #: Checked on EVERY request, not only at login (SEC-5). + is_active: Mapped[bool] = mapped_column(Boolean, default=True, nullable=False) + failed_login_attempts: Mapped[int] = mapped_column(default=0, nullable=False) + + headquarters: Mapped["Headquarters | None"] = relationship() # noqa: F821 diff --git a/app/users/router.py b/app/users/router.py new file mode 100644 index 0000000..23eb901 --- /dev/null +++ b/app/users/router.py @@ -0,0 +1,50 @@ +import uuid + +from fastapi import APIRouter, Depends, Request, status +from sqlalchemy.ext.asyncio import AsyncSession + +from app.auth.dependencies import client_ip, get_current_user, require_role +from app.common.enums import Role +from app.database.session import get_db +from app.users.models import User +from app.users.schemas import MyProfile, UserCreate, UserRead, UserUpdate +from app.users.service import UserService + +router = APIRouter(prefix="/users", tags=["users"]) + + +@router.get("/me/profile", response_model=MyProfile) +async def my_profile( + current_user: User = Depends(get_current_user), db: AsyncSession = Depends(get_db) +) -> MyProfile: + return await UserService(db).my_profile(current_user) + + +@router.get("", response_model=list[UserRead]) +async def list_users( + role: Role | None = None, + current_user: User = Depends(require_role(Role.ADMIN, Role.GM)), + db: AsyncSession = Depends(get_db), +) -> list[User]: + return await UserService(db).list_users(current_user, role) + + +@router.post("", response_model=UserRead, status_code=status.HTTP_201_CREATED) +async def create_user( + payload: UserCreate, + request: Request, + current_user: User = Depends(require_role(Role.ADMIN)), + db: AsyncSession = Depends(get_db), +) -> User: + return await UserService(db).create(payload, current_user, client_ip(request)) + + +@router.patch("/{user_id}", response_model=UserRead) +async def update_user( + user_id: uuid.UUID, + payload: UserUpdate, + request: Request, + current_user: User = Depends(require_role(Role.ADMIN)), + db: AsyncSession = Depends(get_db), +) -> User: + return await UserService(db).update(user_id, payload, current_user, client_ip(request)) diff --git a/app/users/schemas.py b/app/users/schemas.py new file mode 100644 index 0000000..8b27a06 --- /dev/null +++ b/app/users/schemas.py @@ -0,0 +1,65 @@ +import uuid + +from pydantic import BaseModel, ConfigDict, EmailStr, Field, model_validator + +from app.common.enums import Role + + +class UserCreate(BaseModel): + email: EmailStr + password: str = Field(min_length=8, max_length=128) + full_name: str = Field(min_length=2, max_length=200) + employee_code: str = Field(min_length=1, max_length=50) + role: Role + phone: str | None = Field(default=None, max_length=20) + #: Required for MR, forbidden for every other role (R4/R8). + headquarters_id: uuid.UUID | None = None + + @model_validator(mode="after") + def check_hq_matches_role(self): + if self.role == Role.MR and self.headquarters_id is None: + raise ValueError("headquarters_id is required for an MR") + if self.role != Role.MR and self.headquarters_id is not None: + raise ValueError("headquarters_id may only be set for an MR") + return self + + +class UserUpdate(BaseModel): + full_name: str | None = Field(default=None, min_length=2, max_length=200) + #: Sign-in credentials. Admin-only (the whole endpoint is); changing them is audited. + email: EmailStr | None = None + employee_code: str | None = Field(default=None, min_length=1, max_length=50) + #: A new password. Signs the user out everywhere and clears a lockout. + password: str | None = Field(default=None, min_length=8, max_length=128) + phone: str | None = Field(default=None, max_length=20) + headquarters_id: uuid.UUID | None = None + is_active: bool | None = None + + +class UserRead(BaseModel): + model_config = ConfigDict(from_attributes=True) + + id: uuid.UUID + email: str + full_name: str + employee_code: str + role: Role + phone: str | None + headquarters_id: uuid.UUID | None + is_active: bool + + +class MyProfile(BaseModel): + """S4 — the MR profile screen. Includes the DERIVED reporting Area Manager.""" + + id: uuid.UUID + full_name: str + employee_code: str + email: str + role: Role + phone: str | None + headquarters_id: uuid.UUID | None + headquarters_code: str | None + headquarters_name: str | None + reporting_manager_id: uuid.UUID | None + reporting_manager_name: str | None diff --git a/app/users/service.py b/app/users/service.py new file mode 100644 index 0000000..916b5b5 --- /dev/null +++ b/app/users/service.py @@ -0,0 +1,158 @@ +import uuid + +from sqlalchemy import select +from sqlalchemy.exc import IntegrityError +from sqlalchemy.ext.asyncio import AsyncSession + +from app.audit.service import AuditService +from app.auth.security import hash_password +from app.auth.service import AuthService +from app.common.enums import AuditAction, EntityType, Role +from app.common.exceptions import ConflictError, NotFoundError, ValidationError +from app.common.utils import snapshot +from app.organization.models import AMHeadquarters, Headquarters +from app.users.models import User +from app.users.schemas import MyProfile, UserCreate, UserUpdate + +_AUDIT_FIELDS = ["email", "full_name", "employee_code", "role", "headquarters_id", "is_active"] + + +class UserService: + def __init__(self, db: AsyncSession) -> None: + self.db = db + self.audit = AuditService(db) + + async def create(self, data: UserCreate, actor: User, ip: str | None = None) -> User: + if data.headquarters_id is not None: + hq = await self.db.get(Headquarters, data.headquarters_id) + if hq is None: + raise NotFoundError("Headquarters not found") + if hq.company_id != actor.company_id: + raise ValidationError("Headquarters belongs to another company") + + user = User( + company_id=actor.company_id, + email=str(data.email).lower(), + password_hash=hash_password(data.password), + full_name=data.full_name, + employee_code=data.employee_code, + role=data.role, + phone=data.phone, + headquarters_id=data.headquarters_id, + ) + self.db.add(user) + try: + await self.db.flush() + except IntegrityError as exc: + await self.db.rollback() + raise ConflictError("A user with this email or employee code already exists") from exc + + await self.audit.log( + actor_user_id=actor.id, + entity_type=EntityType.USER, + entity_id=user.id, + action=AuditAction.CREATE, + after=snapshot(user, _AUDIT_FIELDS), + ip_address=ip, + ) + await self.db.commit() + return user + + async def update( + self, user_id: uuid.UUID, data: UserUpdate, actor: User, ip: str | None = None + ) -> User: + user = await self.db.get(User, user_id) + if user is None: + raise NotFoundError("User not found") + + if user.company_id != actor.company_id: + raise NotFoundError("User not found") + + before = snapshot(user, _AUDIT_FIELDS) + deactivating = data.is_active is False and user.is_active + + changes = data.model_dump(exclude_unset=True) + new_password = changes.pop("password", None) + if "email" in changes: + if changes["email"] is None: + raise ValidationError("Email cannot be empty") + changes["email"] = str(changes["email"]).lower() + for field, value in changes.items(): + setattr(user, field, value) + + password_reset = new_password is not None + if password_reset: + user.password_hash = hash_password(new_password) + user.failed_login_attempts = 0 # a reset also unlocks the account + + # An MR must keep a headquarters; nobody else may gain one (DB check mirrors this). + if user.role == Role.MR and user.headquarters_id is None: + raise ValidationError("An MR must have a headquarters") + if user.role != Role.MR and user.headquarters_id is not None: + raise ValidationError("Only an MR can have a headquarters") + + after = snapshot(user, _AUDIT_FIELDS) + if password_reset: + after["password_reset"] = True # the fact is logged, never the password or its hash + try: + await self.audit.log( + actor_user_id=actor.id, + entity_type=EntityType.USER, + entity_id=user.id, + action=AuditAction.DEACTIVATE if deactivating else AuditAction.UPDATE, + before=before, + after=after, + ip_address=ip, + ) + await self.db.commit() + except IntegrityError as exc: + await self.db.rollback() + raise ConflictError("A user with this email or employee code already exists") from exc + + # SEC-5 — revoke refresh tokens the moment a user is deactivated, or their + # credentials are changed, so an old session cannot outlive the old password/email. + if deactivating or password_reset or "email" in changes: + await AuthService(self.db).logout(user.id) + return user + + async def list_users(self, actor: User, role: Role | None = None) -> list[User]: + stmt = select(User).where(User.company_id == actor.company_id) + if role is not None: + stmt = stmt.where(User.role == role) + return list((await self.db.execute(stmt)).scalars().all()) + + async def my_profile(self, user: User) -> MyProfile: + """S4 — includes the reporting Area Manager DERIVED through the headquarters.""" + hq_code = hq_name = None + manager_id = manager_name = None + + if user.headquarters_id: + hq = await self.db.get(Headquarters, user.headquarters_id) + if hq: + hq_code, hq_name = hq.code, hq.name + + stmt = ( + select(User) + .join(AMHeadquarters, AMHeadquarters.area_manager_user_id == User.id) + .where( + AMHeadquarters.headquarters_id == user.headquarters_id, + AMHeadquarters.effective_to.is_(None), + ) + ) + manager = (await self.db.execute(stmt)).scalars().first() + if manager: + manager_id, manager_name = manager.id, manager.full_name + + return MyProfile( + id=user.id, + full_name=user.full_name, + employee_code=user.employee_code, + email=user.email, + role=user.role, + phone=user.phone, + headquarters_id=user.headquarters_id, + headquarters_code=hq_code, + headquarters_name=hq_name, + reporting_manager_id=manager_id, + reporting_manager_name=manager_name, + ) diff --git a/docker-compose.dev.yml b/docker-compose.dev.yml new file mode 100644 index 0000000..ae4a86e --- /dev/null +++ b/docker-compose.dev.yml @@ -0,0 +1,18 @@ +# Local development overlay. Never use it on a server: it publishes the database and +# the API — bound to loopback only — and creates the scratch database the tests use. +# +# docker compose -f docker-compose.yml -f docker-compose.dev.yml up -d db +# make dev-up # same thing, whole stack + +services: + db: + ports: + - "127.0.0.1:${DB_PORT:-5432}:5432" + volumes: + - ./scripts/init_test_db.sql:/docker-entrypoint-initdb.d/init_test_db.sql:ro + + api: + ports: + - "127.0.0.1:${API_PORT:-8000}:8000" + environment: + ENVIRONMENT: ${ENVIRONMENT:-development} diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..ecc66d6 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,92 @@ +# Single-VPS production deployment. No Kubernetes, no microservices, no message broker — +# none of it is needed for one company and a handful of MRs, and every piece of +# infrastructure added here is a piece somebody has to operate at 2am. +# +# Only Caddy publishes ports. The database and the API are reachable solely on the +# internal compose network. For local development add the dev overlay: +# docker compose -f docker-compose.yml -f docker-compose.dev.yml up -d db + +x-logging: &default-logging + driver: json-file + options: + max-size: "10m" + max-file: "5" + +services: + db: + image: postgres:16-alpine + environment: + POSTGRES_USER: ${POSTGRES_USER:-pharma} + POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:?set POSTGRES_PASSWORD in .env} + POSTGRES_DB: ${POSTGRES_DB:-pharma} + volumes: + - pgdata:/var/lib/postgresql/data + healthcheck: + test: ["CMD-SHELL", "pg_isready -U $${POSTGRES_USER} -d $${POSTGRES_DB}"] + interval: 5s + timeout: 5s + retries: 10 + restart: unless-stopped + logging: *default-logging + + api: + build: . + depends_on: + db: + condition: service_healthy + environment: + DATABASE_URL: postgresql+asyncpg://${POSTGRES_USER:-pharma}:${POSTGRES_PASSWORD}@db:5432/${POSTGRES_DB:-pharma} + SECRET_KEY: ${SECRET_KEY:?set SECRET_KEY in .env (64+ random characters)} + ENVIRONMENT: ${ENVIRONMENT:-production} + CORS_ORIGINS: ${CORS_ORIGINS:-["https://celtic.upskalor.com","https://www.celtic.upskalor.com","http://localhost:5173","http://localhost:3000"]} + PDF_STORAGE_PATH: /srv/storage/pdf + BACKDATING_WINDOW_DAYS: ${BACKDATING_WINDOW_DAYS:-7} + SUBMISSION_DEADLINE_DAYS: ${SUBMISSION_DEADLINE_DAYS:-1} + WEB_CONCURRENCY: ${WEB_CONCURRENCY:-2} + volumes: + - pdfstore:/srv/storage/pdf + # Immutable container: the only writable places are the PDF volume and tmpfs. + read_only: true + tmpfs: + - /tmp + - /home/appuser/.cache + security_opt: + - no-new-privileges:true + cap_drop: + - ALL + restart: unless-stopped + logging: *default-logging + + # Responsive React web application. It is static after its production build; + # Caddy below provides the public TLS endpoint. + web: + build: ./web + restart: unless-stopped + logging: *default-logging + + # Automatic HTTPS via Let's Encrypt — two lines of config, auto-renewal, + # no certbot cron job to forget about. + caddy: + image: caddy:2-alpine + depends_on: + api: + condition: service_healthy + web: + condition: service_started + ports: + - "${HTTP_PORT:-80}:80" + - "${HTTPS_PORT:-443}:443" + environment: + DOMAIN: ${DOMAIN:-localhost} + volumes: + - ./Caddyfile:/etc/caddy/Caddyfile:ro + - caddydata:/data + - caddyconfig:/config + restart: unless-stopped + logging: *default-logging + +volumes: + pgdata: + pdfstore: + caddydata: + caddyconfig: diff --git a/openapi.json b/openapi.json new file mode 100644 index 0000000..fe53d0b --- /dev/null +++ b/openapi.json @@ -0,0 +1,3518 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "Pharma Field Force Reporting", + "description": "Pharmaceutical field-force reporting \u2014 MVP. One MR, Daily Call Report, AM review, GM approval, locked PDF, audit trail.", + "version": "0.1.0" + }, + "paths": { + "/api/v1/auth/login": { + "post": { + "tags": [ + "auth" + ], + "summary": "Login", + "operationId": "login_api_v1_auth_login_post", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/LoginRequest" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "Successful Response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/TokenPair" + } + } + } + }, + "422": { + "description": "Validation Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/HTTPValidationError" + } + } + } + } + } + } + }, + "/api/v1/auth/refresh": { + "post": { + "tags": [ + "auth" + ], + "summary": "Refresh", + "operationId": "refresh_api_v1_auth_refresh_post", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/RefreshRequest" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "Successful Response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/TokenPair" + } + } + } + }, + "422": { + "description": "Validation Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/HTTPValidationError" + } + } + } + } + } + } + }, + "/api/v1/auth/logout": { + "post": { + "tags": [ + "auth" + ], + "summary": "Logout", + "operationId": "logout_api_v1_auth_logout_post", + "responses": { + "204": { + "description": "Successful Response" + } + }, + "security": [ + { + "HTTPBearer": [] + } + ] + } + }, + "/api/v1/auth/me": { + "get": { + "tags": [ + "auth" + ], + "summary": "Me", + "operationId": "me_api_v1_auth_me_get", + "responses": { + "200": { + "description": "Successful Response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CurrentUser" + } + } + } + } + }, + "security": [ + { + "HTTPBearer": [] + } + ] + } + }, + "/api/v1/users/me/profile": { + "get": { + "tags": [ + "users" + ], + "summary": "My Profile", + "operationId": "my_profile_api_v1_users_me_profile_get", + "responses": { + "200": { + "description": "Successful Response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/MyProfile" + } + } + } + } + }, + "security": [ + { + "HTTPBearer": [] + } + ] + } + }, + "/api/v1/users": { + "get": { + "tags": [ + "users" + ], + "summary": "List Users", + "operationId": "list_users_api_v1_users_get", + "security": [ + { + "HTTPBearer": [] + } + ], + "parameters": [ + { + "name": "role", + "in": "query", + "required": false, + "schema": { + "anyOf": [ + { + "$ref": "#/components/schemas/Role" + }, + { + "type": "null" + } + ], + "title": "Role" + } + } + ], + "responses": { + "200": { + "description": "Successful Response", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/UserRead" + }, + "title": "Response List Users Api V1 Users Get" + } + } + } + }, + "422": { + "description": "Validation Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/HTTPValidationError" + } + } + } + } + } + }, + "post": { + "tags": [ + "users" + ], + "summary": "Create User", + "operationId": "create_user_api_v1_users_post", + "security": [ + { + "HTTPBearer": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/UserCreate" + } + } + } + }, + "responses": { + "201": { + "description": "Successful Response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/UserRead" + } + } + } + }, + "422": { + "description": "Validation Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/HTTPValidationError" + } + } + } + } + } + } + }, + "/api/v1/users/{user_id}": { + "patch": { + "tags": [ + "users" + ], + "summary": "Update User", + "operationId": "update_user_api_v1_users__user_id__patch", + "security": [ + { + "HTTPBearer": [] + } + ], + "parameters": [ + { + "name": "user_id", + "in": "path", + "required": true, + "schema": { + "type": "string", + "format": "uuid", + "title": "User Id" + } + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/UserUpdate" + } + } + } + }, + "responses": { + "200": { + "description": "Successful Response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/UserRead" + } + } + } + }, + "422": { + "description": "Validation Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/HTTPValidationError" + } + } + } + } + } + } + }, + "/api/v1/headquarters": { + "get": { + "tags": [ + "organization" + ], + "summary": "List Headquarters", + "description": "Scoped: an MR sees their own HQ, an AM sees theirs, GM/Admin see all.", + "operationId": "list_headquarters_api_v1_headquarters_get", + "responses": { + "200": { + "description": "Successful Response", + "content": { + "application/json": { + "schema": { + "items": { + "$ref": "#/components/schemas/HeadquartersRead" + }, + "type": "array", + "title": "Response List Headquarters Api V1 Headquarters Get" + } + } + } + } + }, + "security": [ + { + "HTTPBearer": [] + } + ] + }, + "post": { + "tags": [ + "organization" + ], + "summary": "Create Headquarters", + "operationId": "create_headquarters_api_v1_headquarters_post", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/HeadquartersCreate" + } + } + }, + "required": true + }, + "responses": { + "201": { + "description": "Successful Response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/HeadquartersRead" + } + } + } + }, + "422": { + "description": "Validation Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/HTTPValidationError" + } + } + } + } + }, + "security": [ + { + "HTTPBearer": [] + } + ] + } + }, + "/api/v1/headquarters/{headquarters_id}/area-manager": { + "post": { + "tags": [ + "organization" + ], + "summary": "Assign Area Manager", + "operationId": "assign_area_manager_api_v1_headquarters__headquarters_id__area_manager_post", + "security": [ + { + "HTTPBearer": [] + } + ], + "parameters": [ + { + "name": "headquarters_id", + "in": "path", + "required": true, + "schema": { + "type": "string", + "format": "uuid", + "title": "Headquarters Id" + } + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/AssignAreaManager" + } + } + } + }, + "responses": { + "201": { + "description": "Successful Response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/AMHeadquartersRead" + } + } + } + }, + "422": { + "description": "Validation Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/HTTPValidationError" + } + } + } + } + } + } + }, + "/api/v1/doctors": { + "get": { + "tags": [ + "doctors" + ], + "summary": "List Doctors", + "description": "S5 \u2014 an MR gets only their assigned doctors; managers get their HQ scope.", + "operationId": "list_doctors_api_v1_doctors_get", + "responses": { + "200": { + "description": "Successful Response", + "content": { + "application/json": { + "schema": { + "items": { + "$ref": "#/components/schemas/DoctorRead" + }, + "type": "array", + "title": "Response List Doctors Api V1 Doctors Get" + } + } + } + } + }, + "security": [ + { + "HTTPBearer": [] + } + ] + }, + "post": { + "tags": [ + "doctors" + ], + "summary": "Create Doctor", + "description": "A3 \u2014 an MR cannot create a doctor in the MVP. Confirm with client (Q3).", + "operationId": "create_doctor_api_v1_doctors_post", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/DoctorCreate" + } + } + }, + "required": true + }, + "responses": { + "201": { + "description": "Successful Response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/DoctorRead" + } + } + } + }, + "422": { + "description": "Validation Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/HTTPValidationError" + } + } + } + } + }, + "security": [ + { + "HTTPBearer": [] + } + ] + } + }, + "/api/v1/doctors/{doctor_id}": { + "patch": { + "tags": [ + "doctors" + ], + "summary": "Update Doctor", + "operationId": "update_doctor_api_v1_doctors__doctor_id__patch", + "security": [ + { + "HTTPBearer": [] + } + ], + "parameters": [ + { + "name": "doctor_id", + "in": "path", + "required": true, + "schema": { + "type": "string", + "format": "uuid", + "title": "Doctor Id" + } + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/DoctorUpdate" + } + } + } + }, + "responses": { + "200": { + "description": "Successful Response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/DoctorRead" + } + } + } + }, + "422": { + "description": "Validation Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/HTTPValidationError" + } + } + } + } + } + } + }, + "/api/v1/doctors/{doctor_id}/assign": { + "post": { + "tags": [ + "doctors" + ], + "summary": "Assign Doctor", + "description": "An AM may assign only within their own headquarters \u2014 enforced by data scope.", + "operationId": "assign_doctor_api_v1_doctors__doctor_id__assign_post", + "security": [ + { + "HTTPBearer": [] + } + ], + "parameters": [ + { + "name": "doctor_id", + "in": "path", + "required": true, + "schema": { + "type": "string", + "format": "uuid", + "title": "Doctor Id" + } + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/AssignToMR" + } + } + } + }, + "responses": { + "201": { + "description": "Successful Response", + "content": { + "application/json": { + "schema": {} + } + } + }, + "422": { + "description": "Validation Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/HTTPValidationError" + } + } + } + } + } + } + }, + "/api/v1/chemists": { + "get": { + "tags": [ + "chemists" + ], + "summary": "List Chemists", + "operationId": "list_chemists_api_v1_chemists_get", + "responses": { + "200": { + "description": "Successful Response", + "content": { + "application/json": { + "schema": { + "items": { + "$ref": "#/components/schemas/ChemistRead" + }, + "type": "array", + "title": "Response List Chemists Api V1 Chemists Get" + } + } + } + } + }, + "security": [ + { + "HTTPBearer": [] + } + ] + }, + "post": { + "tags": [ + "chemists" + ], + "summary": "Create Chemist", + "operationId": "create_chemist_api_v1_chemists_post", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ChemistCreate" + } + } + }, + "required": true + }, + "responses": { + "201": { + "description": "Successful Response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ChemistRead" + } + } + } + }, + "422": { + "description": "Validation Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/HTTPValidationError" + } + } + } + } + }, + "security": [ + { + "HTTPBearer": [] + } + ] + } + }, + "/api/v1/chemists/{chemist_id}": { + "patch": { + "tags": [ + "chemists" + ], + "summary": "Update Chemist", + "operationId": "update_chemist_api_v1_chemists__chemist_id__patch", + "security": [ + { + "HTTPBearer": [] + } + ], + "parameters": [ + { + "name": "chemist_id", + "in": "path", + "required": true, + "schema": { + "type": "string", + "format": "uuid", + "title": "Chemist Id" + } + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ChemistUpdate" + } + } + } + }, + "responses": { + "200": { + "description": "Successful Response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ChemistRead" + } + } + } + }, + "422": { + "description": "Validation Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/HTTPValidationError" + } + } + } + } + } + } + }, + "/api/v1/chemists/{chemist_id}/assign": { + "post": { + "tags": [ + "chemists" + ], + "summary": "Assign Chemist", + "operationId": "assign_chemist_api_v1_chemists__chemist_id__assign_post", + "security": [ + { + "HTTPBearer": [] + } + ], + "parameters": [ + { + "name": "chemist_id", + "in": "path", + "required": true, + "schema": { + "type": "string", + "format": "uuid", + "title": "Chemist Id" + } + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/AssignToMR" + } + } + } + }, + "responses": { + "201": { + "description": "Successful Response", + "content": { + "application/json": { + "schema": {} + } + } + }, + "422": { + "description": "Validation Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/HTTPValidationError" + } + } + } + } + } + } + }, + "/api/v1/dcr": { + "get": { + "tags": [ + "reports" + ], + "summary": "List Reports", + "description": "S2 (MR) and S6 (manager queue). Scope is applied in the service, never here.", + "operationId": "list_reports_api_v1_dcr_get", + "security": [ + { + "HTTPBearer": [] + } + ], + "parameters": [ + { + "name": "status", + "in": "query", + "required": false, + "schema": { + "anyOf": [ + { + "$ref": "#/components/schemas/DCRStatus" + }, + { + "type": "null" + } + ], + "title": "Status" + } + }, + { + "name": "date_from", + "in": "query", + "required": false, + "schema": { + "anyOf": [ + { + "type": "string", + "format": "date" + }, + { + "type": "null" + } + ], + "title": "Date From" + } + }, + { + "name": "date_to", + "in": "query", + "required": false, + "schema": { + "anyOf": [ + { + "type": "string", + "format": "date" + }, + { + "type": "null" + } + ], + "title": "Date To" + } + }, + { + "name": "limit", + "in": "query", + "required": false, + "schema": { + "type": "integer", + "maximum": 200, + "minimum": 1, + "default": 50, + "title": "Limit" + } + }, + { + "name": "offset", + "in": "query", + "required": false, + "schema": { + "type": "integer", + "minimum": 0, + "default": 0, + "title": "Offset" + } + } + ], + "responses": { + "200": { + "description": "Successful Response", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/DCRListItem" + }, + "title": "Response List Reports Api V1 Dcr Get" + } + } + } + }, + "422": { + "description": "Validation Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/HTTPValidationError" + } + } + } + } + } + }, + "post": { + "tags": [ + "reports" + ], + "summary": "Create Report", + "operationId": "create_report_api_v1_dcr_post", + "security": [ + { + "HTTPBearer": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/DCRCreate" + } + } + } + }, + "responses": { + "201": { + "description": "Successful Response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/DCRRead" + } + } + } + }, + "422": { + "description": "Validation Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/HTTPValidationError" + } + } + } + } + } + } + }, + "/api/v1/dcr/counts": { + "get": { + "tags": [ + "reports" + ], + "summary": "Status Counts", + "description": "Header counts \u2014 the deliberate, cheap replacement for the cut dashboards.", + "operationId": "status_counts_api_v1_dcr_counts_get", + "responses": { + "200": { + "description": "Successful Response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/StatusCounts" + } + } + } + } + }, + "security": [ + { + "HTTPBearer": [] + } + ] + } + }, + "/api/v1/dcr/{dcr_id}": { + "get": { + "tags": [ + "reports" + ], + "summary": "Get Report", + "operationId": "get_report_api_v1_dcr__dcr_id__get", + "security": [ + { + "HTTPBearer": [] + } + ], + "parameters": [ + { + "name": "dcr_id", + "in": "path", + "required": true, + "schema": { + "type": "string", + "format": "uuid", + "title": "Dcr Id" + } + } + ], + "responses": { + "200": { + "description": "Successful Response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/DCRRead" + } + } + } + }, + "422": { + "description": "Validation Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/HTTPValidationError" + } + } + } + } + } + }, + "patch": { + "tags": [ + "reports" + ], + "summary": "Update Report", + "operationId": "update_report_api_v1_dcr__dcr_id__patch", + "security": [ + { + "HTTPBearer": [] + } + ], + "parameters": [ + { + "name": "dcr_id", + "in": "path", + "required": true, + "schema": { + "type": "string", + "format": "uuid", + "title": "Dcr Id" + } + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/DCRUpdate" + } + } + } + }, + "responses": { + "200": { + "description": "Successful Response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/DCRRead" + } + } + } + }, + "422": { + "description": "Validation Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/HTTPValidationError" + } + } + } + } + } + } + }, + "/api/v1/dcr/{dcr_id}/pdf": { + "get": { + "tags": [ + "reports" + ], + "summary": "Download Pdf", + "description": "SEC-7 \u2014 served through an authorised endpoint, never as a guessable static path.", + "operationId": "download_pdf_api_v1_dcr__dcr_id__pdf_get", + "security": [ + { + "HTTPBearer": [] + } + ], + "parameters": [ + { + "name": "dcr_id", + "in": "path", + "required": true, + "schema": { + "type": "string", + "format": "uuid", + "title": "Dcr Id" + } + } + ], + "responses": { + "200": { + "description": "Successful Response", + "content": { + "application/json": { + "schema": {} + } + } + }, + "422": { + "description": "Validation Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/HTTPValidationError" + } + } + } + } + } + } + }, + "/api/v1/dcr/{dcr_id}/calls/doctor": { + "post": { + "tags": [ + "reports" + ], + "summary": "Add Doctor Call", + "operationId": "add_doctor_call_api_v1_dcr__dcr_id__calls_doctor_post", + "security": [ + { + "HTTPBearer": [] + } + ], + "parameters": [ + { + "name": "dcr_id", + "in": "path", + "required": true, + "schema": { + "type": "string", + "format": "uuid", + "title": "Dcr Id" + } + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/DoctorCallCreate" + } + } + } + }, + "responses": { + "201": { + "description": "Successful Response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/DCRRead" + } + } + } + }, + "422": { + "description": "Validation Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/HTTPValidationError" + } + } + } + } + } + } + }, + "/api/v1/dcr/{dcr_id}/calls/chemist": { + "post": { + "tags": [ + "reports" + ], + "summary": "Add Chemist Call", + "operationId": "add_chemist_call_api_v1_dcr__dcr_id__calls_chemist_post", + "security": [ + { + "HTTPBearer": [] + } + ], + "parameters": [ + { + "name": "dcr_id", + "in": "path", + "required": true, + "schema": { + "type": "string", + "format": "uuid", + "title": "Dcr Id" + } + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ChemistCallCreate" + } + } + } + }, + "responses": { + "201": { + "description": "Successful Response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/DCRRead" + } + } + } + }, + "422": { + "description": "Validation Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/HTTPValidationError" + } + } + } + } + } + } + }, + "/api/v1/dcr/{dcr_id}/calls/{call_id}": { + "delete": { + "tags": [ + "reports" + ], + "summary": "Delete Call", + "operationId": "delete_call_api_v1_dcr__dcr_id__calls__call_id__delete", + "security": [ + { + "HTTPBearer": [] + } + ], + "parameters": [ + { + "name": "dcr_id", + "in": "path", + "required": true, + "schema": { + "type": "string", + "format": "uuid", + "title": "Dcr Id" + } + }, + { + "name": "call_id", + "in": "path", + "required": true, + "schema": { + "type": "string", + "format": "uuid", + "title": "Call Id" + } + } + ], + "responses": { + "200": { + "description": "Successful Response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/DCRRead" + } + } + } + }, + "422": { + "description": "Validation Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/HTTPValidationError" + } + } + } + } + } + } + }, + "/api/v1/dcr/{dcr_id}/submit": { + "post": { + "tags": [ + "reports" + ], + "summary": "Submit", + "operationId": "submit_api_v1_dcr__dcr_id__submit_post", + "security": [ + { + "HTTPBearer": [] + } + ], + "parameters": [ + { + "name": "dcr_id", + "in": "path", + "required": true, + "schema": { + "type": "string", + "format": "uuid", + "title": "Dcr Id" + } + } + ], + "responses": { + "200": { + "description": "Successful Response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/DCRRead" + } + } + } + }, + "422": { + "description": "Validation Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/HTTPValidationError" + } + } + } + } + } + } + }, + "/api/v1/dcr/{dcr_id}/forward": { + "post": { + "tags": [ + "reports" + ], + "summary": "Forward", + "description": "The Area Manager forwards or returns \u2014 it does NOT approve (A4/Q4).", + "operationId": "forward_api_v1_dcr__dcr_id__forward_post", + "security": [ + { + "HTTPBearer": [] + } + ], + "parameters": [ + { + "name": "dcr_id", + "in": "path", + "required": true, + "schema": { + "type": "string", + "format": "uuid", + "title": "Dcr Id" + } + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ForwardRequest" + } + } + } + }, + "responses": { + "200": { + "description": "Successful Response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/DCRRead" + } + } + } + }, + "422": { + "description": "Validation Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/HTTPValidationError" + } + } + } + } + } + } + }, + "/api/v1/dcr/{dcr_id}/return": { + "post": { + "tags": [ + "reports" + ], + "summary": "Return Report", + "operationId": "return_report_api_v1_dcr__dcr_id__return_post", + "security": [ + { + "HTTPBearer": [] + } + ], + "parameters": [ + { + "name": "dcr_id", + "in": "path", + "required": true, + "schema": { + "type": "string", + "format": "uuid", + "title": "Dcr Id" + } + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ReturnRequest" + } + } + } + }, + "responses": { + "200": { + "description": "Successful Response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/DCRRead" + } + } + } + }, + "422": { + "description": "Validation Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/HTTPValidationError" + } + } + } + } + } + } + }, + "/api/v1/dcr/{dcr_id}/approve": { + "post": { + "tags": [ + "reports" + ], + "summary": "Approve", + "description": "GM only. SEC-2: ADMIN is absent from this dependency by design.", + "operationId": "approve_api_v1_dcr__dcr_id__approve_post", + "security": [ + { + "HTTPBearer": [] + } + ], + "parameters": [ + { + "name": "dcr_id", + "in": "path", + "required": true, + "schema": { + "type": "string", + "format": "uuid", + "title": "Dcr Id" + } + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApproveRequest" + } + } + } + }, + "responses": { + "200": { + "description": "Successful Response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/DCRRead" + } + } + } + }, + "422": { + "description": "Validation Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/HTTPValidationError" + } + } + } + } + } + } + }, + "/api/v1/audit": { + "get": { + "tags": [ + "audit" + ], + "summary": "Get Audit History", + "description": "Scoped audit history.\n\nFor a report, the caller must be able to view the report itself \u2014 the audit log is\nnot a side door around the data-scope rules.", + "operationId": "get_audit_history_api_v1_audit_get", + "security": [ + { + "HTTPBearer": [] + } + ], + "parameters": [ + { + "name": "entity_type", + "in": "query", + "required": true, + "schema": { + "$ref": "#/components/schemas/EntityType" + } + }, + { + "name": "entity_id", + "in": "query", + "required": true, + "schema": { + "type": "string", + "format": "uuid", + "title": "Entity Id" + } + } + ], + "responses": { + "200": { + "description": "Successful Response", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/AuditLogRead" + }, + "title": "Response Get Audit History Api V1 Audit Get" + } + } + } + }, + "422": { + "description": "Validation Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/HTTPValidationError" + } + } + } + } + } + } + }, + "/api/v1/audit/dcr/{dcr_id}/approval-history": { + "get": { + "tags": [ + "audit" + ], + "summary": "Approval History", + "description": "\"Approval history\" is a filtered view over audit_log, not a second table.", + "operationId": "approval_history_api_v1_audit_dcr__dcr_id__approval_history_get", + "security": [ + { + "HTTPBearer": [] + } + ], + "parameters": [ + { + "name": "dcr_id", + "in": "path", + "required": true, + "schema": { + "type": "string", + "format": "uuid", + "title": "Dcr Id" + } + } + ], + "responses": { + "200": { + "description": "Successful Response", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/ApprovalHistoryItem" + }, + "title": "Response Approval History Api V1 Audit Dcr Dcr Id Approval History Get" + } + } + } + }, + "422": { + "description": "Validation Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/HTTPValidationError" + } + } + } + } + } + } + }, + "/health": { + "get": { + "tags": [ + "meta" + ], + "summary": "Health", + "operationId": "health_health_get", + "responses": { + "200": { + "description": "Successful Response", + "content": { + "application/json": { + "schema": { + "additionalProperties": { + "type": "string" + }, + "type": "object", + "title": "Response Health Health Get" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "AMHeadquartersRead": { + "properties": { + "id": { + "type": "string", + "format": "uuid", + "title": "Id" + }, + "area_manager_user_id": { + "type": "string", + "format": "uuid", + "title": "Area Manager User Id" + }, + "headquarters_id": { + "type": "string", + "format": "uuid", + "title": "Headquarters Id" + }, + "effective_from": { + "type": "string", + "format": "date", + "title": "Effective From" + }, + "effective_to": { + "anyOf": [ + { + "type": "string", + "format": "date" + }, + { + "type": "null" + } + ], + "title": "Effective To" + } + }, + "type": "object", + "required": [ + "id", + "area_manager_user_id", + "headquarters_id", + "effective_from", + "effective_to" + ], + "title": "AMHeadquartersRead" + }, + "ApprovalHistoryItem": { + "properties": { + "action": { + "$ref": "#/components/schemas/AuditAction" + }, + "actor_name": { + "type": "string", + "title": "Actor Name" + }, + "actor_role": { + "type": "string", + "title": "Actor Role" + }, + "comment": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Comment" + }, + "at": { + "type": "string", + "format": "date-time", + "title": "At" + } + }, + "type": "object", + "required": [ + "action", + "actor_name", + "actor_role", + "comment", + "at" + ], + "title": "ApprovalHistoryItem", + "description": "The approval trail as shown on S7 and printed in the PDF." + }, + "ApproveRequest": { + "properties": { + "comment": { + "anyOf": [ + { + "type": "string", + "maxLength": 2000 + }, + { + "type": "null" + } + ], + "title": "Comment" + } + }, + "type": "object", + "title": "ApproveRequest" + }, + "AssignAreaManager": { + "properties": { + "area_manager_user_id": { + "type": "string", + "format": "uuid", + "title": "Area Manager User Id" + }, + "effective_from": { + "anyOf": [ + { + "type": "string", + "format": "date" + }, + { + "type": "null" + } + ], + "title": "Effective From" + } + }, + "type": "object", + "required": [ + "area_manager_user_id" + ], + "title": "AssignAreaManager" + }, + "AssignToMR": { + "properties": { + "mr_user_id": { + "type": "string", + "format": "uuid", + "title": "Mr User Id" + }, + "effective_from": { + "anyOf": [ + { + "type": "string", + "format": "date" + }, + { + "type": "null" + } + ], + "title": "Effective From" + } + }, + "type": "object", + "required": [ + "mr_user_id" + ], + "title": "AssignToMR" + }, + "AuditAction": { + "type": "string", + "enum": [ + "CREATE", + "UPDATE", + "DELETE", + "SUBMIT", + "FORWARD", + "RETURN", + "APPROVE", + "ASSIGN", + "LOGIN", + "DEACTIVATE" + ], + "title": "AuditAction" + }, + "AuditLogRead": { + "properties": { + "id": { + "type": "string", + "format": "uuid", + "title": "Id" + }, + "actor_user_id": { + "type": "string", + "format": "uuid", + "title": "Actor User Id" + }, + "entity_type": { + "$ref": "#/components/schemas/EntityType" + }, + "entity_id": { + "type": "string", + "format": "uuid", + "title": "Entity Id" + }, + "action": { + "$ref": "#/components/schemas/AuditAction" + }, + "comment": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Comment" + }, + "before_data": { + "anyOf": [ + { + "additionalProperties": true, + "type": "object" + }, + { + "type": "null" + } + ], + "title": "Before Data" + }, + "after_data": { + "anyOf": [ + { + "additionalProperties": true, + "type": "object" + }, + { + "type": "null" + } + ], + "title": "After Data" + }, + "ip_address": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Ip Address" + }, + "created_at": { + "type": "string", + "format": "date-time", + "title": "Created At" + } + }, + "type": "object", + "required": [ + "id", + "actor_user_id", + "entity_type", + "entity_id", + "action", + "comment", + "before_data", + "after_data", + "ip_address", + "created_at" + ], + "title": "AuditLogRead" + }, + "CallOutcome": { + "type": "string", + "enum": [ + "MET", + "NOT_AVAILABLE", + "RESCHEDULED" + ], + "title": "CallOutcome" + }, + "ChemistCallCreate": { + "properties": { + "chemist_id": { + "type": "string", + "format": "uuid", + "title": "Chemist Id" + }, + "visit_time": { + "type": "string", + "format": "time", + "title": "Visit Time" + }, + "remarks": { + "anyOf": [ + { + "type": "string", + "maxLength": 2000 + }, + { + "type": "null" + } + ], + "title": "Remarks" + } + }, + "type": "object", + "required": [ + "chemist_id", + "visit_time" + ], + "title": "ChemistCallCreate" + }, + "ChemistCallRead": { + "properties": { + "id": { + "type": "string", + "format": "uuid", + "title": "Id" + }, + "chemist_id": { + "type": "string", + "format": "uuid", + "title": "Chemist Id" + }, + "chemist_name": { + "type": "string", + "title": "Chemist Name" + }, + "visit_time": { + "type": "string", + "format": "time", + "title": "Visit Time" + }, + "remarks": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Remarks" + } + }, + "type": "object", + "required": [ + "id", + "chemist_id", + "chemist_name", + "visit_time", + "remarks" + ], + "title": "ChemistCallRead" + }, + "ChemistCreate": { + "properties": { + "headquarters_id": { + "type": "string", + "format": "uuid", + "title": "Headquarters Id" + }, + "name": { + "type": "string", + "maxLength": 200, + "minLength": 2, + "title": "Name" + }, + "shop_address": { + "type": "string", + "maxLength": 500, + "minLength": 2, + "title": "Shop Address" + }, + "contact_number": { + "anyOf": [ + { + "type": "string", + "maxLength": 20 + }, + { + "type": "null" + } + ], + "title": "Contact Number" + } + }, + "type": "object", + "required": [ + "headquarters_id", + "name", + "shop_address" + ], + "title": "ChemistCreate" + }, + "ChemistRead": { + "properties": { + "id": { + "type": "string", + "format": "uuid", + "title": "Id" + }, + "headquarters_id": { + "type": "string", + "format": "uuid", + "title": "Headquarters Id" + }, + "name": { + "type": "string", + "title": "Name" + }, + "shop_address": { + "type": "string", + "title": "Shop Address" + }, + "contact_number": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Contact Number" + }, + "is_active": { + "type": "boolean", + "title": "Is Active" + } + }, + "type": "object", + "required": [ + "id", + "headquarters_id", + "name", + "shop_address", + "contact_number", + "is_active" + ], + "title": "ChemistRead" + }, + "ChemistUpdate": { + "properties": { + "name": { + "anyOf": [ + { + "type": "string", + "maxLength": 200, + "minLength": 2 + }, + { + "type": "null" + } + ], + "title": "Name" + }, + "shop_address": { + "anyOf": [ + { + "type": "string", + "maxLength": 500, + "minLength": 2 + }, + { + "type": "null" + } + ], + "title": "Shop Address" + }, + "contact_number": { + "anyOf": [ + { + "type": "string", + "maxLength": 20 + }, + { + "type": "null" + } + ], + "title": "Contact Number" + }, + "is_active": { + "anyOf": [ + { + "type": "boolean" + }, + { + "type": "null" + } + ], + "title": "Is Active" + } + }, + "type": "object", + "title": "ChemistUpdate" + }, + "ConversionStatus": { + "type": "string", + "enum": [ + "NOT_STARTED", + "IN_PROGRESS", + "CONVERTED", + "LOST" + ], + "title": "ConversionStatus", + "description": "Core-doctor conversion. Stored as a column on doctor_call, not a table." + }, + "CurrentUser": { + "properties": { + "id": { + "type": "string", + "format": "uuid", + "title": "Id" + }, + "email": { + "type": "string", + "title": "Email" + }, + "full_name": { + "type": "string", + "title": "Full Name" + }, + "employee_code": { + "type": "string", + "title": "Employee Code" + }, + "role": { + "$ref": "#/components/schemas/Role" + }, + "headquarters_id": { + "anyOf": [ + { + "type": "string", + "format": "uuid" + }, + { + "type": "null" + } + ], + "title": "Headquarters Id" + }, + "is_active": { + "type": "boolean", + "title": "Is Active" + } + }, + "type": "object", + "required": [ + "id", + "email", + "full_name", + "employee_code", + "role", + "headquarters_id", + "is_active" + ], + "title": "CurrentUser" + }, + "DCRCreate": { + "properties": { + "report_date": { + "type": "string", + "format": "date", + "title": "Report Date" + }, + "mr_remarks": { + "anyOf": [ + { + "type": "string", + "maxLength": 2000 + }, + { + "type": "null" + } + ], + "title": "Mr Remarks" + }, + "doctor_calls": { + "items": { + "$ref": "#/components/schemas/DoctorCallCreate" + }, + "type": "array", + "title": "Doctor Calls" + }, + "chemist_calls": { + "items": { + "$ref": "#/components/schemas/ChemistCallCreate" + }, + "type": "array", + "title": "Chemist Calls" + } + }, + "type": "object", + "required": [ + "report_date" + ], + "title": "DCRCreate" + }, + "DCRListItem": { + "properties": { + "id": { + "type": "string", + "format": "uuid", + "title": "Id" + }, + "report_date": { + "type": "string", + "format": "date", + "title": "Report Date" + }, + "status": { + "$ref": "#/components/schemas/DCRStatus" + }, + "mr_user_id": { + "type": "string", + "format": "uuid", + "title": "Mr User Id" + }, + "mr_name": { + "type": "string", + "title": "Mr Name" + }, + "headquarters_id": { + "type": "string", + "format": "uuid", + "title": "Headquarters Id" + }, + "headquarters_name": { + "type": "string", + "title": "Headquarters Name" + }, + "doctor_call_count": { + "type": "integer", + "title": "Doctor Call Count" + }, + "chemist_call_count": { + "type": "integer", + "title": "Chemist Call Count" + }, + "submitted_at": { + "anyOf": [ + { + "type": "string", + "format": "date-time" + }, + { + "type": "null" + } + ], + "title": "Submitted At" + }, + "approved_at": { + "anyOf": [ + { + "type": "string", + "format": "date-time" + }, + { + "type": "null" + } + ], + "title": "Approved At" + }, + "returned_by_role": { + "anyOf": [ + { + "$ref": "#/components/schemas/Role" + }, + { + "type": "null" + } + ] + } + }, + "type": "object", + "required": [ + "id", + "report_date", + "status", + "mr_user_id", + "mr_name", + "headquarters_id", + "headquarters_name", + "doctor_call_count", + "chemist_call_count", + "submitted_at", + "approved_at", + "returned_by_role" + ], + "title": "DCRListItem", + "description": "Row for S2/S6 \u2014 the list screens that replaced the cut dashboards." + }, + "DCRRead": { + "properties": { + "id": { + "type": "string", + "format": "uuid", + "title": "Id" + }, + "mr_user_id": { + "type": "string", + "format": "uuid", + "title": "Mr User Id" + }, + "mr_name": { + "type": "string", + "title": "Mr Name" + }, + "employee_code": { + "type": "string", + "title": "Employee Code" + }, + "headquarters_id": { + "type": "string", + "format": "uuid", + "title": "Headquarters Id" + }, + "headquarters_name": { + "type": "string", + "title": "Headquarters Name" + }, + "report_date": { + "type": "string", + "format": "date", + "title": "Report Date" + }, + "status": { + "$ref": "#/components/schemas/DCRStatus" + }, + "is_locked": { + "type": "boolean", + "title": "Is Locked" + }, + "mr_remarks": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Mr Remarks" + }, + "return_reason": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Return Reason" + }, + "returned_by_role": { + "anyOf": [ + { + "$ref": "#/components/schemas/Role" + }, + { + "type": "null" + } + ] + }, + "submitted_at": { + "anyOf": [ + { + "type": "string", + "format": "date-time" + }, + { + "type": "null" + } + ], + "title": "Submitted At" + }, + "approved_at": { + "anyOf": [ + { + "type": "string", + "format": "date-time" + }, + { + "type": "null" + } + ], + "title": "Approved At" + }, + "doctor_calls": { + "items": { + "$ref": "#/components/schemas/DoctorCallRead" + }, + "type": "array", + "title": "Doctor Calls" + }, + "chemist_calls": { + "items": { + "$ref": "#/components/schemas/ChemistCallRead" + }, + "type": "array", + "title": "Chemist Calls" + } + }, + "type": "object", + "required": [ + "id", + "mr_user_id", + "mr_name", + "employee_code", + "headquarters_id", + "headquarters_name", + "report_date", + "status", + "is_locked", + "mr_remarks", + "return_reason", + "returned_by_role", + "submitted_at", + "approved_at", + "doctor_calls", + "chemist_calls" + ], + "title": "DCRRead" + }, + "DCRStatus": { + "type": "string", + "enum": [ + "DRAFT", + "PENDING_AM", + "PENDING_GM", + "RETURNED", + "APPROVED" + ], + "title": "DCRStatus", + "description": "5 states, down from the 7 originally proposed.\n\n- \"Returned by AM\" and \"Returned by GM\" collapse into RETURNED; who returned it\n is stored in `returned_by_role`, which is data, not state.\n- \"Finally Approved\" and \"Locked\" collapse into APPROVED. Immutability is a\n property of APPROVED enforced in one guard, not a second status." + }, + "DCRUpdate": { + "properties": { + "mr_remarks": { + "anyOf": [ + { + "type": "string", + "maxLength": 2000 + }, + { + "type": "null" + } + ], + "title": "Mr Remarks" + } + }, + "type": "object", + "title": "DCRUpdate" + }, + "DoctorCallCreate": { + "properties": { + "doctor_id": { + "type": "string", + "format": "uuid", + "title": "Doctor Id" + }, + "visit_time": { + "type": "string", + "format": "time", + "title": "Visit Time" + }, + "call_outcome": { + "$ref": "#/components/schemas/CallOutcome" + }, + "conversion_status": { + "anyOf": [ + { + "$ref": "#/components/schemas/ConversionStatus" + }, + { + "type": "null" + } + ] + }, + "remarks": { + "anyOf": [ + { + "type": "string", + "maxLength": 2000 + }, + { + "type": "null" + } + ], + "title": "Remarks" + } + }, + "type": "object", + "required": [ + "doctor_id", + "visit_time", + "call_outcome" + ], + "title": "DoctorCallCreate" + }, + "DoctorCallRead": { + "properties": { + "id": { + "type": "string", + "format": "uuid", + "title": "Id" + }, + "doctor_id": { + "type": "string", + "format": "uuid", + "title": "Doctor Id" + }, + "doctor_name": { + "type": "string", + "title": "Doctor Name" + }, + "doctor_speciality": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Doctor Speciality" + }, + "is_core_doctor": { + "type": "boolean", + "title": "Is Core Doctor" + }, + "visit_time": { + "type": "string", + "format": "time", + "title": "Visit Time" + }, + "call_outcome": { + "$ref": "#/components/schemas/CallOutcome" + }, + "conversion_status": { + "anyOf": [ + { + "$ref": "#/components/schemas/ConversionStatus" + }, + { + "type": "null" + } + ] + }, + "remarks": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Remarks" + } + }, + "type": "object", + "required": [ + "id", + "doctor_id", + "doctor_name", + "doctor_speciality", + "is_core_doctor", + "visit_time", + "call_outcome", + "conversion_status", + "remarks" + ], + "title": "DoctorCallRead" + }, + "DoctorCreate": { + "properties": { + "headquarters_id": { + "type": "string", + "format": "uuid", + "title": "Headquarters Id" + }, + "name": { + "type": "string", + "maxLength": 200, + "minLength": 2, + "title": "Name" + }, + "clinic_address": { + "type": "string", + "maxLength": 500, + "minLength": 2, + "title": "Clinic Address" + }, + "speciality": { + "anyOf": [ + { + "type": "string", + "maxLength": 100 + }, + { + "type": "null" + } + ], + "title": "Speciality" + }, + "qualification": { + "anyOf": [ + { + "type": "string", + "maxLength": 100 + }, + { + "type": "null" + } + ], + "title": "Qualification" + }, + "contact_number": { + "anyOf": [ + { + "type": "string", + "maxLength": 20 + }, + { + "type": "null" + } + ], + "title": "Contact Number" + }, + "is_core_doctor": { + "type": "boolean", + "title": "Is Core Doctor", + "default": false + } + }, + "type": "object", + "required": [ + "headquarters_id", + "name", + "clinic_address" + ], + "title": "DoctorCreate" + }, + "DoctorRead": { + "properties": { + "id": { + "type": "string", + "format": "uuid", + "title": "Id" + }, + "headquarters_id": { + "type": "string", + "format": "uuid", + "title": "Headquarters Id" + }, + "name": { + "type": "string", + "title": "Name" + }, + "clinic_address": { + "type": "string", + "title": "Clinic Address" + }, + "speciality": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Speciality" + }, + "qualification": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Qualification" + }, + "contact_number": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Contact Number" + }, + "is_core_doctor": { + "type": "boolean", + "title": "Is Core Doctor" + }, + "is_active": { + "type": "boolean", + "title": "Is Active" + } + }, + "type": "object", + "required": [ + "id", + "headquarters_id", + "name", + "clinic_address", + "speciality", + "qualification", + "contact_number", + "is_core_doctor", + "is_active" + ], + "title": "DoctorRead" + }, + "DoctorUpdate": { + "properties": { + "name": { + "anyOf": [ + { + "type": "string", + "maxLength": 200, + "minLength": 2 + }, + { + "type": "null" + } + ], + "title": "Name" + }, + "clinic_address": { + "anyOf": [ + { + "type": "string", + "maxLength": 500, + "minLength": 2 + }, + { + "type": "null" + } + ], + "title": "Clinic Address" + }, + "speciality": { + "anyOf": [ + { + "type": "string", + "maxLength": 100 + }, + { + "type": "null" + } + ], + "title": "Speciality" + }, + "qualification": { + "anyOf": [ + { + "type": "string", + "maxLength": 100 + }, + { + "type": "null" + } + ], + "title": "Qualification" + }, + "contact_number": { + "anyOf": [ + { + "type": "string", + "maxLength": 20 + }, + { + "type": "null" + } + ], + "title": "Contact Number" + }, + "is_core_doctor": { + "anyOf": [ + { + "type": "boolean" + }, + { + "type": "null" + } + ], + "title": "Is Core Doctor" + }, + "is_active": { + "anyOf": [ + { + "type": "boolean" + }, + { + "type": "null" + } + ], + "title": "Is Active" + } + }, + "type": "object", + "title": "DoctorUpdate" + }, + "EntityType": { + "type": "string", + "enum": [ + "user", + "headquarters", + "doctor", + "chemist", + "dcr" + ], + "title": "EntityType" + }, + "ForwardRequest": { + "properties": { + "comment": { + "anyOf": [ + { + "type": "string", + "maxLength": 2000 + }, + { + "type": "null" + } + ], + "title": "Comment" + } + }, + "type": "object", + "title": "ForwardRequest" + }, + "HTTPValidationError": { + "properties": { + "detail": { + "items": { + "$ref": "#/components/schemas/ValidationError" + }, + "type": "array", + "title": "Detail" + } + }, + "type": "object", + "title": "HTTPValidationError" + }, + "HeadquartersCreate": { + "properties": { + "code": { + "type": "string", + "maxLength": 20, + "minLength": 1, + "title": "Code" + }, + "name": { + "type": "string", + "maxLength": 200, + "minLength": 2, + "title": "Name" + }, + "district": { + "anyOf": [ + { + "type": "string", + "maxLength": 100 + }, + { + "type": "null" + } + ], + "title": "District" + }, + "state": { + "anyOf": [ + { + "type": "string", + "maxLength": 100 + }, + { + "type": "null" + } + ], + "title": "State" + } + }, + "type": "object", + "required": [ + "code", + "name" + ], + "title": "HeadquartersCreate" + }, + "HeadquartersRead": { + "properties": { + "id": { + "type": "string", + "format": "uuid", + "title": "Id" + }, + "company_id": { + "type": "string", + "format": "uuid", + "title": "Company Id" + }, + "code": { + "type": "string", + "title": "Code" + }, + "name": { + "type": "string", + "title": "Name" + }, + "district": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "District" + }, + "state": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "State" + }, + "is_active": { + "type": "boolean", + "title": "Is Active" + } + }, + "type": "object", + "required": [ + "id", + "company_id", + "code", + "name", + "district", + "state", + "is_active" + ], + "title": "HeadquartersRead" + }, + "LoginRequest": { + "properties": { + "email": { + "type": "string", + "format": "email", + "title": "Email" + }, + "password": { + "type": "string", + "minLength": 1, + "title": "Password" + } + }, + "type": "object", + "required": [ + "email", + "password" + ], + "title": "LoginRequest" + }, + "MyProfile": { + "properties": { + "id": { + "type": "string", + "format": "uuid", + "title": "Id" + }, + "full_name": { + "type": "string", + "title": "Full Name" + }, + "employee_code": { + "type": "string", + "title": "Employee Code" + }, + "email": { + "type": "string", + "title": "Email" + }, + "role": { + "$ref": "#/components/schemas/Role" + }, + "phone": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Phone" + }, + "headquarters_id": { + "anyOf": [ + { + "type": "string", + "format": "uuid" + }, + { + "type": "null" + } + ], + "title": "Headquarters Id" + }, + "headquarters_code": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Headquarters Code" + }, + "headquarters_name": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Headquarters Name" + }, + "reporting_manager_id": { + "anyOf": [ + { + "type": "string", + "format": "uuid" + }, + { + "type": "null" + } + ], + "title": "Reporting Manager Id" + }, + "reporting_manager_name": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Reporting Manager Name" + } + }, + "type": "object", + "required": [ + "id", + "full_name", + "employee_code", + "email", + "role", + "phone", + "headquarters_id", + "headquarters_code", + "headquarters_name", + "reporting_manager_id", + "reporting_manager_name" + ], + "title": "MyProfile", + "description": "S4 \u2014 the MR profile screen. Includes the DERIVED reporting Area Manager." + }, + "RefreshRequest": { + "properties": { + "refresh_token": { + "type": "string", + "title": "Refresh Token" + } + }, + "type": "object", + "required": [ + "refresh_token" + ], + "title": "RefreshRequest" + }, + "ReturnRequest": { + "properties": { + "reason": { + "type": "string", + "maxLength": 2000, + "minLength": 10, + "title": "Reason" + } + }, + "type": "object", + "required": [ + "reason" + ], + "title": "ReturnRequest", + "description": "V8 \u2014 a manager must say WHY. This reason is what makes the audit trail useful." + }, + "Role": { + "type": "string", + "enum": [ + "ADMIN", + "GM", + "AM", + "MR" + ], + "title": "Role", + "description": "Operational roles (MR/AM/GM) plus the technical ADMIN role.\n\nADMIN sits OUTSIDE the business hierarchy. It provisions users and masters but\ncan never approve a report or read report content (report \u00a78, SEC-2)." + }, + "StatusCounts": { + "properties": { + "DRAFT": { + "type": "integer", + "title": "Draft", + "default": 0 + }, + "PENDING_AM": { + "type": "integer", + "title": "Pending Am", + "default": 0 + }, + "PENDING_GM": { + "type": "integer", + "title": "Pending Gm", + "default": 0 + }, + "RETURNED": { + "type": "integer", + "title": "Returned", + "default": 0 + }, + "APPROVED": { + "type": "integer", + "title": "Approved", + "default": 0 + } + }, + "type": "object", + "title": "StatusCounts", + "description": "Header counts on the list screens \u2014 the cheap replacement for dashboards." + }, + "TokenPair": { + "properties": { + "access_token": { + "type": "string", + "title": "Access Token" + }, + "refresh_token": { + "type": "string", + "title": "Refresh Token" + }, + "token_type": { + "type": "string", + "title": "Token Type", + "default": "bearer" + }, + "expires_in": { + "type": "integer", + "title": "Expires In" + } + }, + "type": "object", + "required": [ + "access_token", + "refresh_token", + "expires_in" + ], + "title": "TokenPair" + }, + "UserCreate": { + "properties": { + "email": { + "type": "string", + "format": "email", + "title": "Email" + }, + "password": { + "type": "string", + "maxLength": 128, + "minLength": 8, + "title": "Password" + }, + "full_name": { + "type": "string", + "maxLength": 200, + "minLength": 2, + "title": "Full Name" + }, + "employee_code": { + "type": "string", + "maxLength": 50, + "minLength": 1, + "title": "Employee Code" + }, + "role": { + "$ref": "#/components/schemas/Role" + }, + "phone": { + "anyOf": [ + { + "type": "string", + "maxLength": 20 + }, + { + "type": "null" + } + ], + "title": "Phone" + }, + "headquarters_id": { + "anyOf": [ + { + "type": "string", + "format": "uuid" + }, + { + "type": "null" + } + ], + "title": "Headquarters Id" + } + }, + "type": "object", + "required": [ + "email", + "password", + "full_name", + "employee_code", + "role" + ], + "title": "UserCreate" + }, + "UserRead": { + "properties": { + "id": { + "type": "string", + "format": "uuid", + "title": "Id" + }, + "email": { + "type": "string", + "title": "Email" + }, + "full_name": { + "type": "string", + "title": "Full Name" + }, + "employee_code": { + "type": "string", + "title": "Employee Code" + }, + "role": { + "$ref": "#/components/schemas/Role" + }, + "phone": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Phone" + }, + "headquarters_id": { + "anyOf": [ + { + "type": "string", + "format": "uuid" + }, + { + "type": "null" + } + ], + "title": "Headquarters Id" + }, + "is_active": { + "type": "boolean", + "title": "Is Active" + } + }, + "type": "object", + "required": [ + "id", + "email", + "full_name", + "employee_code", + "role", + "phone", + "headquarters_id", + "is_active" + ], + "title": "UserRead" + }, + "UserUpdate": { + "properties": { + "full_name": { + "anyOf": [ + { + "type": "string", + "maxLength": 200, + "minLength": 2 + }, + { + "type": "null" + } + ], + "title": "Full Name" + }, + "phone": { + "anyOf": [ + { + "type": "string", + "maxLength": 20 + }, + { + "type": "null" + } + ], + "title": "Phone" + }, + "headquarters_id": { + "anyOf": [ + { + "type": "string", + "format": "uuid" + }, + { + "type": "null" + } + ], + "title": "Headquarters Id" + }, + "is_active": { + "anyOf": [ + { + "type": "boolean" + }, + { + "type": "null" + } + ], + "title": "Is Active" + } + }, + "type": "object", + "title": "UserUpdate" + }, + "ValidationError": { + "properties": { + "loc": { + "items": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "integer" + } + ] + }, + "type": "array", + "title": "Location" + }, + "msg": { + "type": "string", + "title": "Message" + }, + "type": { + "type": "string", + "title": "Error Type" + }, + "input": { + "title": "Input" + }, + "ctx": { + "type": "object", + "title": "Context" + } + }, + "type": "object", + "required": [ + "loc", + "msg", + "type" + ], + "title": "ValidationError" + } + }, + "securitySchemes": { + "HTTPBearer": { + "type": "http", + "scheme": "bearer" + } + } + } +} \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..61c2768 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,56 @@ +[project] +name = "pharma-field-force" +version = "0.1.0" +description = "Pharmaceutical field-force reporting system — MVP (one MR, DCR, AM review, GM approval, PDF, audit)" +requires-python = ">=3.11" + +dependencies = [ + "fastapi>=0.115.0", + "tzdata>=2024.1", + "uvicorn[standard]>=0.32.0", + "sqlalchemy[asyncio]>=2.0.36", + "asyncpg>=0.30.0", + "psycopg[binary]>=3.2.3", + "alembic>=1.14.0", + "pydantic[email]>=2.9.0", + "pydantic-settings>=2.6.0", + "python-jose[cryptography]>=3.3.0", + "argon2-cffi>=23.1.0", + "python-multipart>=0.0.12", + "jinja2>=3.1.4", + "weasyprint>=63.0", +] + +# The repository contains a React application (`web/`) and Alembic migration +# files alongside the Python application. Explicit discovery prevents +# setuptools from treating those folders as Python distribution packages. +[build-system] +requires = ["setuptools>=68"] +build-backend = "setuptools.build_meta" + +[tool.setuptools.packages.find] +include = ["app*"] +exclude = ["alembic*", "scripts*", "tests*", "web*"] + +[project.optional-dependencies] +dev = [ + "pytest>=8.3.0", + "pytest-asyncio>=0.24.0", + "httpx>=0.27.0", + "ruff>=0.7.0", +] + +[tool.pytest.ini_options] +asyncio_mode = "auto" +asyncio_default_fixture_loop_scope = "session" +asyncio_default_test_loop_scope = "session" +testpaths = ["tests"] +filterwarnings = ["ignore::DeprecationWarning"] + +[tool.ruff] +line-length = 100 +target-version = "py311" + +[tool.ruff.lint] +select = ["E", "F", "I", "UP", "B"] +ignore = ["B008"] # FastAPI Depends() in defaults is idiomatic diff --git a/sales_projection.csv b/sales_projection.csv new file mode 100644 index 0000000..200170d --- /dev/null +++ b/sales_projection.csv @@ -0,0 +1,27 @@ +Sl. No.,Name of the Product,PTS,Sec. Qty,Value,Closing,Sec. Value,Aug. Sales,Value +1,INTEZOLE-PD,106.92,,,,,, +2,INTEZOLE-RD,93.59,,,,,, +3,INTEZOLE-EL,202.37,,,,,, +4,INTEZOLE-ED,125.11,,,,,, +5,INTEZOLE-P40,83.35,,,,,, +6,FENMONAC-P,54.61,,,,,, +7,FENMONAC-SP,95.99,,,,,, +8,FENMONAC-MR,85.37,,,,,, +9,PENORENZ-MR 4,204.17,,,,,, +10,CELVADOX-CV,268.8,,,,,, +11,AMOCLADOX-CV 625,134.06,,,,,, +12,INFEZOX-O,164.11,,,,,, +13,FEBRIVANCE-PLUS,157.03,,,,,, +14,HIFERGLOBIN-XT,126.86,,,,,, +15,VIVACELLIX-360,445.03,,,,,, +16,HEALTHOVANCE-SUPER,198.17,,,,,, +17,HEALTHOVANCE-Q10,397.03,,,,,, +18,MEGAVANCE-FORTE,253.03,,,,,, +19,BONETRA-MAX+,246.86,,,,,, +20,BONETRA STRONG,198.86,,,,,, +21,WEAKOVER,183.77,,,,,, +22,BELLYFULLY,136.0,,,,,, +23,TUMMYSURE,131.25,,,,,, +24,VISCOSYNTH,222.86,,,,,, +25,HIFERGLOBIN-RED+,202.28,,,,,, +26,LYPOPINK-ADV,266.74,,,,,, diff --git a/scripts/__init__.py b/scripts/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/scripts/docker-entrypoint.sh b/scripts/docker-entrypoint.sh new file mode 100755 index 0000000..6f1a226 --- /dev/null +++ b/scripts/docker-entrypoint.sh @@ -0,0 +1,20 @@ +#!/bin/sh +# Container entrypoint: bring the schema up to date, then hand over to the server. +# Migrations are idempotent, so restarting the container is always safe. Data import +# scripts (which replace table contents) are never run from here. +set -eu + +if [ "${RUN_MIGRATIONS:-1}" = "1" ]; then + attempt=1 + until alembic upgrade head; do + if [ "$attempt" -ge 15 ]; then + echo "entrypoint: database migration failed after $attempt attempts" >&2 + exit 1 + fi + echo "entrypoint: database not ready (attempt $attempt), retrying in 3s" >&2 + attempt=$((attempt + 1)) + sleep 3 + done +fi + +exec "$@" diff --git a/scripts/harden_audit.sql b/scripts/harden_audit.sql new file mode 100644 index 0000000..6c46d08 --- /dev/null +++ b/scripts/harden_audit.sql @@ -0,0 +1,46 @@ +-- SEC-3: make the audit log genuinely append-only. +-- +-- The application must be able to INSERT into audit_log and SELECT from it, and +-- nothing else. Enforcing this at the database role level means that even an +-- application bug — or an attacker with the application's credentials — cannot +-- rewrite history. +-- +-- Run this ONCE after the first migration, as a superuser: +-- psql -U postgres -d pharma -f scripts/harden_audit.sql +-- +-- Assumes the application connects as the role `pharma_app`. Create that role +-- separately from the migration role: migrations need DDL rights, the running +-- application does not. + +-- 1. The application role (create it if it does not exist). +DO $$ +BEGIN + IF NOT EXISTS (SELECT 1 FROM pg_roles WHERE rolname = 'pharma_app') THEN + CREATE ROLE pharma_app LOGIN PASSWORD 'change-me-before-production'; + END IF; +END +$$; + +-- 2. Normal rights on every other table. +GRANT USAGE ON SCHEMA public TO pharma_app; +GRANT SELECT, INSERT, UPDATE, DELETE ON ALL TABLES IN SCHEMA public TO pharma_app; +GRANT USAGE, SELECT ON ALL SEQUENCES IN SCHEMA public TO pharma_app; + +-- 3. audit_log is the exception: insert and read only. +REVOKE UPDATE, DELETE, TRUNCATE ON audit_log FROM pharma_app; + +-- 4. Same policy for tables created by future migrations. +ALTER DEFAULT PRIVILEGES IN SCHEMA public + GRANT SELECT, INSERT, UPDATE, DELETE ON TABLES TO pharma_app; + +-- 5. Belt and braces: a trigger, so the rule survives a mis-granted privilege. +CREATE OR REPLACE FUNCTION audit_log_is_append_only() RETURNS trigger AS $$ +BEGIN + RAISE EXCEPTION 'audit_log is append-only: % is not permitted', TG_OP; +END; +$$ LANGUAGE plpgsql; + +DROP TRIGGER IF EXISTS trg_audit_log_append_only ON audit_log; +CREATE TRIGGER trg_audit_log_append_only + BEFORE UPDATE OR DELETE ON audit_log + FOR EACH ROW EXECUTE FUNCTION audit_log_is_append_only(); diff --git a/scripts/import_csv_data.py b/scripts/import_csv_data.py new file mode 100644 index 0000000..812c286 --- /dev/null +++ b/scripts/import_csv_data.py @@ -0,0 +1,116 @@ +"""Import eligible root-level CSV files into their form tables. + +Usage: python -m scripts.import_csv_data [--only-empty] + +Without a flag every form table is REPLACED by its CSV. ``--only-empty`` is the safe +mode for a database that already holds work: a table that has any rows is left +untouched, and only empty tables are loaded (e.g. the product lists). +""" + +import argparse +import asyncio +import csv +import uuid +from pathlib import Path + +from sqlalchemy import text + +from app.database.session import AsyncSessionLocal + +ROOT = Path(__file__).resolve().parent.parent +EXCLUDED_FILES = {"stock.csv"} +CSV_TABLES = { + "Weekly_Report.csv": ("weekly_report", ["employee_name", "report_date", "headquarter", "month", "no_of_days_worked", "no_of_doctor_called", "no_of_chemist_called", "pob_booked", "secondary_sales", "pob_objective", "secondary_objective", "product_offer_scheme_booked", "product_offer_scheme_objective"]), + "FIELD_ACTIVITY_REPORT.csv": ("field_activity_report", ["name", "headquarter", "month", "report_date", "station_worked", "no_of_doctors_called", "no_of_chemists_pds_called", "doctor_call_avg", "chemist_call_avg"]), + "Fare_Chart.csv": ("fare_chart", ["name", "headquarter", "serial_no", "report_date", "from_location", "to_location", "kilometers_km"]), + "Daily_Call_Report.csv": ("daily_call_report_csv", ["name", "headquarter", "report_date", "month", "doctor_sr_no", "doctor_name", "qualification", "product_promote", "product_sample", "remarks", "chemist_sr_no", "chemist_name", "pob", "stockist_visit", "order_value"]), + "CORE_Dr._CALL_CONVERSION.csv": ("core_dr_call_conversion", ["name", "headquarter", "month", "doctor_name", "date_of_visit", "product_targeted", "status"]), + "AREA_COVERED.csv": ("area_covered", ["name", "headquarter", "month", "sale_status", "area_to_cover", "sale_objective", "status"]), + "Sales_and_Stock_Statement.csv": ("sales_and_stock_statement", ["name", "headquarter", "report_date", "month", "serial_no", "product_name", "opening", "receipt", "sale", "closing", "value_in_pts"]), + "TOUR_PLAN.csv": ("tour_plan", ["name", "headquarter", "serial_no", "report_date", "from_location", "to_location", "pob", "stockiest_visit"]), + "STANDARD_TOUR_PLAN.csv": ("standard_tour_plan", ["name", "headquarter", "serial_no", "place"]), + "sales_projection.csv": ("sales_projection", ["name", "headquarter", "report_date", "month", "serial_no", "product_name", "pts", "secondary_qty", "value", "closing", "secondary_value", "aug_sales", "value_2"]), +} +SERIAL_COLUMNS = {"serial_no", "doctor_sr_no", "chemist_sr_no"} + + +def read_rows(path: Path, columns: list[str]) -> list[tuple[int, dict[str, str]]]: + with path.open(newline="", encoding="utf-8-sig") as file: + reader = csv.reader(file) + next(reader, None) + rows: list[tuple[int, dict[str, str]]] = [] + for row in reader: + data = { + column: (row[index] if index < len(row) else "").strip() + for index, column in enumerate(columns) + } + if any(value for column, value in data.items() if column not in SERIAL_COLUMNS): + rows.append((len(rows) + 1, data)) + return rows + + +async def apply_sales_projection_account(db) -> None: + await db.execute( + text( + '''UPDATE "sales_projection" AS projection + SET name = account.full_name, + headquarter = headquarters.name + FROM "user" AS account + LEFT JOIN headquarters ON headquarters.id = account.headquarters_id + WHERE account.role = 'MR' ''' + ) + ) + + +async def import_csv_data(only_empty: bool = False) -> None: + csv_files = sorted(path for path in ROOT.glob("*.csv") if path.name not in EXCLUDED_FILES) + async with AsyncSessionLocal() as db: + imported_rows = 0 + for path in csv_files: + table_name, columns = CSV_TABLES[path.name] + if only_empty: + count = await db.execute(text(f'SELECT COUNT(*) FROM "{table_name}"')) + existing = count.scalar_one() + if existing: + print(f"{table_name}: skipped, already has {existing} rows") + continue + else: + await db.execute(text(f'DELETE FROM "{table_name}"')) + source_columns = columns[4:] if table_name == "sales_projection" else columns + rows = read_rows(path, source_columns) + if table_name == "sales_projection": + rows = [ + (row_number, {"name": "", "headquarter": "", "report_date": "", "month": "", **data}) + for row_number, data in rows + ] + if rows: + column_names = ", ".join(f'"{column}"' for column in columns) + parameters = ", ".join(f":{column}" for column in columns) + statement = text( + f'INSERT INTO "{table_name}" ' + f'(id, source_row_number, {column_names}) ' + f'VALUES (:id, :source_row_number, {parameters})' + ) + await db.execute( + statement, + [ + {"id": uuid.uuid4(), "source_row_number": row_number, **data} + for row_number, data in rows + ], + ) + imported_rows += len(rows) + print(f"{table_name}: {len(rows)} rows") + if table_name == "sales_projection": + await apply_sales_projection_account(db) + await db.commit() + print(f"Imported {imported_rows} rows from {len(csv_files)} CSV files.") + + +if __name__ == "__main__": + parser = argparse.ArgumentParser(description=__doc__.splitlines()[0]) + parser.add_argument( + "--only-empty", + action="store_true", + help="load only tables that have no rows; never delete existing data", + ) + asyncio.run(import_csv_data(parser.parse_args().only_empty)) \ No newline at end of file diff --git a/scripts/init_test_db.sql b/scripts/init_test_db.sql new file mode 100644 index 0000000..c8fdc83 --- /dev/null +++ b/scripts/init_test_db.sql @@ -0,0 +1,3 @@ +-- Creates the scratch database the test suite uses. +-- Runs automatically on first `docker compose up` via docker-entrypoint-initdb.d. +CREATE DATABASE pharma_test OWNER pharma; diff --git a/scripts/seed.py b/scripts/seed.py new file mode 100644 index 0000000..4fba7e9 --- /dev/null +++ b/scripts/seed.py @@ -0,0 +1,127 @@ +"""Seed the minimum MVP system described in report §10.2. + +Creates: 1 company, 1 headquarters, 1 GM, 1 AM, 1 MR, 1 System Admin, +15 doctors (3 flagged as core) and 5 chemists, all assigned to the MR. + + python -m scripts.seed + +Idempotent: running it twice does not duplicate anything. +""" + +import asyncio +import sys +import uuid +from datetime import date + +from sqlalchemy import select + +from app.auth.security import hash_password +from app.chemists.models import Chemist, ChemistAssignment +from app.common.enums import Role +from app.database.session import AsyncSessionLocal +from app.doctors.models import Doctor, DoctorAssignment +from app.organization.models import AMHeadquarters, Company, Headquarters +from app.users.models import User + +DEMO_PASSWORD = "ChangeMe123!" + +SPECIALITIES = [ + "General Medicine", "Paediatrics", "Orthopaedics", "Cardiology", "Dermatology", +] + +SURNAMES = [ + "Sen", "Patra", "Rout", "Mishra", "Jena", "Sahoo", "Panda", "Das", + "Nayak", "Pradhan", "Behera", "Swain", "Barik", "Mohapatra", "Tripathy", +] + + +async def seed() -> None: + async with AsyncSessionLocal() as db: + existing = ( + await db.execute(select(Company).where(Company.name == "Acme Pharma Pvt Ltd")) + ).scalar_one_or_none() + if existing: + print("Seed data already present — nothing to do.") + return + + company = Company(id=uuid.uuid4(), name="Acme Pharma Pvt Ltd", address="Bhubaneswar") + db.add(company) + await db.flush() + + hq = Headquarters( + id=uuid.uuid4(), company_id=company.id, code="BBSR", + name="Bhubaneswar", district="Khordha", state="Odisha", + ) + db.add(hq) + await db.flush() + + def make(role: Role, name: str, code: str, hq_id=None) -> User: + return User( + id=uuid.uuid4(), company_id=company.id, + email=f"{code.lower()}@acmepharma.in", + password_hash=hash_password(DEMO_PASSWORD), + full_name=name, employee_code=code, role=role, headquarters_id=hq_id, + ) + + admin = make(Role.ADMIN, "System Administrator", "ADM001") + gm = make(Role.GM, "Anita Mohanty", "GM001") + am = make(Role.AM, "Suresh Behera", "AM001") + mr = make(Role.MR, "Ravi Das", "MR001", hq.id) + db.add_all([admin, gm, am, mr]) + await db.flush() + + db.add( + AMHeadquarters( + area_manager_user_id=am.id, headquarters_id=hq.id, effective_from=date.today() + ) + ) + + for i in range(15): + doctor = Doctor( + id=uuid.uuid4(), headquarters_id=hq.id, + name=f"Dr {SURNAMES[i]}", + speciality=SPECIALITIES[i % len(SPECIALITIES)], + qualification="MBBS, MD" if i % 3 == 0 else "MBBS", + clinic_address=f"Clinic {i + 1}, Unit {i % 9 + 1}, Bhubaneswar", + is_core_doctor=i < 3, + ) + db.add(doctor) + await db.flush() + db.add( + DoctorAssignment( + doctor_id=doctor.id, mr_user_id=mr.id, effective_from=date.today() + ) + ) + + for i in range(5): + chemist = Chemist( + id=uuid.uuid4(), headquarters_id=hq.id, + name=f"{['Konark','Utkal','Kalinga','Sriya','Jagannath'][i]} Medical Stores", + shop_address=f"Shop {i + 1}, Market Building, Bhubaneswar", + contact_number=f"9{i}0000000{i}", + ) + db.add(chemist) + await db.flush() + db.add( + ChemistAssignment( + chemist_id=chemist.id, mr_user_id=mr.id, effective_from=date.today() + ) + ) + + await db.commit() + + print("Seeded the minimum MVP system.\n") + print(f" Password for every account: {DEMO_PASSWORD}\n") + print(" System Admin adm001@acmepharma.in") + print(" General Mgr gm001@acmepharma.in") + print(" Area Manager am001@acmepharma.in") + print(" MR mr001@acmepharma.in") + print("\n 1 headquarters (BBSR), 15 doctors (3 core), 5 chemists — all assigned to MR001.") + print("\n CHANGE THESE PASSWORDS before any real use.") + + +if __name__ == "__main__": + try: + asyncio.run(seed()) + except KeyboardInterrupt: + sys.exit(1) diff --git a/scripts/setup.sh b/scripts/setup.sh new file mode 100755 index 0000000..75c321c --- /dev/null +++ b/scripts/setup.sh @@ -0,0 +1,72 @@ +#!/usr/bin/env bash +# Prepare .env for a Docker deployment on this machine. Safe to re-run. +# +# ./scripts/setup.sh # production values +# DOMAIN=app.example.com ./scripts/setup.sh +# +# What it does: +# * creates .env from .env.example if it does not exist +# * generates SECRET_KEY when it is missing or a placeholder +# * sets ENVIRONMENT=production and DEBUG=false +# * generates POSTGRES_PASSWORD only for a brand-new database (an existing database +# volume keeps the password it was created with, so it is never changed here) +# * picks free host ports: if 80/443 are taken by another service (a host nginx, another +# Caddy, ...), it serves plain HTTP on the first free ports from 2000/2443 instead +set -euo pipefail +cd "$(dirname "$0")/.." + +ENV_FILE=.env +PROJECT=${COMPOSE_PROJECT_NAME:-$(basename "$PWD" | tr '[:upper:]' '[:lower:]' | tr -cd 'a-z0-9_-')} + +[ -f "$ENV_FILE" ] || { cp .env.example "$ENV_FILE"; echo "created $ENV_FILE from .env.example"; } + +get() { grep -E "^$1=" "$ENV_FILE" | tail -1 | cut -d= -f2- || true; } +set_kv() { + if grep -qE "^$1=" "$ENV_FILE"; then sed -i -E "s|^$1=.*|$1=$2|" "$ENV_FILE" + else printf '%s=%s\n' "$1" "$2" >> "$ENV_FILE"; fi +} +random() { python3 -c "import secrets;print(secrets.token_urlsafe($1))" 2>/dev/null \ + || openssl rand -base64 "$1" | tr -d '\n=+/'; } + +# Ports this project's own containers already publish are not "busy" for us. +own_ports=$(docker ps --filter "label=com.docker.compose.project=$PROJECT" \ + --format '{{.Ports}}' 2>/dev/null | grep -oE ':[0-9]+->' | tr -d ':>-' || true) +busy() { + echo "$own_ports" | grep -qx "$1" && return 1 + (exec 3<>"/dev/tcp/127.0.0.1/$1") 2>/dev/null +} +free_from() { local p=$1; while busy "$p"; do p=$((p + 1)); done; echo "$p"; } + +# --- secrets --------------------------------------------------------------- +key=$(get SECRET_KEY) +case "$key" in ""|replace-with*|change-me*) key="" ;; esac +if [ "${#key}" -lt 32 ]; then set_kv SECRET_KEY "$(random 64)"; echo "generated SECRET_KEY"; fi + +set_kv ENVIRONMENT production +set_kv DEBUG false + +if docker volume inspect "${PROJECT}_pgdata" >/dev/null 2>&1; then + echo "database volume exists: keeping POSTGRES_PASSWORD" + case "$(get POSTGRES_PASSWORD)" in pharma|replace-with*|"") + echo "WARNING: the database still uses a weak/default password; rotate it (see README)." ;; + esac +else + case "$(get POSTGRES_PASSWORD)" in pharma|replace-with*|"") + set_kv POSTGRES_PASSWORD "$(random 24)"; echo "generated POSTGRES_PASSWORD" ;; + esac +fi + +# --- ports ----------------------------------------------------------------- +[ -n "${DOMAIN:-}" ] && set_kv DOMAIN "$DOMAIN" +domain=$(get DOMAIN); domain=${domain:-localhost} +if [ "$domain" != ":80" ] && ! busy 80 && ! busy 443; then + set_kv HTTP_PORT 80; set_kv HTTPS_PORT 443 + echo "ports 80/443 are free: Caddy serves $domain directly" +else + http=$(free_from "$(get HTTP_PORT | grep -vx 80 || echo 2000)") + https=$(free_from "$(get HTTPS_PORT | grep -vx 443 || echo 2443)") + set_kv DOMAIN ":80"; set_kv HTTP_PORT "$http"; set_kv HTTPS_PORT "$https" + echo "ports 80/443 are in use: Caddy serves plain HTTP on host port $http" + echo " -> point your existing reverse proxy at http://127.0.0.1:$http" +fi +echo "done. Next: docker compose up -d --build" diff --git a/stock.csv b/stock.csv new file mode 100644 index 0000000..97162d3 --- /dev/null +++ b/stock.csv @@ -0,0 +1,27 @@ +Sl. No.,Product,Pack,Qty,Unit +1,INTEZOLE-PD,10X10 CAP,10+2, +2,INTEZOLE-RD,10X10 CAP,10+2, +3,INTEZOLE-EL,10X10 CAP,10+2, +4,INTEZOLE-ED,10X10 CAP,10+2, +5,INTEZOLE-P40,10X10 TAB,10+1, +6,FENMONAC-P,10X10 TAB,10+1, +7,FENMONAC-SP,10X10 TAB,10+1, +8,FENMONAC-MR,10X10 TAB,10+1, +9,PENORENZ-MR 4,10X10 TAB,10+1, +10,CELVADOX-CV,10X1X10 TAB,NA, +11,AMOCLADOV-CV 625,10X1X10 TAB,10+1, +12,INFEZOX-O,10X10 TAB,9+1, +13,FEBRIVANCE-PLUS,10X10 TAB,10+2, +14,HIFERGLOBIN-XT,10X10 TAB,9+1, +15,VIVACELLIX-360,10X10 TAB,NA, +16,HEALTHOVANCE-SUPER,10X10 TAB,9+1, +17,HEALTHOVANCE-Q10,10X10 TAB,NA, +18,MEGAVANCE-FORTE,10X1X10CAP,10+2, +19,BONETRA-STRONG,10X1X10CAP,9+1, +20,BONETRA-MAX+,10X1X10CAP,9+1, +21,WEAKOVER,200ML SYRUP,11+1, +22,BELLYFULLY,200ML SYRUP,11+1, +23,TUMMY SURE,200ML SYRUP,14+1, +24,VISCOSYNTH,200ML SYRUP,11+1, +25,HIFERGLOBIN-RED+,200ML SYRUP,14+1, +26,LYPOPINK-ADV,200ML SYRUP,NA, diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/conftest.py b/tests/conftest.py new file mode 100644 index 0000000..af33f39 --- /dev/null +++ b/tests/conftest.py @@ -0,0 +1,187 @@ +"""Test fixtures. + +Tests run against a REAL PostgreSQL database, never SQLite. This system depends on +constraints that SQLite does not implement the same way — partial unique indexes, +composite uniques, jsonb — so testing on SQLite would mean testing a different system +from the one that ships. + +Set TEST_DATABASE_URL to point at a scratch database. Docker Compose provides one: + postgresql+asyncpg://pharma:pharma@localhost:5432/pharma_test +""" + +import os +import uuid +from collections.abc import AsyncGenerator +from datetime import date + +import pytest +from httpx import ASGITransport, AsyncClient +from sqlalchemy import text +from sqlalchemy.ext.asyncio import AsyncSession, async_sessionmaker, create_async_engine + +os.environ.setdefault("SECRET_KEY", "test-secret-not-for-production") +os.environ.setdefault("ENVIRONMENT", "test") + +TEST_DATABASE_URL = os.environ.get( + "TEST_DATABASE_URL", "postgresql+asyncpg://pharma:pharma@127.0.0.1:5432/pharma_test" +) + +from app.auth.security import hash_password # noqa: E402 +from app.common.enums import Role # noqa: E402 +from app.database.all_models import Base # noqa: E402 +from app.database.session import get_db # noqa: E402 +from app.main import app as fastapi_app # noqa: E402 +from app.organization.models import AMHeadquarters, Company, Headquarters # noqa: E402 +from app.users.models import User # noqa: E402 + +TABLES = [ + "audit_log", + "product", + "doctor_call", + "chemist_call", + "daily_call_report", + "doctor_assignment", + "chemist_assignment", + "doctor", + "chemist", + "am_headquarters", + "form_approval", + "refresh_token", + '"user"', + "headquarters", + "company", +] + + +@pytest.fixture(scope="session") +def anyio_backend() -> str: + return "asyncio" + + +@pytest.fixture(scope="session") +async def engine(): + eng = create_async_engine(TEST_DATABASE_URL, poolclass=None) + async with eng.begin() as conn: + await conn.run_sync(Base.metadata.create_all) + yield eng + await eng.dispose() + + +@pytest.fixture +async def session_factory(engine): + factory = async_sessionmaker(bind=engine, class_=AsyncSession, expire_on_commit=False) + async with engine.begin() as conn: + await conn.execute(text(f"TRUNCATE {', '.join(TABLES)} RESTART IDENTITY CASCADE")) + return factory + + +@pytest.fixture +async def db(session_factory) -> AsyncGenerator[AsyncSession, None]: + async with session_factory() as s: + yield s + + +@pytest.fixture +async def client(session_factory, tmp_path) -> AsyncGenerator[AsyncClient, None]: + from app.config.settings import settings + + settings.PDF_STORAGE_PATH = str(tmp_path / "pdf") + + async def _override_get_db() -> AsyncGenerator[AsyncSession, None]: + async with session_factory() as s: + try: + yield s + except Exception: + await s.rollback() + raise + + fastapi_app.dependency_overrides[get_db] = _override_get_db + transport = ASGITransport(app=fastapi_app) + async with AsyncClient(transport=transport, base_url="http://test") as ac: + yield ac + fastapi_app.dependency_overrides.clear() + + +# --------------------------------------------------------------------------- +# Organisation fixture: the minimum MVP system — 1 company, 2 HQs, GM, 2 AMs, 2 MRs. +# The second HQ/AM/MR exist purely so the negative-scope tests (X1, X2) have someone +# to be denied. +# --------------------------------------------------------------------------- + +DEFAULT_PASSWORD = "Str0ngPassw0rd!" + + +@pytest.fixture +async def org(db: AsyncSession) -> dict: + company = Company(id=uuid.uuid4(), name="Acme Pharma Pvt Ltd") + db.add(company) + await db.flush() + + hq1 = Headquarters( + id=uuid.uuid4(), company_id=company.id, code="BBSR", name="Bhubaneswar", + district="Khordha", state="Odisha", + ) + hq2 = Headquarters( + id=uuid.uuid4(), company_id=company.id, code="SBP", name="Sambalpur", + district="Sambalpur", state="Odisha", + ) + db.add_all([hq1, hq2]) + await db.flush() + + def make(role: Role, name: str, code: str, hq_id=None) -> User: + return User( + id=uuid.uuid4(), + company_id=company.id, + email=f"{code.lower()}@acmepharma.in", + password_hash=hash_password(DEFAULT_PASSWORD), + full_name=name, + employee_code=code, + role=role, + headquarters_id=hq_id, + ) + + admin = make(Role.ADMIN, "System Admin", "ADM001") + gm = make(Role.GM, "Anita Mohanty", "GM001") + am1 = make(Role.AM, "Suresh Behera", "AM001") + am2 = make(Role.AM, "Rakesh Sahu", "AM002") + mr1 = make(Role.MR, "Ravi Das", "MR001", hq1.id) + mr2 = make(Role.MR, "Priya Nayak", "MR002", hq2.id) + db.add_all([admin, gm, am1, am2, mr1, mr2]) + await db.flush() + + db.add_all( + [ + AMHeadquarters( + area_manager_user_id=am1.id, headquarters_id=hq1.id, + effective_from=date.today(), + ), + AMHeadquarters( + area_manager_user_id=am2.id, headquarters_id=hq2.id, + effective_from=date.today(), + ), + ] + ) + await db.commit() + + return { + "company": company, "hq1": hq1, "hq2": hq2, + "admin": admin, "gm": gm, "am1": am1, "am2": am2, "mr1": mr1, "mr2": mr2, + } + + +async def login(client: AsyncClient, user: User) -> dict[str, str]: + resp = await client.post( + "/api/v1/auth/login", + json={"email": user.email, "password": DEFAULT_PASSWORD}, + ) + assert resp.status_code == 200, resp.text + return {"Authorization": f"Bearer {resp.json()['access_token']}"} + + +@pytest.fixture +async def auth(client: AsyncClient, org: dict) -> dict[str, dict[str, str]]: + """Ready-made Authorization headers for every role.""" + return { + key: await login(client, org[key]) + for key in ("admin", "gm", "am1", "am2", "mr1", "mr2") + } diff --git a/tests/e2e/__init__.py b/tests/e2e/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/e2e/test_area_manager_headquarters.py b/tests/e2e/test_area_manager_headquarters.py new file mode 100644 index 0000000..40cbee2 --- /dev/null +++ b/tests/e2e/test_area_manager_headquarters.py @@ -0,0 +1,100 @@ +"""An Area Manager can manage any number of headquarters; only an Admin can change that.""" + +import uuid + +from sqlalchemy import select + +from app.organization.models import Headquarters + +API = "/api/v1/headquarters" + + +async def _third_hq(db, org) -> Headquarters: + hq = Headquarters( + id=uuid.uuid4(), company_id=org["company"].id, code="CTC", name="Cuttack", + district="Cuttack", state="Odisha", + ) + db.add(hq) + await db.commit() + return hq + + +def _hq_ids(resp) -> set[str]: + return {row["headquarters_id"] for row in resp.json()} + + +class TestAreaManagerHeadquarters: + async def test_one_am_can_hold_several_headquarters(self, client, auth, org, db): + hq3 = await _third_hq(db, org) + wanted = [str(org["hq1"].id), str(org["hq2"].id), str(hq3.id)] + resp = await client.put( + f"{API}/area-managers/{org['am1'].id}", headers=auth["admin"], + json={"headquarters_ids": wanted}, + ) + assert resp.status_code == 200, resp.text + assert _hq_ids(resp) == set(wanted) + + listing = await client.get(f"{API}/area-managers", headers=auth["admin"]) + mine = {r["headquarters_id"] for r in listing.json() if r["area_manager_user_id"] == str(org["am1"].id)} + assert mine == set(wanted) + + async def test_taking_a_headquarters_moves_it_from_the_other_am(self, client, auth, org): + # am2 currently manages hq2; give hq2 to am1 as well. + await client.put( + f"{API}/area-managers/{org['am1'].id}", headers=auth["admin"], + json={"headquarters_ids": [str(org["hq1"].id), str(org["hq2"].id)]}, + ) + listing = (await client.get(f"{API}/area-managers", headers=auth["admin"])).json() + owners = {r["headquarters_id"]: r["area_manager_user_id"] for r in listing} + assert owners[str(org["hq2"].id)] == str(org["am1"].id) # one AM per HQ still holds + assert len(listing) == len(owners) + + async def test_omitted_headquarters_are_released(self, client, auth, org): + resp = await client.put( + f"{API}/area-managers/{org['am1'].id}", headers=auth["admin"], + json={"headquarters_ids": []}, + ) + assert resp.status_code == 200 + assert resp.json() == [] + # am1 loses scope over hq1 straight away. + hqs = await client.get(API, headers=auth["am1"]) + assert hqs.json() == [] + + async def test_am_sees_all_of_their_headquarters(self, client, auth, org): + await client.put( + f"{API}/area-managers/{org['am1'].id}", headers=auth["admin"], + json={"headquarters_ids": [str(org["hq1"].id), str(org["hq2"].id)]}, + ) + hqs = await client.get(API, headers=auth["am1"]) + assert {h["code"] for h in hqs.json()} == {"BBSR", "SBP"} + + async def test_setting_the_same_set_twice_is_a_no_op(self, client, auth, org): + body = {"headquarters_ids": [str(org["hq1"].id)]} + first = await client.put(f"{API}/area-managers/{org['am1'].id}", headers=auth["admin"], json=body) + second = await client.put(f"{API}/area-managers/{org['am1'].id}", headers=auth["admin"], json=body) + assert first.status_code == second.status_code == 200 + assert len(second.json()) == 1 + + async def test_only_an_am_can_be_assigned(self, client, auth, org): + resp = await client.put( + f"{API}/area-managers/{org['mr1'].id}", headers=auth["admin"], + json={"headquarters_ids": [str(org["hq1"].id)]}, + ) + assert resp.status_code in (400, 422), resp.text + + async def test_unknown_headquarters_is_rejected(self, client, auth, org): + resp = await client.put( + f"{API}/area-managers/{org['am1'].id}", headers=auth["admin"], + json={"headquarters_ids": [str(uuid.uuid4())]}, + ) + assert resp.status_code == 404, resp.text + + async def test_permissions(self, client, auth, org): + body = {"headquarters_ids": [str(org["hq1"].id)]} + for who in ("gm", "am1", "mr1"): + put = await client.put(f"{API}/area-managers/{org['am1'].id}", headers=auth[who], json=body) + assert put.status_code == 403, (who, put.text) + # GM may read the mappings (to see who manages what), AM and MR may not. + assert (await client.get(f"{API}/area-managers", headers=auth["gm"])).status_code == 200 + for who in ("am1", "mr1"): + assert (await client.get(f"{API}/area-managers", headers=auth[who])).status_code == 403 diff --git a/tests/e2e/test_dcr_form_fields.py b/tests/e2e/test_dcr_form_fields.py new file mode 100644 index 0000000..b990236 --- /dev/null +++ b/tests/e2e/test_dcr_form_fields.py @@ -0,0 +1,193 @@ +"""Product promoted/sample, POB, stockist visit and order: stored, returned, validated, printed.""" + +from datetime import date + +from tests.e2e.test_full_approval_flow import _create_masters + +API = "/api/v1" + + +async def _draft(client, auth, org): + doctors, chemists = await _create_masters(client, auth, org, n_doctors=2, n_chemists=1) + resp = await client.post(f"{API}/dcr", headers=auth["mr1"], json={"report_date": date.today().isoformat()}) + assert resp.status_code == 201, resp.text + return resp.json()["id"], doctors, chemists + + +class TestFormFields: + async def test_fields_round_trip_through_the_api(self, client, auth, org): + dcr_id, doctors, chemists = await _draft(client, auth, org) + d = await client.post( + f"{API}/dcr/{dcr_id}/calls/doctor", headers=auth["mr1"], + json={"doctor_id": doctors[0]["id"], "visit_time": "09:30:00", "call_outcome": "MET", + "product_promote": " Calcium ", "product_sample": "Vit D", "remarks": "ok"}, + ) + assert d.status_code == 201, d.text + c = await client.post( + f"{API}/dcr/{dcr_id}/calls/chemist", headers=auth["mr1"], + json={"chemist_id": chemists[0]["id"], "visit_time": "10:00:00", "pob": "12,500"}, + ) + assert c.status_code == 201, c.text + patched = await client.patch( + f"{API}/dcr/{dcr_id}", headers=auth["mr1"], + json={"stockist_visit": "Ganesh Distributors", "order_value": "45,000"}, + ) + assert patched.status_code == 200, patched.text + + report = (await client.get(f"{API}/dcr/{dcr_id}", headers=auth["mr1"])).json() + assert report["doctor_calls"][0]["product_promote"] == "Calcium" # trimmed + assert report["doctor_calls"][0]["product_sample"] == "Vit D" + assert report["chemist_calls"][0]["pob"] == "12,500" + assert report["stockist_visit"] == "Ganesh Distributors" + assert report["order_value"] == "45,000" + + async def test_blank_values_are_stored_as_null_and_can_be_cleared(self, client, auth, org): + dcr_id, _, _ = await _draft(client, auth, org) + await client.patch(f"{API}/dcr/{dcr_id}", headers=auth["mr1"], json={"stockist_visit": "X"}) + cleared = await client.patch(f"{API}/dcr/{dcr_id}", headers=auth["mr1"], json={"stockist_visit": " "}) + assert cleared.json()["stockist_visit"] is None + + async def test_patching_one_field_leaves_the_others_alone(self, client, auth, org): + dcr_id, _, _ = await _draft(client, auth, org) + await client.patch(f"{API}/dcr/{dcr_id}", headers=auth["mr1"], json={"mr_remarks": "Good day", "order_value": "10"}) + again = await client.patch(f"{API}/dcr/{dcr_id}", headers=auth["mr1"], json={"stockist_visit": "S"}) + body = again.json() + assert (body["mr_remarks"], body["order_value"], body["stockist_visit"]) == ("Good day", "10", "S") + + async def test_too_long_values_are_rejected(self, client, auth, org): + dcr_id, doctors, _ = await _draft(client, auth, org) + too_long = await client.patch(f"{API}/dcr/{dcr_id}", headers=auth["mr1"], json={"stockist_visit": "x" * 201}) + assert too_long.status_code == 422 + bad_call = await client.post( + f"{API}/dcr/{dcr_id}/calls/doctor", headers=auth["mr1"], + json={"doctor_id": doctors[0]["id"], "visit_time": "09:30:00", "call_outcome": "MET", "product_promote": "x" * 201}, + ) + assert bad_call.status_code == 422 + + async def test_only_the_owner_can_edit_them_and_only_while_editable(self, client, auth, org): + dcr_id, doctors, _ = await _draft(client, auth, org) + assert (await client.patch(f"{API}/dcr/{dcr_id}", headers=auth["mr2"], json={"order_value": "1"})).status_code in (403, 404) + assert (await client.patch(f"{API}/dcr/{dcr_id}", headers=auth["am1"], json={"order_value": "1"})).status_code == 403 + await client.post( + f"{API}/dcr/{dcr_id}/calls/doctor", headers=auth["mr1"], + json={"doctor_id": doctors[0]["id"], "visit_time": "09:30:00", "call_outcome": "MET"}, + ) + assert (await client.post(f"{API}/dcr/{dcr_id}/submit", headers=auth["mr1"])).status_code == 200 + locked = await client.patch(f"{API}/dcr/{dcr_id}", headers=auth["mr1"], json={"order_value": "1"}) + assert locked.status_code == 409 # submitted reports are locked + + async def test_approved_pdf_is_generated_with_the_new_layout(self, client, auth, org): + dcr_id, doctors, chemists = await _draft(client, auth, org) + await client.post( + f"{API}/dcr/{dcr_id}/calls/doctor", headers=auth["mr1"], + json={"doctor_id": doctors[0]["id"], "visit_time": "09:30:00", "call_outcome": "MET", "product_promote": "Calcium"}, + ) + await client.post(f"{API}/dcr/{dcr_id}/submit", headers=auth["mr1"]) + assert (await client.post(f"{API}/dcr/{dcr_id}/approve", headers=auth["am1"], json={})).status_code == 200 + pdf = await client.get(f"{API}/dcr/{dcr_id}/pdf", headers=auth["mr1"]) + assert pdf.status_code == 200 and pdf.content.startswith(b"%PDF-") + + +class TestResponsesReflectTheChange: + """Regression: the response to an add/remove used to list the visits as they were BEFORE it.""" + + async def test_adding_a_visit_returns_it_in_the_same_response(self, client, auth, org): + dcr_id, doctors, chemists = await _draft(client, auth, org) + added = await client.post( + f"{API}/dcr/{dcr_id}/calls/doctor", headers=auth["mr1"], + json={"doctor_id": doctors[0]["id"], "visit_time": "09:30:00", "call_outcome": "MET"}, + ) + assert [c["doctor_id"] for c in added.json()["doctor_calls"]] == [doctors[0]["id"]] + second = await client.post( + f"{API}/dcr/{dcr_id}/calls/chemist", headers=auth["mr1"], + json={"chemist_id": chemists[0]["id"], "visit_time": "10:00:00"}, + ) + body = second.json() + assert len(body["doctor_calls"]) == 1 and len(body["chemist_calls"]) == 1 + + async def test_removing_a_visit_returns_the_report_without_it(self, client, auth, org): + dcr_id, doctors, _ = await _draft(client, auth, org) + for i, doctor in enumerate(doctors): + r = await client.post( + f"{API}/dcr/{dcr_id}/calls/doctor", headers=auth["mr1"], + json={"doctor_id": doctor["id"], "visit_time": f"09:{30 + i}:00", "call_outcome": "MET"}, + ) + call_id = r.json()["doctor_calls"][0]["id"] + removed = await client.delete(f"{API}/dcr/{dcr_id}/calls/{call_id}", headers=auth["mr1"]) + assert removed.status_code == 200, removed.text + assert call_id not in [c["id"] for c in removed.json()["doctor_calls"]] + assert len(removed.json()["doctor_calls"]) == len(doctors) - 1 + # ...and a fresh read agrees. + again = (await client.get(f"{API}/dcr/{dcr_id}", headers=auth["mr1"])).json() + assert len(again["doctor_calls"]) == len(doctors) - 1 + + +class TestDownloadUsesTheCurrentLayout: + async def test_a_report_approved_under_an_older_layout_still_downloads_in_the_new_one(self, client, auth, org, db): + from pathlib import Path + + from sqlalchemy import select + + from app.reports.models import DailyCallReport + + dcr_id, doctors, _ = await _draft(client, auth, org) + await client.post( + f"{API}/dcr/{dcr_id}/calls/doctor", headers=auth["mr1"], + json={"doctor_id": doctors[0]["id"], "visit_time": "09:30:00", "call_outcome": "MET"}, + ) + await client.post(f"{API}/dcr/{dcr_id}/submit", headers=auth["mr1"]) + assert (await client.post(f"{API}/dcr/{dcr_id}/approve", headers=auth["am1"], json={})).status_code == 200 + + # Simulate the file stored back when an older design was in use. + stored = (await db.execute(select(DailyCallReport.pdf_path).where(DailyCallReport.id == dcr_id))).scalar_one() + Path(stored).write_bytes(b"%PDF-1.4 OLD DESIGN") + + pdf = await client.get(f"{API}/dcr/{dcr_id}/pdf", headers=auth["mr1"]) + assert pdf.status_code == 200 + assert b"OLD DESIGN" not in pdf.content and pdf.content.startswith(b"%PDF-") and len(pdf.content) > 5000 + # ...and still only for approved reports. + draft_id, _, _ = await _draft_second(client, auth, org) + assert (await client.get(f"{API}/dcr/{draft_id}/pdf", headers=auth["mr1"])).status_code == 422 + + +async def _draft_second(client, auth, org): + """A second, unapproved report (yesterday's) for the same MR.""" + from datetime import timedelta + + resp = await client.post( + f"{API}/dcr", headers=auth["mr1"], json={"report_date": (date.today() - timedelta(days=1)).isoformat()} + ) + assert resp.status_code == 201, resp.text + return resp.json()["id"], None, None + + +class TestApprovedPdfIsSigned: + async def test_the_pdf_names_the_approving_area_manager_from_the_audit_trail(self, client, auth, org, db): + from sqlalchemy import select + + from app.pdf.service import PDFService + from app.reports.models import DailyCallReport + from app.reports.repository import DCRRepository + + dcr_id, doctors, _ = await _draft(client, auth, org) + await client.post( + f"{API}/dcr/{dcr_id}/calls/doctor", headers=auth["mr1"], + json={"doctor_id": doctors[0]["id"], "visit_time": "09:30:00", "call_outcome": "MET"}, + ) + await client.post(f"{API}/dcr/{dcr_id}/submit", headers=auth["mr1"]) + assert (await client.post(f"{API}/dcr/{dcr_id}/approve", headers=auth["am1"], json={})).status_code == 200 + + report = await DCRRepository(db).get_full( + (await db.execute(select(DailyCallReport.id).where(DailyCallReport.id == dcr_id))).scalar_one() + ) + context = await PDFService(db)._context(report) + assert context["approval"]["name"] == "Suresh Behera" + assert len(context["approval"]["at"]) == 16 and context["mr_signed"] == "Ravi Das (MR001)" + + async def test_a_report_that_is_not_approved_has_no_approval_signature(self, client, auth, org, db): + from app.pdf.service import PDFService + from app.reports.repository import DCRRepository + + dcr_id, _, _ = await _draft(client, auth, org) + report = await DCRRepository(db).get_full(dcr_id if not isinstance(dcr_id, str) else __import__("uuid").UUID(dcr_id)) + assert (await PDFService(db)._context(report))["approval"] is None diff --git a/tests/e2e/test_duplicate_requests.py b/tests/e2e/test_duplicate_requests.py new file mode 100644 index 0000000..5668a61 --- /dev/null +++ b/tests/e2e/test_duplicate_requests.py @@ -0,0 +1,145 @@ +"""Sending the same request twice (a double click, a slow network) never creates or changes anything twice.""" + +from datetime import date + +import pytest +from sqlalchemy import text + +from tests.e2e.test_full_approval_flow import _create_masters + +API = "/api/v1" + + +@pytest.fixture +async def tables(db): + await db.execute(text('DROP TABLE IF EXISTS "fare_chart"')) + await db.execute(text( + 'CREATE TABLE "fare_chart" (id UUID PRIMARY KEY, source_row_number INTEGER, name TEXT, headquarter TEXT, ' + "serial_no TEXT, report_date TEXT, from_location TEXT, to_location TEXT, kilometers_km TEXT, owner_user_id UUID)" + )) + await db.execute(text("DROP TABLE IF EXISTS stock_inventory")) + await db.execute(text( + "CREATE TABLE stock_inventory (id SERIAL PRIMARY KEY, serial_no INTEGER UNIQUE, product_name TEXT NOT NULL, " + "pack TEXT, quantity TEXT, unit TEXT)" + )) + await db.commit() + + +async def _audit_count(db, entity_id, action) -> int: + row = await db.execute( + text("SELECT count(*) FROM audit_log WHERE entity_id = :e AND action = :a"), {"e": entity_id, "a": action} + ) + return row.scalar_one() + + +class TestReports: + async def _submitted(self, client, auth, org): + doctors, _ = await _create_masters(client, auth, org, n_doctors=1, n_chemists=1) + dcr = (await client.post(f"{API}/dcr", headers=auth["mr1"], json={"report_date": date.today().isoformat()})).json()["id"] + await client.post( + f"{API}/dcr/{dcr}/calls/doctor", headers=auth["mr1"], + json={"doctor_id": doctors[0]["id"], "visit_time": "09:30:00", "call_outcome": "MET"}, + ) + return dcr, doctors + + async def test_submitting_twice_is_one_submission(self, client, auth, org, db): + dcr, _ = await self._submitted(client, auth, org) + first = await client.post(f"{API}/dcr/{dcr}/submit", headers=auth["mr1"]) + second = await client.post(f"{API}/dcr/{dcr}/submit", headers=auth["mr1"]) + assert first.status_code == second.status_code == 200 + assert second.json()["status"] == "PENDING_AM" + assert second.json()["submitted_at"] == first.json()["submitted_at"] + assert await _audit_count(db, dcr, "SUBMIT") == 1 + + async def test_approving_twice_is_one_approval(self, client, auth, org, db): + dcr, _ = await self._submitted(client, auth, org) + await client.post(f"{API}/dcr/{dcr}/submit", headers=auth["mr1"]) + first = await client.post(f"{API}/dcr/{dcr}/approve", headers=auth["am1"], json={}) + second = await client.post(f"{API}/dcr/{dcr}/approve", headers=auth["am1"], json={}) + assert first.status_code == second.status_code == 200 + assert second.json()["approved_at"] == first.json()["approved_at"] + assert await _audit_count(db, dcr, "APPROVE") == 1 + + async def test_an_area_manager_of_another_hq_still_cannot_approve(self, client, auth, org): + dcr, _ = await self._submitted(client, auth, org) + await client.post(f"{API}/dcr/{dcr}/submit", headers=auth["mr1"]) + await client.post(f"{API}/dcr/{dcr}/approve", headers=auth["am1"], json={}) + assert (await client.post(f"{API}/dcr/{dcr}/approve", headers=auth["am2"], json={})).status_code == 403 + + async def test_adding_the_same_visit_or_creating_the_same_report_twice_is_refused(self, client, auth, org): + dcr, doctors = await self._submitted(client, auth, org) + again = await client.post( + f"{API}/dcr/{dcr}/calls/doctor", headers=auth["mr1"], + json={"doctor_id": doctors[0]["id"], "visit_time": "10:30:00", "call_outcome": "MET"}, + ) + assert again.status_code == 409 + assert (await client.post(f"{API}/dcr", headers=auth["mr1"], json={"report_date": date.today().isoformat()})).status_code == 409 + report = (await client.get(f"{API}/dcr/{dcr}", headers=auth["mr1"])).json() + assert len(report["doctor_calls"]) == 1 + + +class TestSetup: + async def test_the_same_doctor_headquarters_product_and_user_cannot_be_created_twice(self, client, auth, org): + doctor = {"headquarters_id": str(org["hq1"].id), "name": "Dr Twice", "clinic_address": "1 Main Road"} + assert (await client.post(f"{API}/doctors", headers=auth["admin"], json=doctor)).status_code == 201 + assert (await client.post(f"{API}/doctors", headers=auth["admin"], json=doctor)).status_code == 409 + + hq = {"code": "NEW1", "name": "New Place"} + assert (await client.post(f"{API}/headquarters", headers=auth["admin"], json=hq)).status_code == 201 + assert (await client.post(f"{API}/headquarters", headers=auth["admin"], json=hq)).status_code == 409 + + product = {"name": "Twice Tonic"} + assert (await client.post(f"{API}/products", headers=auth["admin"], json=product)).status_code == 201 + assert (await client.post(f"{API}/products", headers=auth["admin"], json=product)).status_code == 409 + + user = {"email": "dup@acmepharma.in", "password": "Str0ngPass9", "full_name": "Dup User", "employee_code": "D1", "role": "GM"} + assert (await client.post(f"{API}/users", headers=auth["admin"], json=user)).status_code == 201 + assert (await client.post(f"{API}/users", headers=auth["admin"], json=user)).status_code == 409 + + async def test_assigning_twice_leaves_one_assignment(self, client, auth, org): + doctors, _ = await _create_masters(client, auth, org, n_doctors=1, n_chemists=0) + again = await client.post(f"{API}/doctors/{doctors[0]['id']}/assign", headers=auth["admin"], json={"mr_user_id": str(org["mr1"].id)}) + assert again.status_code == 201 + visible = await client.get(f"{API}/doctors", headers=auth["mr1"]) + assert len(visible.json()) == 1 + + async def test_area_manager_assignment_is_repeatable(self, client, auth, org): + body = {"headquarters_ids": [str(org["hq1"].id)]} + for _ in range(2): + resp = await client.put(f"{API}/headquarters/area-managers/{org['am1'].id}", headers=auth["admin"], json=body) + assert resp.status_code == 200 and len(resp.json()) == 1 + + async def test_the_stock_list_keeps_each_product_once(self, client, auth, tables): + item = {"product_name": "ZINCOVIT-X", "pack": "10X10 TAB"} + assert (await client.post(f"{API}/products/stock-inventory", headers=auth["admin"], json=item)).status_code == 201 + for spelling in ("ZINCOVIT-X", " zincovit-x "): + dup = await client.post(f"{API}/products/stock-inventory", headers=auth["admin"], json={"product_name": spelling}) + assert dup.status_code == 409, spelling + other = (await client.post(f"{API}/products/stock-inventory", headers=auth["admin"], json={"product_name": "OTHER-Y"})).json() + clash = await client.patch(f"{API}/products/stock-inventory/{other['id']}", headers=auth["admin"], json={"product_name": "zincovit-x"}) + assert clash.status_code == 409 + keep = await client.patch(f"{API}/products/stock-inventory/{other['id']}", headers=auth["admin"], json={"product_name": "OTHER-Y", "pack": "new"}) + assert keep.status_code == 200 # saving a product under its own name is fine + + +class TestCompanyForms: + async def test_an_identical_row_is_a_repeat_but_a_different_one_is_not(self, client, auth, tables): + row = {"report_date": "2026-09-21", "from_location": "Bhubaneswar", "to_location": "Puri", "kilometers_km": "69"} + assert (await client.post(f"{API}/csv-data/fare_chart/rows", headers=auth["mr1"], json=row)).status_code == 201 + repeat = await client.post(f"{API}/csv-data/fare_chart/rows", headers=auth["mr1"], json=row) + assert repeat.status_code == 409, repeat.text + other = {**row, "to_location": "Cuttack", "kilometers_km": "39"} + assert (await client.post(f"{API}/csv-data/fare_chart/rows", headers=auth["mr1"], json=other)).status_code == 201 + rows = (await client.get(f"{API}/csv-data/fare_chart/rows", headers=auth["mr1"])).json() + assert len(rows) == 2 + + async def test_repeated_send_and_approve_are_absorbed(self, client, auth, org, tables): + await client.post(f"{API}/csv-data/fare_chart/rows", headers=auth["mr1"], json={"from_location": "A", "to_location": "B"}) + statuses = [ + (await client.post(f"{API}/csv-data/fare_chart/approval/request", headers=auth["mr1"])).json()["status"] for _ in range(3) + ] + assert statuses == ["pending"] * 3 + approved = [ + (await client.post(f"{API}/csv-data/fare_chart/approval/approve?owner_id={org['mr1'].id}", headers=auth["am1"])).json()["status"] for _ in range(3) + ] + assert approved == ["approved"] * 3 diff --git a/tests/e2e/test_form_approval.py b/tests/e2e/test_form_approval.py new file mode 100644 index 0000000..7ef234a --- /dev/null +++ b/tests/e2e/test_form_approval.py @@ -0,0 +1,114 @@ +"""Company-form approvals live on the server, so everyone sees the same state at once.""" + +import pytest +from sqlalchemy import text + +from app.csv_data.router import _signature + +API = "/api/v1/csv-data" + + +@pytest.fixture +async def fare_chart(db): + await db.execute(text('DROP TABLE IF EXISTS "fare_chart"')) + await db.execute(text( + 'CREATE TABLE "fare_chart" (id UUID PRIMARY KEY, source_row_number INTEGER, name TEXT, headquarter TEXT, ' + "serial_no TEXT, report_date TEXT, from_location TEXT, to_location TEXT, kilometers_km TEXT, owner_user_id UUID)" + )) + await db.commit() + + +async def _add_row(client, auth) -> str: + resp = await client.post(f"{API}/fare_chart/rows", headers=auth["mr1"], json={"from_location": "A", "to_location": "B"}) + assert resp.status_code == 201, resp.text + return resp.json()["id"] + + +def _by_table(resp): + return {a["table_name"]: a for a in resp.json()} + + +class TestFormApproval: + async def test_every_approval_form_starts_as_draft_for_everyone(self, client, auth): + # An MR sees all three forms as drafts; an Area Manager or admin has nothing to act on yet. + forms = _by_table(await client.get(f"{API}/approvals", headers=auth["mr1"])) + assert set(forms) == {"tour_plan", "standard_tour_plan", "fare_chart"} + assert {f["status"] for f in forms.values()} == {"draft"} + for who in ("am1", "admin"): + resp = await client.get(f"{API}/approvals", headers=auth[who]) + assert resp.status_code == 200 and resp.json() == [], (who, resp.text) + + async def test_mr_requests_and_am_approves_and_both_see_it_immediately(self, client, auth, org, fare_chart): + await _add_row(client, auth) + sent = await client.post(f"{API}/fare_chart/approval/request", headers=auth["mr1"]) + assert sent.status_code == 200 and sent.json()["status"] == "pending" + assert _by_table(await client.get(f"{API}/approvals", headers=auth["am1"]))["fare_chart"]["status"] == "pending" + + done = await client.post(f"{API}/fare_chart/approval/approve?owner_id={org['mr1'].id}", headers=auth["am1"]) + assert done.status_code == 200, done.text + assert done.json()["status"] == "approved" and done.json()["approved_by_name"] == "Suresh Behera" + # The MR's very next read shows the AM's approval — no shared browser needed. + seen = _by_table(await client.get(f"{API}/approvals", headers=auth["mr1"]))["fare_chart"] + assert (seen["status"], seen["approved_by_name"]) == ("approved", "Suresh Behera") + + async def test_an_empty_form_cannot_be_sent_for_approval(self, client, auth, fare_chart): + resp = await client.post(f"{API}/fare_chart/approval/request", headers=auth["mr1"]) + assert resp.status_code == 422, resp.text + assert _by_table(await client.get(f"{API}/approvals", headers=auth["mr1"]))["fare_chart"]["status"] == "draft" + + async def test_nothing_can_be_approved_until_it_has_been_sent(self, client, auth, org, fare_chart): + await _add_row(client, auth) + early = await client.post(f"{API}/fare_chart/approval/approve?owner_id={org['mr1'].id}", headers=auth["am1"]) + assert early.status_code == 409, early.text + assert _by_table(await client.get(f"{API}/approvals", headers=auth["mr1"]))["fare_chart"]["status"] == "draft" + assert (await client.get(f"{API}/approvals", headers=auth["am1"])).json() == [] # a draft is nothing for the AM to act on + + async def test_double_clicks_are_harmless(self, client, auth, org, fare_chart): + await _add_row(client, auth) + for _ in range(2): + assert (await client.post(f"{API}/fare_chart/approval/request", headers=auth["mr1"])).json()["status"] == "pending" + for _ in range(2): + assert (await client.post(f"{API}/fare_chart/approval/approve?owner_id={org['mr1'].id}", headers=auth["am1"])).json()["status"] == "approved" + # Once approved, sending again is refused until something changes. + assert (await client.post(f"{API}/fare_chart/approval/request", headers=auth["mr1"])).status_code == 409 + + async def test_only_the_right_role_can_act(self, client, auth, org): + for who in ("am1", "admin", "gm"): + assert (await client.post(f"{API}/fare_chart/approval/request", headers=auth[who])).status_code == 403, who + for who in ("mr1", "admin", "gm"): + assert (await client.post(f"{API}/fare_chart/approval/approve?owner_id={org['mr1'].id}", headers=auth[who])).status_code == 403, who + + async def test_forms_without_an_approval_step_are_not_found(self, client, auth, org): + for table in ("weekly_report", "nonsense"): + assert (await client.post(f"{API}/{table}/approval/approve?owner_id={org['mr1'].id}", headers=auth["am1"])).status_code == 404 + + async def test_changing_the_rows_withdraws_a_pending_or_approved_form(self, client, auth, org, fare_chart): + row_id = await _add_row(client, auth) + for change in ( + lambda: client.patch(f"{API}/fare_chart/rows/{row_id}", headers=auth["mr1"], json={"to_location": "C"}), + lambda: client.post(f"{API}/fare_chart/rows", headers=auth["mr1"], json={"from_location": "X", "to_location": "Y"}), + ): + await client.post(f"{API}/fare_chart/approval/request", headers=auth["mr1"]) + await client.post(f"{API}/fare_chart/approval/approve?owner_id={org['mr1'].id}", headers=auth["am1"]) + assert (await change()).status_code in (200, 201) + state = _by_table(await client.get(f"{API}/approvals", headers=auth["mr1"]))["fare_chart"] + assert state["status"] == "draft" and state["approved_by_name"] is None + # A pending (not yet approved) form is withdrawn too, so the AM never signs stale data. + await client.post(f"{API}/fare_chart/approval/request", headers=auth["mr1"]) + assert (await client.delete(f"{API}/fare_chart/rows/{row_id}", headers=auth["mr1"])).status_code == 204 + assert (await client.get(f"{API}/approvals", headers=auth["am1"])).json() == [] # withdrawn: nothing left for the AM + + async def test_the_pdf_signature_comes_from_the_server_not_the_browser(self, client, auth, org, db, fare_chart): + # Not approved: a browser claiming otherwise changes nothing. + mr = org["mr1"].id + assert await _signature("fare_chart", mr, db) == ("pending", None, None) + spoof = await client.get(f"{API}/fare_chart/pdf?approval_status=approved&am_name=Somebody", headers=auth["mr1"]) + assert spoof.status_code == 200 + await _add_row(client, auth) + await client.post(f"{API}/fare_chart/approval/request", headers=auth["mr1"]) + await client.post(f"{API}/fare_chart/approval/approve?owner_id={org['mr1'].id}", headers=auth["am1"]) + await db.rollback() # see the other session's commit + status, name, when = await _signature("fare_chart", mr, db) + assert (status, name) == ("approved", "Suresh Behera") + assert when and len(when) == 16 and when[2] == "/" and when[13] == ":" # dd/mm/yyyy HH:MM + assert await _signature("weekly_report", mr, db) == (None, None, None) diff --git a/tests/e2e/test_form_ownership.py b/tests/e2e/test_form_ownership.py new file mode 100644 index 0000000..5e8b4fe --- /dev/null +++ b/tests/e2e/test_form_ownership.py @@ -0,0 +1,153 @@ +"""Company forms belong to one MR; only that MR's own Area Manager receives and signs the request.""" + +import pytest +from sqlalchemy import text + +from app.csv_data.config import TABLES +from app.csv_data.router import _load_rows + +API = "/api/v1/csv-data" + + +async def _make_table(db, name: str, owned: bool) -> None: + columns = "".join(f", {c} TEXT" for c in TABLES[name]) + owner = ", owner_user_id UUID" if owned else "" + await db.execute(text(f'DROP TABLE IF EXISTS "{name}"')) + await db.execute(text(f'CREATE TABLE "{name}" (id UUID PRIMARY KEY, source_row_number INTEGER{owner}{columns})')) + await db.commit() + + +@pytest.fixture +async def forms(db): + for name in ("fare_chart", "tour_plan", "standard_tour_plan"): + await _make_table(db, name, owned=True) + + +async def _add(client, headers, place="A", **query) -> str: + resp = await client.post(f"{API}/fare_chart/rows", headers=headers, json={"from_location": place, "to_location": "Z"}, params=query) + assert resp.status_code == 201, resp.text + return resp.json()["id"] + + +async def _approvals(client, headers): + resp = await client.get(f"{API}/approvals", headers=headers) + assert resp.status_code == 200, resp.text + return resp.json() + + +class TestRowsBelongToTheirMR: + async def test_each_mr_sees_only_their_own_rows_numbered_from_one(self, client, auth, forms): + await _add(client, auth["mr1"], "A") + await _add(client, auth["mr1"], "B") + await _add(client, auth["mr2"], "C") + mine = (await client.get(f"{API}/fare_chart/rows", headers=auth["mr1"])).json() + theirs = (await client.get(f"{API}/fare_chart/rows", headers=auth["mr2"])).json() + assert [r["from_location"] for r in mine] == ["A", "B"] and [r["serial_no"] for r in mine] == ["1", "2"] + assert [r["from_location"] for r in theirs] == ["C"] and [r["serial_no"] for r in theirs] == ["1"] + + async def test_an_mr_cannot_change_or_remove_another_mrs_row(self, client, auth, forms): + row = await _add(client, auth["mr1"]) + assert (await client.patch(f"{API}/fare_chart/rows/{row}", headers=auth["mr2"], json={"to_location": "Q"})).status_code == 403 + assert (await client.delete(f"{API}/fare_chart/rows/{row}", headers=auth["mr2"])).status_code == 403 + assert (await client.get(f"{API}/fare_chart/rows/{row}/pdf", headers=auth["mr2"])).status_code == 403 + assert (await client.get(f"{API}/fare_chart/rows", headers=auth["mr2"])).json() == [] + + async def test_an_area_manager_sees_only_the_mrs_of_their_headquarters(self, client, auth, org, forms): + await _add(client, auth["mr1"], "A") + await _add(client, auth["mr2"], "C") + assert [r["from_location"] for r in (await client.get(f"{API}/fare_chart/rows", headers=auth["am1"])).json()] == ["A"] + assert [r["from_location"] for r in (await client.get(f"{API}/fare_chart/rows", headers=auth["am2"])).json()] == ["C"] + other = await client.get(f"{API}/fare_chart/rows", headers=auth["am2"], params={"owner_id": str(org["mr1"].id)}) + assert other.status_code == 403 + assert (await client.get(f"{API}/fare_chart/pdf", headers=auth["am2"], params={"owner_id": str(org["mr1"].id)})).status_code == 403 + + async def test_the_admin_needs_to_say_which_mr_a_new_row_is_for(self, client, auth, org, forms): + assert (await client.post(f"{API}/fare_chart/rows", headers=auth["admin"], json={"from_location": "A"})).status_code == 422 + made = await client.post(f"{API}/fare_chart/rows", headers=auth["admin"], json={"from_location": "A"}, params={"owner_id": str(org["mr2"].id)}) + assert made.status_code == 201 and made.json()["name"] == "Priya Nayak" + assert len((await client.get(f"{API}/fare_chart/rows", headers=auth["mr2"])).json()) == 1 + assert (await client.get(f"{API}/fare_chart/rows", headers=auth["mr1"])).json() == [] + + +class TestOnlyTheAssignedAreaManagerGetsTheRequest: + async def test_the_request_reaches_only_the_mrs_own_area_manager(self, client, auth, org, forms): + await _add(client, auth["mr1"]) + assert (await client.post(f"{API}/fare_chart/approval/request", headers=auth["mr1"])).json()["status"] == "pending" + mine = await _approvals(client, auth["am1"]) + assert [(a["table_name"], a["owner_name"], a["status"]) for a in mine] == [("fare_chart", "Ravi Das", "pending")] + assert await _approvals(client, auth["am2"]) == [] # the other headquarters' manager never sees it + assert [a["status"] for a in await _approvals(client, auth["mr2"]) if a["table_name"] == "fare_chart"] == ["draft"] + + async def test_another_area_manager_cannot_approve_it(self, client, auth, org, forms): + await _add(client, auth["mr1"]) + await client.post(f"{API}/fare_chart/approval/request", headers=auth["mr1"]) + wrong = await client.post(f"{API}/fare_chart/approval/approve", headers=auth["am2"], params={"owner_id": str(org["mr1"].id)}) + assert wrong.status_code == 403, wrong.text + assert [a["status"] for a in await _approvals(client, auth["am1"])] == ["pending"] + right = await client.post(f"{API}/fare_chart/approval/approve", headers=auth["am1"], params={"owner_id": str(org["mr1"].id)}) + assert right.status_code == 200 and right.json()["approved_by_name"] == "Suresh Behera" + + async def test_one_mrs_approval_does_not_approve_another_mrs_form(self, client, auth, org, forms): + await _add(client, auth["mr1"]) + await _add(client, auth["mr2"]) + for who in ("mr1", "mr2"): + await client.post(f"{API}/fare_chart/approval/request", headers=auth[who]) + await client.post(f"{API}/fare_chart/approval/approve", headers=auth["am1"], params={"owner_id": str(org["mr1"].id)}) + status = {a["owner_name"]: a["status"] for a in await _approvals(client, auth["admin"])} + assert status == {"Ravi Das": "approved", "Priya Nayak": "pending"} + + async def test_editing_one_mrs_rows_only_withdraws_that_mrs_approval(self, client, auth, org, forms): + row1 = await _add(client, auth["mr1"]) + await _add(client, auth["mr2"]) + for who in ("mr1", "mr2"): + await client.post(f"{API}/fare_chart/approval/request", headers=auth[who]) + assert (await client.patch(f"{API}/fare_chart/rows/{row1}", headers=auth["mr1"], json={"to_location": "Q"})).status_code == 200 + status = {a["owner_name"]: a["status"] for a in await _approvals(client, auth["admin"]) if a["status"] != "draft"} + assert status == {"Priya Nayak": "pending"} + + async def test_a_form_cannot_be_sent_when_no_area_manager_is_assigned(self, client, auth, org, db, forms): + await _add(client, auth["mr1"]) + await db.execute(text("UPDATE am_headquarters SET effective_to = current_date WHERE headquarters_id = :h"), {"h": org["hq1"].id}) + await db.commit() + resp = await client.post(f"{API}/fare_chart/approval/request", headers=auth["mr1"]) + assert resp.status_code == 422 and "Area Manager" in resp.text + + async def test_the_pdf_is_signed_by_the_approver_of_that_mr_only(self, client, auth, org, db, forms): + from app.csv_data.router import _signature + + await _add(client, auth["mr1"]) + await _add(client, auth["mr2"]) + await client.post(f"{API}/fare_chart/approval/request", headers=auth["mr1"]) + await client.post(f"{API}/fare_chart/approval/approve", headers=auth["am1"], params={"owner_id": str(org["mr1"].id)}) + await db.rollback() # see the other session's commit + assert (await _signature("fare_chart", org["mr1"].id, db))[:2] == ("approved", "Suresh Behera") + assert (await _signature("fare_chart", org["mr2"].id, db)) == ("pending", None, None) + assert (await _signature("fare_chart", None, db)) == ("pending", None, None) # several MRs at once: unsigned + + +class TestMonthlyDownload: + @pytest.fixture + async def weekly(self, db): + await _make_table(db, "weekly_report", owned=False) + for i, month in enumerate(["November", "December", "november", None]): + await db.execute( + text('INSERT INTO "weekly_report" (id, source_row_number, employee_name, month) VALUES (gen_random_uuid(), :n, :name, :m)'), + {"n": i + 1, "name": f"row{i}", "m": month}, + ) + await db.commit() + + async def test_only_the_chosen_month_is_returned_ignoring_case_and_spaces(self, db, org, weekly): + november = await _load_rows("weekly_report", db, org["admin"], month=" NOVEMBER ") + assert len(november) == 2 + assert len(await _load_rows("weekly_report", db, org["admin"])) == 4 # no month chosen = the whole form + + async def test_downloading_a_month_gives_a_pdf_and_a_month_without_rows_is_refused(self, client, auth, weekly): + ok = await client.get(f"{API}/weekly_report/pdf", headers=auth["mr1"], params={"month": "December"}) + assert ok.status_code == 200 and ok.headers["content-type"].startswith("application/pdf") + assert "weekly_report-december.pdf" in ok.headers["content-disposition"] + none = await client.get(f"{API}/weekly_report/pdf", headers=auth["mr1"], params={"month": "March"}) + assert none.status_code == 404 and "March" in none.text + + async def test_a_form_without_a_month_rejects_the_filter(self, client, auth, forms): + resp = await client.get(f"{API}/fare_chart/pdf", headers=auth["mr1"], params={"month": "November"}) + assert resp.status_code == 422 diff --git a/tests/e2e/test_full_approval_flow.py b/tests/e2e/test_full_approval_flow.py new file mode 100644 index 0000000..d7827de --- /dev/null +++ b/tests/e2e/test_full_approval_flow.py @@ -0,0 +1,598 @@ +"""THE acceptance test — the 13-step flow from the report, plus 3 negative-scope tests. + +This is the definition of done for Phase 1. It walks the complete value chain: +setup → entry → approval → PDF → audit. If this passes, the product is real. + +The three negative tests (X1-X3) matter as much as the thirteen positive ones: a +permission system that has never been tested against a wrong-scope request is a +permission system that does not work. +""" + +from datetime import date + +import pytest + +from app.common.enums import DCRStatus + +pytestmark = pytest.mark.anyio + +API = "/api/v1" + + +# --------------------------------------------------------------------------- +# Steps 1-3: Admin sets up users, org mapping and masters +# --------------------------------------------------------------------------- + + +async def _create_masters(client, auth, org, n_doctors=15, n_chemists=5): + """Steps 3: Admin creates doctors and chemists and assigns them to the MR.""" + doctors, chemists = [], [] + + for i in range(n_doctors): + resp = await client.post( + f"{API}/doctors", + headers=auth["admin"], + json={ + "headquarters_id": str(org["hq1"].id), + "name": f"Dr Doctor {i:02d}", + "clinic_address": f"Clinic {i:02d}, Bhubaneswar", + "speciality": "General Medicine", + # The first three are core doctors, so conversion status is exercised. + "is_core_doctor": i < 3, + }, + ) + assert resp.status_code == 201, resp.text + doctor = resp.json() + assign = await client.post( + f"{API}/doctors/{doctor['id']}/assign", + headers=auth["admin"], + json={"mr_user_id": str(org["mr1"].id)}, + ) + assert assign.status_code == 201, assign.text + doctors.append(doctor) + + for i in range(n_chemists): + resp = await client.post( + f"{API}/chemists", + headers=auth["admin"], + json={ + "headquarters_id": str(org["hq1"].id), + "name": f"Chemist {i:02d}", + "shop_address": f"Shop {i:02d}, Bhubaneswar", + }, + ) + assert resp.status_code == 201, resp.text + chemist = resp.json() + assign = await client.post( + f"{API}/chemists/{chemist['id']}/assign", + headers=auth["admin"], + json={"mr_user_id": str(org["mr1"].id)}, + ) + assert assign.status_code == 201, assign.text + chemists.append(chemist) + + return doctors, chemists + + +class TestStep1And2Setup: + async def test_admin_creates_user_and_org_mapping(self, client, auth, org): + """Step 1-2: users exist with correct roles, and the MR's profile resolves + both its headquarters and its DERIVED reporting Area Manager.""" + resp = await client.get(f"{API}/users/me/profile", headers=auth["mr1"]) + assert resp.status_code == 200, resp.text + profile = resp.json() + + assert profile["role"] == "MR" + assert profile["headquarters_code"] == "BBSR" + assert profile["headquarters_name"] == "Bhubaneswar" + # Derived through am_headquarters, not stored on the MR. + assert profile["reporting_manager_name"] == "Suresh Behera" + + async def test_admin_can_create_a_new_mr(self, client, auth, org): + resp = await client.post( + f"{API}/users", + headers=auth["admin"], + json={ + "email": "newmr@acmepharma.in", + "password": "An0therStr0ngPwd!", + "full_name": "New Rep", + "employee_code": "MR010", + "role": "MR", + "headquarters_id": str(org["hq1"].id), + }, + ) + assert resp.status_code == 201, resp.text + assert resp.json()["role"] == "MR" + + async def test_creating_an_mr_without_hq_is_rejected(self, client, auth): + resp = await client.post( + f"{API}/users", + headers=auth["admin"], + json={ + "email": "bad@acmepharma.in", + "password": "An0therStr0ngPwd!", + "full_name": "Bad Rep", + "employee_code": "MR011", + "role": "MR", + }, + ) + assert resp.status_code == 422 + + +class TestStep3And5Masters: + async def test_mr_sees_exactly_the_assigned_doctors(self, client, auth, org): + """Step 3 + Step 5 (S5): 15 doctors created and assigned → MR sees 15.""" + await _create_masters(client, auth, org) + + resp = await client.get(f"{API}/doctors", headers=auth["mr1"]) + assert resp.status_code == 200 + assert len(resp.json()) == 15 + + resp = await client.get(f"{API}/chemists", headers=auth["mr1"]) + assert len(resp.json()) == 5 + + async def test_other_mr_sees_none_of_them(self, client, auth, org): + """An MR can view only their own data (R5).""" + await _create_masters(client, auth, org) + resp = await client.get(f"{API}/doctors", headers=auth["mr2"]) + assert resp.json() == [] + + async def test_mr_cannot_create_a_doctor(self, client, auth, org): + """A3/Q3 — not permitted in the MVP.""" + resp = await client.post( + f"{API}/doctors", + headers=auth["mr1"], + json={ + "headquarters_id": str(org["hq1"].id), + "name": "Dr Selfmade", + "clinic_address": "Nowhere", + }, + ) + assert resp.status_code == 403 + + +class TestStep4Login: + async def test_login_returns_token_pair(self, client, org): + resp = await client.post( + f"{API}/auth/login", + json={"email": org["mr1"].email, "password": "Str0ngPassw0rd!"}, + ) + assert resp.status_code == 200 + body = resp.json() + assert body["access_token"] and body["refresh_token"] + assert body["token_type"] == "bearer" + + async def test_wrong_password_rejected(self, client, org): + resp = await client.post( + f"{API}/auth/login", + json={"email": org["mr1"].email, "password": "wrong-password"}, + ) + assert resp.status_code == 401 + + async def test_refresh_rotates_the_token(self, client, org): + first = await client.post( + f"{API}/auth/login", + json={"email": org["mr1"].email, "password": "Str0ngPassw0rd!"}, + ) + refresh_token = first.json()["refresh_token"] + + second = await client.post(f"{API}/auth/refresh", json={"refresh_token": refresh_token}) + assert second.status_code == 200 + + # The presented token is burned on rotation. + replay = await client.post(f"{API}/auth/refresh", json={"refresh_token": refresh_token}) + assert replay.status_code == 401 + + async def test_unauthenticated_request_rejected(self, client): + assert (await client.get(f"{API}/dcr")).status_code == 401 + + +# --------------------------------------------------------------------------- +# Steps 5-13: the full report lifecycle +# --------------------------------------------------------------------------- + + +class TestFullApprovalFlow: + async def test_thirteen_step_flow(self, client, auth, org): + doctors, chemists = await _create_masters(client, auth, org) + today = date.today().isoformat() + + # --- Step 5: MR creates a DCR --------------------------------- + resp = await client.post( + f"{API}/dcr", + headers=auth["mr1"], + json={"report_date": today, "mr_remarks": "Covered MG Road belt."}, + ) + assert resp.status_code == 201, resp.text + dcr = resp.json() + assert dcr["status"] == DCRStatus.DRAFT.value + assert dcr["is_locked"] is False + dcr_id = dcr["id"] + + # --- Step 6: 5 doctor calls + 2 chemist calls ----------------- + for i in range(5): + payload = { + "doctor_id": doctors[i]["id"], + "visit_time": f"{9 + i:02d}:30:00", + "call_outcome": "MET", + "remarks": f"Discussed product line {i}", + } + if doctors[i]["is_core_doctor"]: + payload["conversion_status"] = "IN_PROGRESS" + r = await client.post( + f"{API}/dcr/{dcr_id}/calls/doctor", headers=auth["mr1"], json=payload + ) + assert r.status_code == 201, r.text + + for i in range(2): + r = await client.post( + f"{API}/dcr/{dcr_id}/calls/chemist", + headers=auth["mr1"], + json={ + "chemist_id": chemists[i]["id"], + "visit_time": f"{15 + i:02d}:00:00", + "remarks": "Stock check", + }, + ) + assert r.status_code == 201, r.text + + # A duplicate doctor on the same report is refused (V5). + dup = await client.post( + f"{API}/dcr/{dcr_id}/calls/doctor", + headers=auth["mr1"], + json={ + "doctor_id": doctors[0]["id"], + "visit_time": "17:00:00", + "call_outcome": "MET", + }, + ) + assert dup.status_code == 409 + assert dup.json()["error"]["code"] == "CONFLICT" + + # --- Step 7: the draft persists ------------------------------- + resp = await client.get(f"{API}/dcr/{dcr_id}", headers=auth["mr1"]) + dcr = resp.json() + assert len(dcr["doctor_calls"]) == 5 + assert len(dcr["chemist_calls"]) == 2 + assert dcr["status"] == DCRStatus.DRAFT.value + + # A second report for the same date is refused (V1/A9). + again = await client.post( + f"{API}/dcr", headers=auth["mr1"], json={"report_date": today} + ) + assert again.status_code == 409 + + # --- Step 8: MR submits --------------------------------------- + resp = await client.post(f"{API}/dcr/{dcr_id}/submit", headers=auth["mr1"]) + assert resp.status_code == 200, resp.text + assert resp.json()["status"] == DCRStatus.PENDING_AM.value + assert resp.json()["submitted_at"] is not None + + # --- Step 9a: AM returns it ----------------------------------- + queue = await client.get(f"{API}/dcr?status=PENDING_AM", headers=auth["am1"]) + assert [r["id"] for r in queue.json()] == [dcr_id] + + # A reason is mandatory (V8). + no_reason = await client.post( + f"{API}/dcr/{dcr_id}/return", headers=auth["am1"], json={"reason": "bad"} + ) + assert no_reason.status_code == 422 + + resp = await client.post( + f"{API}/dcr/{dcr_id}/return", + headers=auth["am1"], + json={"reason": "Please add remarks for the two chemist visits."}, + ) + assert resp.status_code == 200, resp.text + returned = resp.json() + assert returned["status"] == DCRStatus.RETURNED.value + assert returned["returned_by_role"] == "AM" + assert "chemist visits" in returned["return_reason"] + + # The MR can edit again once returned. + edit = await client.patch( + f"{API}/dcr/{dcr_id}", + headers=auth["mr1"], + json={"mr_remarks": "Covered MG Road belt. Chemist remarks added."}, + ) + assert edit.status_code == 200 + + # --- Step 9b: MR resubmits ------------------------------------ + resp = await client.post(f"{API}/dcr/{dcr_id}/submit", headers=auth["mr1"]) + assert resp.json()["status"] == DCRStatus.PENDING_AM.value + # Resubmission clears the previous return. + assert resp.json()["return_reason"] is None + + # --- Step 10: the Area Manager gives the final approval ------- + # There is no General Manager stage, and the GM cannot approve. + gm_try = await client.post(f"{API}/dcr/{dcr_id}/approve", headers=auth["gm"], json={}) + assert gm_try.status_code == 403, gm_try.text + gone = await client.post(f"{API}/dcr/{dcr_id}/forward", headers=auth["am1"], json={}) + assert gone.status_code in (404, 405), gone.text + + am_approve = await client.post( + f"{API}/dcr/{dcr_id}/approve", + headers=auth["am1"], + json={"comment": "Approved for the month."}, + ) + assert am_approve.status_code == 200, am_approve.text + assert am_approve.json()["status"] == DCRStatus.APPROVED.value + approved_view = await client.get(f"{API}/dcr/{dcr_id}", headers=auth["gm"]) + assert approved_view.status_code == 200, approved_view.text + approved = approved_view.json() + assert approved["status"] == DCRStatus.APPROVED.value + assert approved["approved_at"] is not None + + # --- Step 11: the report is locked ---------------------------- + # APPROVED is the lock. There is no separate LOCKED status. + assert approved["is_locked"] is True + + locked_edit = await client.patch( + f"{API}/dcr/{dcr_id}", headers=auth["mr1"], json={"mr_remarks": "sneaky edit"} + ) + assert locked_edit.status_code == 409 + assert locked_edit.json()["error"]["code"] == "REPORT_LOCKED" + + locked_add = await client.post( + f"{API}/dcr/{dcr_id}/calls/doctor", + headers=auth["mr1"], + json={ + "doctor_id": doctors[9]["id"], + "visit_time": "18:00:00", + "call_outcome": "MET", + }, + ) + assert locked_add.status_code == 409 + + # No role can move an approved report anywhere (A6/Q6 — no reopen). + for role in ("gm", "admin"): + again = await client.post(f"{API}/dcr/{dcr_id}/approve", headers=auth[role], json={}) + assert again.status_code in (403, 409) + # The approving AM repeating the click changes nothing (idempotent), and is not an error. + repeat = await client.post(f"{API}/dcr/{dcr_id}/approve", headers=auth["am1"], json={}) + assert repeat.status_code == 200 and repeat.json()["approved_at"] == approved["approved_at"] + # ...but an approved report can still not be returned or reopened by anybody. + for role in ("gm", "am1", "admin", "mr1"): + back = await client.post(f"{API}/dcr/{dcr_id}/return", headers=auth[role], json={"reason": "reopen it please"}) + assert back.status_code in (403, 409), role + + # --- Step 12: MR, AM and GM each download the PDF ------------- + for role in ("mr1", "am1", "gm"): + pdf = await client.get(f"{API}/dcr/{dcr_id}/pdf", headers=auth[role]) + assert pdf.status_code == 200, f"{role}: {pdf.text}" + assert pdf.headers["content-type"] == "application/pdf" + assert pdf.content.startswith(b"%PDF-") + assert len(pdf.content) > 500 + + # --- Step 13: the audit history is complete ------------------- + history = await client.get( + f"{API}/audit/dcr/{dcr_id}/approval-history", headers=auth["gm"] + ) + assert history.status_code == 200, history.text + actions = [h["action"] for h in history.json()] + + # create → submit → return → submit → approve + assert actions == ["CREATE", "SUBMIT", "RETURN", "SUBMIT", "APPROVE"], actions + + entries = history.json() + assert entries[2]["actor_name"] == "Suresh Behera" + assert entries[2]["actor_role"] == "AM" + assert "chemist visits" in entries[2]["comment"] + # The final entry is the Area Manager's approval. + assert entries[-1]["actor_name"] == "Suresh Behera" + assert entries[-1]["actor_role"] == "AM" + assert entries[-1]["comment"] == "Approved for the month." + assert all(e["at"] for e in entries) + + +# --------------------------------------------------------------------------- +# Negative-scope tests — X1, X2, X3 +# --------------------------------------------------------------------------- + + +class TestNegativeScope: + async def _submitted_report(self, client, auth, org): + doctors, _ = await _create_masters(client, auth, org, n_doctors=2, n_chemists=1) + resp = await client.post( + f"{API}/dcr", headers=auth["mr1"], json={"report_date": date.today().isoformat()} + ) + dcr_id = resp.json()["id"] + await client.post( + f"{API}/dcr/{dcr_id}/calls/doctor", + headers=auth["mr1"], + json={ + "doctor_id": doctors[0]["id"], + "visit_time": "10:00:00", + "call_outcome": "MET", + }, + ) + await client.post(f"{API}/dcr/{dcr_id}/submit", headers=auth["mr1"]) + return dcr_id + + async def test_x1_second_mr_cannot_see_the_first_mrs_report(self, client, auth, org): + dcr_id = await self._submitted_report(client, auth, org) + + resp = await client.get(f"{API}/dcr/{dcr_id}", headers=auth["mr2"]) + assert resp.status_code == 403, resp.text + assert resp.json()["error"]["code"] == "FORBIDDEN" + + # It must not appear in their list either. + listing = await client.get(f"{API}/dcr", headers=auth["mr2"]) + assert listing.json() == [] + + async def test_x2_area_manager_of_another_hq_cannot_see_it(self, client, auth, org): + dcr_id = await self._submitted_report(client, auth, org) + + resp = await client.get(f"{API}/dcr/{dcr_id}", headers=auth["am2"]) + assert resp.status_code == 403, resp.text + + # And cannot act on it. + for action, body in (("approve", {}), ("return", {"reason": "Not my headquarters at all"})): + assert ( + await client.post(f"{API}/dcr/{dcr_id}/{action}", headers=auth["am2"], json=body) + ).status_code == 403 + + listing = await client.get(f"{API}/dcr?status=PENDING_AM", headers=auth["am2"]) + assert listing.json() == [] + + async def test_x3_admin_cannot_approve(self, client, auth, org): + """SEC-2 — the single most important governance rule in the design.""" + dcr_id = await self._submitted_report(client, auth, org) + + resp = await client.post(f"{API}/dcr/{dcr_id}/approve", headers=auth["admin"], json={}) + assert resp.status_code == 403, resp.text + + # Admin may inspect report content but cannot approve it. + assert ( + await client.get(f"{API}/dcr/{dcr_id}", headers=auth["admin"]) + ).status_code == 200 + + async def test_admin_cannot_create_a_report(self, client, auth): + resp = await client.post( + f"{API}/dcr", headers=auth["admin"], json={"report_date": date.today().isoformat()} + ) + assert resp.status_code == 403 + + async def test_deactivated_user_loses_access_immediately(self, client, auth, org): + """SEC-5 — is_active is checked on every request, not only at login.""" + assert (await client.get(f"{API}/dcr", headers=auth["mr1"])).status_code == 200 + + deact = await client.patch( + f"{API}/users/{org['mr1'].id}", headers=auth["admin"], json={"is_active": False} + ) + assert deact.status_code == 200 + + assert (await client.get(f"{API}/dcr", headers=auth["mr1"])).status_code == 401 + + +# --------------------------------------------------------------------------- +# Validation rules +# --------------------------------------------------------------------------- + + +class TestValidationRules: + async def test_v2_future_date_rejected(self, client, auth, org): + from datetime import timedelta + + future = (date.today() + timedelta(days=1)).isoformat() + resp = await client.post(f"{API}/dcr", headers=auth["mr1"], json={"report_date": future}) + assert resp.status_code == 422 + assert resp.json()["error"]["code"] == "VALIDATION_ERROR" + + async def test_v3_beyond_backdating_window_rejected(self, client, auth, org): + from datetime import timedelta + + from app.config.settings import settings + + old = (date.today() - timedelta(days=settings.BACKDATING_WINDOW_DAYS + 1)).isoformat() + resp = await client.post(f"{API}/dcr", headers=auth["mr1"], json={"report_date": old}) + assert resp.status_code == 422 + assert "back-dating" in resp.json()["error"]["message"] + + async def test_v4_cannot_submit_without_a_doctor_call(self, client, auth, org): + resp = await client.post( + f"{API}/dcr", headers=auth["mr1"], json={"report_date": date.today().isoformat()} + ) + dcr_id = resp.json()["id"] + + submit = await client.post(f"{API}/dcr/{dcr_id}/submit", headers=auth["mr1"]) + assert submit.status_code == 422 + assert "at least one doctor call" in submit.json()["error"]["message"] + + async def test_v6_unassigned_doctor_rejected(self, client, auth, org): + """A doctor from another HQ, not assigned to this MR.""" + other = await client.post( + f"{API}/doctors", + headers=auth["admin"], + json={ + "headquarters_id": str(org["hq2"].id), + "name": "Dr Outsider", + "clinic_address": "Sambalpur", + }, + ) + resp = await client.post( + f"{API}/dcr", headers=auth["mr1"], json={"report_date": date.today().isoformat()} + ) + dcr_id = resp.json()["id"] + + call = await client.post( + f"{API}/dcr/{dcr_id}/calls/doctor", + headers=auth["mr1"], + json={ + "doctor_id": other.json()["id"], + "visit_time": "10:00:00", + "call_outcome": "MET", + }, + ) + assert call.status_code == 422 + assert "not assigned" in call.json()["error"]["message"] + + async def test_v7_conversion_status_only_for_core_doctors(self, client, auth, org): + doctors, _ = await _create_masters(client, auth, org, n_doctors=5, n_chemists=1) + non_core = next(d for d in doctors if not d["is_core_doctor"]) + + resp = await client.post( + f"{API}/dcr", headers=auth["mr1"], json={"report_date": date.today().isoformat()} + ) + dcr_id = resp.json()["id"] + + call = await client.post( + f"{API}/dcr/{dcr_id}/calls/doctor", + headers=auth["mr1"], + json={ + "doctor_id": non_core["id"], + "visit_time": "10:00:00", + "call_outcome": "MET", + "conversion_status": "CONVERTED", + }, + ) + assert call.status_code == 422 + assert "core doctor" in call.json()["error"]["message"] + + async def test_cannot_edit_while_pending_with_the_manager(self, client, auth, org): + doctors, _ = await _create_masters(client, auth, org, n_doctors=2, n_chemists=1) + resp = await client.post( + f"{API}/dcr", headers=auth["mr1"], json={"report_date": date.today().isoformat()} + ) + dcr_id = resp.json()["id"] + await client.post( + f"{API}/dcr/{dcr_id}/calls/doctor", + headers=auth["mr1"], + json={ + "doctor_id": doctors[0]["id"], + "visit_time": "10:00:00", + "call_outcome": "MET", + }, + ) + await client.post(f"{API}/dcr/{dcr_id}/submit", headers=auth["mr1"]) + + edit = await client.patch( + f"{API}/dcr/{dcr_id}", headers=auth["mr1"], json={"mr_remarks": "late change"} + ) + assert edit.status_code == 409 + assert edit.json()["error"]["code"] == "REPORT_LOCKED" + + async def test_pdf_unavailable_before_approval(self, client, auth, org): + doctors, _ = await _create_masters(client, auth, org, n_doctors=2, n_chemists=1) + resp = await client.post( + f"{API}/dcr", headers=auth["mr1"], json={"report_date": date.today().isoformat()} + ) + dcr_id = resp.json()["id"] + + pdf = await client.get(f"{API}/dcr/{dcr_id}/pdf", headers=auth["mr1"]) + assert pdf.status_code == 422 + assert "finally approved" in pdf.json()["error"]["message"] + + +class TestStatusCounts: + async def test_counts_replace_the_dashboard(self, client, auth, org): + doctors, _ = await _create_masters(client, auth, org, n_doctors=2, n_chemists=1) + resp = await client.post( + f"{API}/dcr", headers=auth["mr1"], json={"report_date": date.today().isoformat()} + ) + assert resp.status_code == 201 + + counts = await client.get(f"{API}/dcr/counts", headers=auth["mr1"]) + assert counts.status_code == 200 + assert counts.json()["DRAFT"] == 1 + assert counts.json()["APPROVED"] == 0 diff --git a/tests/e2e/test_user_credentials.py b/tests/e2e/test_user_credentials.py new file mode 100644 index 0000000..6de84e5 --- /dev/null +++ b/tests/e2e/test_user_credentials.py @@ -0,0 +1,78 @@ +"""An Administrator can change any user's sign-in credentials; nobody else can.""" + +from tests.conftest import DEFAULT_PASSWORD + +API = "/api/v1" +NEW_PASSWORD = "Brand-New-Pass-42" + + +async def _login(client, email, password): + return await client.post(f"{API}/auth/login", json={"email": email, "password": password}) + + +class TestAdminChangesCredentials: + async def test_password_reset_replaces_the_old_password(self, client, auth, org): + resp = await client.patch(f"{API}/users/{org['mr1'].id}", headers=auth["admin"], json={"password": NEW_PASSWORD}) + assert resp.status_code == 200, resp.text + assert "password" not in resp.json() and "password_hash" not in resp.json() + assert (await _login(client, org["mr1"].email, DEFAULT_PASSWORD)).status_code == 401 + assert (await _login(client, org["mr1"].email, NEW_PASSWORD)).status_code == 200 + + async def test_password_reset_signs_the_user_out_everywhere(self, client, org, auth): + first = await _login(client, org["mr1"].email, DEFAULT_PASSWORD) + old_refresh = first.json()["refresh_token"] + await client.patch(f"{API}/users/{org['mr1'].id}", headers=auth["admin"], json={"password": NEW_PASSWORD}) + again = await client.post(f"{API}/auth/refresh", json={"refresh_token": old_refresh}) + assert again.status_code == 401 + + async def test_password_reset_unlocks_a_locked_account(self, client, auth, org, db): + org["mr1"].failed_login_attempts = 99 + await db.commit() + assert (await _login(client, org["mr1"].email, DEFAULT_PASSWORD)).status_code == 401 + await client.patch(f"{API}/users/{org['mr1'].id}", headers=auth["admin"], json={"password": NEW_PASSWORD}) + assert (await _login(client, org["mr1"].email, NEW_PASSWORD)).status_code == 200 + + async def test_email_change_moves_the_login(self, client, auth, org): + resp = await client.patch(f"{API}/users/{org['mr1'].id}", headers=auth["admin"], json={"email": "Ravi.New@Acmepharma.in"}) + assert resp.status_code == 200, resp.text + assert resp.json()["email"] == "ravi.new@acmepharma.in" # stored lower-case, as at creation + assert (await _login(client, org["mr1"].email, DEFAULT_PASSWORD)).status_code == 401 + assert (await _login(client, "ravi.new@acmepharma.in", DEFAULT_PASSWORD)).status_code == 200 + + async def test_employee_code_and_phone_can_change(self, client, auth, org): + resp = await client.patch(f"{API}/users/{org['mr1'].id}", headers=auth["admin"], json={"employee_code": "MR777", "phone": "9000000001"}) + assert resp.status_code == 200, resp.text + assert resp.json()["employee_code"] == "MR777" + + async def test_duplicate_email_or_code_is_a_clean_409(self, client, auth, org): + dup_email = await client.patch(f"{API}/users/{org['mr1'].id}", headers=auth["admin"], json={"email": org["mr2"].email}) + assert dup_email.status_code == 409, dup_email.text + dup_code = await client.patch(f"{API}/users/{org['mr1'].id}", headers=auth["admin"], json={"employee_code": org["mr2"].employee_code}) + assert dup_code.status_code == 409, dup_code.text + # ...and the user is untouched afterwards. + assert (await _login(client, org["mr1"].email, DEFAULT_PASSWORD)).status_code == 200 + + async def test_weak_password_and_bad_email_are_rejected(self, client, auth, org): + assert (await client.patch(f"{API}/users/{org['mr1'].id}", headers=auth["admin"], json={"password": "short"})).status_code == 422 + assert (await client.patch(f"{API}/users/{org['mr1'].id}", headers=auth["admin"], json={"email": "not-an-email"})).status_code == 422 + + async def test_only_the_admin_can_change_credentials(self, client, auth, org): + for who in ("gm", "am1", "mr1", "mr2"): + resp = await client.patch(f"{API}/users/{org['mr1'].id}", headers=auth[who], json={"password": NEW_PASSWORD}) + assert resp.status_code == 403, (who, resp.text) + + async def test_the_password_never_reaches_the_audit_log(self, client, auth, org, db): + from sqlalchemy import select + + from app.audit.models import AuditLog + + await client.patch(f"{API}/users/{org['mr1'].id}", headers=auth["admin"], json={"password": NEW_PASSWORD}) + rows = (await db.execute(select(AuditLog).where(AuditLog.entity_id == org["mr1"].id))).scalars().all() + blob = " ".join(f"{r.before_data} {r.after_data}" for r in rows) + assert NEW_PASSWORD not in blob and "password_hash" not in blob + assert any(r.after_data and r.after_data.get("password_reset") for r in rows) + + async def test_admin_can_reset_their_own_password(self, client, auth, org): + resp = await client.patch(f"{API}/users/{org['admin'].id}", headers=auth["admin"], json={"password": NEW_PASSWORD}) + assert resp.status_code == 200, resp.text + assert (await _login(client, org["admin"].email, NEW_PASSWORD)).status_code == 200 diff --git a/tests/integration/__init__.py b/tests/integration/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/integration/test_db_constraints.py b/tests/integration/test_db_constraints.py new file mode 100644 index 0000000..bbdbebb --- /dev/null +++ b/tests/integration/test_db_constraints.py @@ -0,0 +1,195 @@ +"""Database-level guarantees. + +These are the constraints the service layer alone cannot guarantee — under +concurrency, only the database can. Each of these was called out in the report as a +schema-level rule that cannot be retrofitted cheaply. +""" + +import uuid +from datetime import date, time, timedelta + +import pytest +from sqlalchemy.exc import IntegrityError + +from app.common.enums import CallOutcome, DCRStatus +from app.doctors.models import Doctor +from app.organization.models import AMHeadquarters +from app.reports.models import DailyCallReport, DoctorCall + + +async def _doctor(db, hq_id, name="Dr Sen", clinic="MG Road"): + doc = Doctor(id=uuid.uuid4(), headquarters_id=hq_id, name=name, clinic_address=clinic) + db.add(doc) + await db.flush() + return doc + + +class TestOneReportPerMRPerDay: + """V1 / A9 — the constraint the report flagged as the missing piece of the MVP.""" + + async def test_duplicate_date_rejected(self, db, org): + for _ in range(2): + db.add( + DailyCallReport( + id=uuid.uuid4(), + mr_user_id=org["mr1"].id, + headquarters_id=org["hq1"].id, + report_date=date.today(), + status=DCRStatus.DRAFT, + ) + ) + with pytest.raises(IntegrityError): + await db.flush() + + async def test_different_dates_allowed(self, db, org): + for offset in (0, 1): + db.add( + DailyCallReport( + id=uuid.uuid4(), + mr_user_id=org["mr1"].id, + headquarters_id=org["hq1"].id, + report_date=date.today() - timedelta(days=offset), + status=DCRStatus.DRAFT, + ) + ) + await db.flush() # must not raise + + async def test_different_mrs_same_date_allowed(self, db, org): + for mr, hq in (("mr1", "hq1"), ("mr2", "hq2")): + db.add( + DailyCallReport( + id=uuid.uuid4(), + mr_user_id=org[mr].id, + headquarters_id=org[hq].id, + report_date=date.today(), + status=DCRStatus.DRAFT, + ) + ) + await db.flush() # must not raise + + +class TestNoDuplicateDoctorCall: + """V5 / A11.""" + + async def test_same_doctor_twice_on_one_report_rejected(self, db, org): + doctor = await _doctor(db, org["hq1"].id) + dcr = DailyCallReport( + id=uuid.uuid4(), + mr_user_id=org["mr1"].id, + headquarters_id=org["hq1"].id, + report_date=date.today(), + status=DCRStatus.DRAFT, + ) + db.add(dcr) + await db.flush() + + for hour in (10, 16): + db.add( + DoctorCall( + dcr_id=dcr.id, + doctor_id=doctor.id, + visit_time=time(hour, 0), + call_outcome=CallOutcome.MET, + ) + ) + with pytest.raises(IntegrityError): + await db.flush() + + +class TestOneActiveAreaManagerPerHQ: + """The partial unique index `uq_active_am_per_hq`.""" + + async def test_second_active_am_rejected(self, db, org): + db.add( + AMHeadquarters( + area_manager_user_id=org["am2"].id, + headquarters_id=org["hq1"].id, # already managed by am1 + effective_from=date.today(), + ) + ) + with pytest.raises(IntegrityError): + await db.flush() + + async def test_allowed_once_previous_mapping_is_closed(self, db, org): + existing = ( + await db.execute( + AMHeadquarters.__table__.select().where( + AMHeadquarters.headquarters_id == org["hq1"].id + ) + ) + ).first() + assert existing is not None + + await db.execute( + AMHeadquarters.__table__.update() + .where(AMHeadquarters.headquarters_id == org["hq1"].id) + .values(effective_to=date.today()) + ) + db.add( + AMHeadquarters( + area_manager_user_id=org["am2"].id, + headquarters_id=org["hq1"].id, + effective_from=date.today(), + ) + ) + await db.flush() # must not raise + + +class TestMRRequiresHeadquarters: + """The `ck_user_mr_requires_hq` check — R4/R8 enforced in the schema.""" + + async def test_mr_without_hq_rejected(self, db, org): + from app.auth.security import hash_password + from app.common.enums import Role + from app.users.models import User + + db.add( + User( + id=uuid.uuid4(), + company_id=org["company"].id, + email="orphan@acmepharma.in", + password_hash=hash_password("x" * 12), + full_name="Orphan MR", + employee_code="MR999", + role=Role.MR, + headquarters_id=None, + ) + ) + with pytest.raises(IntegrityError): + await db.flush() + + async def test_gm_with_hq_rejected(self, db, org): + from app.auth.security import hash_password + from app.common.enums import Role + from app.users.models import User + + db.add( + User( + id=uuid.uuid4(), + company_id=org["company"].id, + email="gm2@acmepharma.in", + password_hash=hash_password("x" * 12), + full_name="Wrong GM", + employee_code="GM999", + role=Role.GM, + headquarters_id=org["hq1"].id, + ) + ) + with pytest.raises(IntegrityError): + await db.flush() + + +class TestApprovedAtConsistency: + async def test_approved_without_timestamp_rejected(self, db, org): + db.add( + DailyCallReport( + id=uuid.uuid4(), + mr_user_id=org["mr1"].id, + headquarters_id=org["hq1"].id, + report_date=date.today(), + status=DCRStatus.APPROVED, + approved_at=None, + ) + ) + with pytest.raises(IntegrityError): + await db.flush() diff --git a/tests/unit/__init__.py b/tests/unit/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/unit/test_business_timezone.py b/tests/unit/test_business_timezone.py new file mode 100644 index 0000000..65e6a9d --- /dev/null +++ b/tests/unit/test_business_timezone.py @@ -0,0 +1,71 @@ +"""Visit times and report dates are judged in the company's timezone, not the server's UTC. + +Regression: the server clock is UTC, so at 12:35 IST (07:05 UTC) an MR who logged a +09:00 visit was told it was "in the future", and around midnight IST "today" was +still yesterday. +""" + +from datetime import date, datetime, time +from types import SimpleNamespace +from zoneinfo import ZoneInfo + +import pytest + +from app.common.exceptions import ValidationError +from app.reports import service as svc + +IST = ZoneInfo("Asia/Kolkata") + + +@pytest.fixture +def at(monkeypatch): + """Freeze 'now' to a given IST moment and switch the production-only rule on.""" + + def _freeze(year, month, day, hour, minute): + now = datetime(year, month, day, hour, minute, tzinfo=IST) + monkeypatch.setattr(svc, "local_now", lambda: now) + monkeypatch.setattr(svc, "local_today", lambda: now.date()) + monkeypatch.setattr(svc.settings, "ENVIRONMENT", "production") + return now + + return _freeze + + +def _service() -> svc.DCRService: + return svc.DCRService.__new__(svc.DCRService) # the checks under test need no database + + +def _report(day: date) -> SimpleNamespace: + return SimpleNamespace(report_date=day) + + +class TestVisitTime: + def test_a_morning_visit_is_accepted_at_lunchtime_ist(self, at): + at(2026, 9, 21, 12, 35) # 07:05 UTC — the old code rejected everything after 07:05 + _service()._validate_visit_time(_report(date(2026, 9, 21)), time(9, 0)) + + def test_a_visit_later_today_is_still_rejected(self, at): + at(2026, 9, 21, 12, 35) + with pytest.raises(ValidationError): + _service()._validate_visit_time(_report(date(2026, 9, 21)), time(18, 0)) + + def test_past_days_accept_any_time(self, at): + at(2026, 9, 21, 12, 35) + _service()._validate_visit_time(_report(date(2026, 9, 20)), time(23, 59)) + + +class TestReportDate: + def test_today_is_todays_ist_date_just_after_midnight(self, at): + at(2026, 9, 21, 1, 0) # still 20 Sep in UTC + _service()._validate_report_date(date(2026, 9, 21)) + + def test_tomorrow_is_rejected(self, at): + at(2026, 9, 21, 1, 0) + with pytest.raises(ValidationError): + _service()._validate_report_date(date(2026, 9, 22)) + + +def test_local_helpers_use_the_configured_timezone(): + from app.common.utils import local_now + + assert str(local_now().tzinfo) == "Asia/Kolkata" diff --git a/tests/unit/test_csv_access_for_am.py b/tests/unit/test_csv_access_for_am.py new file mode 100644 index 0000000..5c90624 --- /dev/null +++ b/tests/unit/test_csv_access_for_am.py @@ -0,0 +1,38 @@ +import pytest +from sqlalchemy import text + +pytestmark = pytest.mark.anyio + +API = "/api/v1" + + +async def test_am_can_list_only_approval_csv_tables_and_download_approval_pdf(client, auth, db): + await db.execute( + text( + ''' + CREATE TABLE IF NOT EXISTS "fare_chart" ( + id UUID PRIMARY KEY, + source_row_number INTEGER, + name TEXT, + headquarter TEXT, + serial_no TEXT, + report_date TEXT, + from_location TEXT, + to_location TEXT, + kilometers_km TEXT, + owner_user_id UUID + ) + ''' + ) + ) + await db.commit() + + resp = await client.get(f"{API}/csv-data/tables", headers=auth["am1"]) + assert resp.status_code == 200, resp.text + table_names = {item["name"] for item in resp.json()} + assert table_names == {"standard_tour_plan", "tour_plan", "fare_chart"} + assert "daily_call_report_csv" not in table_names + + pdf = await client.get(f"{API}/csv-data/fare_chart/pdf", headers=auth["am1"]) + assert pdf.status_code == 200, pdf.text + assert pdf.headers["content-type"].startswith("application/pdf") diff --git a/tests/unit/test_csv_form_pdfs.py b/tests/unit/test_csv_form_pdfs.py new file mode 100644 index 0000000..39ecba1 --- /dev/null +++ b/tests/unit/test_csv_form_pdfs.py @@ -0,0 +1,205 @@ +"""Company-form PDF layouts: what each form prints, independent of the PDF engine.""" + +import pytest + +from app.csv_data.config import CSV_LABELS, TABLES +from app.pdf.forms import build_form_context +from app.pdf.service import _html_to_text, _minimal_pdf, csv_pdf_bytes, csv_table_pdf_bytes + + +def _rows(table: str, count: int = 2, **values) -> list[dict[str, object]]: + return [ + {**{c: "" for c in TABLES[table]}, "serial_no": str(i + 1), **values} for i in range(count) + ] + + +def _ctx(table: str, rows, **kw): + return build_form_context(table, CSV_LABELS[table], TABLES[table], rows, **kw) + + +def test_every_form_has_its_own_template(): + templates = {_ctx(name, [])["template"] for name in TABLES} + assert len(templates) == len(TABLES) + + +def test_every_stored_row_is_printed_and_blank_lines_pad_to_the_form_length(): + ctx = _ctx("tour_plan", _rows("tour_plan", 3, from_location="BBSR", pob="10")) + body = ctx["grids"]["main"]["rows"] + assert len(body) == 25 + assert [r["blank"] for r in body[:4]] == [False, False, False, True] + assert body[0]["cells"][2] == "BBSR" + + +def test_rows_beyond_the_printed_form_length_are_not_dropped(): + ctx = _ctx("standard_tour_plan", _rows("standard_tour_plan", 40, place="Puri")) + assert len(ctx["grids"]["main"]["rows"]) == 40 + + +def test_identity_is_gathered_from_all_rows_not_just_the_first(): + rows = _rows("fare_chart", 2) + rows[0]["name"], rows[1]["name"] = "", "Ravi Das" + assert _ctx("fare_chart", rows)["meta_rows"][0][0] == ("NAME:", "Ravi Das") + + +# Headings exactly as printed on the company forms, in printed order. +PRINTED_HEADERS = { + "tour_plan": ["Sl.No.", "Date", "From", "To", "POB", "Stockiest Visit"], + "standard_tour_plan": ["Sl.No.", "PLACE"], + "fare_chart": ["Sl.No.", "Date", "From", "To", "Kilometers (KM)"], + "area_covered": ["SALE STATUS", "AREA TO COVER", "SALE OBJECTIVE", "STATUS"], + "core_dr_call_conversion": ["DOCTOR NAME", "DATE OF VISIT", "PRODUCT TARGETED", "STATUS"], + "field_activity_report": [ + "DATE", + "STATION WORKED", + "NO. OF DOCTORS CALLED", + "NO. OF CHEMISTS/PDS CALLED", + ], + "sales_and_stock_statement": [ + "Sl.No.", + "Name of the Product", + "Opening", + "Receipt", + "Sale", + "Closing", + "Value in PTS", + ], + "sales_projection": [ + "SL. No.", + "NAME OF THE PRODUCT", + "PTS", + "SEC. QTY", + "VALUE", + "CLOSING", + "SEC. VALUE", + "AUG. SALES", + "VALUE", + ], +} +PRINTED_LINES = { + "tour_plan": 25, + "standard_tour_plan": 25, + "fare_chart": 25, + "area_covered": 28, + "core_dr_call_conversion": 28, + "field_activity_report": 25, + "sales_and_stock_statement": 26, + "sales_projection": 26, +} + + +@pytest.mark.parametrize("table", list(PRINTED_HEADERS)) +def test_form_headings_and_ruled_lines_match_the_printed_form(table): + grid = _ctx(table, [])["grids"]["main"] + assert grid["headers"] == PRINTED_HEADERS[table] + assert len(grid["rows"]) == PRINTED_LINES[table] + assert all(r["blank"] for r in grid["rows"]) + + +def test_daily_call_report_has_both_printed_tables(): + grids = _ctx("daily_call_report_csv", [])["grids"] + assert grids["doctors"]["headers"] == [ + "SR. NO.", + "DR. NAME", + "QUALIFICATION", + "PRODUCT PROMOTE", + "PRODUCT SAMPLE", + "REMARKS", + ] + assert len(grids["doctors"]["rows"]) == 10 + assert grids["chemists"]["headers"] == ["SR. NO.", "NAME OF THE CHEMIST", "POB"] + assert len(grids["chemists"]["rows"]) == 5 + + +def test_blank_lines_carry_on_numbering_and_tour_plan_numbers_have_a_dot(): + body = _ctx("tour_plan", _rows("tour_plan", 2))["grids"]["main"]["rows"] + assert [r["cells"][0] for r in body[:4]] == ["1.", "2.", "3.", "4."] + body = _ctx("sales_projection", _rows("sales_projection", 1))["grids"]["main"]["rows"] + assert [r["cells"][0] for r in body[:3]] == ["1", "2", "3"] + + +def test_product_lists_print_in_their_own_columns(): + rows = _rows("sales_projection", 2) + rows[0].update(product_name="INTEZOLE-PD", pts="106.92") + rows[1].update(product_name="INTEZOLE-RD", pts="93.59", secondary_qty="4") + cells = [r["cells"] for r in _ctx("sales_projection", rows)["grids"]["main"]["rows"][:2]] + assert cells[0][:3] == ["1", "INTEZOLE-PD", "106.92"] + assert cells[1][:4] == ["2", "INTEZOLE-RD", "93.59", "4"] + + +def test_no_form_prints_dashboard_extras(): + for table in TABLES: + ctx = _ctx(table, _rows(table, 2, pob="5", kilometers_km="9")) + for grid in ctx["grids"].values(): + assert "totals" not in grid + assert "stats_items" not in ctx + + +def test_import_script_columns_match_the_tables(): + """A drifted column list rolled back the whole import, leaving the product lists empty.""" + from scripts.import_csv_data import CSV_TABLES + + for table, columns in CSV_TABLES.values(): + assert tuple(columns) == TABLES[table], table + + +def test_iso_dates_print_day_first_and_free_text_is_untouched(): + rows = _rows("fare_chart", 2) + rows[0]["report_date"], rows[1]["report_date"] = "2026-09-18", "week 3" + cells = [r["cells"][1] for r in _ctx("fare_chart", rows)["grids"]["main"]["rows"][:2]] + assert cells == ["18/09/2026", "week 3"] + + +def test_stored_serial_numbers_are_kept_for_single_row_pdfs(): + rows = _rows("tour_plan", 1) + rows[0]["serial_no"] = "7" + assert _ctx("tour_plan", rows)["grids"]["main"]["rows"][0]["cells"][0] == "7." + + +def test_weekly_report_prints_one_report_per_stored_row(): + rows = _rows("weekly_report", 3, employee_name="Ravi", pob_booked="5") + assert len(_ctx("weekly_report", rows)["reports"]) == 3 + + +def test_daily_call_report_splits_doctor_and_chemist_lines(): + rows = _rows("daily_call_report_csv", 3) + rows[0]["doctor_name"] = "Dr. A" + rows[1]["chemist_name"], rows[1]["pob"] = "Sahu Medical", "100" + rows[2]["stockist_visit"], rows[2]["order_value"] = "Yes", "5000" + ctx = _ctx("daily_call_report_csv", rows) + assert ctx["grids"]["doctors"]["rows"][0]["cells"][:2] == ["1", "Dr. A"] + assert ctx["grids"]["chemists"]["rows"][0]["cells"][:2] == ["1", "Sahu Medical"] + assert (ctx["stockist_visit"], ctx["order_value"]) == ("Yes", "5000") + + +def test_only_approval_forms_carry_an_approval_block(): + assert _ctx("fare_chart", [], approval_status="approved", am_name="Meera")["approval"][ + "line" + ] == ("APPROVAL SIGNATURE: Meera") + assert _ctx("fare_chart", [])["approval"]["value"] == "PENDING" + assert _ctx("sales_and_stock_statement", [])["approval"] is None + + +@pytest.mark.parametrize("table", list(TABLES)) +def test_every_form_renders_a_pdf_even_when_empty_or_hostile(table): + rows = _rows(table, 2, **{c: "")])) + assert " + diff --git a/web/package-lock.json b/web/package-lock.json new file mode 100644 index 0000000..b496007 --- /dev/null +++ b/web/package-lock.json @@ -0,0 +1,1798 @@ +{ + "name": "pharma-field-force-web", + "version": "0.1.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "pharma-field-force-web", + "version": "0.1.0", + "dependencies": { + "@vitejs/plugin-react": "^4.3.4", + "react": "^18.3.1", + "react-dom": "^18.3.1", + "vite": "^6.0.7" + }, + "devDependencies": { + "@types/react": "^18.3.18", + "@types/react-dom": "^18.3.5", + "typescript": "~5.7.3" + } + }, + "node_modules/@babel/code-frame": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.29.7.tgz", + "integrity": "sha512-Aup7aUOfpbAUg2ROOJN6Iw5f9DMBlzu0mIkm/malLQFN/YQgO48wCj0Kxa3sEHJvPVFg7siR+qRInwXd2qhQKw==", + "license": "MIT", + "dependencies": { + "@babel/helper-validator-identifier": "^7.29.7", + "js-tokens": "^4.0.0", + "picocolors": "^1.1.1" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/compat-data": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.29.7.tgz", + "integrity": "sha512-locTkQyKvwIEgBzVrn8693ebc97F2U8ZHjbXwDXJ5Fn2TCpNwTlKcaKLkdHop5c/icOFE7qt7Q9JC5hnKNa6Gg==", + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/core": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.29.7.tgz", + "integrity": "sha512-RgHBCvtjbOK2gXSNBNIkNoEc9qoVEtau3hj8gEqKQuL3HZAibKarWFEI3Lfm6EYKkLalOh8eSrj9b+ch9H/VBA==", + "license": "MIT", + "dependencies": { + "@babel/code-frame": "^7.29.7", + "@babel/generator": "^7.29.7", + "@babel/helper-compilation-targets": "^7.29.7", + "@babel/helper-module-transforms": "^7.29.7", + "@babel/helpers": "^7.29.7", + "@babel/parser": "^7.29.7", + "@babel/template": "^7.29.7", + "@babel/traverse": "^7.29.7", + "@babel/types": "^7.29.7", + "@jridgewell/remapping": "^2.3.5", + "convert-source-map": "^2.0.0", + "debug": "^4.1.0", + "gensync": "^1.0.0-beta.2", + "json5": "^2.2.3", + "semver": "^6.3.1" + }, + "engines": { + "node": ">=6.9.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/babel" + } + }, + "node_modules/@babel/generator": { + "version": "7.29.8", + "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.29.8.tgz", + "integrity": "sha512-gZbepsdh3WDtgZKWL+vTPh71LSBrm/Y4/QDZBVCcYfmeTEEuoOYwlSy+G1StfJg+/Zy550u/3TATbm7qDbbMtg==", + "license": "MIT", + "dependencies": { + "@babel/parser": "^7.29.8", + "@babel/types": "^7.29.8", + "@jridgewell/gen-mapping": "^0.3.12", + "@jridgewell/trace-mapping": "^0.3.28", + "jsesc": "^3.0.2" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-compilation-targets": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/helper-compilation-targets/-/helper-compilation-targets-7.29.7.tgz", + "integrity": "sha512-wem6WaBj4NaVYVdNhLPPVacES6ZJ+KBBfSkTMD3YZxbP3rm3Di85tJU5ljaUNhaOynt+Aj0xruhYuzQBt8n71g==", + "license": "MIT", + "dependencies": { + "@babel/compat-data": "^7.29.7", + "@babel/helper-validator-option": "^7.29.7", + "browserslist": "^4.24.0", + "lru-cache": "^5.1.1", + "semver": "^6.3.1" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-globals": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/helper-globals/-/helper-globals-7.29.7.tgz", + "integrity": "sha512-3nQVUAtvkKH9zahfWgw96Jc/uFOmjACE1kQz82E2lqWmHBgjzbNlsC22nuQTfahmWeQtTq5nQ/4Nnd2A1wj4zA==", + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-module-imports": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/helper-module-imports/-/helper-module-imports-7.29.7.tgz", + "integrity": "sha512-ejHwrQQYcm9xnTivShn2IDOlIzInN34AXskvq9QicvCtEzq1Vzclu/tKF8Jq1Cg8JG2GL6/EmjgsCT7lXepE3g==", + "license": "MIT", + "dependencies": { + "@babel/traverse": "^7.29.7", + "@babel/types": "^7.29.7" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-module-transforms": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/helper-module-transforms/-/helper-module-transforms-7.29.7.tgz", + "integrity": "sha512-UPUVSyXbOh627KiCIGQSgwWzGeBKLkaJ9PJEdrngIwMSzxLR4jS4+f1f1jb7VzBbg8nFLaYotvVPFCTqdrmTAg==", + "license": "MIT", + "dependencies": { + "@babel/helper-module-imports": "^7.29.7", + "@babel/helper-validator-identifier": "^7.29.7", + "@babel/traverse": "^7.29.7" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0" + } + }, + "node_modules/@babel/helper-plugin-utils": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/helper-plugin-utils/-/helper-plugin-utils-7.29.7.tgz", + "integrity": "sha512-G7sHYigPY17oO5SYWnfD/0MTBwVR781S/JI643e/JhUYgVgWE/61SoW3NH9KWUKyKq5LVh3npif99Wkt6j86Jw==", + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-string-parser": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.29.7.tgz", + "integrity": "sha512-Pb5ijPrZ89GDH8223L4UP8i6QApWxs04RbPQJTeWDV0/keR2E36MeKnyr6LYmUUvqRRI+Iv87SuF1W6ErINzYw==", + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-validator-identifier": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.29.7.tgz", + "integrity": "sha512-qehxGkRj55h/ff8EMaJ+cYhyaKlHIxqYDn682wQD7RNp9UujOQsHog2uS0r2vzr4pW+sXf90NeeayjcNaX3fFg==", + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-validator-option": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-option/-/helper-validator-option-7.29.7.tgz", + "integrity": "sha512-N9ZErrD+yW5geCDtBqnOoxmR8+tNKiGuxKlDpuJxfsqpa2dFcexaziGAE/qoHLiDDreVNMupxGmSoNlyvsA3gw==", + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helpers": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.29.7.tgz", + "integrity": "sha512-1k2lAGRMfHTcwuNYcCNUmaUffmQv8KWMfh2iJUUeRlwlwH4FdNG7mfPI10NPfLHJFThE4Tyr4mv7kTNZOiPuBg==", + "license": "MIT", + "dependencies": { + "@babel/template": "^7.29.7", + "@babel/types": "^7.29.7" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/parser": { + "version": "7.29.8", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.29.8.tgz", + "integrity": "sha512-E8lTAYNB1KW+FH+VGJuZM1ioAx2E6oVlvQFRrf5P8ZZmsiJXYAD9vTFV7yyEURNzgh1dFqMZuO6tUwcARbqFCA==", + "license": "MIT", + "dependencies": { + "@babel/types": "^7.29.8" + }, + "bin": { + "parser": "bin/babel-parser.js" + }, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@babel/plugin-transform-react-jsx-self": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-react-jsx-self/-/plugin-transform-react-jsx-self-7.29.7.tgz", + "integrity": "sha512-TL0hMc9xzy86VD31nUiwzd5otRAcyEPcsegCxolO0PvcXuH1v0kECe/UIznYFihpkvU5wg/jk4v0TTEFfm53fw==", + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.29.7" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-react-jsx-source": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-react-jsx-source/-/plugin-transform-react-jsx-source-7.29.7.tgz", + "integrity": "sha512-06IyK09H3wi4cGbhDBwp5gUGo0IKtnYa8tyTiephirPCK6fbobVGiXMMI5zLQ4aKEYP3wZ3ArU44o+8KMrSG/Q==", + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.29.7" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/template": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.29.7.tgz", + "integrity": "sha512-puq+Gf35oI24FeN11LkoUQFqv9uwNeWpxXZi/Ji3rRIoKAzKnxRaZ+Gkj0vKS9ZCiTESfng1N9LyOyXvo+m+Gg==", + "license": "MIT", + "dependencies": { + "@babel/code-frame": "^7.29.7", + "@babel/parser": "^7.29.7", + "@babel/types": "^7.29.7" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/traverse": { + "version": "7.29.8", + "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.29.8.tgz", + "integrity": "sha512-I5z7H3bf/41ktsNVLtpN0wAa336HkqIHQ5BuPLEhTkt1jVSyZpeNKIzTgEWmlxjdg81R0IgUCcaE+Ok3NvrfZg==", + "license": "MIT", + "dependencies": { + "@babel/code-frame": "^7.29.7", + "@babel/generator": "^7.29.8", + "@babel/helper-globals": "^7.29.7", + "@babel/parser": "^7.29.8", + "@babel/template": "^7.29.7", + "@babel/types": "^7.29.8", + "debug": "^4.3.1" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/types": { + "version": "7.29.8", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.29.8.tgz", + "integrity": "sha512-Vj1jF3cPfxg7OAfoI7QnVKLoILlm2JF9pnVHrX8qx7AHMiYWT+NDAA7jChlNgRS4WTLc/fD1lXLmPixluj+3Gg==", + "license": "MIT", + "dependencies": { + "@babel/helper-string-parser": "^7.29.7", + "@babel/helper-validator-identifier": "^7.29.7" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@esbuild/aix-ppc64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.25.12.tgz", + "integrity": "sha512-Hhmwd6CInZ3dwpuGTF8fJG6yoWmsToE+vYgD4nytZVxcu1ulHpUQRAB1UJ8+N1Am3Mz4+xOByoQoSZf4D+CpkA==", + "cpu": [ + "ppc64" + ], + "license": "MIT", + "optional": true, + "os": [ + "aix" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/android-arm": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.25.12.tgz", + "integrity": "sha512-VJ+sKvNA/GE7Ccacc9Cha7bpS8nyzVv0jdVgwNDaR4gDMC/2TTRc33Ip8qrNYUcpkOHUT5OZ0bUcNNVZQ9RLlg==", + "cpu": [ + "arm" + ], + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/android-arm64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.25.12.tgz", + "integrity": "sha512-6AAmLG7zwD1Z159jCKPvAxZd4y/VTO0VkprYy+3N2FtJ8+BQWFXU+OxARIwA46c5tdD9SsKGZ/1ocqBS/gAKHg==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/android-x64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.25.12.tgz", + "integrity": "sha512-5jbb+2hhDHx5phYR2By8GTWEzn6I9UqR11Kwf22iKbNpYrsmRB18aX/9ivc5cabcUiAT/wM+YIZ6SG9QO6a8kg==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/darwin-arm64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.25.12.tgz", + "integrity": "sha512-N3zl+lxHCifgIlcMUP5016ESkeQjLj/959RxxNYIthIg+CQHInujFuXeWbWMgnTo4cp5XVHqFPmpyu9J65C1Yg==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/darwin-x64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.25.12.tgz", + "integrity": "sha512-HQ9ka4Kx21qHXwtlTUVbKJOAnmG1ipXhdWTmNXiPzPfWKpXqASVcWdnf2bnL73wgjNrFXAa3yYvBSd9pzfEIpA==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/freebsd-arm64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.25.12.tgz", + "integrity": "sha512-gA0Bx759+7Jve03K1S0vkOu5Lg/85dou3EseOGUes8flVOGxbhDDh/iZaoek11Y8mtyKPGF3vP8XhnkDEAmzeg==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/freebsd-x64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.25.12.tgz", + "integrity": "sha512-TGbO26Yw2xsHzxtbVFGEXBFH0FRAP7gtcPE7P5yP7wGy7cXK2oO7RyOhL5NLiqTlBh47XhmIUXuGciXEqYFfBQ==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-arm": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.25.12.tgz", + "integrity": "sha512-lPDGyC1JPDou8kGcywY0YILzWlhhnRjdof3UlcoqYmS9El818LLfJJc3PXXgZHrHCAKs/Z2SeZtDJr5MrkxtOw==", + "cpu": [ + "arm" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-arm64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.25.12.tgz", + "integrity": "sha512-8bwX7a8FghIgrupcxb4aUmYDLp8pX06rGh5HqDT7bB+8Rdells6mHvrFHHW2JAOPZUbnjUpKTLg6ECyzvas2AQ==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-ia32": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.25.12.tgz", + "integrity": "sha512-0y9KrdVnbMM2/vG8KfU0byhUN+EFCny9+8g202gYqSSVMonbsCfLjUO+rCci7pM0WBEtz+oK/PIwHkzxkyharA==", + "cpu": [ + "ia32" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-loong64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.25.12.tgz", + "integrity": "sha512-h///Lr5a9rib/v1GGqXVGzjL4TMvVTv+s1DPoxQdz7l/AYv6LDSxdIwzxkrPW438oUXiDtwM10o9PmwS/6Z0Ng==", + "cpu": [ + "loong64" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-mips64el": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.25.12.tgz", + "integrity": "sha512-iyRrM1Pzy9GFMDLsXn1iHUm18nhKnNMWscjmp4+hpafcZjrr2WbT//d20xaGljXDBYHqRcl8HnxbX6uaA/eGVw==", + "cpu": [ + "mips64el" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-ppc64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.25.12.tgz", + "integrity": "sha512-9meM/lRXxMi5PSUqEXRCtVjEZBGwB7P/D4yT8UG/mwIdze2aV4Vo6U5gD3+RsoHXKkHCfSxZKzmDssVlRj1QQA==", + "cpu": [ + "ppc64" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-riscv64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.25.12.tgz", + "integrity": "sha512-Zr7KR4hgKUpWAwb1f3o5ygT04MzqVrGEGXGLnj15YQDJErYu/BGg+wmFlIDOdJp0PmB0lLvxFIOXZgFRrdjR0w==", + "cpu": [ + "riscv64" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-s390x": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.25.12.tgz", + "integrity": "sha512-MsKncOcgTNvdtiISc/jZs/Zf8d0cl/t3gYWX8J9ubBnVOwlk65UIEEvgBORTiljloIWnBzLs4qhzPkJcitIzIg==", + "cpu": [ + "s390x" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-x64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.25.12.tgz", + "integrity": "sha512-uqZMTLr/zR/ed4jIGnwSLkaHmPjOjJvnm6TVVitAa08SLS9Z0VM8wIRx7gWbJB5/J54YuIMInDquWyYvQLZkgw==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/netbsd-arm64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-arm64/-/netbsd-arm64-0.25.12.tgz", + "integrity": "sha512-xXwcTq4GhRM7J9A8Gv5boanHhRa/Q9KLVmcyXHCTaM4wKfIpWkdXiMog/KsnxzJ0A1+nD+zoecuzqPmCRyBGjg==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/netbsd-x64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.25.12.tgz", + "integrity": "sha512-Ld5pTlzPy3YwGec4OuHh1aCVCRvOXdH8DgRjfDy/oumVovmuSzWfnSJg+VtakB9Cm0gxNO9BzWkj6mtO1FMXkQ==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/openbsd-arm64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-arm64/-/openbsd-arm64-0.25.12.tgz", + "integrity": "sha512-fF96T6KsBo/pkQI950FARU9apGNTSlZGsv1jZBAlcLL1MLjLNIWPBkj5NlSz8aAzYKg+eNqknrUJ24QBybeR5A==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/openbsd-x64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.25.12.tgz", + "integrity": "sha512-MZyXUkZHjQxUvzK7rN8DJ3SRmrVrke8ZyRusHlP+kuwqTcfWLyqMOE3sScPPyeIXN/mDJIfGXvcMqCgYKekoQw==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/openharmony-arm64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/openharmony-arm64/-/openharmony-arm64-0.25.12.tgz", + "integrity": "sha512-rm0YWsqUSRrjncSXGA7Zv78Nbnw4XL6/dzr20cyrQf7ZmRcsovpcRBdhD43Nuk3y7XIoW2OxMVvwuRvk9XdASg==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "openharmony" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/sunos-x64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.25.12.tgz", + "integrity": "sha512-3wGSCDyuTHQUzt0nV7bocDy72r2lI33QL3gkDNGkod22EsYl04sMf0qLb8luNKTOmgF/eDEDP5BFNwoBKH441w==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "sunos" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/win32-arm64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.25.12.tgz", + "integrity": "sha512-rMmLrur64A7+DKlnSuwqUdRKyd3UE7oPJZmnljqEptesKM8wx9J8gx5u0+9Pq0fQQW8vqeKebwNXdfOyP+8Bsg==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/win32-ia32": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.25.12.tgz", + "integrity": "sha512-HkqnmmBoCbCwxUKKNPBixiWDGCpQGVsrQfJoVGYLPT41XWF8lHuE5N6WhVia2n4o5QK5M4tYr21827fNhi4byQ==", + "cpu": [ + "ia32" + ], + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/win32-x64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.25.12.tgz", + "integrity": "sha512-alJC0uCZpTFrSL0CCDjcgleBXPnCrEAhTBILpeAp7M/OFgoqtAetfBzX0xM00MUsVVPpVjlPuMbREqnZCXaTnA==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@jridgewell/gen-mapping": { + "version": "0.3.13", + "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.13.tgz", + "integrity": "sha512-2kkt/7niJ6MgEPxF0bYdQ6etZaA+fQvDcLKckhy1yIQOzaoKjBBjSj63/aLVjYE3qhRt5dvM+uUyfCg6UKCBbA==", + "license": "MIT", + "dependencies": { + "@jridgewell/sourcemap-codec": "^1.5.0", + "@jridgewell/trace-mapping": "^0.3.24" + } + }, + "node_modules/@jridgewell/remapping": { + "version": "2.3.5", + "resolved": "https://registry.npmjs.org/@jridgewell/remapping/-/remapping-2.3.5.tgz", + "integrity": "sha512-LI9u/+laYG4Ds1TDKSJW2YPrIlcVYOwi2fUC6xB43lueCjgxV4lffOCZCtYFiH6TNOX+tQKXx97T4IKHbhyHEQ==", + "license": "MIT", + "dependencies": { + "@jridgewell/gen-mapping": "^0.3.5", + "@jridgewell/trace-mapping": "^0.3.24" + } + }, + "node_modules/@jridgewell/resolve-uri": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.2.tgz", + "integrity": "sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==", + "license": "MIT", + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@jridgewell/sourcemap-codec": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.6.0.tgz", + "integrity": "sha512-T7jf+5zgsZHwNJ4lvQ7/aezbyk0nNX+zJVWpmHA7VYsEx7a7qr5Rg5IbtJFqkgze5Y2sruq1RUY8Q837Od7iFw==", + "license": "MIT" + }, + "node_modules/@jridgewell/trace-mapping": { + "version": "0.3.31", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.31.tgz", + "integrity": "sha512-zzNR+SdQSDJzc8joaeP8QQoCQr8NuYx2dIIytl1QeBEZHJ9uW6hebsrYgbz8hJwUQao3TWCMtmfV8Nu1twOLAw==", + "license": "MIT", + "dependencies": { + "@jridgewell/resolve-uri": "^3.1.0", + "@jridgewell/sourcemap-codec": "^1.4.14" + } + }, + "node_modules/@napi-rs/lzma-linux-x64-gnu": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/@napi-rs/lzma-linux-x64-gnu/-/lzma-linux-x64-gnu-1.5.1.tgz", + "integrity": "sha512-oTXEIha4SsuXdTA4Iyskj0kpdx2yVXdhd75c2v3xGrHFfVMsbhTPZU/nMPL4sWKo4pBHm3aucLaqGlF696dTyQ==", + "cpu": [ + "x64" + ], + "libc": [ + "glibc" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^22.20 || ^24.12 || >=25" + } + }, + "node_modules/@rolldown/pluginutils": { + "version": "1.0.0-beta.27", + "resolved": "https://registry.npmjs.org/@rolldown/pluginutils/-/pluginutils-1.0.0-beta.27.tgz", + "integrity": "sha512-+d0F4MKMCbeVUJwG96uQ4SgAznZNSq93I3V+9NHA4OpvqG8mRCpGdKmK8l/dl02h2CCDHwW2FqilnTyDcAnqjA==", + "license": "MIT" + }, + "node_modules/@rollup/rollup-android-arm-eabi": { + "version": "4.63.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.63.1.tgz", + "integrity": "sha512-UZ8sUxPTiHWYX9QNdJedb1kDZSpS1t/VPWBWGSgqHNi9w3Cu6IXvu2mzbhiTiPvtrqgTQJ+zqiAq2iPIPilpaQ==", + "cpu": [ + "arm" + ], + "license": "MIT", + "optional": true, + "os": [ + "android" + ] + }, + "node_modules/@rollup/rollup-android-arm64": { + "version": "4.63.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.63.1.tgz", + "integrity": "sha512-cQ4nFQABN5cDvDpbvJ7bMStCpnaVxynZrRMfUJYgxcIk9Sh54FIO1vtfkg0B69REjER77ioZ/ov+eAApx/KmLQ==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "android" + ] + }, + "node_modules/@rollup/rollup-darwin-arm64": { + "version": "4.63.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.63.1.tgz", + "integrity": "sha512-FQNqd1lRy/0QhDk3xeRIkSBiCpXCiDnZO3YLVdcDKN1UBiKToNftCzcXYNLshmPDUMlu2TdeS8tGcsU6f3YF1Q==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ] + }, + "node_modules/@rollup/rollup-darwin-x64": { + "version": "4.63.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.63.1.tgz", + "integrity": "sha512-pvD16V939D3CloK0+qikpGaxiPrDUXTe7Y5cWOMkMSy7m1cawa8EGy/kXYi/G/cKAC4HDAbSnzCIk1WmsoOKXg==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ] + }, + "node_modules/@rollup/rollup-freebsd-arm64": { + "version": "4.63.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-arm64/-/rollup-freebsd-arm64-4.63.1.tgz", + "integrity": "sha512-pcFGeL2345VwdTnJhA6zLbew+YgWB0qBG2+dMtXjCicf6+rm6kO6cOoh5VnTe0ZMrMRgRyuHmCJxZWrIdzYuOw==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ] + }, + "node_modules/@rollup/rollup-freebsd-x64": { + "version": "4.63.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-x64/-/rollup-freebsd-x64-4.63.1.tgz", + "integrity": "sha512-mRJlqSRulVzcKq/LKA6ICSIc3K/l4fzlVn/gePn2nXIHy8seRi5z/eeRE0d/XMBxcMldiXtQTSpRj0tkkC3g8Q==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ] + }, + "node_modules/@rollup/rollup-linux-arm-gnueabihf": { + "version": "4.63.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.63.1.tgz", + "integrity": "sha512-YDUNvVM85TI3g/1OpnqKP1h4NeW/j64DfWMf+G3M809xNk1bJSnpFp4sh83NpmVE5DXnkh8ULor4LTVZKoYLHw==", + "cpu": [ + "arm" + ], + "libc": [ + "glibc" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-arm-musleabihf": { + "version": "4.63.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-musleabihf/-/rollup-linux-arm-musleabihf-4.63.1.tgz", + "integrity": "sha512-7Mcn71p9ZuQFAj+h+dhQXy/yeLePRS2yKRnmW1DijA9thKO5qap0GNOIQK4yQ6iP3SU0Mrb/yWo8h8vgRba8lw==", + "cpu": [ + "arm" + ], + "libc": [ + "musl" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-arm64-gnu": { + "version": "4.63.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.63.1.tgz", + "integrity": "sha512-4YiLQTX6U4CSl0L9cluep9A9W6UmTfqBDc2/CH6wlu54pl4E7Jn3cOD8oxzvBDEGk/JMKgJ47C8g+radF7mwvg==", + "cpu": [ + "arm64" + ], + "libc": [ + "glibc" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-arm64-musl": { + "version": "4.63.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.63.1.tgz", + "integrity": "sha512-2ra8F7w8OquwZN9z2/fKFnli69wa8PLwaVzRMIPGb13ByMJwC28Fbp8YcVGoUhlYMTt7j5j9bNgpysrN2UM+vw==", + "cpu": [ + "arm64" + ], + "libc": [ + "musl" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-loong64-gnu": { + "version": "4.63.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-loong64-gnu/-/rollup-linux-loong64-gnu-4.63.1.tgz", + "integrity": "sha512-Sy20ncyhjmBP0Ml+UvQbimjlk6VFgjW5uNP+qqwHB00mTE8Bl2C1TuHTlRwK2YoXeZbee5lP2XevBWVkAQAtSQ==", + "cpu": [ + "loong64" + ], + "libc": [ + "glibc" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-loong64-musl": { + "version": "4.63.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-loong64-musl/-/rollup-linux-loong64-musl-4.63.1.tgz", + "integrity": "sha512-noITLp8oNjYliPnGWmLyelIHwULGqbHloQHGw1rtxbWhTuWooRpnZarZQJ1y9EUC4szuCusCc+HEpUtxpIwYvA==", + "cpu": [ + "loong64" + ], + "libc": [ + "musl" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-ppc64-gnu": { + "version": "4.63.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-ppc64-gnu/-/rollup-linux-ppc64-gnu-4.63.1.tgz", + "integrity": "sha512-hlxxXd+F1mWiAcaFR7Sv9ZQT6m6UfI8+Vy/kFJzztq2pDMU/0wZ9sish0iszNZvsQDo8Gc0i5yuFEOz5dDf6fA==", + "cpu": [ + "ppc64" + ], + "libc": [ + "glibc" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-ppc64-musl": { + "version": "4.63.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-ppc64-musl/-/rollup-linux-ppc64-musl-4.63.1.tgz", + "integrity": "sha512-EF7OpqQTQ/BvGqLzUi4rEHuagCV9MugAUXSHemwPW5vxZ75RR+jxO/2j95Ph2dalMpFHSVECjRoioHZgA9zOYA==", + "cpu": [ + "ppc64" + ], + "libc": [ + "musl" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-riscv64-gnu": { + "version": "4.63.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.63.1.tgz", + "integrity": "sha512-wQO3JesW9PRkwlabQ27y7sPfVOOTLRG73I4F2UYHG5PXun3J9U3y+b7ezVKSYbsvSKGQ1k1cq8Qlun4C9kLt3w==", + "cpu": [ + "riscv64" + ], + "libc": [ + "glibc" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-riscv64-musl": { + "version": "4.63.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-musl/-/rollup-linux-riscv64-musl-4.63.1.tgz", + "integrity": "sha512-ouAGwhO6wHRXdnOVCOsB0tRFkA7nhNB2Nwax6oECXN0YiN8EYUTBAOudADOB1PI+yDL61TeNx/u7MVCzksNbkQ==", + "cpu": [ + "riscv64" + ], + "libc": [ + "musl" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-s390x-gnu": { + "version": "4.63.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.63.1.tgz", + "integrity": "sha512-q2R38Sn+1J8RxhfJ+T54wSWmyKXWec+9jgDfqO2AtArEqHO5R2aeayp5H5OYLr5UYDVGsVaZPEFUooMhYCdz5A==", + "cpu": [ + "s390x" + ], + "libc": [ + "glibc" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-x64-gnu": { + "version": "4.63.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.63.1.tgz", + "integrity": "sha512-gfI5T24WLLuFfSKw7Go/zDXjAAV0fny0swTaDv+WjK7vqcw4cRhFfdsyKL1n+ukI+ooBxn3bVQnyrn06WpI50w==", + "cpu": [ + "x64" + ], + "libc": [ + "glibc" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-x64-musl": { + "version": "4.63.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.63.1.tgz", + "integrity": "sha512-4h6XqthmB4Hspji84wvgk+ElodTsGj+dbZqHJHHtKxj4mYq0ANSEEPX9ys3moJueqsRjwpaJYH7874Itwnj2ow==", + "cpu": [ + "x64" + ], + "libc": [ + "musl" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-openbsd-x64": { + "version": "4.63.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-openbsd-x64/-/rollup-openbsd-x64-4.63.1.tgz", + "integrity": "sha512-dlfCOa87o1VAYegLQ9EKilx2JCeRofiyPGhTCmqnuXZ6bMPiycO1rq1+sKoulAp7pGLIsTIw+1x5R+zgh5LhhA==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "openbsd" + ] + }, + "node_modules/@rollup/rollup-openharmony-arm64": { + "version": "4.63.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-openharmony-arm64/-/rollup-openharmony-arm64-4.63.1.tgz", + "integrity": "sha512-cjkLbOlfcm3QGhMM1J5zaZjsw1GggbN6rw9UTSSRrPrR1KkcXnN7Uq9rPw34xImQ9VOY9GN+6u2Zj80B9ptkcw==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "openharmony" + ] + }, + "node_modules/@rollup/rollup-win32-arm64-msvc": { + "version": "4.63.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.63.1.tgz", + "integrity": "sha512-Li1KdUnWGE4N3e1F/B4RTB1ms+nG4WBgjByO46pkeBVX/2UBsY53xf5vK9WygVmnH3RwncIST7lkSdLSY6P9lg==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@rollup/rollup-win32-ia32-msvc": { + "version": "4.63.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.63.1.tgz", + "integrity": "sha512-t4ZYOSoLTgwhuFMrmTMLx/+i1DQVK7HYqMc6kY46EApwi8X0nIVphzdNoThU3xt6n+N5urG1/gxBdCaKDLavfg==", + "cpu": [ + "ia32" + ], + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@rollup/rollup-win32-x64-gnu": { + "version": "4.63.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-gnu/-/rollup-win32-x64-gnu-4.63.1.tgz", + "integrity": "sha512-RgroPfMmKlD1RzSDxvwgcPiy2HNQKoYV7OmwIXDsk73uKW5t6B/V8KIy27SMv/FNXFo/oSBtWc9J0X7t91ezZg==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@rollup/rollup-win32-x64-msvc": { + "version": "4.63.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.63.1.tgz", + "integrity": "sha512-at8QVep6S3h5Y6gSbdGU06bRY5WJkf6WUduM9YtvYMbYhB1MOFfUgc6kehitQXzOtMSaT70q7f9ydPhpqu821w==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@types/babel__core": { + "version": "7.20.5", + "resolved": "https://registry.npmjs.org/@types/babel__core/-/babel__core-7.20.5.tgz", + "integrity": "sha512-qoQprZvz5wQFJwMDqeseRXWv3rqMvhgpbXFfVyWhbx9X47POIA6i/+dXefEmZKoAgOaTdaIgNSMqMIU61yRyzA==", + "license": "MIT", + "dependencies": { + "@babel/parser": "^7.20.7", + "@babel/types": "^7.20.7", + "@types/babel__generator": "*", + "@types/babel__template": "*", + "@types/babel__traverse": "*" + } + }, + "node_modules/@types/babel__generator": { + "version": "7.27.0", + "resolved": "https://registry.npmjs.org/@types/babel__generator/-/babel__generator-7.27.0.tgz", + "integrity": "sha512-ufFd2Xi92OAVPYsy+P4n7/U7e68fex0+Ee8gSG9KX7eo084CWiQ4sdxktvdl0bOPupXtVJPY19zk6EwWqUQ8lg==", + "license": "MIT", + "dependencies": { + "@babel/types": "^7.0.0" + } + }, + "node_modules/@types/babel__template": { + "version": "7.4.4", + "resolved": "https://registry.npmjs.org/@types/babel__template/-/babel__template-7.4.4.tgz", + "integrity": "sha512-h/NUaSyG5EyxBIp8YRxo4RMe2/qQgvyowRwVMzhYhBCONbW8PUsg4lkFMrhgZhUe5z3L3MiLDuvyJ/CaPa2A8A==", + "license": "MIT", + "dependencies": { + "@babel/parser": "^7.1.0", + "@babel/types": "^7.0.0" + } + }, + "node_modules/@types/babel__traverse": { + "version": "7.28.0", + "resolved": "https://registry.npmjs.org/@types/babel__traverse/-/babel__traverse-7.28.0.tgz", + "integrity": "sha512-8PvcXf70gTDZBgt9ptxJ8elBeBjcLOAcOtoO/mPJjtji1+CdGbHgm77om1GrsPxsiE+uXIpNSK64UYaIwQXd4Q==", + "license": "MIT", + "dependencies": { + "@babel/types": "^7.28.2" + } + }, + "node_modules/@types/estree": { + "version": "1.0.9", + "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.9.tgz", + "integrity": "sha512-GhdPgy1el4/ImP05X05Uw4cw2/M93BCUmnEvWZNStlCzEKME4Fkk+YpoA5OiHNQmoS7Cafb8Xa3Pya8m1Qrzeg==", + "license": "MIT" + }, + "node_modules/@types/prop-types": { + "version": "15.7.15", + "resolved": "https://registry.npmjs.org/@types/prop-types/-/prop-types-15.7.15.tgz", + "integrity": "sha512-F6bEyamV9jKGAFBEmlQnesRPGOQqS2+Uwi0Em15xenOxHaf2hv6L8YCVn3rPdPJOiJfPiCnLIRyvwVaqMY3MIw==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/react": { + "version": "18.3.31", + "resolved": "https://registry.npmjs.org/@types/react/-/react-18.3.31.tgz", + "integrity": "sha512-vfEqpXTvwT91yhmwdfouStN2hSKwTvyRs8qpLfADyrq/kxDw0hZM7Wk9Ug1FELj8hIby+S/+kQCSRFF32nv2Qw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/prop-types": "*", + "csstype": "^3.2.2" + } + }, + "node_modules/@types/react-dom": { + "version": "18.3.7", + "resolved": "https://registry.npmjs.org/@types/react-dom/-/react-dom-18.3.7.tgz", + "integrity": "sha512-MEe3UeoENYVFXzoXEWsvcpg6ZvlrFNlOQ7EOsvhI3CfAXwzPfO8Qwuxd40nepsYKqyyVQnTdEfv68q91yLcKrQ==", + "dev": true, + "license": "MIT", + "peerDependencies": { + "@types/react": "^18.0.0" + } + }, + "node_modules/@vitejs/plugin-react": { + "version": "4.7.0", + "resolved": "https://registry.npmjs.org/@vitejs/plugin-react/-/plugin-react-4.7.0.tgz", + "integrity": "sha512-gUu9hwfWvvEDBBmgtAowQCojwZmJ5mcLn3aufeCsitijs3+f2NsrPtlAWIR6OPiqljl96GVCUbLe0HyqIpVaoA==", + "license": "MIT", + "dependencies": { + "@babel/core": "^7.28.0", + "@babel/plugin-transform-react-jsx-self": "^7.27.1", + "@babel/plugin-transform-react-jsx-source": "^7.27.1", + "@rolldown/pluginutils": "1.0.0-beta.27", + "@types/babel__core": "^7.20.5", + "react-refresh": "^0.17.0" + }, + "engines": { + "node": "^14.18.0 || >=16.0.0" + }, + "peerDependencies": { + "vite": "^4.2.0 || ^5.0.0 || ^6.0.0 || ^7.0.0" + } + }, + "node_modules/baseline-browser-mapping": { + "version": "2.11.22", + "resolved": "https://registry.npmjs.org/baseline-browser-mapping/-/baseline-browser-mapping-2.11.22.tgz", + "integrity": "sha512-pWc4w51fBFd7mav43/zKRC+RI6f4yfzQoVlfvE8dECePyfkn1bzLp01Fj0QACcyCZyFhiEMyD2qScfKRWgWibA==", + "license": "Apache-2.0", + "bin": { + "baseline-browser-mapping": "dist/cli.cjs" + }, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/browserslist": { + "version": "4.28.9", + "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.28.9.tgz", + "integrity": "sha512-EWazOblFYUvlGZcfGhPUPmYh3nikUxBVb+y9MJun5f3hBi812X+8MSQTujLBtgK3cf51fJWbWfOjyeO954d+Eg==", + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/browserslist" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/browserslist" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "dependencies": { + "baseline-browser-mapping": "^2.11.20", + "caniuse-lite": "^1.0.30001810", + "electron-to-chromium": "^1.5.420", + "node-releases": "^2.0.54", + "update-browserslist-db": "^1.3.2" + }, + "bin": { + "browserslist": "cli.js" + }, + "engines": { + "node": "^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7" + } + }, + "node_modules/caniuse-lite": { + "version": "1.0.30001810", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001810.tgz", + "integrity": "sha512-TITQPUkaz+aVk5GL6NhOdwk1aEaNTSDPsGFWrTuhKGtjTF70jL/Oht2W4c6rXUe5fu7Ie19VIahAXHIIiWWNeg==", + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/browserslist" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/caniuse-lite" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "CC-BY-4.0" + }, + "node_modules/convert-source-map": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-2.0.0.tgz", + "integrity": "sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg==", + "license": "MIT" + }, + "node_modules/csstype": { + "version": "3.2.3", + "resolved": "https://registry.npmjs.org/csstype/-/csstype-3.2.3.tgz", + "integrity": "sha512-z1HGKcYy2xA8AGQfwrn0PAy+PB7X/GSj3UVJW9qKyn43xWa+gl5nXmU4qqLMRzWVLFC8KusUX8T/0kCiOYpAIQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/debug": { + "version": "4.4.3", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz", + "integrity": "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==", + "license": "MIT", + "dependencies": { + "ms": "^2.1.3" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/electron-to-chromium": { + "version": "1.5.426", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.426.tgz", + "integrity": "sha512-2Gcq6inCQs/AqfHP3f5ftCzk+pqeW2VlA1LgmPqEj2hfBO8HiZRspNYkD4HzFBe4u6lGqca4BspFr6Ix4Q400g==", + "license": "ISC" + }, + "node_modules/esbuild": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.25.12.tgz", + "integrity": "sha512-bbPBYYrtZbkt6Os6FiTLCTFxvq4tt3JKall1vRwshA3fdVztsLAatFaZobhkBC8/BrPetoa0oksYoKXoG4ryJg==", + "hasInstallScript": true, + "license": "MIT", + "bin": { + "esbuild": "bin/esbuild" + }, + "engines": { + "node": ">=18" + }, + "optionalDependencies": { + "@esbuild/aix-ppc64": "0.25.12", + "@esbuild/android-arm": "0.25.12", + "@esbuild/android-arm64": "0.25.12", + "@esbuild/android-x64": "0.25.12", + "@esbuild/darwin-arm64": "0.25.12", + "@esbuild/darwin-x64": "0.25.12", + "@esbuild/freebsd-arm64": "0.25.12", + "@esbuild/freebsd-x64": "0.25.12", + "@esbuild/linux-arm": "0.25.12", + "@esbuild/linux-arm64": "0.25.12", + "@esbuild/linux-ia32": "0.25.12", + "@esbuild/linux-loong64": "0.25.12", + "@esbuild/linux-mips64el": "0.25.12", + "@esbuild/linux-ppc64": "0.25.12", + "@esbuild/linux-riscv64": "0.25.12", + "@esbuild/linux-s390x": "0.25.12", + "@esbuild/linux-x64": "0.25.12", + "@esbuild/netbsd-arm64": "0.25.12", + "@esbuild/netbsd-x64": "0.25.12", + "@esbuild/openbsd-arm64": "0.25.12", + "@esbuild/openbsd-x64": "0.25.12", + "@esbuild/openharmony-arm64": "0.25.12", + "@esbuild/sunos-x64": "0.25.12", + "@esbuild/win32-arm64": "0.25.12", + "@esbuild/win32-ia32": "0.25.12", + "@esbuild/win32-x64": "0.25.12" + } + }, + "node_modules/escalade": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.2.0.tgz", + "integrity": "sha512-WUj2qlxaQtO4g6Pq5c29GTcWGDyd8itL8zTlipgECz3JesAiiOKotd8JU6otB3PACgG6xkJUyVhboMS+bje/jA==", + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/fdir": { + "version": "6.5.0", + "resolved": "https://registry.npmjs.org/fdir/-/fdir-6.5.0.tgz", + "integrity": "sha512-tIbYtZbucOs0BRGqPJkshJUYdL+SDH7dVM8gjy+ERp3WAUjLEFJE+02kanyHtwjWOnwrKYBiwAmM0p4kLJAnXg==", + "license": "MIT", + "engines": { + "node": ">=12.0.0" + }, + "peerDependencies": { + "picomatch": "^3 || ^4" + }, + "peerDependenciesMeta": { + "picomatch": { + "optional": true + } + } + }, + "node_modules/fsevents": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", + "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", + "hasInstallScript": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + } + }, + "node_modules/gensync": { + "version": "1.0.0-beta.2", + "resolved": "https://registry.npmjs.org/gensync/-/gensync-1.0.0-beta.2.tgz", + "integrity": "sha512-3hN7NaskYvMDLQY55gnW3NQ+mesEAepTqlg+VEbj7zzqEMBVNhzcGYYeqFo/TlYz6eQiFcp1HcsCZO+nGgS8zg==", + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/js-tokens": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", + "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==", + "license": "MIT" + }, + "node_modules/jsesc": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-3.1.0.tgz", + "integrity": "sha512-/sM3dO2FOzXjKQhJuo0Q173wf2KOo8t4I8vHy6lF9poUp7bKT0/NHE8fPX23PwfhnykfqnC2xRxOnVw5XuGIaA==", + "license": "MIT", + "bin": { + "jsesc": "bin/jsesc" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/json5": { + "version": "2.2.3", + "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.3.tgz", + "integrity": "sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==", + "license": "MIT", + "bin": { + "json5": "lib/cli.js" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/loose-envify": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.4.0.tgz", + "integrity": "sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==", + "license": "MIT", + "dependencies": { + "js-tokens": "^3.0.0 || ^4.0.0" + }, + "bin": { + "loose-envify": "cli.js" + } + }, + "node_modules/lru-cache": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-5.1.1.tgz", + "integrity": "sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w==", + "license": "ISC", + "dependencies": { + "yallist": "^3.0.2" + } + }, + "node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", + "license": "MIT" + }, + "node_modules/nanoid": { + "version": "3.3.19", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.19.tgz", + "integrity": "sha512-Y2tUNy4ouw6tq5oDSKeQYGOyhkUBhNOcGV/02KC+6kd9eDGqdZd++mjMiIDilrBYvjEnCYvVtsuHCuP+okSfug==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "bin": { + "nanoid": "bin/nanoid.cjs" + }, + "engines": { + "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1" + } + }, + "node_modules/node-releases": { + "version": "2.0.55", + "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.55.tgz", + "integrity": "sha512-mIrE/Cw9y+9Au6dS5vDKDhQza9YvG6w+ZrS6X+ZzA7yFW/soAeaups4Qzn1bL6g5FVy8WtP79+0j82oPIbqRjQ==", + "license": "MIT", + "engines": { + "node": ">=18" + } + }, + "node_modules/picocolors": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz", + "integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==", + "license": "ISC" + }, + "node_modules/picomatch": { + "version": "4.0.7", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.7.tgz", + "integrity": "sha512-qcJu88Q2IWqJsDD529JKMdwGm/dvInW4HvQnRwiH9JtihJvzGOscDtHE3x1pBKeUOTysQ8kVmLnJ2kJu7yhcGA==", + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, + "node_modules/postcss": { + "version": "8.5.28", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.28.tgz", + "integrity": "sha512-RRuzqDtt5Y9h3quz5hWhK+TPnsmVs6WwSU6LkJMeY4HstUEDuYTG8UJSdawMRzmzAtV+KEoG8N3Qg2qLy5vM/A==", + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/postcss/" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/postcss" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "dependencies": { + "nanoid": "^3.3.18", + "picocolors": "^1.1.1", + "source-map-js": "^1.2.1" + }, + "engines": { + "node": "^10 || ^12 || >=14" + } + }, + "node_modules/react": { + "version": "18.3.1", + "resolved": "https://registry.npmjs.org/react/-/react-18.3.1.tgz", + "integrity": "sha512-wS+hAgJShR0KhEvPJArfuPVN1+Hz1t0Y6n5jLrGQbkb4urgPE/0Rve+1kMB1v/oWgHgm4WIcV+i7F2pTVj+2iQ==", + "license": "MIT", + "dependencies": { + "loose-envify": "^1.1.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/react-dom": { + "version": "18.3.1", + "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-18.3.1.tgz", + "integrity": "sha512-5m4nQKp+rZRb09LNH59GM4BxTh9251/ylbKIbpe7TpGxfJ+9kv6BLkLBXIjjspbgbnIBNqlI23tRnTWT0snUIw==", + "license": "MIT", + "dependencies": { + "loose-envify": "^1.1.0", + "scheduler": "^0.23.2" + }, + "peerDependencies": { + "react": "^18.3.1" + } + }, + "node_modules/react-refresh": { + "version": "0.17.0", + "resolved": "https://registry.npmjs.org/react-refresh/-/react-refresh-0.17.0.tgz", + "integrity": "sha512-z6F7K9bV85EfseRCp2bzrpyQ0Gkw1uLoCel9XBVWPg/TjRj94SkJzUTGfOa4bs7iJvBWtQG0Wq7wnI0syw3EBQ==", + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/rollup": { + "version": "4.63.1", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.63.1.tgz", + "integrity": "sha512-3Df9jsstwhccuEfmAMi9l8XUh/GOkVObmFTU7CCVBysEbcOZLl84jCtaAZMcPiMz2EGKsATzQcU+Xr3n/wU6cg==", + "license": "MIT", + "dependencies": { + "@types/estree": "1.0.9" + }, + "bin": { + "rollup": "dist/bin/rollup" + }, + "engines": { + "node": ">=18.0.0", + "npm": ">=8.0.0" + }, + "optionalDependencies": { + "@napi-rs/lzma-linux-x64-gnu": "1.5.1", + "@rollup/rollup-android-arm-eabi": "4.63.1", + "@rollup/rollup-android-arm64": "4.63.1", + "@rollup/rollup-darwin-arm64": "4.63.1", + "@rollup/rollup-darwin-x64": "4.63.1", + "@rollup/rollup-freebsd-arm64": "4.63.1", + "@rollup/rollup-freebsd-x64": "4.63.1", + "@rollup/rollup-linux-arm-gnueabihf": "4.63.1", + "@rollup/rollup-linux-arm-musleabihf": "4.63.1", + "@rollup/rollup-linux-arm64-gnu": "4.63.1", + "@rollup/rollup-linux-arm64-musl": "4.63.1", + "@rollup/rollup-linux-loong64-gnu": "4.63.1", + "@rollup/rollup-linux-loong64-musl": "4.63.1", + "@rollup/rollup-linux-ppc64-gnu": "4.63.1", + "@rollup/rollup-linux-ppc64-musl": "4.63.1", + "@rollup/rollup-linux-riscv64-gnu": "4.63.1", + "@rollup/rollup-linux-riscv64-musl": "4.63.1", + "@rollup/rollup-linux-s390x-gnu": "4.63.1", + "@rollup/rollup-linux-x64-gnu": "4.63.1", + "@rollup/rollup-linux-x64-musl": "4.63.1", + "@rollup/rollup-openbsd-x64": "4.63.1", + "@rollup/rollup-openharmony-arm64": "4.63.1", + "@rollup/rollup-win32-arm64-msvc": "4.63.1", + "@rollup/rollup-win32-ia32-msvc": "4.63.1", + "@rollup/rollup-win32-x64-gnu": "4.63.1", + "@rollup/rollup-win32-x64-msvc": "4.63.1", + "fsevents": "~2.3.2" + } + }, + "node_modules/scheduler": { + "version": "0.23.2", + "resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.23.2.tgz", + "integrity": "sha512-UOShsPwz7NrMUqhR6t0hWjFduvOzbtv7toDH1/hIrfRNIDBnnBWd0CwJTGvTpngVlmwGCdP9/Zl/tVrDqcuYzQ==", + "license": "MIT", + "dependencies": { + "loose-envify": "^1.1.0" + } + }, + "node_modules/semver": { + "version": "6.3.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", + "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", + "license": "ISC", + "bin": { + "semver": "bin/semver.js" + } + }, + "node_modules/source-map-js": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.1.tgz", + "integrity": "sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA==", + "license": "BSD-3-Clause", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/tinyglobby": { + "version": "0.2.17", + "resolved": "https://registry.npmjs.org/tinyglobby/-/tinyglobby-0.2.17.tgz", + "integrity": "sha512-wXR/dYpcqKmfWpEdZjiKJOwCNFndD0DMnrW/cYjVGttEkBfVgcLFHoNrlj47mjOVic9yyNu65alsgF4NQyTa2g==", + "license": "MIT", + "dependencies": { + "fdir": "^6.5.0", + "picomatch": "^4.0.4" + }, + "engines": { + "node": ">=12.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/SuperchupuDev" + } + }, + "node_modules/typescript": { + "version": "5.7.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.7.3.tgz", + "integrity": "sha512-84MVSjMEHP+FQRPy3pX9sTVV/INIex71s9TL2Gm5FG/WG1SqXeKyZ0k7/blY/4FdOzI12CBy1vGc4og/eus0fw==", + "dev": true, + "license": "Apache-2.0", + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=14.17" + } + }, + "node_modules/update-browserslist-db": { + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.3.3.tgz", + "integrity": "sha512-pJ2sYawQS0R/WI928Gj5GlPhTGzbMelq0+4INtSYNDV9ErKJcX6xjGWkoG/VnB3dpUm00zALaqkrUD77pO5TDQ==", + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/browserslist" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/browserslist" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "dependencies": { + "escalade": "^3.2.0", + "picocolors": "^1.1.1" + }, + "bin": { + "update-browserslist-db": "cli.js" + }, + "peerDependencies": { + "browserslist": ">= 4.21.0" + } + }, + "node_modules/vite": { + "version": "6.4.3", + "resolved": "https://registry.npmjs.org/vite/-/vite-6.4.3.tgz", + "integrity": "sha512-NTKlcQjlAK7MlQoyb6LgaqHc8sso/pVyUJYWMws3jg21uTJw/LddqIFPcPqP6PzpgbIcZyKI85sFE4HBrQDA8A==", + "license": "MIT", + "dependencies": { + "esbuild": "^0.25.0", + "fdir": "^6.4.4", + "picomatch": "^4.0.2", + "postcss": "^8.5.3", + "rollup": "^4.34.9", + "tinyglobby": "^0.2.13" + }, + "bin": { + "vite": "bin/vite.js" + }, + "engines": { + "node": "^18.0.0 || ^20.0.0 || >=22.0.0" + }, + "funding": { + "url": "https://github.com/vitejs/vite?sponsor=1" + }, + "optionalDependencies": { + "fsevents": "~2.3.3" + }, + "peerDependencies": { + "@types/node": "^18.0.0 || ^20.0.0 || >=22.0.0", + "jiti": ">=1.21.0", + "less": "*", + "lightningcss": "^1.21.0", + "sass": "*", + "sass-embedded": "*", + "stylus": "*", + "sugarss": "*", + "terser": "^5.16.0", + "tsx": "^4.8.1", + "yaml": "^2.4.2" + }, + "peerDependenciesMeta": { + "@types/node": { + "optional": true + }, + "jiti": { + "optional": true + }, + "less": { + "optional": true + }, + "lightningcss": { + "optional": true + }, + "sass": { + "optional": true + }, + "sass-embedded": { + "optional": true + }, + "stylus": { + "optional": true + }, + "sugarss": { + "optional": true + }, + "terser": { + "optional": true + }, + "tsx": { + "optional": true + }, + "yaml": { + "optional": true + } + } + }, + "node_modules/yallist": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.1.1.tgz", + "integrity": "sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==", + "license": "ISC" + } + } +} diff --git a/web/package.json b/web/package.json new file mode 100644 index 0000000..cf39887 --- /dev/null +++ b/web/package.json @@ -0,0 +1,22 @@ +{ + "name": "pharma-field-force-web", + "private": true, + "version": "0.1.0", + "type": "module", + "scripts": { + "dev": "vite --config vite.config.ts", + "build": "tsc --noEmit && vite build --config vite.config.ts", + "preview": "vite preview" + }, + "dependencies": { + "@vitejs/plugin-react": "^4.3.4", + "vite": "^6.0.7", + "react": "^18.3.1", + "react-dom": "^18.3.1" + }, + "devDependencies": { + "@types/react": "^18.3.18", + "@types/react-dom": "^18.3.5", + "typescript": "~5.7.3" + } +} diff --git a/web/public/celtic-logo.svg b/web/public/celtic-logo.svg new file mode 100644 index 0000000..317b7c3 --- /dev/null +++ b/web/public/celtic-logo.svg @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + diff --git a/web/src/App.tsx b/web/src/App.tsx new file mode 100644 index 0000000..3454ae3 --- /dev/null +++ b/web/src/App.tsx @@ -0,0 +1,59 @@ +import { AppShell } from "./components/layout/AppShell"; +import { ToastProvider } from "./components/ui/Toast"; +import { Skeleton } from "./components/ui/States"; +import { matchPath, useLocation } from "./lib/router"; +import { SessionProvider, useSession } from "./lib/session"; +import { DashboardPage } from "./pages/DashboardPage"; +import { DirectoryPage } from "./pages/DirectoryPage"; +import { LoginPage } from "./pages/LoginPage"; +import { NotFoundPage } from "./pages/NotFoundPage"; +import { ProductsPage } from "./pages/ProductsPage"; +import { ProfilePage } from "./pages/ProfilePage"; +import { AdminPage } from "./pages/admin/AdminPage"; +import { UsersPage } from "./pages/admin/UsersPage"; +import { FormsPage } from "./pages/forms/FormsPage"; +import { NewReportPage } from "./pages/reports/NewReportPage"; +import { ReportDetailPage } from "./pages/reports/ReportDetailPage"; +import { ReportsPage } from "./pages/reports/ReportsPage"; +import type { Role } from "./types"; + +/** Which roles may open which screens; anything else renders "not found". */ +const ROUTES: { pattern: string; roles?: Role[]; render: (params: Record) => JSX.Element }[] = [ + { pattern: "/", render: () => }, + { pattern: "/reports", roles: ["MR", "AM", "GM"], render: () => }, + { pattern: "/reports/new", roles: ["MR"], render: () => }, + { pattern: "/reports/:id", roles: ["MR", "AM", "GM"], render: (p) => }, + { pattern: "/directory", render: () => }, + { pattern: "/products", render: () => }, + { pattern: "/forms", roles: ["MR", "AM", "ADMIN"], render: () => }, + { pattern: "/forms/:table", roles: ["MR", "AM", "ADMIN"], render: (p) => }, + { pattern: "/profile", render: () => }, + { pattern: "/admin", roles: ["ADMIN"], render: () => }, + { pattern: "/users", roles: ["ADMIN", "GM"], render: () => }, +]; + +function Routes({ role }: { role: Role }) { + const path = useLocation(); + for (const route of ROUTES) { + const params = matchPath(route.pattern, path); + if (params && (!route.roles || route.roles.includes(role))) return route.render(params); + } + return ; +} + +function Gate() { + const { user, loading } = useSession(); + if (loading) return
; + if (!user) return ; + return ; +} + +export default function App() { + return ( + + + + + + ); +} diff --git a/web/src/api/client.ts b/web/src/api/client.ts new file mode 100644 index 0000000..b83fed9 --- /dev/null +++ b/web/src/api/client.ts @@ -0,0 +1,109 @@ +/** Low-level HTTP client: base URL, bearer token, silent refresh, file downloads. */ + +export const API_BASE = "/api/v1"; + +interface TokenPair { + access_token: string; + refresh_token: string; +} + +let accessToken = localStorage.getItem("access_token"); +let refreshToken = localStorage.getItem("refresh_token"); +let onSignedOut: (() => void) | null = null; + +export const auth = { + get token() { + return accessToken; + }, + save(tokens: TokenPair) { + accessToken = tokens.access_token; + refreshToken = tokens.refresh_token; + localStorage.setItem("access_token", accessToken); + localStorage.setItem("refresh_token", refreshToken); + }, + clear() { + accessToken = refreshToken = null; + localStorage.removeItem("access_token"); + localStorage.removeItem("refresh_token"); + }, + /** Called when the session can no longer be refreshed, so the UI can return to sign-in. */ + onSignedOut(handler: () => void) { + onSignedOut = handler; + }, +}; + +export class ApiError extends Error { + constructor( + message: string, + readonly status: number, + ) { + super(message); + } +} + +async function refreshSession(): Promise { + const tokens = await request( + "/auth/refresh", + { method: "POST", body: JSON.stringify({ refresh_token: refreshToken }) }, + false, + ); + auth.save(tokens); +} + +async function send(path: string, init: RequestInit = {}, retry = true): Promise { + const headers = new Headers(init.headers); + if (accessToken) headers.set("Authorization", `Bearer ${accessToken}`); + if (init.body && !headers.has("Content-Type")) headers.set("Content-Type", "application/json"); + + const response = await fetch(`${API_BASE}${path}`, { ...init, headers }); + + if (response.status === 401 && retry && refreshToken) { + try { + await refreshSession(); + return send(path, init, false); + } catch { + auth.clear(); + onSignedOut?.(); + } + } + if (!response.ok) { + const body = await response.json().catch(() => null); + throw new ApiError(body?.error?.message || `Request failed (${response.status})`, response.status); + } + return response.status === 204 ? (undefined as T) : ((await response.json()) as T); +} + +const inFlight = new Map>(); + +/** + * Every API call goes through here. A change (POST/PATCH/PUT/DELETE) identical to one that is + * still on its way — a double click, a second tab of the same click — shares that one request + * instead of sending a duplicate, so it can never be applied twice. + */ +export function request(path: string, init: RequestInit = {}, retry = true): Promise { + const method = (init.method ?? "GET").toUpperCase(); + if (method === "GET" || !retry) return send(path, init, retry); + const key = `${method} ${path} ${typeof init.body === "string" ? init.body : ""}`; + const pending = inFlight.get(key); + if (pending) return pending as Promise; + const call = send(path, init, retry).finally(() => inFlight.delete(key)); + inFlight.set(key, call); + return call; +} + +export const json = (method: string, body?: unknown): RequestInit => ({ + method, + ...(body === undefined ? {} : { body: JSON.stringify(body) }), +}); + +/** Fetch a protected file and hand it to the browser as a download. */ +export async function download(url: string, filename: string): Promise { + const response = await fetch(url, { headers: { Authorization: `Bearer ${accessToken}` } }); + if (!response.ok) throw new ApiError("The PDF could not be downloaded", response.status); + const href = URL.createObjectURL(await response.blob()); + const link = document.createElement("a"); + link.href = href; + link.download = filename; + link.click(); + URL.revokeObjectURL(href); +} diff --git a/web/src/api/index.ts b/web/src/api/index.ts new file mode 100644 index 0000000..0adc9a5 --- /dev/null +++ b/web/src/api/index.ts @@ -0,0 +1,90 @@ +import type { + Approval, AreaManagerMapping, Chemist, CsvRow, CsvTable, Dcr, DcrListItem, Doctor, FormOwner, Headquarters, + FormApproval, Product, Profile, StatusCounts, StockInventory, User, +} from "../types"; +import { API_BASE, auth, download, json, request } from "./client"; + +export { ApiError, auth } from "./client"; + +type Payload = Record; + +/** `?a=1&b=2` from the values that are set, or nothing. */ +const query = (params: Record) => { + const q = new URLSearchParams(Object.entries(params).filter((e): e is [string, string] => !!e[1])); + return q.size ? `?${q}` : ""; +}; + +export const api = { + // session + async login(email: string, password: string) { + auth.save(await request("/auth/login", json("POST", { email, password }))); + return request("/auth/me"); + }, + me: () => request("/auth/me"), + profile: () => request("/users/me/profile"), + + // daily call reports + reports: () => request("/dcr?limit=200"), + counts: () => request("/dcr/counts"), + report: (id: string) => request(`/dcr/${id}`), + createReport: (payload: Payload) => request("/dcr", json("POST", payload)), + updateReport: (id: string, payload: Payload) => request(`/dcr/${id}`, json("PATCH", payload)), + addDoctorCall: (id: string, payload: Payload) => request(`/dcr/${id}/calls/doctor`, json("POST", payload)), + addChemistCall: (id: string, payload: Payload) => request(`/dcr/${id}/calls/chemist`, json("POST", payload)), + deleteCall: (id: string, callId: string) => request(`/dcr/${id}/calls/${callId}`, json("DELETE")), + submit: (id: string) => request(`/dcr/${id}/submit`, json("POST")), + returnReport: (id: string, reason: string) => request(`/dcr/${id}/return`, json("POST", { reason })), + approve: (id: string, comment: string) => request(`/dcr/${id}/approve`, json("POST", { comment: comment || null })), + approvalHistory: (id: string) => request(`/audit/dcr/${id}/approval-history`), + downloadReportPdf: (id: string) => download(`${API_BASE}/dcr/${id}/pdf`, `DCR-${id}.pdf`), + + // masters and organisation + doctors: () => request("/doctors"), + chemists: () => request("/chemists"), + headquarters: () => request("/headquarters"), + users: () => request("/users"), + areaManagerMappings: () => request("/headquarters/area-managers"), + setAreaManagerHeadquarters: (areaManagerId: string, headquarters_ids: string[]) => + request(`/headquarters/area-managers/${areaManagerId}`, json("PUT", { headquarters_ids })), + products: () => request("/products"), + stockInventory: () => request("/products/stock-inventory"), + createStockItem: (payload: Payload) => request("/products/stock-inventory", json("POST", payload)), + updateStockItem: (id: number, payload: Payload) => request(`/products/stock-inventory/${id}`, json("PATCH", payload)), + deleteStockItem: (id: number) => request(`/products/stock-inventory/${id}`, json("DELETE")), + updateDoctor: (id: string, payload: Payload) => request(`/doctors/${id}`, json("PATCH", payload)), + updateChemist: (id: string, payload: Payload) => request(`/chemists/${id}`, json("PATCH", payload)), + createHeadquarters: (payload: Payload) => request("/headquarters", json("POST", payload)), + createUser: (payload: Payload) => request("/users", json("POST", payload)), + updateUser: (id: string, payload: Payload) => request(`/users/${id}`, json("PATCH", payload)), + assignAreaManager: (headquartersId: string, area_manager_user_id: string) => + request(`/headquarters/${headquartersId}/area-manager`, json("POST", { area_manager_user_id })), + createDoctor: (payload: Payload) => request("/doctors", json("POST", payload)), + createChemist: (payload: Payload) => request("/chemists", json("POST", payload)), + createProduct: (payload: Payload) => request("/products", json("POST", payload)), + assignDoctor: (doctorId: string, mr_user_id: string) => + request(`/doctors/${doctorId}/assign`, json("POST", { mr_user_id })), + assignChemist: (chemistId: string, mr_user_id: string) => + request(`/chemists/${chemistId}/assign`, json("POST", { mr_user_id })), + + // company forms (CSV tables) + csvTables: () => request("/csv-data/tables"), + /** `ownerId` picks one MR's copy of a form (Area Manager and admin); an MR always gets their own. */ + csvRows: (table: string, ownerId?: string) => request(`/csv-data/${table}/rows${query({ owner_id: ownerId })}`), + createCsvRow: (table: string, payload: Record, ownerId?: string) => + request(`/csv-data/${table}/rows${query({ owner_id: ownerId })}`, json("POST", payload)), + updateCsvRow: (table: string, id: string, payload: Record) => + request(`/csv-data/${table}/rows/${id}`, json("PATCH", payload)), + deleteCsvRow: (table: string, id: string) => request(`/csv-data/${table}/rows/${id}`, json("DELETE")), + formApprovals: () => request("/csv-data/approvals"), + requestFormApproval: (table: string) => request(`/csv-data/${table}/approval/request`, json("POST")), + approveForm: (table: string, ownerId: string) => + request(`/csv-data/${table}/approval/approve${query({ owner_id: ownerId })}`, json("POST")), + formOwners: () => request("/csv-data/owners"), + /** The approval signature on the PDF is decided by the server, not sent from here. */ + downloadCsvPdf(table: string, opts: { rowId?: string; ownerId?: string; month?: string } = {}) { + const { rowId, ownerId, month } = opts; + if (rowId) return download(`${API_BASE}/csv-data/${table}/rows/${rowId}/pdf`, `${table}-${rowId}.pdf`); + const suffix = month ? `-${month.toLowerCase()}` : ""; + return download(`${API_BASE}/csv-data/${table}/pdf${query({ owner_id: ownerId, month })}`, `${table}${suffix}.pdf`); + }, +}; diff --git a/web/src/components/admin/HeadquartersChecklist.tsx b/web/src/components/admin/HeadquartersChecklist.tsx new file mode 100644 index 0000000..150b65c --- /dev/null +++ b/web/src/components/admin/HeadquartersChecklist.tsx @@ -0,0 +1,30 @@ +import type { Headquarters } from "../../types"; + +/** Pick any number of headquarters. `owners` shows who manages each one today. */ +export function HeadquartersChecklist({ headquarters, selected, onChange, owners = {}, disabled = false }: { + headquarters: Headquarters[]; + selected: ReadonlySet; + onChange: (next: Set) => void; + owners?: Record; + disabled?: boolean; +}) { + if (headquarters.length === 0) return

No headquarters yet — create one under Organisation first.

; + const toggle = (id: string) => { + const next = new Set(selected); + if (next.has(id)) next.delete(id); else next.add(id); + onChange(next); + }; + return ( +
+ {headquarters.map((h) => ( + + ))} +
+ ); +} diff --git a/web/src/components/layout/AppShell.tsx b/web/src/components/layout/AppShell.tsx new file mode 100644 index 0000000..f8fccc7 --- /dev/null +++ b/web/src/components/layout/AppShell.tsx @@ -0,0 +1,52 @@ +import { type ReactNode, useEffect, useState } from "react"; +import { Sidebar } from "./Sidebar"; +import { Topbar } from "./Topbar"; +import { titleFor } from "../../lib/navigation"; +import { useSession, useUser } from "../../lib/session"; +import { useLocation } from "../../lib/router"; +import { useAppUpdate } from "../../hooks/useAppUpdate"; + +const COLLAPSE_KEY = "sidebar-collapsed"; + +function readCollapsed(): boolean { + try { return localStorage.getItem(COLLAPSE_KEY) === "1"; } catch { return false; } +} + +export function AppShell({ children }: { children: ReactNode }) { + const user = useUser(); + const { signOut } = useSession(); + const path = useLocation(); + const [collapsed, setCollapsed] = useState(readCollapsed); + const [mobileOpen, setMobileOpen] = useState(false); + const update = useAppUpdate(); + + useEffect(() => { + try { localStorage.setItem(COLLAPSE_KEY, collapsed ? "1" : "0"); } catch { /* storage unavailable */ } + }, [collapsed]); + useEffect(() => { document.title = `${titleFor(path)} · Celtic Life Science`; }, [path]); + useEffect(() => { window.scrollTo(0, 0); }, [path]); + + return ( +
+ setCollapsed((v) => !v)} + onNavigate={() => setMobileOpen(false)} + /> + {mobileOpen &&
setMobileOpen(false)} />} +
+ {update.stale && ( +
+ A new version of the app is available. + +
+ )} + setMobileOpen(true)} onSignOut={signOut} /> +
{children}
+
+
+ ); +} diff --git a/web/src/components/layout/Sidebar.tsx b/web/src/components/layout/Sidebar.tsx new file mode 100644 index 0000000..436939f --- /dev/null +++ b/web/src/components/layout/Sidebar.tsx @@ -0,0 +1,43 @@ +import { Icon } from "../ui/Icon"; +import { Link } from "../../lib/router"; +import { navigationFor } from "../../lib/navigation"; +import type { Role } from "../../types"; + +const isActive = (to: string, path: string) => (to === "/" ? path === "/" : path === to || path.startsWith(`${to}/`)); + +export function Sidebar({ role, path, collapsed, mobileOpen, onToggleCollapsed, onNavigate }: { + role: Role; path: string; collapsed: boolean; mobileOpen: boolean; + onToggleCollapsed: () => void; onNavigate: () => void; +}) { + return ( + + ); +} diff --git a/web/src/components/layout/Topbar.tsx b/web/src/components/layout/Topbar.tsx new file mode 100644 index 0000000..07c66d3 --- /dev/null +++ b/web/src/components/layout/Topbar.tsx @@ -0,0 +1,52 @@ +import { useEffect, useRef, useState } from "react"; +import { Avatar } from "../ui/Misc"; +import { Badge } from "../ui/Badge"; +import { Icon } from "../ui/Icon"; +import { ROLE_LABEL } from "../../lib/format"; +import { Link } from "../../lib/router"; +import type { User } from "../../types"; + +export function Topbar({ user, title, onMenu, onSignOut }: { user: User; title: string; onMenu: () => void; onSignOut: () => void }) { + const [open, setOpen] = useState(false); + const menu = useRef(null); + + useEffect(() => { + if (!open) return; + const close = (e: MouseEvent | KeyboardEvent) => { + if (e instanceof KeyboardEvent ? e.key === "Escape" : !menu.current?.contains(e.target as Node)) setOpen(false); + }; + document.addEventListener("mousedown", close); + document.addEventListener("keydown", close); + return () => { + document.removeEventListener("mousedown", close); + document.removeEventListener("keydown", close); + }; + }, [open]); + + return ( +
+ +

{title}

+
+ {ROLE_LABEL[user.role]} +
+ + {open && ( +
+
+ {user.full_name} + {user.email} +
+ setOpen(false)}>Profile + +
+ )} +
+
+
+ ); +} diff --git a/web/src/components/reports/AddVisitForm.tsx b/web/src/components/reports/AddVisitForm.tsx new file mode 100644 index 0000000..8540486 --- /dev/null +++ b/web/src/components/reports/AddVisitForm.tsx @@ -0,0 +1,135 @@ +import { type FormEvent, useState } from "react"; +import { Alert } from "../ui/Alert"; +import { Button } from "../ui/Button"; +import { Field, Input, Select, Textarea } from "../ui/Field"; +import { useToast } from "../ui/Toast"; +import { api } from "../../api"; +import { useAsync } from "../../hooks/useAsync"; +import { errorMessage, nowHHMM, todayISO } from "../../lib/format"; +import { amount, maxLength, required, useValidation } from "../../lib/validation"; +import type { Chemist, Dcr, Doctor } from "../../types"; + +export function AddVisitForm({ dcr, doctors, chemists, onChange }: { + dcr: Dcr; doctors: Doctor[]; chemists: Chemist[]; onChange: (dcr: Dcr) => void; +}) { + const toast = useToast(); + const products = useAsync(api.stockInventory, []); + const [error, setError] = useState(null); + const [kind, setKind] = useState<"doctor" | "chemist">("doctor"); + const [targetId, setTargetId] = useState(""); + const [time, setTime] = useState(nowHHMM); + const [outcome, setOutcome] = useState("MET"); + const [conversion, setConversion] = useState("NOT_STARTED"); + const [promote, setPromote] = useState(""); + const [sample, setSample] = useState(""); + const [pob, setPob] = useState(""); + const [remarks, setRemarks] = useState(""); + const [busy, setBusy] = useState(false); + + const selectedDoctor = kind === "doctor" ? doctors.find((d) => d.id === targetId) : undefined; + const options = kind === "doctor" ? doctors : chemists; + // Visit times are local; today's report cannot hold a visit later than now. + const isToday = dcr.report_date === todayISO(); + const label = kind === "doctor" ? "Doctor" : "Chemist"; + + const v = useValidation({ + target: [required(label)], + time: [required("Visit time"), (t) => (isToday && t > nowHHMM() ? "A visit today cannot be later than the current time" : null)], + promote: [maxLength(200, "Product promoted")], + sample: [maxLength(200, "Product sample")], + pob: [maxLength(100, "POB"), amount("POB")], + remarks: [maxLength(2000, "Remarks")], + }); + const values = () => ({ target: targetId, time, promote, sample, pob, remarks }); + const on = (name: string, set: (value: string) => void) => (e: { target: { value: string } }) => { set(e.target.value); v.retouch(name, e.target.value); }; + const blur = (name: string) => (e: { target: { value: string } }) => v.touch(name, e.target.value); + + async function submit(e: FormEvent) { + e.preventDefault(); + if (!v.check(values(), e.currentTarget)) return; + setBusy(true); + setError(null); + try { + const updated = kind === "doctor" + ? await api.addDoctorCall(dcr.id, { + doctor_id: targetId, visit_time: time, call_outcome: outcome, + conversion_status: selectedDoctor?.is_core_doctor ? conversion : null, + product_promote: promote.trim() || null, product_sample: sample.trim() || null, remarks: remarks.trim() || null, + }) + : await api.addChemistCall(dcr.id, { chemist_id: targetId, visit_time: time, pob: pob.trim() || null, remarks: remarks.trim() || null }); + onChange(updated); + toast.success(`${label} visit added`); + setTargetId(""); setPromote(""); setSample(""); setPob(""); setRemarks(""); + v.clear(); + } catch (err) { + setError(errorMessage(err, "Could not add the visit")); // shown right here, where the MR is looking + } finally { + setBusy(false); + } + } + + return ( +
+ {error} + + + + + + + + + + {kind === "doctor" && ( + + + + )} + {selectedDoctor?.is_core_doctor && ( + + + + )} + {kind === "doctor" ? ( + <> + + + + + + + + {(products.data ?? []).map((p) => + + ) : ( + + + + )} + +