Skip to content

Commit

Permalink
Add queryuser.most_recent_digest
Browse files Browse the repository at this point in the history
This commit adds a new queryuser.most_recent_digest column which will be
used for storing the ID of the message that was last sent to a user for
a query / user combination. This will then be used in conjunction with
most_recent_seen to establish what messages should be included in a
digest
  • Loading branch information
Andrew Isherwood committed Oct 30, 2020
1 parent b89aa50 commit 17d42c3
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
'use strict';

var dbm;
var type;
var seed;
var fs = require('fs');
var path = require('path');
var Promise;

/**
* We receive the dbmigrate dependency from dbmigrate initially.
* This enables us to not have to rely on NODE_PATH.
*/
exports.setup = function(options, seedLink) {
dbm = options.dbmigrate;
type = dbm.dataType;
seed = seedLink;
Promise = options.Promise;
};

exports.up = function(db) {
var filePath = path.join(__dirname, 'sqls', '20201022124658-20201022613846-add-queryuser-most-recent-digest-up.sql');
return new Promise( function( resolve, reject ) {
fs.readFile(filePath, {encoding: 'utf-8'}, function(err,data){
if (err) return reject(err);
console.log('received data: ' + data);

resolve(data);
});
})
.then(function(data) {
return db.runSql(data);
});
};

exports.down = function(db) {
var filePath = path.join(__dirname, 'sqls', '20201022124658-20201022613846-add-queryuser-most-recent-digest-down.sql');
return new Promise( function( resolve, reject ) {
fs.readFile(filePath, {encoding: 'utf-8'}, function(err,data){
if (err) return reject(err);
console.log('received data: ' + data);

resolve(data);
});
})
.then(function(data) {
return db.runSql(data);
});
};

exports._meta = {
"version": 1
};
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE queryuser DROP COLUMN most_recent_digest;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE queryuser ADD COLUMN most_recent_digest INTEGER;

0 comments on commit 17d42c3

Please sign in to comment.