feature-slices

command
v0.7.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 9, 2026 License: MIT Imports: 8 Imported by: 0

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/

Directories

Path Synopsis
features

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL