diff --git a/backend/pyproject.toml b/backend/pyproject.toml index eb8e00cf..90c98477 100644 --- a/backend/pyproject.toml +++ b/backend/pyproject.toml @@ -44,6 +44,9 @@ notebooks = [ "seaborn~=0.12.2", ] +[project.scripts] +transcribee-migrate = "transcribee_backend.db.run_migrations:main" + [tool.uv] override-dependencies = [ "sqlalchemy==1.4.41" @@ -67,7 +70,7 @@ test = "pytest tests/" pyright = "pyright transcribee_backend/" [tool.setuptools] -packages = ["transcribee_backend"] +packages = ["transcribee_backend", "transcribee_backend.db"] [build-system] requires = ["setuptools", "setuptools-scm"] diff --git a/backend/transcribee_backend/db/run_migrations.py b/backend/transcribee_backend/db/run_migrations.py new file mode 100644 index 00000000..71fb1918 --- /dev/null +++ b/backend/transcribee_backend/db/run_migrations.py @@ -0,0 +1,19 @@ +#!/usr/bin/env python + +from os import path + +from alembic import command +from alembic.config import Config + + +def main(): + alembic_cfg = Config() + alembic_cfg.set_main_option( + "script_location", + path.join(path.dirname(path.realpath(__file__)), "migrations"), + ) + command.upgrade(alembic_cfg, "head") + + +if __name__ == "__main__": + main()