Documentation
¶
Overview ¶
Example: feature-slices
A vertical slice owns its models and its migrations. Deleting features/posts removes the model, the generated code and the migrations of that feature together, and nothing else changes.
Key concepts shown:
- modules in drel.yaml: each slice names its packages.
- Per-slice migrations: `drel migrate new --module posts <name>` writes into features/posts/migrations and diffs that slice's own snapshot.
- Embedded sets: generation writes a migrations_drel.go with //go:embed, so each slice exposes its migrations as an fs.FS.
- ApplyMigrationsFS: drel merges the sets in version order, so the migrations run in the order they were written, not in the order the arguments appear.
- db.Modules.<Slice>: a slice reaches only its own repositories.
- db.Tx(ctx).Modules.<Slice>: the same, bound to one shared transaction.
Regenerate with:
go run ../../cmd/drel generate go run ../../cmd/drel migrate new --module users <name>
Runs against in-memory SQLite. No external database is needed.
Usage:
go run ./examples/feature-slices/
Click to show internal directories.
Click to hide internal directories.