What's new in SeaORM 0.8.0
Tags: rust, githunt, news, opensource
Published: 2022-05-15 11:36:12

🎉 We are pleased to release SeaORM [`0.8.0`](https://github.com/SeaQL/sea-orm/releases/tag/0.8.0) today! Here are some feature highlights 🌟:

## Migration Utilities Moved to `sea-orm-migration` crate

[[#666](https://github.com/SeaQL/sea-orm/pull/666)] Utilities of SeaORM migration have been moved from `sea-schema` to `sea-orm-migration` crate. Users are advised to upgrade from older versions with the following steps:

1. Bump `sea-orm` version to `0.8.0`.
2. Replace `sea-schema` dependency with `sea-orm-migration` in your `migration` crate.
    ```diff title=migration/Cargo.toml
    [dependencies]
    - sea-schema = { version = "^0.7.0", ... }
    + sea-orm-migration = { version = "^0.8.0" }
    ```
3. Find and replace `use sea_schema::migration::` with `use sea_orm_migration::` in your `migration` crate.
    ```diff
    - use sea_schema::migration::prelude::*;
    + use sea_orm_migration::prelude::*;

    - use sea_schema::migration::*;
    + use sea_orm_migration::*;
    ```

Designed by:

- [Chris Tsang](https://github.com/tyt2y3)

Contributed by:

- [Billy Chan](https://github.com/billy1624)

## Generating New Migration

[[#656](https://github.com/SeaQL/sea-orm/pull/656)] You can create a new migration with the `migrate generate` subcommand. This simplifies the migration process, as new migrations no longer need to be added manually.

```shell
# A migration file `MIGRATION_DIR/src/mYYYYMMDD_HHMMSS_create_product_table.rs` will be created.
# And, the migration file will be imported and included in the migrator located at `MIGRATION_DIR/src/lib.rs`.
sea-orm-cli migrate generate create_product_table
```

Proposed & Contributed by:

- [Viktor Bahr](https://github.com/viktorbahr)

## Inserting One with Default

[[#589](https://github.com/SeaQL/sea-orm/pull/589)] Insert a row populate with default values. Note that the target table should have default values defined for all of its columns.

```rust
let pear = fruit::ActiveModel {
    ..Default::default() // all attributes are `NotSet`
};

// The SQL statement:
//   - MySQL: INSERT INTO `fruit` VALUES ()
//   - SQLite: INSERT INTO "fruit" DEFAULT VALUES
//   - PostgreSQL: INSERT INTO "fruit" VALUES (DEFAULT) RETURNING "id", "name", "cake_id"
let pear: fruit::Model = pear.insert(db).await?;
```

Proposed by:

- [Crypto-Virus](https://github.com/Crypto-Virus)

Contributed by:

- [Billy Chan](https://github.com/billy1624)

## Checking if an `ActiveModel` is changed

[[#683](https://github.com/SeaQL/sea-orm/pull/683)] You can check whether any field in an `ActiveModel` is `Set` with the help of the `is_changed` method.

```rust
let mut fruit: fruit::ActiveModel = Default::default();
assert!(!fruit.is_changed());

fruit.set(fruit::Column::Name, "apple".into());
assert!(fruit.is_changed());
```

Proposed by:

- [Karol Fuksiewicz](https://github.com/kudlatyamroth)

Contributed by:

- [Kirawi](https://github.com/kirawi)

## Minor Improvements

- [[#670](https://github.com/SeaQL/sea-orm/pull/670)] Add `max_connections` option to `sea-orm-cli generate entity` subcommand
- [[#677](https://github.com/SeaQL/sea-orm/pull/677)] Derive `Eq` and `Clone` for `DbErr`

Proposed & Contributed by:

- [benluelo](https://github.com/benluelo)
- [Sebastien Guillemot](https://github.com/SebastienGllmt)

## Integration Examples

SeaORM plays well with the other crates in the async ecosystem. It can be integrated easily with common RESTful frameworks and also gRPC frameworks; check out our new [Tonic example](https://github.com/SeaQL/sea-orm/tree/master/examples/tonic_example) to see how it works. More examples [wanted](https://github.com/SeaQL/sea-orm/issues/269)!

- [Rocket Example](https://github.com/SeaQL/sea-orm/tree/master/examples/rocket_example)
- [Actix Example](https://github.com/SeaQL/sea-orm/tree/master/examples/actix_example)
- [Axum Example](https://github.com/SeaQL/sea-orm/tree/master/examples/axum_example)
- [Poem Example](https://github.com/SeaQL/sea-orm/tree/master/examples/poem_example)
- [GraphQL Example](https://github.com/SeaQL/sea-orm/tree/master/examples/graphql_example)
- [jsonrpsee Example](https://github.com/SeaQL/sea-orm/tree/master/examples/jsonrpsee_example)
- [Tonic Example](https://github.com/SeaQL/sea-orm/tree/master/examples/tonic_example)

## Who's using SeaORM?

The following products are powered by SeaORM:

- [Caido](https://caido.io/): A lightweight web security auditing toolkit
- [Sensei](https://l2.technology/sensei): A Bitcoin lightning node implementation
- [Svix](https://www.svix.com/): The enterprise ready webhooks service

SeaORM is the foundation of [StarfishQL](https://github.com/SeaQL/starfish-ql), an experimental graph database and query engine.

For more projects, see [Built with SeaORM](https://github.com/SeaQL/sea-orm/blob/master/COMMUNITY.md#built-with-seaorm).

## Sponsor

Our [GitHub Sponsor](https://github.com/sponsors/SeaQL) profile is up! If you feel generous, a small donation will be greatly appreciated.

A big shout out to our sponsors 😇:

- [Émile Fugulin](https://github.com/Sytten)
- [Zachary Vander Velden](https://github.com/exzachlyvv)
- [Dean Sheather](https://github.com/deansheather)
- [Shane Sveller](https://github.com/shanesveller)
- [Sakti Dwi Cahyono](https://github.com/sakti)
- Unnamed Sponsor

## Community

SeaQL is a community driven project. We welcome you to participate, contribute and together build for Rust's future.

Here is the roadmap for SeaORM [`0.9.x`](https://github.com/SeaQL/sea-orm/milestone/9).

## GSoC 2022

We are super excited to be selected as a Google Summer of Code 2022 [mentor organization](https://summerofcode.withgoogle.com/programs/2022/organizations/seaql). The application is now closed, but the program is about to start! If you have thoughts over how we are going to implement the [project ideas](https://github.com/SeaQL/summer-of-code/tree/main/2022), feel free to participate in the discussion.