commit 4904c04e3e387b1e15cdc8e5e6f18789e884f29a
parent 3f27a12b0fb899adfc14828a725a888a68d87d18
Author: Dan Stillman <dstillman@zotero.org>
Date: Fri, 16 Jun 2006 16:09:18 +0000
Add dateCreated and dateModified columns to itemNotes
Update itemNotes.dateModified on item update
Diffstat:
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
@@ -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
@@ -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
@@ -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)
);