Built motion from commit 654a660.|0.0.150
[motion.git] / server / models / voice_musiconhold.js
1 /* jshint indent: 2 */
2
3 module.exports = function(sequelize, DataTypes) {
4   var VoiceMusicOnHold = sequelize.define('VoiceMusicOnHold', {
5     name: {
6       type: DataTypes.STRING,
7       allowNull: false,
8       unique: true
9     },
10     mode: {
11       type: DataTypes.ENUM('custom', 'files', 'mp3nb', 'quietmp3nb', 'quietmp3', 'mp3'),
12       allowNull: true,
13       defaultValue: 'files'
14     },
15     directory: {
16       type: DataTypes.STRING,
17       allowNull: true,
18     },
19     application: {
20       type: DataTypes.STRING,
21       allowNull: true,
22     },
23     digit: {
24       type: DataTypes.STRING,
25       allowNull: true,
26     },
27     sort: {
28       type: DataTypes.STRING,
29       allowNull: true,
30       defaultValue: 'alpha'
31     },
32     format: {
33       type: DataTypes.STRING,
34       allowNull: true,
35       defaultValue: 'wav'
36     },
37     stamp: {
38       type: 'TIMESTAMP'
39     },
40     defaultEntry: {
41       type: DataTypes.BOOLEAN,
42       defaultValue: 0
43     }
44   }, {
45     tableName: 'voice_musiconhold'
46   });
47
48   VoiceMusicOnHold.beforeUpdate(function(moh) {
49     if (moh.changed('name')) {
50       throw new Error({
51         message: "You can't modify a moh class name"
52       });
53     }
54   });
55
56
57   VoiceMusicOnHold.beforeDelete(function(moh) {
58     if (moh.defaultEntry) {
59       throw new Error({
60         message: "You can't delete a default moh class"
61       });
62     }
63   });
64
65   return VoiceMusicOnHold;
66 };