This commit is contained in:
Waylon Walker 2023-06-22 16:02:03 -05:00
parent 8480cd3d24
commit e86e432102
No known key found for this signature in database
GPG key ID: 66E2BF2B4190EFE4
11 changed files with 352 additions and 69 deletions

View file

@ -1,4 +1,5 @@
from pathlib import Path
from typing import Annotated
import alembic
from alembic.config import Config
@ -6,6 +7,7 @@ import copier
import typer
from learn_sql_model.cli.common import verbose_callback
from learn_sql_model.config import get_config
model_app = typer.Typer()
@ -40,11 +42,18 @@ def create_revision(
callback=verbose_callback,
help="show the log messages",
),
message: str = typer.Option(
prompt=True,
),
message: Annotated[
str,
typer.Option(
"--message",
"-m",
prompt=True,
),
] = None,
):
alembic_cfg = Config("alembic.ini")
config = get_config()
alembic_cfg.set_main_option("sqlalchemy.url", config.database_url)
alembic.command.revision(
config=alembic_cfg,
message=message,
@ -63,7 +72,17 @@ def checkout(
revision: str = typer.Option("head"),
):
alembic_cfg = Config("alembic.ini")
alembic.command.upgrade(config=alembic_cfg, revision="head")
config = get_config()
alembic_cfg.set_main_option("sqlalchemy.url", config.database_url)
alembic.command.upgrade(config=alembic_cfg, revision=revision)
@model_app.command()
def status():
alembic_cfg = Config("alembic.ini")
config = get_config()
alembic_cfg.set_main_option("sqlalchemy.url", config.database_url)
alembic.command.current(config=alembic_cfg)
@model_app.command()