Search documentation

Find a page in the Andurel docs.

scaffold

andurel generate scaffold creates a full resource from an existing table migration: constructed model API, entity and data types, optional factory, controller, typed routes, and views or Inertia pages.

When to use

  • Add a full resource when the matching migration already exists under migrations/.
  • Prefer model or controller when you only need one layer.

Usage

1andurel generate scaffold NAME [flags]

NAME is CamelCase. One lowercase namespace segment is allowed (admin/Widget). Namespaced scaffolds place controllers under controllers/admin, use admin.* route names, and Admin-prefixed symbols.

Flags

Flag What it does
--api Generate a JSON API controller under controllers/api instead of UI pages
--host Named virtual host (routing.HostName); default primary
--prefix Path/package namespace (independent of --host)
--primary-key Specify the primary key column (skips interactive detection)
--table-name Override the default table name derived from NAME
--skip-factory Skip generating a factory for the model
--dry-run / --diff Preview without writing; see generate for shared flags

--host and --prefix are independent, the same as controller. Do not invent --host values: declare routing.HostName consts in config/hosts.go and load them into App.Hosts first.

Without --api, generation follows the project UI in andurel.lock (Inertia adapter or Templ).

Examples

1andurel generate scaffold Product --dry-run --diff --json
2andurel generate scaffold Product
3andurel generate scaffold admin/Widget
4andurel generate scaffold Widget --host=admin
5andurel generate scaffold Product --api
6andurel generate scaffold Product --table-name catalog_products --primary-key id

A typical scaffold writes:

  • models/product.go and related query SQL
  • models/factories entry (unless --skip-factory)
  • controllers/products.go (or controllers/api / namespaced path)
  • router/routes/products.go
  • Templ views or Inertia pages for the configured adapter

Next

1andurel sync routes --json
2andurel sync payloads --json
3andurel doctor --json

See Generators for Inertia payload and TypeScript flow, and migration when the table does not exist yet.