Exemple #1
0
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']
Exemple #2
0
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']
Exemple #3
0
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)
Exemple #4
0
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)
Exemple #5
0
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']
Exemple #6
0
def test_two_ups(db):
    migration.up(db, MIGRATIONS)
    migration.up(db, MIGRATIONS)
    assert trim_backend_tables(tables(db)) == [VERSION_TABLE, 'first', 'second']
Exemple #7
0
def test_nothing(db):
    assert tables(db) == []
Exemple #8
0
def test_up_and_down_multiple_operations(db):
    migration.up(db, MIGRATIONS)
    migration.down(db, MIGRATIONS)
    assert trim_backend_tables(tables(db)) == [VERSION_TABLE]
Exemple #9
0
def test_up_multiple_operations(db):
    migration.up(db, MIGRATIONS)
    assert trim_backend_tables(tables(db)) == [VERSION_TABLE, 'one', 'two']