parent
d7112909eb
commit
9291cbafdc
20
lib/mysql.js
20
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();
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue