add modified trigger
This commit is contained in:
parent
815e40a698
commit
d4b6e34b98
@ -9,7 +9,7 @@ public class DatabaseHelper extends SQLiteOpenHelper {
|
||||
|
||||
private final String TAG = this.getClass().getSimpleName();
|
||||
public static final String DATABASE_NAME = "OfflineStorage.db";
|
||||
public static final int DATABASE_VERSION = 1;
|
||||
public static final int DATABASE_VERSION = 2;
|
||||
|
||||
public DatabaseHelper(Context context) {
|
||||
super(context, DATABASE_NAME, null, DATABASE_VERSION);
|
||||
@ -20,6 +20,7 @@ public class DatabaseHelper extends SQLiteOpenHelper {
|
||||
db.execSQL("DROP TABLE IF EXISTS feeds;");
|
||||
db.execSQL("DROP TABLE IF EXISTS articles;");
|
||||
db.execSQL("DROP VIEW IF EXISTS feeds_unread;");
|
||||
db.execSQL("DROP TRIGGER IF EXISTS articles_set_modified;");
|
||||
|
||||
db.execSQL("CREATE TABLE IF NOT EXISTS feeds (" +
|
||||
BaseColumns._ID + " INTEGER PRIMARY KEY AUTOINCREMENT," +
|
||||
@ -40,10 +41,16 @@ public class DatabaseHelper extends SQLiteOpenHelper {
|
||||
"link TEXT, " +
|
||||
"feed_id INTEGER, " +
|
||||
"tags TEXT, " +
|
||||
"content TEXT," +
|
||||
"selected BOOLEAN" +
|
||||
"content TEXT, " +
|
||||
"selected BOOLEAN, " +
|
||||
"modified BOOLEAN" +
|
||||
");");
|
||||
|
||||
db.execSQL("CREATE TRIGGER articles_set_modified UPDATE OF marked, published, unread ON articles " +
|
||||
"BEGIN " +
|
||||
" UPDATE articles SET modified = 1 WHERE " + BaseColumns._ID + " = " + "OLD." + BaseColumns._ID + "; " +
|
||||
"END;");
|
||||
|
||||
db.execSQL("CREATE VIEW feeds_unread AS SELECT feeds."+BaseColumns._ID+" AS "+BaseColumns._ID+", " +
|
||||
"feeds.title AS title, " +
|
||||
"SUM(articles.unread) AS unread FROM feeds " +
|
||||
|
Loading…
Reference in New Issue
Block a user