Search in sources :

Example 1 with NewEmptyModel

use of com.orm.androrm.impl.migration.NewEmptyModel in project androrm by androrm.

the class RenameModelMigrationTest method testRenameTable.

public void testRenameTable() {
    Migrator<NewEmptyModel> migrator = new Migrator<NewEmptyModel>(NewEmptyModel.class);
    assertTrue(mHelper.tableExists(EmptyModel.class));
    EmptyModel model1 = new EmptyModel();
    model1.save(getContext());
    assertEquals(1, EmptyModel.objects(getContext()).count());
    assertEquals(0, NewEmptyModel.objects(getContext()).count());
    migrator.renameModel("EmptyModel", NewEmptyModel.class);
    migrator.migrate(getContext());
    assertFalse(mHelper.tableExists(EmptyModel.class));
    assertEquals(1, NewEmptyModel.objects(getContext()).count());
    Filter filter = new Filter();
    filter.is("mModel", "newemptymodel").is("mAction", "rename_table").is("mValue", "newemptymodel");
    assertEquals(1, Migration.objects(getContext()).filter(filter).count());
}
Also used : Filter(com.orm.androrm.Filter) EmptyModel(com.orm.androrm.impl.migration.EmptyModel) NewEmptyModel(com.orm.androrm.impl.migration.NewEmptyModel) Migrator(com.orm.androrm.migration.Migrator) NewEmptyModel(com.orm.androrm.impl.migration.NewEmptyModel)

Aggregations

Filter (com.orm.androrm.Filter)1 EmptyModel (com.orm.androrm.impl.migration.EmptyModel)1 NewEmptyModel (com.orm.androrm.impl.migration.NewEmptyModel)1 Migrator (com.orm.androrm.migration.Migrator)1