hubfly db
hubfly db creates and operates Managed Databases: PostgreSQL, MySQL and SQLite (libSQL) that Hubfly space runs for you. It covers the whole lifecycle, from quoting a price to running SQL, binding a database to an app, exporting data and changing configuration. hubfly database and hubfly databases are aliases.
Basics
<db>is a database instance id or name. When two managed projects use the same name, add--project <id|name>.- Hubfly space chooses where managed databases run, so there is no
--regionflag. - Sizes are
nano,small,medium,largeandxlarge, or a custom--cpuand--memory;hubfly db engineslists them with prices. - Commands that print data accept
--json. Passwords and tokens are printed only with--reveal, or once when they are created. - Run
hubfly db helpfor the full usage text.
terminal
Create And Inspect
hubfly db list [--project <id|name>] [--json]
hubfly db engines [--json]
hubfly db info <db> [--json]
hubfly db create [<name>] [--engine postgresql|mysql|libsql] [--version <v>]
[--size <preset>|--cpu <n> --memory <mib>] [--storage <gib>]
[--project <id|name|new>] [--project-name <name>]
[--database <name>]
[--private] [--allow <cidr>]... [--allow-my-ip]
[--yes] [--no-wait] [--timeout <duration>] [--json]| Command | What it does |
|---|---|
db list | Databases in your managed projects: name, engine and version, status (including a running operation), size, monthly price, project and id. |
db engines | Whether new databases are being accepted, the engines and versions (default, LTS), size presets with monthly prices, the storage range and your instance limit. |
db info | Engine and version (and whether an update is available), status, size, storage, price, host and port, default database, admin user, TLS, public access and allowlist, deletion protection and any pending restart. With --json it returns instance and connection. |
db create | Checks your input against the catalog, quotes the monthly price, asks you to confirm, creates the database and waits until it is ready. It prints the host, port, database and user, never the password. |
| Create flag | Meaning |
|---|---|
--engine | postgresql, mysql or libsql. In a terminal you are asked; otherwise the default is postgresql. |
--version | Engine version such as 17 or 9.7. Defaults to the engine's default version. |
--size | A size preset. Defaults to the smallest preset with enough memory for the engine (MySQL needs 1 GiB). |
--cpu, --memory | A custom size instead of a preset: 0.25–8 vCPU in 0.25 steps, memory in MiB in 256 MiB steps. |
--storage | Storage in GiB, 1–500. Defaults to 10. It can grow later but never shrink. |
--project | The managed project to create it in, or new for a new managed project. In a terminal you can pick one. |
--project-name | Name of the new project with --project new. Defaults to the database name. |
--database | Default database name (PostgreSQL and MySQL), initially app. The admin user is always admin. |
--private | Create without a public endpoint. See public access. |
--allow, --allow-my-ip | IP allowlist entries; repeat --allow for several. --allow-my-ip adds the address you are connecting from. |
--yes | Accept the quoted price without a prompt. Required when no terminal is attached. |
--no-wait, --timeout | Return as soon as the create request is accepted, or limit how long to wait (for example 20m). |
terminal
Lifecycle And Settings
hubfly db delete <db> [--yes] [--wait]
hubfly db start|stop|restart <db> [--no-wait] [--json]
hubfly db resize <db> [--size <preset>|--cpu <n> --memory <mib>] [--storage <gib>] [--restart] [--yes] [--no-wait] [--json]
hubfly db upgrade <db> [--yes] [--no-wait]
hubfly db rename <db> <new-name>
hubfly db protect <db> on|off| Command | What it does |
|---|---|
db delete | Deletes the database immediately and permanently after you type its name (or pass --yes). Deletion protection must be off. --wait follows the deletion until it finishes. Exports already taken stay downloadable until they expire. |
db start, stop, restart | Waits for the operation unless --no-wait. Stopping disconnects every client; a stopped database pays for storage only. |
db resize | Quotes the old and new monthly price and asks you to confirm. The database must be running. Storage can only grow. Adding CPU or memory applies without a restart; reducing memory stops and starts the database. When the new size changes engine settings that need a restart, --restart restarts as part of the resize; otherwise the database shows a pending restart. |
db upgrade | Applies an available update for the engine's version line, after you confirm. The database restarts during the update. db info shows whether one is available. |
db rename | Changes the display name. The hostname and connection strings stay the same. |
db protect | Turns deletion protection on or off. |
terminal
Connect
hubfly db url <db> [--database <name>] [--reveal] [--json]
hubfly db env <db> [--database <name>] [--reveal] [--format dotenv|json]
hubfly db credentials <db> [--reveal] [--json]
hubfly db credentials rotate <db> [--yes] [--json]
hubfly db connect <db> [--database <name>] [-- <client args>...]
hubfly db shell <db>
hubfly db cert <db> [--output <file>]| Command | What it does |
|---|---|
db url | Prints the connection URL in the same format app bindings use, including the TLS parameter. The password is masked unless you pass --reveal, which is recorded in the activity log. For libSQL it prints the libsql:// URL; create a token with db tokens create. |
db env | Prints DATABASE_URL=…, or the libSQL URL variable, ready for a .env file or as JSON. |
db credentials | Shows the admin user and a masked password; --reveal shows the password. |
db credentials rotate | Replaces the admin password and prints the new one once. App bindings that use the admin user get the new URL (redeploy those apps); update any other client yourself. On libSQL it replaces the token signing key instead, which invalidates every token; connected apps receive new tokens. |
db connect | Starts psql or mysql on your machine with TLS required. It first checks that your IP may connect and tells you the fix if not (hubfly db network allow <db> --my-ip). The password goes through the environment or a temporary file, never the command line. Arguments after -- are passed to the client. libSQL is HTTPS only: use db query or a libSQL client. |
db shell | Opens a SQL shell that runs on Hubfly space through the same terminal connection as hubfly ssh, so nothing needs to be installed: psql signed in as the admin role, or the mysql client, which asks for the admin password. PostgreSQL and MySQL; the database must be running. |
db cert | Writes the instance's CA certificate (PEM) to standard output or --output, for clients that verify the server (sslmode=verify-full). |
terminal
Run SQL
hubfly db query <db> [<sql>|--file <path|->] [--database <name>] [--write] [--max-rows <n>]
[--timeout <duration>] [--format table|json|csv]db query runs SQL through Hubfly space, like the Dashboard's SQL editor, so it works without a local client or an allowlist entry. SQL comes from the argument, from --file (- for standard input) or from piped input. Queries are read-only unless you pass --write. Results print as a table, or with --format json or csv (CSV takes the first result set). The command exits with a non-zero status when a statement fails.
terminal
Databases, Users, Tokens, Extensions
hubfly db databases [list] <db> [--json]
hubfly db databases create <db> <name> [--owner <user>] [--json]
hubfly db databases delete <db> <name> [--force] [--yes]
hubfly db users [list] <db> [--json]
hubfly db users create <db> <name> [--preset read_only|read_write|admin] [--databases <a,b>|--all-databases] [--json]
hubfly db users update <db> <name> [--preset <preset>] [--databases <a,b>|--all-databases] [--json]
hubfly db users delete <db> <name> [--reassign-to <user>] [--yes]
hubfly db users rotate <db> <name> [--yes] [--json]
hubfly db tokens [list] <db> [--json] (SQLite/libSQL)
hubfly db tokens create <db> <name> [--access read_only|full_access] [--expires <days>] [--json]
hubfly db tokens revoke <db> <tokenId> [--yes]
hubfly db extensions [list] <db> [--database <name>] [--json] (PostgreSQL)
hubfly db extensions install <db> <name> [--database <name>]
hubfly db extensions remove <db> <name> [--database <name>] [--cascade] [--yes]| Command | What it does |
|---|---|
db databases | PostgreSQL and MySQL. create adds a database (optionally owned by --owner). delete asks you to type the database name; it fails while sessions use the database unless --force, which ends those sessions first. |
db users | PostgreSQL and MySQL. Presets: read_only, read_write (can also run migrations) and admin (never a superuser), for --databases a,b or --all-databases. create and rotate print the password once. delete can hand the user's objects to another user with --reassign-to. The admin user created with the instance cannot be deleted. |
db tokens | SQLite (libSQL). create prints a token once, with read_only or full_access and an optional expiry in days. revoke replaces the signing key, which invalidates every token; connected apps get new tokens automatically. |
db extensions | PostgreSQL. Lists available and installed extensions per database, installs one from Hubfly space's allowlist, or removes one (--cascade also drops objects that depend on it). |
terminal
Export And Import
hubfly db export <db> [--database <name>] [--format native|sql] [--output <file>] [--no-wait]
hubfly db exports [list] <db> [--json]
hubfly db exports download <db> <exportId> [--output <file>]
hubfly db import <db> <file> [--database <name>] [--format native|sql] [--yes] [--no-wait]db exportstarts an export, waits for it and downloads the file. With--no-waitit prints the export id; download it later withdb exports download. Exports stay downloadable for 7 days.- Formats: PostgreSQL
native(apg_dumpcustom-format archive) orsql(plain SQL); MySQL and libSQLsql, gzip-compressed. db importuploads a file and restores it into a database after you confirm, because it writes into that database. Files are limited to 5 GB.
terminal
Read SQL, explorer and exports for how imports behave per engine.
Network And Apps
hubfly db network <db> [--json]
hubfly db network public <db> on|off [--yes]
hubfly db network allow <db> (<cidr>|--my-ip) [--label <text>]
hubfly db network remove <db> <cidr>
hubfly db bind <db> --to <project> [--env <NAME>] [--database <name>] [--new-user [--access read_only|read_write]] [--json]
hubfly db bind list <db> [--json]
hubfly db bind remove <db> <bindingId> [--keep-variable] [--yes]| Command | What it does |
|---|---|
db network | Shows the endpoint, public access and the allowlist with labels. |
db network public | Turns public access on or off. Turning it off asks for confirmation: clients outside Hubfly space and apps that use the public host lose access. |
db network allow, remove | Adds or removes an allowlist entry (up to 64). A bare IP becomes a /32 or /128 range; --my-ip uses the address you connect from. |
db bind | Writes DATABASE_URL (or --env NAME), or LIBSQL_URL and LIBSQL_AUTH_TOKEN for libSQL, into a Cell project. --new-user creates a dedicated user with read_write or read_only access instead of using the admin user. The app picks the values up on its next deploy. |
db bind list, remove | Lists bindings, or removes one together with the variables it wrote (--keep-variable keeps them). |
terminal
Operate
hubfly db logs <db> [--tail <bytes>] [--follow]
hubfly db metrics <db> [--window <duration>] [--json]
hubfly db operations <db> [--limit <n>] [--json]
hubfly db sessions [list] <db> [--json]
hubfly db sessions cancel|terminate <db> <sessionId> [--yes]
hubfly db insights <db> [--order-by total_time|mean_time|calls] [--limit <n>] [--json]
hubfly db insights reset <db> [--yes]
hubfly db config <db> [--all] [--json]
hubfly db config set <db> <key>=<value>... [--restart now|later] [--note <text>] [--yes]
hubfly db config history <db> [--limit <n>] [--json]
hubfly db config revert <db> <revisionId> [--restart now|later] [--yes]| Command | What it does |
|---|---|
db logs | Recent server logs, with passwords and tokens scrubbed. --follow keeps printing new lines until you press Ctrl-C. |
db metrics | CPU, memory, storage and network figures, plus database statistics, over a window such as 1h. |
db operations | Recent operations (create, resize, restart, export…) with status, current step and error. |
db sessions | PostgreSQL and MySQL sessions: user, database, client address (marked when it arrived through Hubfly space's proxy), state, duration and query. cancel stops the running query; terminate closes the session. |
db insights | PostgreSQL and MySQL query statistics, ordered by total time, mean time or calls. insights reset clears them. |
db config | PostgreSQL and MySQL. config set validates the change, shows what changes and what needs a restart, then applies it after you confirm. Settings that need a restart wait for the next restart unless you pass --restart now. history lists applied revisions and revert returns to one. |
terminal
Scripting And Secrets
- JSON output. With
--json, standard output carries only JSON; prompts and progress go to standard error. - Confirmations. Creating, resizing, deleting and other destructive commands ask first. Without a terminal they stop with
confirmation required; re-run with --yesinstead of guessing; pass--yesonce you have reviewed the change. - Secrets. Passwords appear only with
--reveal(an audited reveal) or once when they are created or rotated; tokens appear only when created.--debugnever prints them. - Waiting. Long operations show progress and wait;
--no-waitreturns as soon as Hubfly space has accepted the request. Follow it later withhubfly db operations. - Exit codes. Non-zero on failure, with distinct codes for usage errors, authentication, conflicts and timeouts. See exit codes.
Use it in CI
HUBFLY_TOKEN, pass --yes to accept quotes and confirmations you have reviewed, and read results with --json. For example, hubfly db query app-db --file schema-check.sql --format json fails the job when a statement fails.