I am using diesel_cli_ext to generate Rust model code:
diesel_ext --schema-file src/model/diesel/dolphin/dolphin_schema.rs --model > src/model/diesel/dolphin/dolphin_models.rs
The generated model looks like this:
#[derive(Queryable, Debug)]
pub struct AdminUser {
pub id: i64,
pub nickname: Option<String>,
pub avatar_url: Option<String>,
pub phone: Option<String>,
pub updated_time: Option<i64>,
pub created_time: Option<i64>,
pub salt: Option<String>,
pub pwd: Option<String>,
pub sex: Option<i32>,
pub level_type: Option<String>,
pub phone_region: Option<String>,
pub country_code: Option<i32>,
pub user_status: Option<String>,
}
Is it possible to add more annotations when generating the model? I'd like to have these derives:
#[derive(Serialize, Queryable, Deserialize, Default)]
I have been adding it by myself, but the next generation overwrites the previous modifications.
Reading the "how to use" documentation shows that a command line option allows you to modify the derive
s:
-d, --derive DERIVES
set struct derives
There's also an issue for per-table derive modifications.