Skip to content

CLI

lumbung talks to a Lumbung engine over its REST API.

Connection settings come from flags, then LUMBUNG_URL, LUMBUNG_TOKEN and LUMBUNG_DATABASE, then the profile saved by lumbung login.

Every command takes these flags:

--json print JSON instead of tables
--profile string saved profile to use
--token string API token (or LUMBUNG_TOKEN)
--url string engine URL (or LUMBUNG_URL)
-y, --yes don't ask before destructive actions

List, create, delete, reset, promote and diff branches.

Create a branch as a copy of another branch or a snapshot.

lumbung branch create NAME [flags]
--db string database name or id (default: the profile's)
--expires-in-days int delete the branch automatically after this many days
--from string branch to copy (default: the default branch)
--from-snapshot string snapshot id to copy instead
--protected protect the branch from delete and reset
Terminal window
lumbung branch create pr-42 --db app --expires-in-days 7

Delete a branch.

lumbung branch delete BRANCH [flags]
--db string database name or id (default: the profile's)

Show how a branch’s schema differs from another branch.

lumbung branch diff BRANCH [flags]
--against string branch to compare with (default: the default branch)
--db string database name or id (default: the profile's)
Terminal window
lumbung branch diff pr-42 --db app --against main

List a database’s branches.

lumbung branch list [flags]
--db string database name or id (default: the profile's)

Make a branch the database’s default.

lumbung branch promote BRANCH [flags]
--db string database name or id (default: the profile's)

Reset a branch to a fresh copy of its parent.

lumbung branch reset BRANCH [flags]
--db string database name or id (default: the profile's)

List, create, delete and restore databases.

Create a database with an empty main branch.

lumbung db create NAME

Move a database to the trash.

lumbung db delete NAME

List databases.

lumbung db list

Restore a database from the trash.

lumbung db restore NAME_OR_ID [flags]
--name string restore under this name instead of the old one

List databases in the trash.

lumbung db trash

Download a branch as a SQLite file or SQL dump.

lumbung export [flags]
--branch string branch name or id (default: the database's default branch)
--db string database name or id (default: the profile's)
--format string db or sql (default "db")
-o, --output string write to this file instead of standard output
Terminal window
lumbung export --db app -o app.db
lumbung export --db app --format sql > dump.sql

Import a SQLite file or SQL dump into a branch.

Imports FILE into a branch. A file starting with the SQLite header is imported as a database file, anything else as a SQL dump, unless –format says otherwise. By default the branch must have no tables; –mode replace overwrites it (not allowed on a protected branch).

lumbung import FILE [flags]
--branch string branch name or id (default: the database's default branch)
--db string database name or id (default: the profile's)
--format string db or sql (default: detected from the file)
--mode string empty or replace (default "empty")
Terminal window
lumbung import app.db --db app
lumbung import dump.sql --db app --branch staging --mode replace

Save the engine URL and a token as a profile.

Saves the engine URL and a token (and optionally a default database) to the config file, mode 600, as the profile named by –profile (default “default”), and makes it current. The token is read from –token, LUMBUNG_TOKEN, or one line on standard input.

lumbung login [flags]
--db string default database for commands that need one
Terminal window
lumbung login --url http://127.0.0.1:4870 --db app < token.txt
lumbung login --url https://db.example.com --token lmb_... --profile prod

Apply a folder of .sql migrations in order.

Apply pending migrations.

lumbung migrate apply [flags]
--branch string branch name or id (default: the database's default branch)
--db string database name or id (default: the profile's)
--dir string folder of .sql files (default "migrations")
Terminal window
lumbung migrate apply --db app --dir drizzle
lumbung migrate apply --db app --branch pr-42 --dir migrations

Show which migrations are applied.

lumbung migrate status [flags]
--branch string branch name or id (default: the database's default branch)
--db string database name or id (default: the profile's)
--dir string folder of .sql files (default "migrations")

Run one SQL statement.

Runs one statement with bound parameters in its own transaction. Each –arg binds the next ? placeholder; it is read as JSON (42, 1.5, true, null, “text”) when it parses, otherwise as text.

lumbung query SQL [flags]
--arg stringArray a parameter value; repeat for each ?
--branch string branch name or id (default: the database's default branch)
--db string database name or id (default: the profile's)
--read-only run on a read-only connection
Terminal window
lumbung query "SELECT * FROM users WHERE id = ?" --db app --arg 1
lumbung query "INSERT INTO users (name) VALUES (?)" --db app --branch dev --arg Ana

An interactive SQL prompt.

Reads SQL until a statement ends with a semicolon, runs it, and prints the result. Ctrl-C cancels a running statement or clears the line; Ctrl-D or .quit leaves. Commands: .tables, .schema [TABLE], .branch NAME, .help, .quit.

lumbung shell [flags]
--branch string branch name or id (default: the database's default branch)
--db string database name or id (default: the profile's)

List, take and restore snapshots.

Take a snapshot of a branch.

lumbung snapshot create [flags]
--branch string branch name or id (default: the database's default branch)
--db string database name or id (default: the profile's)
--label string a note to find it by

List a branch’s snapshots.

lumbung snapshot list [flags]
--branch string branch name or id (default: the database's default branch)
--db string database name or id (default: the profile's)

Restore a snapshot into a new branch.

lumbung snapshot restore SNAPSHOT_ID [flags]
--db string database name or id (default: the profile's)
--into string name of the new branch
Terminal window
lumbung snapshot restore sn_... --db app --into before-migration

List, create and revoke API tokens.

Create a token; the full token is printed once.

lumbung token create [flags]
--access string read, write or admin (default "read")
--branch string limit the token to this branch of --db
--db string limit the token to this database (default: the whole instance)
--expires-in-days int expire after this many days (0: never)
--name string what the token is for
Terminal window
lumbung token create --name ci --db app --access write --expires-in-days 90

List tokens.

lumbung token list

Revoke a token.

lumbung token revoke TOKEN_ID

Print the CLI version.

lumbung version