Exemplo n.º 1
0
    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)
Exemplo n.º 2
0
    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)
Exemplo n.º 3
0
def do_db_upgrade(options, args):
    """Upgrade the database's migration level"""
    try:
        db_version = args[2]
    except IndexError:
        db_version = None

    print ("Upgrading database to version %s" % db_version)
    migration.upgrade(options, version=db_version)
Exemplo n.º 4
0
def do_db_upgrade(options, args):
    """Upgrade the database's migration level"""
    try:
        db_version = args[2]
    except IndexError:
        db_version = None

    print "Upgrading database to version %s" % db_version
    migration.upgrade(options, version=db_version)
Exemplo n.º 5
0
 def upgrade_database(version):
     """Upgrade database to the specified version"""
     migration.upgrade(Command._get_connection_string(), version=version)
Exemplo n.º 6
0
 def upgrade_database(version):
     """Upgrade database to the specified version"""
     migration.upgrade(Command._get_connection_string(), version=version)