package com.philisense.rdgo.db;

import io.realm.DynamicRealm;
import io.realm.FieldAttribute;
import io.realm.RealmMigration;
import io.realm.RealmObjectSchema;
import io.realm.RealmSchema;

/**
 * Created by chenxiaopeng on 2018/2/7.
 */

public class Migration implements RealmMigration {
    @Override
    public void migrate(DynamicRealm realm, long oldVersion, long newVersion) {
        RealmSchema schema = realm.getSchema();

        if (oldVersion == 0) {
            RealmObjectSchema personSchema = schema.get("UserDb");

            personSchema
                    .addField("warehouseCode", String.class, FieldAttribute.REQUIRED);

            oldVersion++;
        }
    }
}
