Open nikolay-hristov opened 5 years ago
Hi, You must add requirements before pool init: ` const mysql = require('mysql'); const migration = require('mysql-migrations');
let pool = mysql.createPool({ connectionLimit : config.MYSQL_CONN_POOL, host : config.MYSQL_HOST, user : config.MYSQL_USER, password : config.MYSQL_PASSWORD, database : config.MYSQL_DATABASE }); migration.init(pool, __dirname + '/migrations'); `
Hi @rozhnev,
of course, I just didn't post them here, these are my requires
const pool = require('./storage/adapters/mysql_pool.js');
const config = require('./config.js');
const migration = require('mysql-migrations');
Note: My pool comes from another file, I concatenated the two for this issue
P.S. Normal migrations work, but custom ones return the error mentioned in the beginning
I'm getting an error that conn.query is not a function.
This is my migration init:
let pool = mysql.createPool({ connectionLimit : config.MYSQL_CONN_POOL, host : config.MYSQL_HOST, user : config.MYSQL_USER, password : config.MYSQL_PASSWORD, database : config.MYSQL_DATABASE }); migration.init(pool, __dirname + '/migrations');
This is my migration code:
module.exports = { 'up' : function (conn, cb) { conn.query (`ALTER TABLE progress DROP FOREIGN KEY progress_player_id; ALTER TABLE progress ADD CONSTRAINT progress_player_id FOREIGN KEY (player_id) REFERENCES player (id) ON DELETE CASCADE ON UPDATE CASCADE;`, function (err, res) { cb(); }); }, 'down' : function (conn, cb) { conn.query (`ALTER TABLE progress DROP FOREIGN KEY progress_player_id;ALTER TABLE progress ADD CONSTRAINT progress_player_id FOREIGN KEY (player_id) REFERENCES player (id) ON DELETE NO ACTION ON UPDATE NO ACTION;`, function (err, res) { cb(); }); } }
I also faced this issue when using custom migration with function conn.query()
is not a function , any workaround for this one?
Any luck with this issue @nikolay-hristov @rozhnev I am also facing this issue too.
I'm getting an error that conn.query is not a function.
This is my migration init:
This is my migration code: