Skip to content

civex db

Database management commands.

Command Description
current Show the database's current migration revision and whether it's up to date.
migrate Apply any pending migrations now, instead of waiting for the next connect.
move Move this project's data to another database.
moves List past database moves, newest first.
revert Switch back to the database a move came from.
setup-docker Set up a Docker-managed PostgreSQL container for this civex project.
setup-postgres Configure civex to use a PostgreSQL database.
status Show the database's connection, migration, and (if applicable) Docker container status.
teardown Stop and remove this project's Docker-managed PostgreSQL container and its data.

civex db current

Show the database's current migration revision and whether it's up to date.

Usage

civex db current

civex db migrate

Apply any pending migrations now, instead of waiting for the next connect.

Usage

civex db migrate

civex db move

Move this project's data to another database.

Copies every record, schema, collection and everything else into the destination, checks the copy against the original, and only then points this project at it. The original database is never changed or removed, so civex db revert can switch back. The destination must be empty or new; nothing is ever overwritten. The same steps apply whichever way you move: SQLite to Docker PostgreSQL, back again, or from one PostgreSQL server to another.

Usage

civex db move [OPTIONS]

Options

Option Type Default Description
--to str Where to move the data: sqlite (a new file), docker (this project's Docker PostgreSQL) or postgres (a server you run). Asked if left out.
--path str File to create, for --to sqlite.
--url str Full connection URL, for --to postgres. Env: CIVEX_DB_URL.
--host str Server host, for --to postgres.
--port int 5432 Server port, for --to postgres.
--database str Database name, for --to postgres.
--user str User name, for --to postgres.
--password str Password, for --to postgres. Env: CIVEX_DB_PASSWORD.
--yes, -y flag false Don't ask for confirmation.
--json flag false Print the outcome as JSON, with no progress bar or prompts.

civex db moves

List past database moves, newest first.

Usage

civex db moves

civex db revert

Switch back to the database a move came from.

Nothing is copied back: records written to the new database since the move stay there. To carry those across too, move again into a fresh destination.

Usage

civex db revert [OPTIONS] MOVE_ID

Arguments

Argument Type Required Description
MOVE_ID str yes Id of the move to undo (see civex db moves).

Options

Option Type Default Description
--yes, -y flag false Don't ask for confirmation.

civex db setup-docker

Set up a Docker-managed PostgreSQL container for this civex project.

Starts (or reuses) a named postgres:16 container, then updates _civex/config.toml with the new URL and creates all tables. The new database starts empty and your data is not copied into it: to carry an existing project's data across, use civex db move --to docker instead. Refuses to switch a project that has records to an empty database.

Usage

civex db setup-docker

civex db setup-postgres

Configure civex to use a PostgreSQL database.

Auto-detects a local PostgreSQL server, creates the database and user role if needed, then writes the URL to _civex/config.toml and creates all tables. Pass [bold]--url[/bold] to skip interactive prompts (useful in scripts/CI).

Usage

civex db setup-postgres [OPTIONS]

Options

Option Type Default Description
--url str Full PostgreSQL URL — skips all prompts. Example: postgresql+psycopg2://user:pass@host:5432/dbname Env: CIVEX_DB_URL.

civex db status

Show the database's connection, migration, and (if applicable) Docker container status.

Usage

civex db status

civex db teardown

Stop and remove this project's Docker-managed PostgreSQL container and its data.

civex init / civex db setup-docker create a per-project container that keeps running (--restart unless-stopped) even after the project directory is deleted. Run this before abandoning a project to avoid leaving it behind. Does nothing to a manually-managed PostgreSQL server.

Usage

civex db teardown [OPTIONS]

Options

Option Type Default Description
--yes, -y flag false Skip the confirmation prompt