text: "use strict";
  
  module.exports = function(sequelize, DataTypes) {
      var Devices = sequelize.define('devices', {
          id: {
              type: DataTypes.INTEGER(11),
              allowNull: false,
              primaryKey: true,
              autoIncrement: true,
              unique: true
          },
          company_id: {
              type: DataTypes.INTEGER(11),
              allowNull: false,
              defaultValue: 1
          },
          username: {
              type: DataTypes.STRING(30),
              allowNull: true
          },
          login_data_id: {
              type: DataTypes.INTEGER(11),
              allowNull: true
          },
          googleappid: {
              type: DataTypes.STRING(255),
              allowNull: true
          },
          device_active: {
              type: DataTypes.BOOLEAN,
              allowNull: false,
              defaultValue: false
          },
          device_id: {
              type: DataTypes.STRING(255),
              allowNull: false,
  			unique: true
          },
          device_ip: {
              type: DataTypes.STRING(24),
              allowNull: true
  		},
          device_mac_address: {
              type: DataTypes.STRING(15),
              allowNull: true
          },
          device_wifimac_address: {
              type: DataTypes.STRING(15),
              allowNull: true
          },
  		ntype: {
              type: DataTypes.STRING(2),
              allowNull: false,
              defaultValue: '1'
          },
          appid: {
              type: DataTypes.INTEGER(11),
              allowNull: false
          },
          app_name: {
              type: DataTypes.STRING(45),
              allowNull: false
          },
          app_version: {
              type: DataTypes.STRING(20),
              allowNull: false
          },
          device_brand: {
              type: DataTypes.STRING(100),
              allowNull: true
          },
          os: {
              type: DataTypes.STRING,
              allowNull: true
          },
  		screen_resolution: {
              type: DataTypes.STRING(10),
              allowNull: true
          },
  		hdmi: {
              type: DataTypes.STRING,
              allowNull: false,
              defaultValue: false
          },
  		api_version: {
              type: DataTypes.STRING(16),
              allowNull: true
          },
  		firmware: {
              type: DataTypes.STRING(128),
              allowNull: true
          },
  		language: {
              type: DataTypes.STRING(10),
              allowNull: true
          },
          vmx_id: {
              type: DataTypes.STRING(255),
              allowNull: true,
          },
          vmx_player_id: {
              type: DataTypes.STRING(255),
              allowNull: true,
          },
          vmx_subscription_id: {
              type: DataTypes.STRING(255),
              allowNull: true,
          },
          vmx_subscription_end: {
              type: DataTypes.DATE,
              allowNull: true,
          },
          createdAt: {
              type: DataTypes.DATE,
              allowNull: true
          },
          updatedAt: {
              type: DataTypes.DATE,
              allowNull: true
          }
      }, {
          tableName: 'devices',
          associate: function(models) {
              Devices.belongsTo(models.login_data, {foreignKey: 'login_data_id'});
              Devices.belongsTo(models.settings, {foreignKey: 'company_id'});
              Devices.belongsTo(models.app_group, {foreignKey: 'appid'});
              Devices.hasOne(models.device_mediaplayer, {foreignKey: 'device_id'})
              //Devices.belongsToMany(models.media_player, { as: 'devices', through: 'device_mediaplayer' })
          }
      });
      return Devices;
  };
  