The Prax schema is a declarative language for defining your data models, relationships, and database configuration in a single, type-safe file.
A Prax schema is a text file (located at prax/schema.prax)
that serves as the single source of truth for your database structure. It defines:
Prax uses your schema to generate type-safe Rust code, create database migrations, and validate your queries at compile time.
Here's the simplest possible schema to get started:
A production-ready schema demonstrating all major features:
Click on any component to learn more:
Configure database connections, code generation output, and plugins.
Define database tables, primary keys, indexes, and constraints.
Scalar types, type modifiers, default values, and database-specific types.
One-to-one, one-to-many, many-to-many relationships and referential actions.
Field and model attributes for validation, mapping, defaults, and more.
Type-safe enumerated values with database-level enforcement.
Read-only database views with custom SQL for aggregations and joins.
Prax uses a dedicated prax/ directory
for the schema and migrations:
The typical workflow when working with Prax schemas:
Write your models, enums, and relations in prax/schema.prax
Run prax generate to create type-safe Rust code
Run prax migrate dev to generate SQL migration files
Run prax migrate deploy to apply migrations to production
Ready to dive deeper? Start with Models to learn how to define your database tables, then explore Fields & Types for the full type system.