const config = require('../../config');
const providers = config.providers;
const crypto = require('crypto');
const bcrypt = require('bcrypt');
const moment = require('moment');

module.exports = function(sequelize, DataTypes) {
  const mix_sessions = sequelize.define(
    'mix_sessions',
    {
      id: {
        type: DataTypes.UUID,
        defaultValue: DataTypes.UUIDV4,
        primaryKey: true,
      },

mix_type: {
        type: DataTypes.ENUM,
      
      

        values: [

"auto_mix",


"assisted_mix"

        ],

      },

status: {
        type: DataTypes.ENUM,
      
      

        values: [

"queued",


"running",


"completed",


"failed"

        ],

      },

stereo_widening_amount: {
        type: DataTypes.DECIMAL,
      
      

      },

compression_amount: {
        type: DataTypes.DECIMAL,
      
      

      },

eq_amount: {
        type: DataTypes.DECIMAL,
      
      

      },

started_at: {
        type: DataTypes.DATE,
      
      

      },

finished_at: {
        type: DataTypes.DATE,
      
      

      },

      importHash: {
        type: DataTypes.STRING(255),
        allowNull: true,
        unique: true,
      },
    },
    {
      timestamps: true,
      paranoid: true,
      freezeTableName: true,
    },
  );

  mix_sessions.associate = (db) => {


/// loop through entities and it's fields, and if ref === current e[name] and create relation has many on parent entity





























//end loop



    db.mix_sessions.belongsTo(db.songs, {
      as: 'song',
      foreignKey: {
        name: 'songId',
      },
      constraints: false,
    });

    db.mix_sessions.belongsTo(db.users, {
      as: 'requested_user',
      foreignKey: {
        name: 'requested_userId',
      },
      constraints: false,
    });

    db.mix_sessions.belongsTo(db.assets, {
      as: 'result_mix_asset',
      foreignKey: {
        name: 'result_mix_assetId',
      },
      constraints: false,
    });

    db.mix_sessions.belongsTo(db.organizations, {
      as: 'organizations',
      foreignKey: {
        name: 'organizationsId',
      },
      constraints: false,
    });




    db.mix_sessions.belongsTo(db.users, {
      as: 'createdBy',
    });

    db.mix_sessions.belongsTo(db.users, {
      as: 'updatedBy',
    });
  };



  return mix_sessions;
};


