All files / migrations 3-botTokenStorage.js

16.67% Statements 1/6
100% Branches 0/0
0% Functions 0/2
16.67% Lines 1/6

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23    1x                                        
'use strict';
 
module.exports = {
    async up (next) {
        await this.query(`CREATE TABLE tokens (
            senderId varchar(73),
            pageId varchar(73),
            token varchar(400)
 
            CONSTRAINT PK_tokens PRIMARY KEY CLUSTERED (senderId, pageId)
        )`);
 
        // varchar(max) is invalid for use as a key column in an index
        await this.query('CREATE INDEX tokens_token ON tokens (token)');
 
        next();
    },
    async down (next) {
        await this.query('DROP TABLE IF EXISTS tokens');
        next();
    }
};