Monolith Model Development
Use this skill when
- •Adding a new persisted domain entity.
- •Updating schema and model helpers.
Default approach
- •Scaffold with
make generator model <Name> field:type...when possible. - •Confirm model is added to
db/db.goAutoMigrate list. - •Add/adjust helper functions in
app/models/<name>.go. - •Add tests under
app/models/*_test.goand rungo test ./....
Expected model conventions
- •Embed
gorm.Model. - •Include
IsActive boolsoft-delete style flag. - •Provide CRUD helpers (
CreateX,GetXByID,GetAllXs,UpdateX,DeleteX). - •Keep validation in hooks (
BeforeSave/AfterSave) or explicit helper functions.
If you need full REST scaffolding
Use make generator resource <singular> field:type....
This will create model + controller + routes + views in one pass.
Migration notes
- •Auto migration occurs during
db.InitDB()on startup. - •Adding a model without registering it in AutoMigrate means no schema creation.