Refactor Alembic configuration and update Docker setup

- Removed the `alembic.ini` file and migrated its configuration to `pyproject.toml` under `[tool.alembic]`, enhancing project organization.
- Updated the `Dockerfile` to copy `pyproject.toml` instead of `alembic.ini`, ensuring the new configuration is utilized during the build process.
- Modified `entrypoint.sh` to use the new Alembic configuration from `pyproject.toml` for database migrations.
- Updated README documentation to reflect the new Alembic configuration and usage instructions.
This commit is contained in:
2026-02-18 13:06:57 +03:00
parent 28973489a5
commit ec58739852
6 changed files with 17 additions and 45 deletions

View File

@@ -1,8 +1,8 @@
"""Alembic env: use duty_teller config DATABASE_URL and db.models.Base."""
import logging
import os
import sys
from logging.config import fileConfig
from sqlalchemy import create_engine
from alembic import context
@@ -12,9 +12,15 @@ sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
import duty_teller.config as config
from duty_teller.db.models import Base
# Logging when config is in pyproject.toml (no fileConfig)
logging.basicConfig(
format="%(levelname)-5.5s [%(name)s] %(message)s",
datefmt="%H:%M:%S",
level=logging.INFO,
)
logging.getLogger("sqlalchemy.engine").setLevel(logging.WARN)
config_alembic = context.config
if config_alembic.config_file_name is not None:
fileConfig(config_alembic.config_file_name)
database_url = config.DATABASE_URL
config_alembic.set_main_option("sqlalchemy.url", database_url)