| β¬ οΈ Back | π Docs Root |
This README file provides essential information and commands for managing database migrations for the Telegram Bot when it operates in βdirectβ data mode (i.e., when the bot has its own database).
It clarifies that these migrations are only relevant when BOT_DATA_MODE=direct and that in api mode, the bot interacts with a backend via REST, without direct database access.
The README outlines key Alembic commands for managing migrations:
alembic upgrade head
This command applies all migration scripts that have not yet been run, bringing the database schema up to the latest version.
alembic revision --autogenerate -m "add_user_subscriptions"
This command automatically generates a new migration script based on changes detected in the SQLAlchemy models. The -m flag allows adding a descriptive message for the migration.
alembic current
This command displays the current version of the database schema.
The documentation highlights that the bot uses a dedicated PostgreSQL schema named bot_app (configurable via the DB_SCHEMA environment variable). This approach enables sharing a single database instance (e.g., Neon) with other backend services like Django or FastAPI, while maintaining schema separation.