Skip to content

Commit

Permalink
insert keyword to Comic DB, update Chapter DB and imager DB
Browse files Browse the repository at this point in the history
  • Loading branch information
Haleydu committed Aug 31, 2020
1 parent 28e07f8 commit 4e72077
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ android {
}

greendao {
schemaVersion 10
schemaVersion 11
}

dependencies {
Expand Down
20 changes: 20 additions & 0 deletions app/src/main/java/com/hiroshi/cimoc/helper/DBOpenHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;

import com.hiroshi.cimoc.model.ChapterDao;
import com.hiroshi.cimoc.model.ComicDao;
import com.hiroshi.cimoc.model.DaoMaster;
import com.hiroshi.cimoc.model.ImageUrlDao;
import com.hiroshi.cimoc.model.SourceDao;
import com.hiroshi.cimoc.model.TagDao;
import com.hiroshi.cimoc.model.TagRefDao;
Expand Down Expand Up @@ -52,6 +54,10 @@ public void onUpgrade(Database db, int oldVersion, int newVersion) {
updateLocal(db);
case 9:
updateSource(db);
case 10:
updateIntroAndAuthor(db);
ChapterDao.createTable(db, true);
ImageUrlDao.createTable(db, true);
}
}

Expand All @@ -69,6 +75,20 @@ private void updateLocal(Database db) {
db.endTransaction();
}

private void updateIntroAndAuthor(Database db) {
db.beginTransaction();
db.execSQL("ALTER TABLE \"COMIC\" RENAME TO \"COMIC2\"");
ComicDao.createTable(db, false);
db.execSQL("INSERT INTO \"COMIC\" (\"_id\", \"SOURCE\", \"CID\", \"TITLE\", \"COVER\", " +
"\"UPDATE\", \"HIGHLIGHT\", \"LOCAL\", \"FAVORITE\", \"HISTORY\", \"DOWNLOAD\", " +
"\"LAST\", \"PAGE\", \"CHAPTER\", \"INTRO\", \"AUTHOR\") SELECT \"_id\", \"SOURCE\", \"CID\", \"TITLE\", " +
"\"COVER\", \"UPDATE\", \"HIGHLIGHT\", \"LOCAL\", \"FAVORITE\", \"HISTORY\", \"DOWNLOAD\", " +
"\"LAST\", \"PAGE\", \"CHAPTER\" ,null,null FROM \"COMIC2\"");
db.execSQL("DROP TABLE \"COMIC2\"");
db.setTransactionSuccessful();
db.endTransaction();
}

private void updateSource(Database db) {
db.beginTransaction();
db.execSQL("ALTER TABLE \"SOURCE\" RENAME TO \"SOURCE2\"");
Expand Down

0 comments on commit 4e72077

Please sign in to comment.