From d040c41802a9bc0b18017131ef53e987fc796742 Mon Sep 17 00:00:00 2001
From: Gadgetmies <71213783+gadgetmies@users.noreply.github.com>
Date: Tue, 29 Nov 2022 22:47:33 +0200
Subject: [PATCH] Use isSilent flag in SQL migration templates

Previously setting the db-migrate instance isSilent flag did not prevent the printing of the SQL migration files
This causes a huge amount of noise in the output and there was no way to prevent this when calling the
up()-function.

Signed-off-by: Gadgetmies <gadgetmies@gmail.com>
---
 lib/template.js | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/lib/template.js b/lib/template.js
index d36be851..29d82123 100644
--- a/lib/template.js
+++ b/lib/template.js
@@ -105,7 +105,7 @@ Template.prototype.sqlFileLoaderTemplate = function () {
     '  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);",
+    "      if (db.log.isSilent !== true) console.log('received data: ' + data);",
     '',
     '      resolve(data);',
     '    });',
@@ -122,7 +122,7 @@ Template.prototype.sqlFileLoaderTemplate = function () {
     '  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);",
+    "      if (db.log.isSilent !== true) console.log('received data: ' + data);",
     '',
     '      resolve(data);',
     '    });',
@@ -171,7 +171,7 @@ Template.prototype.sqlFileLoaderIgnoreOnInitTemplate = function () {
     '    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);",
+    "         if (db.log.isSilent !== true) console.log('received data: ' + data);",
     '',
     '         resolve(data);',
     '       });',
@@ -181,7 +181,7 @@ Template.prototype.sqlFileLoaderIgnoreOnInitTemplate = function () {
     '    });',
     '  }',
     '  else {',
-    "   console.log('ignoring on init: ' + filePath)",
+    "   if (db.log.isSilent !== true) console.log('ignoring on init: ' + filePath)",
     '   return null;',
     '  }',
     '};',
@@ -193,7 +193,7 @@ Template.prototype.sqlFileLoaderIgnoreOnInitTemplate = function () {
     '  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);",
+    "      if (db.log.isSilent !== true) console.log('received data: ' + data);",
     '',
     '      resolve(data);',
     '    });',