Project setup
Install the necessary CLI tools:
cargo-make
will be used to simplify the creation of the internal model representation.rorm-cli
is needed to create, manage and apply migrations files.
If you encounter problems with the CLI utilities, always check whether any of them are outdated by rebuilding with the above command.
Project initialization
Create a file named Makefile.toml
.
It will be used by cargo-make
.
Here is the reference
for cargo-make
.
This is an example Makefile, which sets the needed feature flags to generate migrations.
The following commands are provided through this makefile:
- Make migration files:
cargo make make-migrations
- Apply migrations to the database:
cargo make migrate
- Build the project normally:
cargo make build
- Run the project normally:
cargo make run
[tasks.cleanmodels]
command = "rm"
args = ["-f", ".models.json"]
[tasks.genmodels]
command = "cargo"
args = ["run", "-r", "-F rorm-main"]
dependencies = ["cleanmodels"]
[tasks.make-migrations]
command = "rorm-cli"
args = ["make-migrations"]
dependencies = ["genmodels"]
[tasks.migrate]
command = "rorm-cli"
args = ["migrate"]
[tasks.build]
command = "cargo"
args = ["build", "--release"]
[tasks.run]
command = "cargo"
args = ["run", "--release"]