重新设置我们的azure服务器时,equalise.sync()方法挂在它刚刚创建的表的SHOW INDEX上。即使该表几乎与刚创建的表相同。
我们的关系'教师'的模型如下:
'use strict';
module.exports = function(sequelize, DataTypes) {
var Teacher = sequelize.define('Teacher', {
email: DataTypes.STRING
} , {
classMethods: {
associate: function(models) {
// associations can be defined here
}
}
});
return Teacher;
};
这是来自成功创建的学生关系的代码,继续经过SHOW INDEX并且不会导致脚本挂起:
'use strict';
module.exports = function(sequelize, DataTypes) {
var Student = sequelize.define('Student', {
email: DataTypes.STRING
}, {
classMethods: {
associate: function(models) {
// associations can be defined here
}
}
});
return Student;
};
这是代码在挂起/崩溃之前所处的位置:
d-i89-237-11:IoTSchool-Backend mitchell$ npm start
> express-example@0.0.0 start /Users/mitchell/Documents/deco3801/IoTSchool-Backend
> node ./bin/www
Executing (default): CREATE TABLE IF NOT EXISTS `Events` (`id` INTEGER auto_increment , `ename` VARCHAR(255), `edata` VARCHAR(255), `type` INTEGER, `time` VARCHAR(255), `deviceid` VARCHAR(255), `createdAt` DATETIME NOT NULL, `updatedAt` DATETIME NOT NULL, PRIMARY KEY (`id`)) ENGINE=InnoDB;
Executing (default): SHOW INDEX FROM `Events` FROM `IoTSchool`
Executing (default): CREATE TABLE IF NOT EXISTS `Schools` (`id` INTEGER NOT NULL auto_increment , `name` VARCHAR(255), `email` VARCHAR(255), `password` VARCHAR(255), `accessToken` VARCHAR(255), `createdAt` DATETIME NOT NULL, `updatedAt` DATETIME NOT NULL, PRIMARY KEY (`id`)) ENGINE=InnoDB;
Executing (default): SHOW INDEX FROM `Schools` FROM `IoTSchool`
Executing (default): CREATE TABLE IF NOT EXISTS `Photons` (`id` INTEGER NOT NULL auto_increment , `sid` VARCHAR(255), `type` VARCHAR(255), `pid` VARCHAR(255) NOT NULL UNIQUE, `createdAt` DATETIME NOT NULL, `updatedAt` DATETIME NOT NULL, `SchoolId` INTEGER, PRIMARY KEY (`id`), FOREIGN KEY (`SchoolId`) REFERENCES `Schools` (`id`) ON DELETE SET NULL ON UPDATE CASCADE) ENGINE=InnoDB;
Executing (default): SHOW INDEX FROM `Photons` FROM `IoTSchool`
Executing (default): CREATE TABLE IF NOT EXISTS `Students` (`id` INTEGER NOT NULL auto_increment , `email` VARCHAR(255), `createdAt` DATETIME NOT NULL, `updatedAt` DATETIME NOT NULL, PRIMARY KEY (`id`)) ENGINE=InnoDB;
Executing (default): SHOW INDEX FROM `Students` FROM `IoTSchool`
Executing (default): CREATE TABLE IF NOT EXISTS `Users` (`id` INTEGER NOT NULL auto_increment , `username` VARCHAR(255), `createdAt` DATETIME NOT NULL, `updatedAt` DATETIME NOT NULL, PRIMARY KEY (`id`)) ENGINE=InnoDB;
Executing (default): SHOW INDEX FROM `Users` FROM `IoTSchool`
Executing (default): CREATE TABLE IF NOT EXISTS `Tasks` (`id` INTEGER NOT NULL auto_increment , `title` VARCHAR(255), `createdAt` DATETIME NOT NULL, `updatedAt` DATETIME NOT NULL, `UserId` INTEGER NOT NULL, PRIMARY KEY (`id`), FOREIGN KEY (`UserId`) REFERENCES `Users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE) ENGINE=InnoDB;
Executing (default): SHOW INDEX FROM `Tasks` FROM `IoTSchool`
Executing (default): CREATE TABLE IF NOT EXISTS `Teachers` (`teacherid` INTEGER auto_increment , `email` VARCHAR(255), `createdAt` DATETIME NOT NULL, `updatedAt` DATETIME NOT NULL, PRIMARY KEY (`teacherid`)) ENGINE=InnoDB;
Executing (default): SHOW INDEX FROM `Tasks` FROM `iotschoolmysql`
Unhandled rejection SequelizeConnectionError: Quit inactivity timeout
at Quit._callback (/Users/mitchell/Documents/deco3801/IoTSchool-Backend/node_modules/sequelize/lib/dialects/mysql/connection-manager.js:104:30)
at Quit.Sequence.end (/Users/mitchell/Documents/deco3801/IoTSchool-Backend/node_modules/mysql/lib/protocol/sequences/Sequence.js:96:24)
at /Users/mitchell/Documents/deco3801/IoTSchool-Backend/node_modules/mysql/lib/protocol/Protocol.js:393:18
at Array.forEach (native)
at /Users/mitchell/Documents/deco3801/IoTSchool-Backend/node_modules/mysql/lib/protocol/Protocol.js:392:13
at process._tickCallback (node.js:355:11)
Unhandled rejection SequelizeConnectionError: Quit inactivity timeout
at Quit._callback (/Users/mitchell/Documents/deco3801/IoTSchool-Backend/node_modules/sequelize/lib/dialects/mysql/connection-manager.js:104:30)
at Quit.Sequence.end (/Users/mitchell/Documents/deco3801/IoTSchool-Backend/node_modules/mysql/lib/protocol/sequences/Sequence.js:96:24)
at /Users/mitchell/Documents/deco3801/IoTSchool-Backend/node_modules/mysql/lib/protocol/Protocol.js:393:18
at Array.forEach (native)
at /Users/mitchell/Documents/deco3801/IoTSchool-Backend/node_modules/mysql/lib/protocol/Protocol.js:392:13
at process._tickCallback (node.js:355:11)