'use strict';
const { Model } = require('sequelize');
const { defaultKeys, modelDefaults, actionUsers } = require('../sequelize/defaults');
module.exports = (sequelize, DataTypes) => {
  class Designation extends Model {
    static associate(models) {
      actionUsers(Designation, models);
      Designation.belongsTo(models.Branch, {
        targetKey: "branch_id",
        foreignKey: "branch_id",
        as: "branches",
      });
    }
  }

  Designation.init({
    ...defaultKeys("designation_id"),
    tbl_ref_id: {
      type: DataTypes.STRING,
      allowNull: true,
    },
    designation_name: {
      type: DataTypes.STRING,
      allowNull: false,
    },
    designation_descp: {
      type: DataTypes.STRING,
      allowNull: true,
    },
    active_status: {
      type: DataTypes.BOOLEAN,
      allowNull: false,
      defaultValue: 1,
    },
  }, modelDefaults(sequelize, 'designation'));
  return Designation;
};