def get(db): if VERSION_TABLE not in tables(db): return None else: e = db.execute( text("""SELECT id FROM %s LIMIT 1;""" % (VERSION_TABLE, ))) e = e.fetchone() return dict(e)['id']
def get(db): if VERSION_TABLE not in tables(db): return None else: e = db.execute(text( """SELECT id FROM %s LIMIT 1;""" % (VERSION_TABLE,) )) e = e.fetchone() return dict(e)['id']
def create_version(db, v): # TODO: make this atomic / look into alembic to check if they solve the issue. if VERSION_TABLE not in tables(db): db.execute( text("""CREATE TABLE %s (id VARCHAR(128));""" % (VERSION_TABLE, ))) db.execute(text("""INSERT INTO %s (id) VALUES (:id);""" % (VERSION_TABLE, )), id=v)
def create_version(db, v): # TODO: make this atomic / look into alembic to check if they solve the issue. if VERSION_TABLE not in tables(db): db.execute(text( """CREATE TABLE %s (id VARCHAR(128));""" % (VERSION_TABLE,) )) db.execute(text( """INSERT INTO %s (id) VALUES (:id);""" % (VERSION_TABLE,) ), id=v)
def test_up_up_and_down(db): migration.up(db, MIGRATIONS) migration.up(db, MIGRATIONS) migration.down(db, MIGRATIONS) assert trim_backend_tables(tables(db)) == [VERSION_TABLE, 'first']
def test_two_ups(db): migration.up(db, MIGRATIONS) migration.up(db, MIGRATIONS) assert trim_backend_tables(tables(db)) == [VERSION_TABLE, 'first', 'second']
def test_nothing(db): assert tables(db) == []
def test_up_and_down_multiple_operations(db): migration.up(db, MIGRATIONS) migration.down(db, MIGRATIONS) assert trim_backend_tables(tables(db)) == [VERSION_TABLE]
def test_up_multiple_operations(db): migration.up(db, MIGRATIONS) assert trim_backend_tables(tables(db)) == [VERSION_TABLE, 'one', 'two']