assert DatabaseDescriptor.getDefsVersion().equals(prior);
// add a cf.
CFMetaData newCf1 = addTestCF("Keyspace1", "MigrationCf_1", "Migration CF");
Migration m1 = new AddColumnFamily(newCf1);
m1.apply();
UUID ver1 = m1.getVersion();
assert DatabaseDescriptor.getDefsVersion().equals(ver1);
// rename it.
Migration m2 = new RenameColumnFamily("Keyspace1", "MigrationCf_1", "MigrationCf_2");
m2.apply();
UUID ver2 = m2.getVersion();
assert DatabaseDescriptor.getDefsVersion().equals(ver2);
// drop it.
Migration m3 = new DropColumnFamily("Keyspace1", "MigrationCf_2");
m3.apply();
UUID ver3 = m3.getVersion();
assert DatabaseDescriptor.getDefsVersion().equals(ver3);
// now lets load the older migrations to see if that code works.
Collection<IColumn> serializedMigrations = Migration.getLocalMigrations(ver1, ver3);
assert serializedMigrations.size() == 3;
// test deserialization of the migrations.
Migration[] reconstituded = new Migration[3];
int i = 0;
for (IColumn col : serializedMigrations)
{
UUID version = UUIDGen.getUUID(col.name());
reconstituded[i] = Migration.deserialize(col.value());
assert version.equals(reconstituded[i].getVersion());
i++;
}
assert m1.getClass().equals(reconstituded[0].getClass());
assert m2.getClass().equals(reconstituded[1].getClass());
assert m3.getClass().equals(reconstituded[2].getClass());
// verify that the row mutations are the same. rather than exposing the private fields, serialize and verify.
assert m1.serialize().equals(reconstituded[0].serialize());
assert m2.serialize().equals(reconstituded[1].serialize());
assert m3.serialize().equals(reconstituded[2].serialize());
}