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

module.exports = (sequelize) => {
  const TenderQuotationFile = sequelize.define(
    "tenderquotationfile",
    {
      id: {
        type: DataTypes.INTEGER,
        autoIncrement: true,
        primaryKey: true,
      },
      creation: { type: DataTypes.DATE, allowNull: false },
      modified: { type: DataTypes.DATE, allowNull: false },
      modified_by: { type: DataTypes.INTEGER, allowNull: false },
      owner: { type: DataTypes.INTEGER, allowNull: false },
      enabled: { type: DataTypes.BOOLEAN, allowNull: false },

      filename: { type: DataTypes.STRING(255), allowNull: true},
      size: { type: DataTypes.INTEGER, allowNull: true},
      type: { type: DataTypes.STRING(50), allowNull: true},
      tenderquotation_id: { type: DataTypes.INTEGER, allowNull: false },
    },
    {
      tableName: "tenderquotationfiles",
      freezeTableName: true,
    }
  );

  /**
   * Associates the Province model with other models.
   * @param {object} models - The models to associate with.
   */
  TenderQuotationFile.associate = (models) => {
    TenderQuotationFile.belongsTo(models.TenderQuotation, { foreignKey: "tenderquotation_id", onDelete: "CASCADE" });
  };

  return TenderQuotationFile;
};
