Esempio n. 1
0
def apply_migrations(db_dsn=None):

    db_dsn = db_dsn or settings.DB_DSN

    current_dir = Path(__name__).parent
    config_dir = Path(current_dir) / 'ketl' / 'db' / 'config'

    alembic_cfg = Config(file_=str(config_dir / 'alembic.ini'))
    alembic_cfg.set_main_option('script_location', str(config_dir))
    alembic_cfg.set_main_option('sqlalchemy.url', db_dsn)
    command.upgrade(alembic_cfg, 'head')
Esempio n. 2
0
def update_db(update=True):
    db_connection = DatabaseConnection(database=options.sql_database,
                                   hostname=options.sql_host,
                                   port=options.sql_port,
                                   username=options.sql_user,
                                   password=options.sql_password,
                                   dialect=options.sql_dialect)
    alembic_cfg = Config('alembic/alembic.ini')
    alembic_cfg.attributes['configure_logger'] = False
    alembic_cfg.set_main_option('sqlalchemy.url', unquote_plus(str(db_connection)))
    if update:
        command.upgrade(alembic_cfg, "head")
    else:
        command.stamp(alembic_cfg, "head")
Esempio n. 3
0
def update_db(update=True):
    db_connection = DatabaseConnection(database=options.sql_database,
                                   hostname=options.sql_host,
                                   port=options.sql_port,
                                   username=options.sql_user,
                                   password=options.sql_password,
                                   dialect=options.sql_dialect)
    alembic_cfg = Config('alembic/alembic.ini')
    alembic_cfg.attributes['configure_logger'] = False
    alembic_cfg.set_main_option('sqlalchemy.url', unquote_plus(str(db_connection)))
    if update:
        command.upgrade(alembic_cfg, "head")
    else:
        command.stamp(alembic_cfg, "head")
Esempio n. 4
0
def update_db(update=True):
    logging.info("Checking for Database Updates...")
    db_connection = DatabaseConnection(
        database=options.sql_database,
        hostname=options.sql_host,
        port=options.sql_port,
        username=options.sql_user,
        password=options.sql_password,
        dialect=options.sql_dialect,
    )
    alembic_cfg = Config("alembic/alembic.ini")
    alembic_cfg.attributes["configure_logger"] = False
    alembic_cfg.set_main_option("sqlalchemy.url", unquote(str(db_connection)))
    if update:
        command.upgrade(alembic_cfg, "head")
    else:
        command.stamp(alembic_cfg, "head")