From 4904c04e3e387b1e15cdc8e5e6f18789e884f29a Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Fri, 16 Jun 2006 16:09:18 +0000 Subject: [PATCH] Add dateCreated and dateModified columns to itemNotes Update itemNotes.dateModified on item update --- chrome/chromeFiles/content/scholar/xpcom/data_access.js | 6 ++++-- chrome/chromeFiles/content/scholar/xpcom/schema.js | 4 ++-- schema.sql | 4 +++- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/chrome/chromeFiles/content/scholar/xpcom/data_access.js b/chrome/chromeFiles/content/scholar/xpcom/data_access.js index 3e85e66c75..3485df4199 100644 --- a/chrome/chromeFiles/content/scholar/xpcom/data_access.js +++ b/chrome/chromeFiles/content/scholar/xpcom/data_access.js @@ -710,7 +710,8 @@ Scholar.Item.prototype.addNote = function(text){ **/ Scholar.Item.prototype.updateNote = function(noteID, text){ Scholar.DB.beginTransaction(); - var sql = "UPDATE itemNotes SET note=? WHERE itemID=? AND noteID=?"; + var sql = "UPDATE itemNotes SET note=?, dateModified=CURRENT_TIMESTAMP " + + "WHERE itemID=? AND noteID=?"; Scholar.DB.query(sql, [{'string':text}, {'int':this.getID()}, {'int':noteID}] ); @@ -753,7 +754,8 @@ Scholar.Item.prototype.getNote = function(noteID){ * Returns an array of noteIDs for this item **/ Scholar.Item.prototype.getNotes = function(){ - var sql = "SELECT noteID FROM itemNotes WHERE itemID=" + this.getID(); + var sql = "SELECT noteID FROM itemNotes WHERE itemID=" + this.getID() + + " ORDER BY dateCreated"; return Scholar.DB.columnQuery(sql); } diff --git a/chrome/chromeFiles/content/scholar/xpcom/schema.js b/chrome/chromeFiles/content/scholar/xpcom/schema.js index e609148c21..73ad4b6a9c 100644 --- a/chrome/chromeFiles/content/scholar/xpcom/schema.js +++ b/chrome/chromeFiles/content/scholar/xpcom/schema.js @@ -370,7 +370,7 @@ Scholar.Schema = new function(){ // // Change this value to match the schema version // - var toVersion = 20; + var toVersion = 21; if (toVersion != _getSchemaSQLVersion()){ throw('Schema version does not match version in _migrateSchema()'); @@ -385,7 +385,7 @@ Scholar.Schema = new function(){ // Each block performs the changes necessary to move from the // previous revision to that one. for (var i=parseInt(fromVersion) + 1; i<=toVersion; i++){ - if (i==20){ + if (i==21){ _initializeSchema(); } } diff --git a/schema.sql b/schema.sql index 24ba93f14a..2a45822543 100644 --- a/schema.sql +++ b/schema.sql @@ -1,4 +1,4 @@ --- 20 +-- 21 DROP TABLE IF EXISTS version; CREATE TABLE version ( @@ -65,6 +65,8 @@ noteID INT, itemID INT, note TEXT, + dateCreated DATETIME DEFAULT CURRENT_TIMESTAMP, + dateModified DATETIME DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (noteID), FOREIGN KEY (itemID) REFERENCES items(itemID) );