Пример #1
0
def force_rename_table(old, new):
    from autonomie.models import DBSESSION
    conn = DBSESSION.connection()
    if table_exists(old):
        if table_exists(new):
            op.drop_table(new)
        op.rename_table(old, new)
Пример #2
0
def force_rename_table(old, new):
    from autonomie.models import DBSESSION
    conn = DBSESSION.connection()
    if table_exists(old):
        if table_exists(new):
            op.drop_table(new)
        op.rename_table(old, new)
Пример #3
0
def run_migrations_online():
    if DBSESSION.bind is None:
        raise ValueError(
"\nYou must do Autonomie migrations using the 'autonomie-migrate' script"
"\nand not through 'alembic' directly."
            )

    transaction.begin()
    connection = DBSESSION.connection()

    context.configure(
        connection=connection,
        target_metadata=DBBASE.metadata,
        )

    try:
        context.run_migrations()
    except:
        traceback.print_exc()
        transaction.abort()
    else:
        transaction.commit()
    finally:
        #connection.close()
        pass
Пример #4
0
def column_exists(tbl, column_name):
    from autonomie.models import DBSESSION
    conn = DBSESSION.connection()
    ret = False
    try:
        conn.execute("select %s from %s" % (column_name, tbl))
        ret = True
    except:
        pass
    return ret
Пример #5
0
def table_exists(tbl):
    from autonomie.models import DBSESSION
    conn = DBSESSION.connection()
    ret = False
    try:
        conn.execute("select * from `%s`" % tbl)
        ret = True
    except:
        pass
    return ret
Пример #6
0
def column_exists(tbl, column_name):
    from autonomie.models import DBSESSION
    conn = DBSESSION.connection()
    ret = False
    try:
        conn.execute("select %s from %s" % (column_name, tbl))
        ret = True
    except:
        pass
    return ret
Пример #7
0
def table_exists(tbl):
    from autonomie.models import DBSESSION
    conn = DBSESSION.connection()
    ret = False
    try:
        conn.execute("select * from `%s`" % tbl)
        ret = True
    except:
        pass
    return ret
Пример #8
0
def run_migrations_online():
    if DBSESSION.bind is None:
        raise ValueError(
            "\nYou must do Autonomie migrations using the 'autonomie-migrate' script"
            "\nand not through 'alembic' directly.")

    transaction.begin()
    connection = DBSESSION.connection()

    context.configure(
        connection=connection,
        target_metadata=DBBASE.metadata,
    )

    try:
        context.run_migrations()
    except:
        traceback.print_exc()
        transaction.abort()
    else:
        transaction.commit()
    finally:
        #connection.close()
        pass