mysql-migrations
mysql-migrations copied to clipboard
Forked
Given that this project hasn't had any activity over the past few years, I'm under the impression that it has been abandoned. If this is not the case, let me know. In the meantime, I've made several changes and bug fixes (hanging, processing non-js files, etc) on my own fork and published it. Many of the changes have been opened as PR's to merge back into this repository as well.
Here is an example of some of the configuration changes that lets you save your seed data, procedures, functions, events, log threshold, and a custom logger. I also added the ability to override the process.argv
via the options array.
If @kawadhiya21 would prefer, I'd like to get these changes back into the original mysql-migrations repository here.
const { createPool } = require('mysql');
const { init } = require('@lewismoten/mysql-migrations');
const path = require('path');
var connection = createPool({
connectionLimit: 10,
host: process.env.DB_HOST,
user: process.env.DB_USER,
password: process.env.DB_PASSWORD,
database: process.env.DB_NAME,
multipleStatements: true
});
init(connection, path.join(__dirname, '../migrations'), () => {
console.log('Done.');
}, [
'--update-schema',
'--update-data',
`--template .template.js`,
'--log-level INFO',
// '--logger',
// customLogger
// '--argv'
// ['', '', 'up']
]);
Here is an example of .templatejs
. I wanted a custom template so I could get highlighting of SQL queries to show up properly in my IDE.
const sql = require('../sql');
module.exports = {
up: (conn, cb) => {
conn.query(sql`${{ args.up }}`, (err, res) => {
if (err) throw err;
cb();
});
},
down: sql``
};