Skip to content

Commit

Permalink
✨ Allow running Alembic migrations through DutyBoard cli
Browse files Browse the repository at this point in the history
  • Loading branch information
Jorricks committed Nov 29, 2023
1 parent c08353f commit b020e8d
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
include README.md
include CONTRIBUTING.md
include duty_board/alembic.ini
graft duty_board/plugin/example
graft duty_board/www/static
graft duty_board/www/user_images
Expand Down
9 changes: 9 additions & 0 deletions duty_board/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
import subprocess
import sys
from pathlib import Path
from typing import Any, List

import click
from alembic.config import CommandLine
from click import Context

from duty_board import worker_loop
Expand All @@ -26,6 +28,13 @@ def cli() -> None:
pass


@cli.command(context_settings={"ignore_unknown_options": True, "help_option_names": []})
@click.argument("args", nargs=-1, type=click.UNPROCESSED)
def db(args: List[Any]) -> None:
path_to_alembic_ini = Path(__file__).resolve().parent / "alembic.ini"
CommandLine(prog="DutyBoard db").main(argv=["-c", str(path_to_alembic_ini), *args]) # type: ignore[no-untyped-call]


@cli.command()
def update_calendars() -> None:
logger.info("Updating plugin calendars in the database.")
Expand Down
2 changes: 1 addition & 1 deletion duty_board/alembic.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[alembic]
# path to migration scripts
script_location = alembic
script_location = %(here)s/alembic

# template used to generate migration file names; The default value is %%(rev)s_%%(slug)s
# Uncomment the line below if you want the files to be prepended with date and time
Expand Down
Empty file added duty_board/alembic/__init__.py
Empty file.
1 change: 1 addition & 0 deletions duty_board/alembic/versions/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

0 comments on commit b020e8d

Please sign in to comment.