1
0
Fork 0
mirror of https://github.com/geometer/FBReaderJ.git synced 2025-10-04 10:19:33 +02:00

end position in bookmarks: db side

This commit is contained in:
Nikolay Pultsin 2013-04-29 22:57:20 +02:00
parent afc8ac54ee
commit 7f5257d2fc

View file

@ -77,7 +77,7 @@ final class SQLiteBooksDatabase extends BooksDatabase {
private void migrate() { private void migrate() {
final int version = myDatabase.getVersion(); final int version = myDatabase.getVersion();
final int currentVersion = 22; final int currentVersion = 24;
if (version >= currentVersion) { if (version >= currentVersion) {
return; return;
} }
@ -129,6 +129,10 @@ final class SQLiteBooksDatabase extends BooksDatabase {
updateTables20(); updateTables20();
case 21: case 21:
updateTables21(); updateTables21();
case 22:
updateTables22();
case 23:
updateTables23();
} }
myDatabase.setTransactionSuccessful(); myDatabase.setTransactionSuccessful();
myDatabase.setVersion(currentVersion); myDatabase.setVersion(currentVersion);
@ -1363,4 +1367,20 @@ final class SQLiteBooksDatabase extends BooksDatabase {
"uid TEXT NOT NULL," + "uid TEXT NOT NULL," +
"CONSTRAINT BookUid_Unique UNIQUE (book_id,type,uid))"); "CONSTRAINT BookUid_Unique UNIQUE (book_id,type,uid))");
} }
private void updateTables22() {
myDatabase.execSQL("ALTER TABLE Bookmarks ADD COLUMN end_paragraph INTEGER");
myDatabase.execSQL("ALTER TABLE Bookmarks ADD COLUMN end_word INTEGER");
myDatabase.execSQL("ALTER TABLE Bookmarks ADD COLUMN end_character INTEGER");
}
private void updateTables23() {
myDatabase.execSQL(
"CREATE TABLE IF NOT EXISTS HighlightingStyle(" +
"style_id INTEGER PRIMARY KEY," +
"bg_color INTEGER NOT NULL)");
myDatabase.execSQL("INSERT INTO HighlightingStyle (style_id, bg_color) VALUES (1, 127*256*256 + 127*256 + 127)");
myDatabase.execSQL("ALTER TABLE Bookmarks ADD COLUMN style_id INTEGER NOT NULL REFERENCES HighlightingStyle(style_id) DEFAULT 1");
myDatabase.execSQL("UPDATE Bookmarks SET end_paragraph = LENGTH(bookmark_text)");
}
} }