Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
SRCT
whats-open-android
Commits
667f5518
Commit
667f5518
authored
Jan 05, 2018
by
Robert Hitt
Browse files
Fixed Realm migration issue
parent
0be851a1
Pipeline
#1943
passed with stages
in 2 minutes and 55 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
.gitignore
View file @
667f5518
...
...
@@ -16,6 +16,7 @@ out/
# Gradle files
.gradle/
build/
app/release/
# Local configuration file (sdk path, etc)
local.properties
...
...
app/build.gradle
View file @
667f5518
...
...
@@ -26,8 +26,8 @@ android {
applicationId
"srct.whatsopen"
minSdkVersion
16
targetSdkVersion
26
versionCode
5
versionName
"1.0.
4
"
versionCode
6
versionName
"1.0.
5
"
testInstrumentationRunner
"android.support.test.runner.AndroidJUnitRunner"
}
buildTypes
{
...
...
app/src/main/java/srct/whatsopen/Migration.java
deleted
100644 → 0
View file @
0be851a1
package
srct.whatsopen
;
import
io.realm.DynamicRealm
;
import
io.realm.RealmMigration
;
import
io.realm.RealmObjectSchema
;
import
io.realm.RealmSchema
;
import
srct.whatsopen.model.Location
;
public
class
Migration
implements
RealmMigration
{
@Override
public
void
migrate
(
DynamicRealm
realm
,
long
oldVersion
,
long
newVersion
)
{
RealmSchema
schema
=
realm
.
getSchema
();
if
(
oldVersion
==
-
1
)
{
RealmObjectSchema
facilitySchema
=
schema
.
get
(
"Facility"
);
facilitySchema
.
renameField
(
"mName"
,
"name"
)
.
renameField
(
"mMainSchedule"
,
"mainSchedule"
)
.
renameField
(
"mSpecialSchedules"
,
"specialSchedules"
)
.
removeField
(
"mLocation"
)
.
addField
(
"location"
,
Location
.
class
);
RealmObjectSchema
mainScheduleSchema
=
schema
.
get
(
"MainSchedule"
);
mainScheduleSchema
.
addField
(
"openTwentyFourHours"
,
Boolean
.
class
);
RealmObjectSchema
specialScheduleSchema
=
schema
.
get
(
"SpecialSchedule"
);
specialScheduleSchema
.
addField
(
"openTwentyFourHours"
,
Boolean
.
class
);
oldVersion
++;
}
}
}
app/src/main/java/srct/whatsopen/MyApplication.java
View file @
667f5518
...
...
@@ -6,14 +6,13 @@ import android.content.SharedPreferences;
import
android.content.pm.ActivityInfo
;
import
android.content.res.Configuration
;
import
android.preference.PreferenceManager
;
import
android.util.Log
;
import
com.crashlytics.android.BuildConfig
;
import
com.crashlytics.android.Crashlytics
;
import
com.crashlytics.android.core.CrashlyticsCore
;
import
com.squareup.leakcanary.LeakCanary
;
import
io.fabric.sdk.android.Fabric
;
import
io.realm.DynamicRealm
;
import
io.realm.Realm
;
import
io.realm.RealmConfiguration
;
...
...
@@ -37,9 +36,7 @@ public class MyApplication extends Application {
// Default Realm config. Might want to change this later
Realm
.
init
(
this
);
RealmConfiguration
realmConfig
=
new
RealmConfiguration
.
Builder
()
.
name
(
"default.realm"
)
.
schemaVersion
(
0
)
.
migration
(
new
Migration
())
.
deleteRealmIfMigrationNeeded
()
.
build
();
Realm
.
setDefaultConfiguration
(
realmConfig
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment