From 110e2199734976b009bbc72ede1b530630f4947e Mon Sep 17 00:00:00 2001 From: "dietrich%mozilla.com" Date: Fri, 16 Mar 2007 18:25:38 +0000 Subject: [PATCH] Bug 371827 - places bookmarks need additional metadata (schema changes only, r=sspitzer) --- .../components/places/src/nsNavBookmarks.cpp | 24 ++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/toolkit/components/places/src/nsNavBookmarks.cpp b/toolkit/components/places/src/nsNavBookmarks.cpp index 2181282fbf4..8e4ddaa2a6b 100644 --- a/toolkit/components/places/src/nsNavBookmarks.cpp +++ b/toolkit/components/places/src/nsNavBookmarks.cpp @@ -301,7 +301,29 @@ nsNavBookmarks::InitTables(mozIStorageConnection* aDBConn) "parent INTEGER, " "position INTEGER, " "title LONGVARCHAR, " - "keyword_id INTEGER)")); + "keyword_id INTEGER, " + "dateAdded DATE, " + "lastModified DATE)")); + NS_ENSURE_SUCCESS(rv, rv); + + // Add a trigger for populating the dateAdded and lastModified + // fields after a bookmark is added. + rv = aDBConn->ExecuteSimpleSQL(NS_LITERAL_CSTRING( + "CREATE TRIGGER insert_moz_bookmarks_dateAdded " + "AFTER INSERT ON moz_bookmarks BEGIN " + "UPDATE moz_bookmarks SET " + "dateAdded = DATETIME('NOW'), lastModified = DATETIME('NOW') " + "WHERE rowid = NEW.rowid; " + "END ")); + NS_ENSURE_SUCCESS(rv, rv); + + // Add a trigger for update the lastModified field after a bookmark is updated. + rv = aDBConn->ExecuteSimpleSQL(NS_LITERAL_CSTRING( + "CREATE TRIGGER update_moz_bookmarks_lastModified " + "AFTER UPDATE ON moz_bookmarks BEGIN " + "UPDATE moz_bookmarks SET lastModified = DATETIME('NOW') " + "WHERE rowid = OLD.rowid; " + "END ")); NS_ENSURE_SUCCESS(rv, rv); // this index will make it faster to determine if a given item is