Skip to content
ReferenceCommand line

rent new

Use rent new to scaffold an application with Cargo configuration, a starter User entity, generated client code, schema and migration directories, rent.toml, formatter settings, and development database configuration.

The scaffold is a two-crate workspace. The application crate holds your code. A <name>-db crate holds the schema, the migrations, and the generated client, so an edit to the application never recompiles the client. Keeping the client in its own crate avoids rebuilding it for unrelated application edits as the schema grows.

Start with SQLite

rent new social-app
Created ./social-app
Next: cd ./social-app && rent doctor
social-app/
  Cargo.toml              workspace: social-app, social-app-db
  rent.toml               paths point into social-app-db
  .env  .env.example  .gitignore  rustfmt.toml
  social-app/
    Cargo.toml            depends on social-app-db
    src/main.rs           use social_app_db::generated::client::Client;
  social-app-db/
    Cargo.toml
    build.rs              fails the build when the schema changed after the last `rent generate`
    src/lib.rs            pub mod generated;
    rent/schema.rsl
    rent/migrations/
    rent/generated/

Run every rent command from the workspace root, where rent.toml and .env live.

SQLite is the default and needs no container. The generated application creates rent.db locally.

Start with a server database

rent new social-app --database postgres

The database can be postgres, mysql, or mariadb. Every scaffold writes .env and .env.example. The server variants also add a compose.yaml for a local database container. Rent creates configuration. It does not start Docker automatically.

Choose a Cargo package name

rent new services/social --name social-service --database mariadb

The destination must be absent or empty. Rent refuses to merge a new scaffold into existing files.