diff --git a/lib/mysql.js b/lib/mysql.js index 01b2ad5..9fc08dc 100644 --- a/lib/mysql.js +++ b/lib/mysql.js @@ -26,15 +26,17 @@ exports.initialize = function initializeSchema(schema, callback) { // schema.client.query('SET TIME_ZONE = "+04:00"', callback); schema.client.query('USE `' + s.database + '`', function (err) { - if (err && err.message.match(/(^|: )unknown database/i)) { - var dbName = s.database; - schema.client.query('CREATE DATABASE ' + dbName, function (error) { - if (!error) { - schema.client.query('USE ' + s.database, callback); - } else { - throw error; - } - }); + if (err) { + if (err.message.match(/(^|: )unknown database/i)) { + var dbName = s.database; + schema.client.query('CREATE DATABASE ' + dbName, function (error) { + if (!error) { + schema.client.query('USE ' + s.database, callback); + } else { + throw error; + } + }); + } else throw error; } else callback(); });