Database
AuthSchema selects the application’s user, session, account, and verification models. Your application owns the models and migrations.
Generate a schema
Section titled “Generate a schema”better-auth-rs generate -o src/auth_schema.rsThe output contains all four models, AppAuthSchema, and SQLx migration scaffolding. Include it with mod auth_schema; as shown in installation.
| Role | Stores |
|---|---|
| User | Identity and profile |
| Session | Credential, expiry, and ownership |
| Account | Password or provider credentials |
| Verification | Time-limited proofs |
Add plugin fields
Section titled “Add plugin fields”better-auth-rs generate --plugins username,admin,two-factor -o src/auth_schema.rsReview generated changes before replacing an existing schema. New Rust fields still need database migrations.
run_app_migrations bootstraps a new SQLx database. SchemaMigrator::migrate installs the bundled schema and its ledger; it does not migrate arbitrary application models. Keep your own versioned migration system as the schema evolves.
Continue with SQLx, SeaORM, or existing databases. Additional fields control API input and output separately from physical models.