Documentation
¶
Overview ¶
Package command provides migration and seeder commands for a consumer binary. Parse arguments before starting services; Run uses explicitly supplied resources and leaves their lifecycle with the caller's application. No command resets data.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Command ¶
type Command struct {
// contains filtered or unexported fields
}
Command is an immutable, validated invocation. Its zero value is invalid.
func Parse ¶
Parse validates arguments without application construction or database I/O. Help returns flag.ErrHelp after writing usage to help. Repeated --id flags select seeders for seed run; omission selects the complete seeder registry. --database names the connection of commands that use one; --schema selects one migration target on it.
func (Command) Database ¶
func (c Command) Database() database.ConnectionName
Database is the --database selection; empty selects the caller's default connection. Whoever assembles Resources opens that connection and names it in Resources.DatabaseName.
func (Command) NeedsDatabase ¶
NeedsDatabase reports whether Run uses a database connection. Listing seeders or prunables and showing a migration read only their registries, so resource assembly can leave the pool unconnected.
func (Command) Run ¶
Run executes the selected operation exactly once. Status reports history drift and returns its conflict error; it never applies migrations. Up and seed run write confirmed progress even on failure, then return the original outcome. An output error may follow committed work and never triggers an automatic retry.
type MigrationTarget ¶
MigrationTarget is the runner of one schema's migration history.
type Resources ¶
type Resources struct {
Migrations *migrate.Postgres
MigrationTargets []MigrationTarget
Seeders *seed.Registry
Prunables *prune.Registry
Database *database.DB
DatabaseName database.ConnectionName
}
Resources binds already assembled application services. Only the resources required by the selected command are used. Commands never start or close them.
Migration commands use either one Migrations runner or MigrationTargets, the per-schema runners of one database; --schema selects among targets. Database and MigrationTargets belong to the connection named by DatabaseName, which a --database selection must match. Leave DatabaseName empty for resources that were not assembled for a named selection; such resources accept none.