我目前在我的Android应用程序中使用Ollie ORM。 我想做一些架构迁移。
如果我查看this,我得出结论,我应该创建一个新类。我已经创建了迁移类,如下所示:
import ollie.Migration;
public class MigrateToVersionTwo extends Migration {
@Override
public int getVersion() {
return 2;
}
@Override
public String[] getStatements() {
return new String[]{
"ALTER TABLE events ADD COLUMN test INTEGER;"
};
}
}
我也将database_version从1改为2。
但架构没有任何改变......我错过了什么?
如果您需要更多信息,请参阅AdapterHolderImpl.java类:
package ollie;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import ollie.adapter.BooleanAdapter;
import ollie.adapter.CalendarAdapter;
import ollie.adapter.SqlDateAdapter;
import ollie.adapter.UtilDateAdapter;
import ollie.internal.AdapterHolder;
import ollie.internal.ModelAdapter;
public final class AdapterHolderImpl
implements AdapterHolder {
private static final List<Migration> MIGRATIONS = new ArrayList<Migration>();
private static final Map<Class<? extends Model>, ModelAdapter> MODEL_ADAPTERS = new HashMap<Class<? extends Model>, ModelAdapter>();
private static final Map<Class, TypeAdapter> TYPE_ADAPTERS = new HashMap<Class, TypeAdapter>();
static {
MODEL_ADAPTERS.put(com.me.model.SafeZoneVO.class, new ollie.SafeZoneVO$$ModelAdapter());
MODEL_ADAPTERS.put(com.me.model.EventVO.class, new ollie.EventVO$$ModelAdapter());
MODEL_ADAPTERS.put(com.me.model.ContactVO.class, new ollie.ContactVO$$ModelAdapter());
MODEL_ADAPTERS.put(com.me.model.User.class, new ollie.User$$ModelAdapter());
MODEL_ADAPTERS.put(com.me.model.Place.class, new ollie.Place$$ModelAdapter());
TYPE_ADAPTERS.put(java.util.Calendar.class, new CalendarAdapter());
TYPE_ADAPTERS.put(java.util.Date.class, new UtilDateAdapter());
TYPE_ADAPTERS.put(java.lang.Boolean.class, new BooleanAdapter());
TYPE_ADAPTERS.put(java.sql.Date.class, new SqlDateAdapter());
}
public final List<? extends Migration> getMigrations() {
return MIGRATIONS;
}
public final <T extends Model> ModelAdapter<T> getModelAdapter(Class<? extends Model> cls) {
return MODEL_ADAPTERS.get(cls);
}
public final List<? extends ModelAdapter> getModelAdapters() {
return new ArrayList(MODEL_ADAPTERS.values());
}
public final <D, S> TypeAdapter<D, S> getTypeAdapter(Class<D> cls) {
return TYPE_ADAPTERS.get(cls);
}
}
答案 0 :(得分:2)
事实证明我必须使用最新版本(目前0.3.2-SNAPSHOT
)。
所以,我将构建gradle更改为:
apt 'com.michaelpardo:ollie-compiler:0.3.2-SNAPSHOT'
compile 'com.michaelpardo:ollie:0.3.2-SNAPSHOT'
并为快照版本添加了存储库:
maven { url "https://oss.sonatype.org/content/repositories/snapshots/"}