Created
February 10, 2021 06:54
-
-
Save pingzh/80d4d002224c13f141b6b34be656273b to your computer and use it in GitHub Desktop.
Run alembic command with code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from alembic.config import Config | |
from alembic import command | |
def run_db_migrations(dsn: str) -> None: | |
LOGGER.info('Running DB migrations on %r', dsn) | |
alembic_cfg = Config('alembic.ini') | |
alembic_cfg.set_main_option('sqlalchemy.url', dsn) | |
command.upgrade(alembic_cfg, 'head') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Might need to change it, so it wont affect the current logging