Resolves issues #31, #15.

This commit is contained in:
dgsan 2013-05-30 13:43:01 -07:00
parent d7112909eb
commit 9291cbafdc
1 changed files with 11 additions and 9 deletions

View File

@ -26,15 +26,17 @@ exports.initialize = function initializeSchema(schema, callback) {
// schema.client.query('SET TIME_ZONE = "+04:00"', callback); // schema.client.query('SET TIME_ZONE = "+04:00"', callback);
schema.client.query('USE `' + s.database + '`', function (err) { schema.client.query('USE `' + s.database + '`', function (err) {
if (err && err.message.match(/(^|: )unknown database/i)) { if (err) {
var dbName = s.database; if (err.message.match(/(^|: )unknown database/i)) {
schema.client.query('CREATE DATABASE ' + dbName, function (error) { var dbName = s.database;
if (!error) { schema.client.query('CREATE DATABASE ' + dbName, function (error) {
schema.client.query('USE ' + s.database, callback); if (!error) {
} else { schema.client.query('USE ' + s.database, callback);
throw error; } else {
} throw error;
}); }
});
} else throw error;
} else callback(); } else callback();
}); });