skip to content
ccdocs
Commands

cc db

Manage the databases linked to the active environment, plus database lifecycle (create, copy, restore, drop) and the Postgres connection check. The active database is written as cc.database into the editor's settings.json (picked up by launch.json's -d arg via ${config:cc.database}) and linked in cc's internal records.

Usage

cc db <verb> [args]

cc db is a noun group — run a verb under it (e.g. cc db use, cc db list).

Verbs

VerbDescription
cc db useSet the active database for the current environment
cc db listList databases linked to the current environment
cc db dropDrop a PostgreSQL database (local or dockerized)
cc db initCreate a database from a zip dump file
cc db copyQuick in-place database copy (-CC-COPY suffix)
cc db restoreRestore a database from its CC copy
cc db backupNamed DB snapshots — create, list, restore, delete
cc db renameRename a database (PostgreSQL and cc's record)
cc db linkAdd a database to the environment's pool
cc db unlinkRemove a database from the environment's pool
cc db extendPush the active DB's demo expiry to 2099, disable the update cron
cc db checkDiagnose the Postgres connection

Connection & metadata cache

cc reads Postgres through a self-discovering connector: it probes a configured DSN (the pg.connection setting), then libpq defaults, then common local socket dirs, then localhost TCP — and, for a dockerized Postgres whose port isn't published, it reaches the container via docker exec (no password needed). Run:

cc db check

to see exactly which method connects (a ● marks the one cc uses) — handy when you don't know how your Postgres runs. If nothing connects (e.g. Docker with a password), set a DSN with cc configpg.connection.

Database metadata (name, size, last login, whether it's an Odoo DB, and whether it still exists in Postgres) is kept in a local cache that the daemon refreshes in the background — so cc db list, the companion's /databases page, and tab-completion are instant and never block on psql. Tab-completion only offers databases currently present in Postgres.

Database pool

Each environment can have a pool of databases linked to it. The pool lets you keep multiple databases associated with one environment (e.g. clean, test, prod-copy) and switch between them easily.

  • cc db link staging_copy — adds to the pool without changing the active database
  • cc db unlink old_db — removes from the pool
  • cc db use -p — shows a picker filtered to only pool databases

The active database (referenced by launch.json via ${config:cc.database}) is separate from the pool — linking doesn't change what runs. Use cc db use <name> to make a pool database active.

Workspaces

Databases are scoped to environments, not workspaces. However, since environments belong to projects and projects belong to workspaces, the database pool naturally inherits workspace/version grouping. When you cc switch to a project in a workspace, the environment's active database and pool are immediately available.

On this page