示例#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)
示例#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)
示例#3
0
def do_db_version_control(options):
    """Place a database under migration control"""
    migration.version_control(options)
    print ("Database now under version control")
示例#4
0
def do_db_version_control(options):
    """Place a database under migration control"""
    migration.version_control(options)
    print "Database now under version control"
示例#5
0
 def version_control_database():
     """Place database under migration control"""
     migration.version_control(Command._get_connection_string())
示例#6
0
def do_db_version_control(options):
    """Place a database under migration control"""
    migration.version_control(options['sql_connection'])
    print("Database now under version control")