Skip to main content

tcb db

Manage the database in PG mode and classic mode: SQL execution, schema migrations, data models, the document database, and MySQL.

Command index​

PG mode​

CommandPurpose
tcb db executeExecute SQL statements
tcb db pg migration newCreate a migration file
tcb db pg migration fetchFetch remote migration files
tcb db pg migration listList migration status
tcb db pg migration upPreview or apply pending migrations
tcb db pg migration repairRepair migration history without executing SQL

Migration conventions:

  • Migration files live in cloudbase/migrations/ under the project directory
  • File name format is <version>_<name>.sql, where version is a 14-digit UTC timestamp and name allows lowercase letters and underscores only
  • migration new creates the directory when missing; migration up and migration repair fail if the directory is missing
  • Every subcommand except migration new requires -e/--env-id; all subcommands check the login state first
  • --json is a global option and outputs structured JSON for scripts and CI

Classic mode · Data models​

CommandPurpose
tcb db model listList cloud data models
tcb db model pullPull models from the cloud
tcb db model pushPush local models to the cloud

See Data model overview for the full introduction.

Classic mode · Document database​

CommandPurpose
tcb db nosql executeExecute database native commands
tcb db nosql dumpExport collection data
tcb db nosql restore-timeQuery the restorable time range
tcb db nosql restore-tablesQuery restorable collections
tcb db nosql restoreRun a restore
tcb db nosql restore-taskQuery restore task progress

Enable the document database in the CloudBase console before use.

Classic mode · Relational database MySQL​

CommandPurpose
tcb db instance listList MySQL instances
tcb db instance configQuery or change instance configuration
tcb db monitor slow-logView slow query logs
tcb db instance restartRestart an instance
tcb db backup listList backups
tcb db backup createCreate a backup
tcb db backup restoreRestore a backup
tcb db backup deleteDelete a backup

Notes​

  • tcb db execute takes different parameters in PG mode and in MySQL, see Execute SQL
  • The document database uses tcb db nosql execute, not tcb db execute
  • Data models, the document database, and MySQL are available in classic mode only
  • PG migrations can run declaratively through tcb deploy, see Configuration file

Deprecated​

CommandReplacement
tcb db listtcb db model list
tcb db pulltcb db model pull
tcb db pushtcb db model push