Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

don't skip .sql upgrade scipts after a forced upgrade if the bundled database file is not the latest version #109

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ buildscript {
}

dependencies {
classpath "com.android.tools.build:gradle:0.7.+"
classpath 'com.android.tools.build:gradle:1.5.0'
}
}

Expand Down
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Wed Apr 10 15:27:10 PDT 2013
#Wed Jan 13 15:54:05 GMT 2016
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=http\://services.gradle.org/distributions/gradle-1.9-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-2.8-all.zip
6 changes: 3 additions & 3 deletions library/build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apply plugin: 'android-library'
apply plugin: 'com.android.library'

android {
buildToolsVersion '19.0.0'
buildToolsVersion '19.1.0'
compileSdkVersion 19

defaultConfig {
Expand All @@ -11,7 +11,7 @@ android {

android.libraryVariants.all { variant ->
def name = variant.buildType.name
if (name.equals(com.android.builder.BuilderConstants.DEBUG)) {
if (name.equals(com.android.builder.core.BuilderConstants.DEBUG)) {
return; // Skip debug builds.
}
def task = project.tasks.create "jar${name.capitalize()}", Jar
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,9 +179,13 @@ public synchronized SQLiteDatabase getWritableDatabase() {

// do force upgrade
if (version != 0 && version < mForcedUpgradeVersion) {
//Close the old database
db.close();
db = createOrOpenDatabase(true);
db.setVersion(mNewVersion);
Log.w(TAG, "Forced Upgrade because " + version + " < " + mForcedUpgradeVersion);
version = db.getVersion();
if(version != mNewVersion)
Log.w(TAG, "Forced Upgrade got " + version + ", now an upgrade to " + mNewVersion + " is required");
}

if (version != mNewVersion) {
Expand Down
6 changes: 3 additions & 3 deletions samples/database-v1/build.gradle
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
apply plugin: 'android'
apply plugin: 'com.android.application'

dependencies {
compile project(':library')
}

android {
buildToolsVersion '19.0.0'
buildToolsVersion '19.1.0'
compileSdkVersion 19

defaultConfig {
minSdkVersion 8
packageName 'com.example.sqliteassethelper'
applicationId 'com.example.sqliteassethelper'
targetSdkVersion 19
versionCode 1
versionName '1.0'
Expand Down
9 changes: 3 additions & 6 deletions samples/database-v13-upgrade/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,16 @@ buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.7.+'
}
}
apply plugin: 'android'
apply plugin: 'com.android.application'

repositories {
mavenCentral()
}

android {
compileSdkVersion 19
buildToolsVersion "19.0.0"
buildToolsVersion "19.1.0"

defaultConfig {
minSdkVersion 8
Expand All @@ -24,7 +21,7 @@ android {
}
buildTypes {
release {
runProguard false
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
Expand Down
6 changes: 3 additions & 3 deletions samples/database-v2-upgrade/build.gradle
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
apply plugin: 'android'
apply plugin: 'com.android.application'

dependencies {
compile project(':library')
}

android {
buildToolsVersion '19.0.0'
buildToolsVersion '19.1.0'
compileSdkVersion 19

defaultConfig {
minSdkVersion 8
packageName 'com.example.sqliteassethelper'
applicationId 'com.example.sqliteassethelper'
targetSdkVersion 19
versionCode 2
versionName '2.0'
Expand Down