https://github.com/zhuinden/realm-auto-migration
[ABANDONED] Automatic migration from the currently existing schema to the currently existing model classes.
https://github.com/zhuinden/realm-auto-migration
Last synced: about 1 month ago
JSON representation
[ABANDONED] Automatic migration from the currently existing schema to the currently existing model classes.
- Host: GitHub
- URL: https://github.com/zhuinden/realm-auto-migration
- Owner: Zhuinden
- License: apache-2.0
- Created: 2017-09-28T15:09:25.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-08-09T10:09:53.000Z (almost 7 years ago)
- Last Synced: 2024-10-26T21:34:48.437Z (7 months ago)
- Language: Java
- Homepage:
- Size: 143 KB
- Stars: 14
- Watchers: 3
- Forks: 4
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Realm Auto-Migration
Automatic migration from the currently existing schema to the currently existing model classes.
The API is subject to change.
## Using AutoMigration
Currently you can copy the `AutoMigration.java` file to your project. Not exposed on Jitpack yet or anything.
Please read the section below on what annotations you need to apply to make things work.
## Proguard
```
-keepnames public class * extends io.realm.RealmModel
-keep public class * extends io.realm.RealmModel { *; }
-keepnames public class * extends io.realm.RealmObject
-keep public class * extends io.realm.RealmObject { *; }
-keepattributes *Annotation*
```## Behavior
This migration attempts to migrate the Realm schema from one version to the current models provided in the configuration.
In case of mismatch, fields defined only in schema but not in model are removed, and fields defined only in model but not in schema are added.
## Linked fields
To add `RealmList` field, you must specify {@link MigratedList} on that field with the list type.
This properly supports both links and primitive lists.
`@AutoMigration.MigratedList` must be applied to detect changes in `RealmList`'s `@Required` annotation.
## Example
``` java
public class Dog
extends RealmObject {
@PrimaryKey
private long id;@Index
private String name;@Required
private String ownerName;private Cat cat;
@AutoMigration.MigratedList(listType = Cat.class)
private RealmList manyCats;
@AutoMigration.MigratedList(listType = String.class)
private RealmList phoneNumbers;
}
```## License
Copyright 2017 Gabor Varadi
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License athttp://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.