module.exports = function(sequelize, DataTypes) {
  const testimonials = sequelize.define(
    "testimonials",
    {
      id: { type: DataTypes.UUID, defaultValue: DataTypes.UUIDV4, primaryKey: true },
      name: { type: DataTypes.TEXT },
      role_company: { type: DataTypes.TEXT },
      quote: { type: DataTypes.TEXT },
      photo_url: { type: DataTypes.TEXT },
      visible_on_site: { type: DataTypes.BOOLEAN, defaultValue: true },
      importHash: { type: DataTypes.STRING(255), allowNull: true, unique: true },
    },
    {
      timestamps: true,
      paranoid: true,
      freezeTableName: true,
    },
  );

  testimonials.associate = (db) => {
    db.testimonials.belongsTo(db.users, { as: "createdBy", constraints: false });
    db.testimonials.belongsTo(db.users, { as: "updatedBy", constraints: false });
  };

  return testimonials;
};
