skip to content
ccdocs

cc db

Manage the database linked to the active environment. Writes cc.database into the editor's settings.json (picked up by launch.json's -d arg via ${config:cc.database}) and links the database in CC's internal records.

Usage

cc db [DB_NAME]
cc db [DB_NAME] --rename NEW_NAME
cc db [DB_NAME] --remove
cc db --link DB_NAME
cc db --unlink DB_NAME
cc db -p
cc db -l

If no database name is provided, CC shows a list of PostgreSQL databases matching the active project name.

Flags

FlagDescription
-l, --listList all tracked databases with size and last login
--rename NEW_NAMERename the database in CC's internal records
--removeDrop the PostgreSQL database and remove it from CC records
--extendPush expiration date to 2099 and disable the update cron
--link DB_NAMEAdd a database to the current environment's pool without making it active
--unlink DB_NAMERemove a database from the current environment's pool
-p, --poolWhen prompting, show only databases in the current environment's pool
-y, --yesSkip confirmation prompt

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 -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 <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.

Examples

cc db my_project_v17
# → Sets cc.database in settings.json to my_project_v17, links it to the active env

cc db
# → Shows interactive list of matching databases to choose from

cc db -p
# → Shows only databases in the current environment's pool

cc db --link staging_copy
# → Adds staging_copy to the pool without changing the active DB

cc db old_name --rename new_name
# → Renames the record in CC (does not rename the PostgreSQL database)

cc db old_db --remove
# → Drops the PostgreSQL database after confirmation

On this page