Prepare a database
The first model in this book will read from a teams table in the PostgreSQL database named app. Create it before running the Rust example:
CREATE TABLE teams (
id BIGINT GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
name TEXT NOT NULL
);
The next chapter maps these columns to Team.id: i64 and Team.name: String. The table is plural, while Canyon's default name for Team is team, so the model will use #[canyon_entity(table_name = "teams")].
Use your usual schema tool or SQL client to create the table. Canyon's normal CRUD path reads and writes existing tables; it does not create them. If you use MySQL or SQL Server instead, adapt the identity-column syntax and configure that backend's datasource.
No migration setup is required. Canyon's migrations feature is experimental; leave it disabled for this example. Contributors who want Canyon's Docker test databases can follow Test and contribute.