0.6.0 Migration

0.6.0 Migration

Version 0.6.0 introduced a number of breaking changes (opens in a new tab), here's how to update your project to work properly.

Remove required field specifiers in create

// Before
client
    .user()
    .create(user::name::set("Brendan".to_string()), vec![])
client
    .post()
    .create(post::author::link(user::id::equals(0)), vec![])
 
// After
client
    .user()
    .create("Brendan".to_string(), vec![])
client
    .post()
    .create(user::id::equals(0), vec![])

Use dedicated update and delete actions

// Before
client
    .user()
    .find_unique(user::id::equals(0))
    .update(vec![])
client
    .user()
    .find_unique(user::id::equals(0))
    .delete()
 
// After
client
    .user()
    .update(user::id::equals(0), vec![])
client
    .user()
    .delete(user::id::equals(0))

The pattern also applies to update_many and delete_many:

// Before
client
    .user()
    .find_many(vec![user::name::contains("Brendan".to_string())])
    .update(vec![])
client
    .user()
    .find_many(vec![user::name::contains("Brendan".to_string())])
    .delete()
 
// After
client
    .user()
    .update_many(vec![user::name::contains("Brendan".to_string())], vec![])
client
    .user()
    .delete_many(vec![user::name::contains("Brendan".to_string())])

Use connect/disconnect

The link and unlink relation field functions have been renamed to connect and disconnect respectively.

Use equals instead of cursor field function

The cursor builder function now accepts a UniqueWhereParam, so anywhere that the cursor field function was used can be replaced with equals.

// Before
client
    .user()
    .find_many(vec![])
    .cursor(user::id::cursor(0))
 
// After
client
    .user()
    .find_many(vec![])
    .cursor(user::id::equals(0))

Use QueryError type

prisma_client_rust::queries::Error has been renamed and made accessible as prisma_client_rust::QueryError. Additionally, the error_is_type function has been moved to QueryError::is_prisma_error.

Remove Option handling for update and delete

update and delete now return an error instead of an Option if no record is found. This behaviour is inline with the official Prisma client.

Update error handling for relation accessors

Relation accessors no longer produce string errors, but have a dedicated prisma_client_rust::RelationNotFetchedError type.

Use feature resolver version 2

If you are not using a workspace, set edition = "2021" in your Cargo.toml.

If you are using a workspace, set resolver = "2" in your root Cargo.toml.

More information is available in the release notes (opens in a new tab).