'use strict';

exports.up = async function(db) {
    const cmd = 'CREATE TABLE mailPasswords(' +
        'clientId VARCHAR(128) NOT NULL,' +
        'userId VARCHAR(128) NOT NULL,' +
        'password VARCHAR(1024) NOT NULL,' +
        'creationTime TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,' +
        'FOREIGN KEY(clientId) REFERENCES oidcClients(id),' +
        'FOREIGN KEY(userId) REFERENCES users(id),' +
        'PRIMARY KEY (clientId, userId)) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin';

    await db.runSql(cmd);
};

exports.down = async function(db) {
    await db.runSql('DROP TABLE mailPasswords');
};
