Open dschinkel opened 2 years ago
@dschinkel do you also create your migrations with --sql-file
, i.e.:
db-migrate create <name> --sql-file
I have the same issue, and this is how I create my migrations. And the .js
file that is outputted by the db-migrate create
command includes these lines:
exports.up = function(db) {
var filePath = path.join(__dirname, 'sqls', '<MIGRATION NAME>.sql');
return new Promise( function( resolve, reject ) {
fs.readFile(filePath, {encoding: 'utf-8'}, function(err,data){
if (err) return reject(err);
console.log('received data: ' + data);
(and the same for the exports.down
script)
Where the large output comes from is all the console.log('received data: ' + data);
lines.
In order for .silence(true)
, to properly work, this line would need to look something like:
if (!silenceMode) { console.log('received data: ' + data); }
Where silenceMode
is input into the script somehow. Maybe db.silenceMode
?
@dschinkel if you tell me that you have a different issue, I'll move this to its own GH issue, so as not to pollute this one
It looks like @wzrdtales proposed a solution here: https://github.com/db-migrate/node-db-migrate/issues/453#issuecomment-278749154. @wzrdtales , would you be happy for me to help with its implementation? (no idea how complicated it might end up being)
just one warning ahead. silencing logs is usually a terrible idea. We used that for integration testing, so we could hide unimportant logs. In production in doubt you wont know what happened, which is bad.
Actually there shouldn't be a need to do anything though. https://github.com/db-migrate/node-db-migrate/blob/50b34a8dd2224e21c5f28843d49511a08d1dbe1b/api.js#L98 This is passed over the internal safeOptions param. In v1 it comes in the setup method: https://github.com/db-migrate/node-db-migrate/blob/50b34a8dd2224e21c5f28843d49511a08d1dbe1b/lib/executors/versioned/v1.js#L14
In v2, just in the config object.
I do not want logs of my migration SQL statements. Has this been resolved?
this does not work:
dbmigrate.silence(true);
What can we do to get this to actually work. Is this a bug?
I would not expect to go and manually modify every migration.
I run migrations during tests and I also do not want console logs everywhere when those run migrations every time. It slows down my tests.
I don't know why this issue is being ignored when I see several issues out there on this.
We should be able to rely on silence() and not have to manually remove that console log in every migration file.
Please update the docs and take silence out if it's not working...why is it in the docs if silence doesn't even work?