Code seeds live next to your models with a Seed base class and model instances. The seed declares its database, an on-conflict strategy for re-runs, and the rows to insert, so the same seed can be applied on a fresh checkout and after a rollback without duplicating rows.
Versions are auto-assigned in the C namespace (C0001, C0002, ...) from deterministic module and class ordering, so there is no manual version parameter to keep in sync with the file layout. Each version applies once until rolled back, and the seed table tracks what ran.
The on-conflict strategy decides what a re-apply does: with __seed_on_conflict__ = "update" and __seed_conflict_columns__, an existing row matching the conflict columns is updated rather than duplicated. That is what makes a code seed safe to apply on a fresh checkout and again after a partial rollback.
from dbwarden.seed import Seed
class CountrySeed(Seed):
__seed_database__ = "primary"
__seed_description__ = "initial countries"
__seed_on_conflict__ = "update"
__seed_conflict_columns__ = ["code"]
model = Country
rows = [
Country(code="UY", name="Uruguay"),
Country(code="AR", name="Argentina"),
]Do seeds require the plugin?
Yes. Seed management ships as the official dbwarden-seeds plugin: dbwarden plugin add dbwarden-seeds. The seed commands exist in core, but each one exits with a message until the plugin is installed.
How are code seeds versioned?
Versions are auto-assigned in the C namespace (C0001, C0002, ...) based on deterministic module and class ordering, so there is no manual version parameter to keep in sync.