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)
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)
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
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
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
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
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
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