module.exports = (sequelize, DataTypes) => {
  const MessageBookings = sequelize.define(
    'MessageBookings',
    {
      id: {
        type: DataTypes.UUID,
        defaultValue: DataTypes.UUIDV4,
        allowNull: false,
        primaryKey: true,
      },
      booking_id: {
        type: DataTypes.UUID,
        allowNull: true,
      },
      message_id: {
        type: DataTypes.UUID,
        allowNull: true,
      },
    },
    {
      tableName: 'message_bookings',
      timestamps: false,
    },
  );

  MessageBookings.associate = (models) => {
    MessageBookings.belongsTo(models.Bookings, {
      as: 'booking',
      foreignKey: 'booking_id',
    });
  };

  return MessageBookings;
};
