use of com.emc.storageos.db.common.schema.DbSchema in project coprhd-controller by CoprHD.
the class BaseDbSchemaCheckerTest method testMoveFieldToBaseClass.
@Test
public void testMoveFieldToBaseClass() {
srcSchemas.setSchemas(new ArrayList<DbSchema>());
tgtSchemas.setSchemas(new ArrayList<DbSchema>());
srcSchema = new DataObjectSchema(ChildClassUTBefore.class);
srcSchema.setType(srcSchema.getType());
srcSchemas.addSchema(srcSchema);
tgtSchema = new DataObjectSchema(ChildClassUTAfter1.class);
tgtSchema.setType(tgtSchema.getType());
tgtSchemas.addSchema(tgtSchema);
tgtSchema = new DataObjectSchema(ChildClassUTAfter2.class);
tgtSchema.setType(tgtSchema.getType());
tgtSchemas.addSchema(tgtSchema);
diff = new DbSchemasDiff(srcSchemas, tgtSchemas);
Assert.assertTrue(diff.isUpgradable());
Assert.assertTrue(diff.isChanged());
}
use of com.emc.storageos.db.common.schema.DbSchema in project coprhd-controller by CoprHD.
the class BaseDbSchemaCheckerTest method testCustomMigrationPreUpgrade.
@Test
public void testCustomMigrationPreUpgrade() {
srcSchemas.setSchemas(new ArrayList<DbSchema>());
tgtSchemas.setSchemas(new ArrayList<DbSchema>());
srcSchema = new DataObjectSchema(CustomMigrationExistingField.class);
srcSchema.setType(srcSchema.getType());
srcSchemas.addSchema(srcSchema);
tgtSchema = new DataObjectSchema(CustomMigrationExistingAndNewField.class);
tgtSchema.setType(tgtSchema.getType());
tgtSchemas.addSchema(tgtSchema);
diff = new DbSchemasDiff(srcSchemas, tgtSchemas);
Assert.assertTrue(diff.isUpgradable());
Assert.assertTrue(diff.isChanged());
}
use of com.emc.storageos.db.common.schema.DbSchema in project coprhd-controller by CoprHD.
the class DbSchemaCheckerTest method testGeoNewAnnotationOnNewCF.
@Test
public void testGeoNewAnnotationOnNewCF() {
DbSchema srcGeoSchema = new DataObjectSchema(GeoClassUT.class);
srcSchemas.addSchema(srcGeoSchema);
tgtSchemas.addSchema(srcGeoSchema);
tgtSchema = new DataObjectSchema(GeoNewCF.class);
tgtSchema.setType(srcSchema.getType());
tgtSchemas.addSchema(tgtSchema);
tgtSchemas.addSchema(srcSchema);
DbSchemasDiff diff = new DbSchemasDiff(srcSchemas, tgtSchemas);
// Adding index of new Geo object is allowed
Assert.assertTrue(diff.isUpgradable());
Assert.assertTrue(diff.isChanged());
}
use of com.emc.storageos.db.common.schema.DbSchema in project coprhd-controller by CoprHD.
the class DbSchemaCheckerTest method testGeoNewAnnotationOnNewField.
@Test
public void testGeoNewAnnotationOnNewField() {
DbSchema srcGeoSchema = new DataObjectSchema(GeoClassUT.class);
srcSchemas.addSchema(srcGeoSchema);
tgtSchema = new DataObjectSchema(GeoNewField.class);
tgtSchema.setType(srcSchema.getType());
tgtSchemas.addSchema(tgtSchema);
tgtSchemas.addSchema(srcSchema);
DbSchemasDiff diff = new DbSchemasDiff(srcSchemas, tgtSchemas);
// Adding index on new field of Geo object is allowed
Assert.assertTrue(diff.isUpgradable());
Assert.assertTrue(diff.isChanged());
}
use of com.emc.storageos.db.common.schema.DbSchema in project coprhd-controller by CoprHD.
the class DbSchemaChecker method removeUnusedSchemaIfExists.
/**
* drop schema from db is not allowed, but we have special cases to drop schema such as:
* Data Service separation, we drop schema used by Data Service to perform cleanup,
* during migration we convert xml-based schema stored in db to DbSchemas object as previous
* schema, the dropped schema needs to be skipped before schema comparison in order to removed
* schema , otherwise migration will fail because of unsupported schema change.
*
* @param schemas
* @param ignoreSchemaNames, the list of schema names which needs to be removed from schemas
* @return
*/
private static void removeUnusedSchemaIfExists(DbSchemas schemas, List<String> ignoreSchemaNames) {
Iterator<DbSchema> it = schemas.getSchemas().iterator();
while (it.hasNext()) {
DbSchema schema = it.next();
if (ignoreSchemaNames.contains(schema.getName())) {
log.info("skip schema:{} since it's removed", schema.getName());
it.remove();
}
}
}
Aggregations