Database Commands
andurel db wraps the local PostgreSQL lifecycle, goose migrations, and the cmd/seeds entrypoint. Development talks to the database by name from .env; production applies the embedded migrations with cmd/migrate.
Lifecycle
1andurel db create
2andurel db drop
3andurel db nuke
4andurel db rebuild
5andurel db rebuild --seed test
6andurel db rebuild --skip-seed
createcreates the configured database and is a no-op if it already exists.dropremoves it.nukedrops and recreates an empty database.rebuilddrops, recreates, applies every migration, and runs a seed. Use--seed <name>to choose the seed set and--skip-seedto stop after migrating.
drop, nuke, and rebuild prompt for confirmation. --force skips the prompt and also permits protected system database names such as postgres and template1; reserve it for explicit automation.
The commands connect with the DB_* settings from .env (or the process environment). Only PostgreSQL is supported.
Migrations
1andurel generate migration add_status_to_products
2andurel db migrate up
3andurel db migrate status
4andurel db migrate down
5andurel db migrate up-to 20250101120000
6andurel db migrate down-to 20250101120000
7andurel db migrate reset
8andurel db migrate fix
Migrations are goose SQL files in migrations/ with -- +goose Up and -- +goose Down. The CLI runs bin/goose against the files on disk. reset rolls every migration down and re-applies it; fix renumbers gaps in the sequence.
Do not apply migrations from cmd/app start. Production uses a one-shot process that applies the embedded files:
1go build -o migrate ./cmd/migrate
2./migrate
cmd/migrate opens PostgreSQL with config.NewDatabase, calls storage.RunMigrations on the embedded migrations.Migrations, and exits. Run it as a release step before traffic reaches code that expects the new schema.
Seeds
1andurel db seed --list
2andurel db seed development
3andurel db seed test
4andurel db rebuild --seed test
andurel db seed runs go run ./cmd/seeds, which loads config, opens PostgreSQL, and calls seeds.Run. Named sets live in the seeds.Registry; the scaffold ships development and test. --list prints the available names with --json support.
Seeds use exported domain APIs, not raw SQL and not factories. Keep them idempotent: the development seed keeps a user that already exists, so rebuilds and repeated runs do not fail.
Inspect the database
1andurel db console
2andurel console
3andurel tool dblab
4andurel db migrate status
5andurel inspect migrations --json
console and db console do the same thing: they open usql with the project connection settings. andurel tool dblab opens the terminal database UI. inspect migrations lists the SQL files on disk, and db migrate status reports which ones the database has applied.