const { DataTypes } = require("sequelize");

module.exports = (sequelize) => {
  const TenderInvitation = sequelize.define(
    "tenderinvitation",
    {
      id: {
        type: DataTypes.INTEGER,
        autoIncrement: true,
        primaryKey: true,
      },
      tendervendor_id: { type: DataTypes.INTEGER, allowNull: true },
      tender_id: { type: DataTypes.INTEGER, allowNull: true },
    },
    {
      tableName: "tenderinvitations",
      freezeTableName: true,
    }
  );

  /**
   * Associates the Province model with other models.
   * @param {object} models - The models to associate with.
   */
  TenderInvitation.associate = (models) => {
    TenderInvitation.belongsTo(models.Tender, { foreignKey: "tender_id" });
    TenderInvitation.belongsTo(models.TenderVendor, { foreignKey: "tendervendor_id" });
  };

  return TenderInvitation;
};
