Skip to content

Db

db_downgrade(revision='-1')

Downgrades the database to the previous revision using Alembic.

Source code in cli/db.py
12
13
14
15
16
def db_downgrade(revision: str = "-1"):
    """
    Downgrades the database to the previous revision using Alembic.
    """
    subprocess.run(["alembic", "downgrade", f"{revision}"])

db_make_migrations(message='', auto=True)

Creates a new revision using Alembic.

Args: message (str): The revision message. auto (bool): Whether to generate the revision automatically (default: True).

Source code in cli/db.py
19
20
21
22
23
24
25
26
27
28
29
30
31
32
def db_make_migrations(message: str = "", auto: bool = True):
    """
    Creates a new revision using Alembic.

    Args:
        message (str): The revision message.
        auto (bool): Whether to generate the revision automatically (default: True).
    """
    cmds = ["alembic", "revision"]
    if message:
        cmds += ["-m", f"{message}"]
    if auto:
        cmds += ["--autogenerate"]
    subprocess.run(cmds)

db_upgrade()

Upgrades the database to the latest revision using Alembic.

Source code in cli/db.py
5
6
7
8
9
def db_upgrade():
    """
    Upgrades the database to the latest revision using Alembic.
    """
    subprocess.run(["alembic", "upgrade", "head"])