1. Create orders and customers
An order belongs to one customer; a customer can have several orders. In this example, “远山科技” is a customer and SO-001 is an order for CNY 1,280.
Chapter goal
Finish with customer and order tables plus two customer records. There is no order page yet: this chapter establishes the information and relationships later features will use.
Tables, fields, and relationships
A table stores records of one kind. Fields describe what each record contains. One customer is a customer record; its name and contact are fields.
An order references the customer through customerId instead of copying its name and contact every time. Multiple orders can reference the same customer, keeping one place to maintain contact information.
Integer cents give input, calculations, and display an explicit unit. Convert CNY 1280 in the form to 128000 cents in storage. Later checks use this convention.
Agree on the fields
Use tutorialCustomers for customers:
Use tutorialOrders for orders:
Use only draft, submitted, approved, and rejected as status values. Keep these names throughout the tutorial.
Ask your AI Agent to create the tables
Give the AI Agent the field tables above and this prompt:
Migrations belong in database/main/migrations/; seeds belong in database/main/seeds/. A migration defines structure; a seed inserts example data.
After running the migration, db apply also refreshes the generated database descriptions in database/main/collections/, so there is no separate collections generate step. Editing those generated files does not create a table. A migration reported as skipped may already have run when pnpm dev started, which refreshes the same files; inspect the actual structure.
Check the result
Ask the AI Agent to query both tables. There should be two customers with distinct IDs, a customer reference on orders, a unique order number constraint, and an integer amount. An empty order table is expected at this point.
If migration fails, inspect the named migration and its error. Do not run pnpm nocobase db reset to get past the failure: it drops every managed table and erases earlier work.
Next: Build list and detail pages.

