File size: 763 Bytes
1e92f2d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
const markdownLinkify = require('../utils/markdown-linkify');

exports.up = function(r, conn) {
  return (
    // Markdown linkify each message
    r
      .table('messages')
      .withFields('id', 'content')
      .run(conn)
      .then(cursor => cursor.toArray())
      .then(messages =>
        Promise.all(
          messages.map(message =>
            r
              .table('messages')
              .get(message.id)
              .update({
                content: {
                  body: markdownLinkify(message.content.body),
                },
              })
              .run(conn)
          )
        )
      )
  );
};

exports.down = function(r, conn) {
  // Can't really undo just this change so we don't bother
  return Promise.resolve();
};