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('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();
});