Schema Overview

The Prax schema is a declarative language for defining your data models, relationships, and database configuration in a single, type-safe file.

What is a Schema?

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:

  • Datasources - Database connection configuration
  • Generators - Code generation settings and plugins
  • Models - Database tables and their columns
  • Enums - Type-safe enumerated values
  • Relations - Connections between models
  • Views - Read-only aggregated data

Prax uses your schema to generate type-safe Rust code, create database migrations, and validate your queries at compile time.

Minimal Schema

Here's the simplest possible schema to get started:

Complete Example

A production-ready schema demonstrating all major features:

Schema Components

Click on any component to learn more:

Project Structure

Prax uses a dedicated prax/ directory for the schema and migrations:

Schema Workflow

The typical workflow when working with Prax schemas:

1

Define Schema

Write your models, enums, and relations in prax/schema.prax

2

Generate Client

Run prax generate to create type-safe Rust code

3

Create Migration

Run prax migrate dev to generate SQL migration files

4

Deploy

Run prax migrate deploy to apply migrations to production

Next Steps

Ready to dive deeper? Start with Models to learn how to define your database tables, then explore Fields & Types for the full type system.