Guide 12 of 12

Command reference

Every command is spelled the way Rails spells it. bogie help prints the authoritative short version of this page from inside an app.

Bogie, outside an app

CommandDoes
bogie new NAME [--module=PATH] [--jobs]Generates a new service in ./NAME.
bogie versionPrints the version.
bogie helpThis text.

Bogie, inside an app

Found by its bogie.toml, from any subdirectory.

CommandDoes
bogie generate GENERATOR NAME, bogie gRuns a generator: scaffold, model, migration, controller, service, job, authentication. bogie g -h for its own usage.
bogie destroy GENERATOR NAME, bogie dRemoves what a generator made, registration included.
bogie doctorChecks markers, pinned tools and layout files; confirms every controller is constructed and mounted.
bogie app:update [--pretend]Moves the app to the installed Bogie's layout: a three-way merge between what the recorded version generated, what this version generates, and the file on disk. Refuses on a dirty git tree; a real overlap leaves conflict markers.
bogie server, bogie sRuns the app; migrates at boot. In development it runs under Air: save a file and it rebuilds and restarts.
bogie workerWorks the job queue (apps with jobs; g job adds them to one that has none). Reloads under Air in development, same as bogie server, to its own binary so the two can run side by side.
bogie test [PKGS], bogie tgo test -race -cover ./....
bogie lintgofmt check, go vet, golangci-lint.
bogie ciEvery check, locally, then sign off: bin/ci.
bogie db:createCreates the database for the current environment.
bogie db:dropDrops it, with --yes added for you.
bogie db:prepare (db:setup)Create, migrate, seed.
bogie db:resetDrop then prepare.
bogie db:migrateApplies pending migrations.
bogie db:migrate:statusWhich migrations have run, which are pending.
bogie db:migrate:redoRolls the last migration back and re-applies it.
bogie db:rollbackRolls back the most recent migration.
bogie db:versionThe current schema version.
bogie db:seedApplies pending seeds from db/seeds.
bogie db:seed:rollbackRolls back the most recent seed.
bogie credentials:edit [-e ENV]Opens the encrypted settings for editing.
bogie credentials:show [-e ENV]Prints the decrypted file.
bogie credentials:get [-e ENV] KEYPrints one value.

Tasks that destroy pass --yes on your behalf here, the way a laptop command should; the app's own binary in a deployed container keeps asking. bogie db:migrate:up or any other near-miss points at the nearest real task rather than printing the whole usage.

The reload under bogie server and bogie worker is development only: set <NAME>_ENV to anything else and the plain compiled binary runs with no watcher. Air is pinned as a go tool dependency in the app's own go.mod, next to goose, sqlc and credentials, so a fresh clone needs only Go. Its settings are .air.toml; deleting that file turns reload off.

Generators: bogie g / bogie d

GeneratorArgumentsWrites
migrationNAME [field:type ...]db/migrate/<stamp>_NAME.sql. create_<table>, add_<x>_to_<table> and remove_<x>_from_<table> write their SQL.
modelNAME [field:type ...]The migration, db/queries/<table>.sql, app/domain/<name>.go and the store's app/models/<table>.go; then runs sqlc.
scaffoldNAME [field:type ...]The model, plus app/views/<table>.go and a <Table>Controller with real handlers over the store, registered. The model is singular, the rest plural, as Rails names them.
controllerNAME [action ...]app/controllers/<name>_controller.go, one Rails controller in one file, registered: a field, a wire line and a mount above each marker. Name a resource in the plural. admin/NAME puts it in the admin namespace, app/controllers/admin_controller/, made on first use and registered the same way.
serviceNAMEapp/services/<name>/, ctx first, no HTTP, not wired anywhere.
jobNAMEapp/jobs/<name>.go, a River job, registered above bogie:jobs; the first one on an app with no jobs adds them first, merged in like app:update.
authenticationSHAPEA middleware on a route group, its config key with a development value written to the credentials, and a WithX group helper on the root Server. SHAPE is secret (the Rails app calls this service), token (bearer JWT a user presents) or api_key (keys for machine clients, with a table and api_keys:create).

Flags: --pretend reports without writing, --force overwrites a file that differs, --skip-sqlc skips the sqlc run. Attributes are field:type, with :index or :uniq after the type: string text integer bigint boolean datetime uuid jsonb references. A references field names the other model: post:references is post_id.

bogie d GENERATOR NAME removes what the generator of the same name created: its files, and for a controller the three lines that registered it. A namespaced controller's package goes too once it holds no controller; bogie d authentication token also reverses its three lines in config/config.go, leaving the development value harmless in the credentials file.

api_key registers a subcommand on the app's own binary, not on bogie: bogie api_keys:create NAME reaches it through the same proxy rule as db:*, any colon task bogie does not know itself is shorthand for the binary's own, so it runs blog api_keys create NAME.

The app binary itself

A plain Go CLI with spaces, the form bogie accepts too (bogie db prepare works from outside, since the colon tasks above are shorthand for exactly these):

CommandDoes
blog serveRuns the HTTP server.
blog workerWorks the job queue (apps with jobs enabled).
blog db createCreates the database this environment points at.
blog db drop --yesDrops it; refused in production.
blog db prepareCreate if needed, migrate, seed.
blog db seedApplies pending seeds.
blog db seed-down --yesRolls back the most recent seed.
blog migrate statusWhich migrations have run, which are pending.
blog migrate versionThe current schema version.
blog migrate upApplies every pending migration (also done at boot).
blog migrate down --yesRolls back the most recent migration.
blog migrate down-to N --yesRolls back until the schema is at version N (0 = empty).

These run against whatever database the current <NAME>_ENV selects, including on a deployed host: docker exec <container> blog migrate status.

make targets

TargetDoes
make helpEvery task.
make upStart Postgres (Compose) and wait until it is healthy.
make downStop it, keeping the data.
make resetStop it and destroy the data.
make logsTail the containers.
make psqlOpen a shell on the development database.
make credentialsEdit the encrypted settings (development); ENV=production for its own file and key.
make buildCompile the binary.
make serverRun the HTTP server. One boot, no reload; drop to this for a single set of logs.
make workerWork the job queue (apps with jobs enabled). One boot, no reload.
make testRun the suite with coverage, in the test environment (needs make up).
make sqlcRegenerate app/models from db/queries against db/migrate.
make vetStdlib static analysis.
make fmtFormat.
make lintgofmt check + golangci-lint.
make ciEvery check, locally; green ends with gh signoff (bin/ci).
make tidyPrune and verify the module graph.
make db-createCreate the database, like rails db:create; an existing one is fine.
make db-dropDrop the database and every table in it, like rails db:drop.
make db-prepareCreate if needed, migrate, seed, like rails db:prepare.
make db-resetDrop it and rebuild it from the migrations, like rails db:reset.
make db-migrateApply pending migrations (deployed containers do this at boot).
make db-migrate-downRoll back the last migration; drops its tables.
make db-rollbackRails' name for db-migrate-down; the same task.
make db-migrate-to V=<version>Roll back to a version.
make db-rollback-toRails' name for db-migrate-to; the same task.
make db-migrate-statusWhich migrations have run, and which are pending.
make db-versionThe current schema version.
make db-migrate-redoRoll the last migration back and re-apply it.
make db-seedApply pending seeds from db/seeds, through the binary.
make db-seed-downRoll back the most recent seed.
make g_migration_<name>Author a migration (go tool goose).
make g_seed_<name>Author a seed (go tool goose).