Пример #1
0
def test_version_setter(database):
    schema = Schema(database)
    schema.create_if_needed()
    schema.version = 2
    versions = database.execute('select (version) from schema_versions;')

    assert versions == [{'version': 0}, {'version': 2}]
Пример #2
0
def test_migrate_latest_when_some_migrations_have_been_performed(database):
    migrator = Migrator(database=database, dir_path=path)
    migration = Migration(path / '1_create_bad_decks.py')
    migrator.perform_migration(migration)
    migrator.migrate_latest()

    assert Schema(database).version == 2
Пример #3
0
def test_perform_migration(database):
    migrator = Migrator(database=database, dir_path=path)
    migration = Migration(path / '1_create_bad_decks.py')
    migrator.perform_migration(migration)

    table_exists = database.execute("""
    SELECT EXISTS (
        SELECT 1
        FROM information_schema.tables
        WHERE table_name = 'bad_decks'
    );
    """)

    assert table_exists == [{'exists': True}]
    assert Schema(database).version == 1
Пример #4
0
def test_create_if_needed(database):
    schema = Schema(database)
    schema.create_if_needed()
    versions = database.execute('select (version) from schema_versions;')

    assert versions == [{'version': 0}]
Пример #5
0
def test_version_getter(database):
    schema = Schema(database)
    schema.create_if_needed()

    assert schema.version == 0
Пример #6
0
 def wrapper(database):
     Schema(database).reset()
     func(database)
Пример #7
0
def test_subsequent_migrate_latest(database):
    migrator = Migrator(database=database, dir_path=path)
    migrator.migrate_latest()
    migrator.migrate_latest()

    assert Schema(database).version == 2
Пример #8
0
def test_migrate_latest_persists_schema_version(database):
    migrator = Migrator(database=database, dir_path=path)
    migrator.migrate_latest()

    assert Schema(database).version == 2