Documentation
¶
Overview ¶
Package console is the artisan/ace-style command line: migration:run, migration:rollback --step=N, make:migration, db:seed and friends. Embed it in your app (App.Run) or use the `migro` launcher.
Index ¶
Constants ¶
const ( ExitOK = 0 ExitError = 1 ExitUsage = 2 )
Exit codes returned by Run.
Variables ¶
This section is empty.
Functions ¶
func ConnectionsFromEnv ¶
func ConnectionsFromEnv() map[string]Connection
ConnectionsFromEnv builds the connection table from the environment:
MIGRO_DIALECT / MIGRO_DSN the default connection MIGRO_<NAME>_DIALECT / MIGRO_<NAME>_DSN a named one, used as --database=<name> (lower-cased)
func LoadDotEnv ¶
LoadDotEnv reads KEY=VALUE lines from path into the process environment. Variables that are already set win. A missing file is not an error.
Types ¶
type App ¶
type App struct {
// Connections by name; Default names the one used without --database.
Connections map[string]Connection
Default string
// Env is the application environment ("production" triggers the safety prompt).
// Defaults to MIGRO_ENV, then APP_ENV, then "development".
Env string
// Directories, relative to Root, used by make:* and migration:diff.
Root string
MigrationsDir string // database/migrations
SeedersDir string // database/seeders
FactoriesDir string // database/factories
ModelsDir string // app/models
ObserversDir string // app/observers
SchemaDir string // database/schema: where schema:dump writes and migration:run looks for a dump
// Models are the GORM models migration:diff compares with the database.
Models []any
// Migrations and Seeders default to everything registered via Register in init().
Migrations func() ([]migrate.Migration, error)
Seeders func() []seed.Seeder
Out, Err io.Writer
In io.Reader
Interactive bool // true when In is a terminal; enables the production confirmation prompt
Now func() time.Time
}
App wires commands to your project. Zero values get defaults in Run.
func FromEnv ¶
FromEnv builds an App for root from .env and the environment. Directories can be overridden with MIGRO_MIGRATIONS_DIR, MIGRO_SEEDERS_DIR, MIGRO_FACTORIES_DIR, MIGRO_MODELS_DIR, MIGRO_OBSERVERS_DIR and MIGRO_SCHEMA_DIR.