def _walk_versions(self, sql_connection): # Determine latest version script from the repo, then # upgrade from 1 through to the latest, with no data # in the databases. This just checks that the schema itself # upgrades successfully. # Assert we are not under version control... self.assertRaises(fault.DatabaseMigrationError, migration_api.db_version, sql_connection) # Place the database under version control print migration_api.version_control(sql_connection) cur_version = migration_api.db_version(sql_connection) self.assertEqual(0, cur_version) for version in xrange(1, TestMigrations.REPOSITORY.latest + 1): migration_api.upgrade(sql_connection, version) cur_version = migration_api.db_version(sql_connection) self.assertEqual(cur_version, version) # Now walk it back down to 0 from the latest, testing # the downgrade paths. for version in reversed(xrange(0, TestMigrations.REPOSITORY.latest)): migration_api.downgrade(sql_connection, version) cur_version = migration_api.db_version(sql_connection) self.assertEqual(cur_version, version)
def _walk_versions(self, options): # Determine latest version script from the repo, then # upgrade from 1 through to the latest, with no data # in the databases. This just checks that the schema itself # upgrades successfully. # Assert we are not under version control... self.assertRaises(fault.DatabaseMigrationError, migration_api.db_version, options) # Place the database under version control print options print migration_api.version_control(options) cur_version = migration_api.db_version(options) self.assertEqual(0, cur_version) for version in xrange(1, TestMigrations.REPOSITORY.latest + 1): migration_api.upgrade(options, version) cur_version = migration_api.db_version(options) self.assertEqual(cur_version, version) # Now walk it back down to 0 from the latest, testing # the downgrade paths. for version in reversed( xrange(0, TestMigrations.REPOSITORY.latest)): migration_api.downgrade(options, version) cur_version = migration_api.db_version(options) self.assertEqual(cur_version, version)
def get_database_version(): """Returns database's current migration level""" return migration.db_version(Command._get_connection_string())
def do_db_version(options): """Print database's current migration level""" print (migration.db_version(options))
def do_db_version(options): """Print database's current migration level""" print (migration.db_version(options['sql_connection']))
def do_db_version(options): """Print database's current migration level""" print migration.db_version(options)
def do_db_version(options): """Print database's current migration level""" print(migration.db_version(options['sql_connection']))