#diesel #versioned #versioning #diesel-versioning

macro diesel_versioning_derives

You should not use this crate diredctyl, is is internal to diesel_versioning

1 unstable release

Uses new Rust 2024

new 0.1.0 May 15, 2025

#1914 in Procedural macros


Used in diesel_versioning

MIT/Apache

15KB
285 lines

Diesel-Versioning

Diesel-Versioning implements optimistic locking for Diesel. This is achieved by an additional field on every entity, which should be support optimistic locking.

Getting started

The entity must have implemented diesel::AsChangeset and diesel::Identifiable to implement Versioned. You can use the provided derive macro.

use diesel::AsChangeset;
use diesel::Identifiable;
use diesel_versioning::Versioned;

#[derive(AsChangeset, Identifiable, Versioned)]
#[diesel(table_name = schema::users)]
#[diesel(check_for_backend(diesel::pg::Pg))]
pub struct User {
   pub id: i32,
   #[version]
   pub version: i32,
   pub body: String,
}

Currently only integer values are supported as version field.

If you use the feature-flag async, you have to use VersionedAsync instead of Versioned.

License

Licensed under either of these:

Dependencies

~235–670KB
~15K SLoC