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
| Command | Purpose |
|---|---|
tcb db execute | Execute SQL statements |
tcb db pg migration new | Create a migration file |
tcb db pg migration fetch | Fetch remote migration files |
tcb db pg migration list | List migration status |
tcb db pg migration up | Preview or apply pending migrations |
tcb db pg migration repair | Repair migration history without executing SQL |
Migration conventions:
- Migration files live in
cloudbase/migrations/under the project directory - File name format is
<version>_<name>.sql, whereversionis a 14-digit UTC timestamp andnameallows lowercase letters and underscores only migration newcreates the directory when missing;migration upandmigration repairfail if the directory is missing- Every subcommand except
migration newrequires-e/--env-id; all subcommands check the login state first --jsonis a global option and outputs structured JSON for scripts and CI
Classic mode · Data models
| Command | Purpose |
|---|---|
tcb db model list | List cloud data models |
tcb db model pull | Pull models from the cloud |
tcb db model push | Push local models to the cloud |
See Data model overview for the full introduction.
Classic mode · Document database
| Command | Purpose |
|---|---|
tcb db nosql execute | Execute database native commands |
tcb db nosql dump | Export collection data |
tcb db nosql restore-time | Query the restorable time range |
tcb db nosql restore-tables | Query restorable collections |
tcb db nosql restore | Run a restore |
tcb db nosql restore-task | Query restore task progress |
Enable the document database in the CloudBase console before use.
Classic mode · Relational database MySQL
| Command | Purpose |
|---|---|
tcb db instance list | List MySQL instances |
tcb db instance config | Query or change instance configuration |
tcb db monitor slow-log | View slow query logs |
tcb db instance restart | Restart an instance |
tcb db backup list | List backups |
tcb db backup create | Create a backup |
tcb db backup restore | Restore a backup |
tcb db backup delete | Delete a backup |
Notes
tcb db executetakes different parameters in PG mode and in MySQL, see Execute SQL- The document database uses
tcb db nosql execute, nottcb 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
| Command | Replacement |
|---|---|
tcb db list | tcb db model list |
tcb db pull | tcb db model pull |
tcb db push | tcb db model push |