const Sequelize = require('sequelize');
var db = require("../database/db.js");
const Usuario_Rol = require('./usuario_rol.js');

const Rol = db.sequelize.define('ROL', {

    //INFORMACIÓN PERSONAL
    ID_ROL: {
        primaryKey: true,
        type: Sequelize.BIGINT,
        allowNull: false,
        autoIncrement: true
    },

    ID_SISTEMA: {
        type: Sequelize.INTEGER,
        allowNull: false
    },

    CODIGO: {
        type: Sequelize.INTEGER,
        allowNull: false,
    },

    DESCRIPCION: {
        type: Sequelize.STRING,
        allowNull: false,
    },
    ESTADO: {
        type: Sequelize.INTEGER,
        allowNull: false,
    }
   
},
    {
        timestamps: false,
        id: false
    })


    Rol.hasMany(Usuario_Rol, { foreignKey: 'ID_ROL', sourceKey: 'ID_ROL' });
    Usuario_Rol.belongsTo(Rol, { foreignKey: 'ID_ROL', sourceKey: 'ID_ROL' });
  
  

module.exports = Rol;