668adbe86215eb4074ef1cd85feb6962acb203dd
[motion.git] / server / models / mail_application.js
1 'use strict';
2
3 module.exports = function(sequelize, DataTypes) {
4
5   var MailApplication = sequelize.define('MailApplication', {
6     app: {
7       type: DataTypes.ENUM('queue', 'agent')
8     },
9     priority: {
10       type: DataTypes.INTEGER
11     },
12     timeout: {
13       type: DataTypes.INTEGER,
14       validate: {
15         min: 1
16       }
17     },
18     interval: {
19       type: DataTypes.STRING
20     }
21   }, {
22     tableName: 'mail_applications',
23     associate: function(models) {
24       // hasMany relations
25       MailApplication.belongsTo(models.User, {
26         onDelete: 'restrict'
27       });
28       MailApplication.belongsTo(models.Interval);
29       MailApplication.belongsTo(models.MailQueue, {
30         onDelete: 'restrict'
31       });
32       MailApplication.belongsTo(models.MailAccount, {
33         onDelete: 'restrict'
34       });
35     }
36   });
37
38   return MailApplication;
39 };