commit
ad96800c64
|
@ -26,7 +26,7 @@ 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 && err.message.match(/(^|: )unknown database/i)) {
|
||||||
var dbName = s.database;
|
var dbName = s.database;
|
||||||
schema.client.query('CREATE DATABASE ' + dbName, function (error) {
|
schema.client.query('CREATE DATABASE ' + dbName, function (error) {
|
||||||
if (!error) {
|
if (!error) {
|
||||||
|
@ -66,8 +66,8 @@ MySQL.prototype.query = function (sql, callback) {
|
||||||
var log = this.log;
|
var log = this.log;
|
||||||
if (typeof callback !== 'function') throw new Error('callback should be a function');
|
if (typeof callback !== 'function') throw new Error('callback should be a function');
|
||||||
this.client.query(sql, function (err, data) {
|
this.client.query(sql, function (err, data) {
|
||||||
if (err && err.message.match(/^unknown database/i)) {
|
if (err && err.message.match(/(^|: )unknown database/i)) {
|
||||||
var dbName = err.message.match(/^unknown database '(.*?)'/i)[1];
|
var dbName = err.message.match(/(^|: )unknown database '(.*?)'/i)[1];
|
||||||
client.query('CREATE DATABASE ' + dbName, function (error) {
|
client.query('CREATE DATABASE ' + dbName, function (error) {
|
||||||
if (!error) {
|
if (!error) {
|
||||||
client.query(sql, callback);
|
client.query(sql, callback);
|
||||||
|
|
Loading…
Reference in New Issue