Generator Commands
Generator commands scaffold new files from FORGE's Tera templates. Each generator creates properly structured, wired-up code — models, migrations, handlers, pages, and components — so you spend less time on boilerplate.
forge make:model
Generate a new model struct with optional associated files. You can define fields inline to generate fully typed migrations, Rust structs, DTOs, and admin forms in one step.
Usage
forge make:model <NAME> [FIELDS...] [OPTIONS]FIELDS... are optional positional arguments using name:type syntax. See Field Types Reference for all supported types.
Options
| Option | Type | Default | Description |
|---|---|---|---|
--migration, -m | flag | false | Also generate a database migration. |
--all, -a | flag | false | Generate migration, handler, and admin CRUD pages — the full resource stack. |
--translatable | flag | false | Add translation support with a _translations table and Translatable trait implementation. |
--interactive, -i | flag | false | Launch an interactive field builder that prompts for each field name and type. |
Examples
Model only (no fields):
forge make:model CategoryModel with inline fields and migration:
forge make:model Product -m title:string price:decimal is_active:booleanFull resource stack with fields:
forge make:model Product --all title:string price:decimal status:lookup category:belongs_toThis generates the model, migration (with columns), handler, and admin CRUD pages — all wired with the field definitions you specified.
Translatable model:
forge make:model Article --all --translatable title:string body:textInteractive field builder:
forge make:model Product --all --interactiveThe interactive mode prompts you for each field one at a time:
Interactive field builder (enter empty name to finish)
Available types: string, text, integer, bigint, decimal, boolean,
date, datetime, uuid, json, lookup, belongs_to
Field name (or press Enter to finish): title
Field type for 'title': string
✓ Added: title → string (SQL: VARCHAR(255))
Field name (or press Enter to finish): price
Field type for 'price': decimal
✓ Added: price → decimal (SQL: DECIMAL(10,2))
Field name (or press Enter to finish):
Total fields: 2TIP
--all is the recommended option for new entities. It generates the full stack — model, migration, handler, and admin CRUD pages — in one step, keeping the codebase consistent.
forge make:migration
Generate a new SQL migration file. Like make:model, you can pass inline field definitions to generate a migration with typed columns.
Usage
forge make:migration <NAME> [FIELDS...] [OPTIONS]Options
| Option | Type | Default | Description |
|---|---|---|---|
--create | string | — | Generate a CREATE TABLE migration for the given table name. |
--table | string | — | Generate an ALTER TABLE migration for the given table name. |
Examples
# Create a new table (no fields — empty migration body)
forge make:migration create_categories_table --create=categories
# Create a table with typed columns
forge make:migration create_products_table title:string price:decimal is_active:boolean
# Add a foreign key column
forge make:migration add_category_to_products category:belongs_to
# Alter an existing table
forge make:migration add_slug_to_products --table=productsGenerated files follow the numbered naming convention:
migrations/
00018_create_categories_table.sqlField Types Reference
When you pass FIELDS... to make:model or make:migration, each field uses the name:type syntax. FORGE maps each type to the correct SQL column, Rust type, TypeScript type, and admin form component.
Supported Types
| Type | SQL Column | Rust Type | TS Type | Form Component | Example |
|---|---|---|---|---|---|
string | VARCHAR(255) | String | string | Input | title:string |
text | TEXT | String | string | Textarea | body:text |
integer | INTEGER | i32 | number | Input (number) | quantity:integer |
bigint | BIGINT | i64 | number | Input (number) | views:bigint |
decimal | DECIMAL(10,2) | BigDecimal | number | Input (number) | price:decimal |
boolean | BOOLEAN | bool | boolean | Switch | is_active:boolean |
date | DATE | NaiveDate | string | Input (date) | birth_date:date |
datetime | TIMESTAMPTZ | DateTime<Utc> | string | Input (datetime) | published_at:datetime |
uuid | UUID | Uuid | string | Input | external_id:uuid |
json | JSONB | serde_json::Value | Record<string, unknown> | Textarea | metadata:json |
lookup | UUID (FK → lookups) | Uuid | string | Select | status:lookup |
belongs_to | UUID (FK → related table) | Uuid | string | Select | user:belongs_to |
Type Aliases
Several aliases are accepted for convenience:
| Alias | Resolves To |
|---|---|
str, varchar | string |
longtext | text |
int, i32 | integer |
big_int, i64 | bigint |
float, double, money | decimal |
bool | boolean |
timestamp, timestamptz | datetime |
jsonb | json |
belongsto, relation, fk | belongs_to |
Special Types: Lookup and BelongsTo
Lookup — status:lookup
Creates a foreign key to the lookups table, using the field name as the parent slug. The column becomes status_id and the admin form renders a <Select> populated from the lookup values for the "status" slug.
BelongsTo — user:belongs_to
Creates a foreign key to the related model's table (derived from the field name). user:belongs_to produces a user_id column referencing the users table, and the admin form renders a <Select> populated from that table.
forge make:seeder
Generate a new database seeder file.
Usage
forge make:seeder <NAME>Example
forge make:seeder categoriesCreates:
seeders/
08_categories.sqlforge make:handler
Generate HTTP handler functions for a resource.
Usage
forge make:handler <NAME> [OPTIONS]Options
| Option | Type | Default | Description |
|---|---|---|---|
--api | flag | false | Generate API-only handlers (no admin panel routes). |
--only | string | — | Comma-separated list of actions to generate: index, show, create, update, delete. |
Examples
# Full CRUD handler set
forge make:handler Product
# API-only, limited to index and show
forge make:handler Product --api --only=index,showforge make:middleware
Generate a new Axum middleware.
Usage
forge make:middleware <NAME>Example
forge make:middleware rate_limitCreates:
src/middleware/
rate_limit.rsThe generated file includes the middleware function signature, a request extractor, and a placeholder for your logic.
forge make:page
Generate a Next.js page (or full CRUD page set) for the web or admin app.
Usage
forge make:page <NAME> [OPTIONS]Options
| Option | Type | Default | Description |
|---|---|---|---|
--app | string | web | Target application: web or admin. |
--crud | flag | false | Generate a complete CRUD page set: list, create, edit, and view. |
Examples
# Single web page
forge make:page about --app=web
# Admin CRUD pages
forge make:page Product --app=admin --crudWhen --crud is used with --app=admin, the following pages are created:
admin/app/(dashboard)/products/
page.tsx # List view with data table
create/page.tsx # Create form
[id]/page.tsx # Detail view
[id]/edit/page.tsx # Edit formforge make:component
Generate a React component.
Usage
forge make:component <NAME> [OPTIONS]Options
| Option | Type | Default | Description |
|---|---|---|---|
--app | string | web | Target application: web or admin. |
--shared | flag | false | Place the component in a shared directory accessible by both apps. |
Examples
# Web-specific component
forge make:component hero-banner --app=web
# Shared component
forge make:component data-table --sharedComplete Workflow Example
The following example demonstrates a typical feature workflow using generators. Starting from a single command with inline fields, FORGE creates every file needed for a fully functional Product resource.
# 1. Generate the full resource stack with fields
forge make:model Product --all --translatable \
title:string price:decimal sku:string \
is_active:boolean status:lookup category:belongs_toThis creates:
api/src/models/product.rs # Model struct with typed fields + Translatable trait
api/src/dto/product.rs # Request/response DTOs
api/src/handlers/admin/products.rs # Admin CRUD handlers
api/src/services/product.rs # Business logic service
migrations/00018_create_products_table.sql # With columns for every field
migrations/00019_create_product_translations_table.sql
seeders/08_products.sql
admin/app/(dashboard)/products/page.tsx # List page
admin/app/(dashboard)/products/create/page.tsx # Create form with inputs
admin/app/(dashboard)/products/[id]/edit/page.tsx # Edit formThe migration includes typed columns, foreign keys, and defaults — all derived from the field definitions:
CREATE TABLE products (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
title VARCHAR(255) NOT NULL,
price DECIMAL(10,2) NOT NULL,
sku VARCHAR(255) NOT NULL,
is_active BOOLEAN NOT NULL DEFAULT false,
status_id UUID REFERENCES lookups(id),
category_id UUID REFERENCES categories(id),
created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
updated_at TIMESTAMPTZ NOT NULL DEFAULT now()
);# 2. Run the migration
forge migrate:run# 3. Seed initial data
forge seed --class products# 4. Start development
forge serveTIP
Combine generators with Database Commands and Development Commands to go from idea to running feature in under a minute.
See Also
- Project Commands — scaffold entire projects
- Database Commands — run generated migrations and seeders
- Language Commands — manage translations for translatable models