The last model we need is Message, which relates to the records in the messages table:
#[derive(Debug, Identifiable, Queryable, Associations, Serialize, Deserialize)]
#[belongs_to(Channel)]
#[belongs_to(User)]
#[table_name = "messages"]
pub struct Message {
pub id: Id,
pub timestamp: NaiveDateTime,
pub channel_id: Id,
pub user_id: Id,
pub text: String,
}
This model also uses derived traits which we discussed in the first example. Now, we can implement our database interaction crate using the generated schema and the declared models.