Skip to main content

Database Management

Cloud development provides cloud database and data model to organize and manage data.

Users can manage databases through CloudBase CLI, performing operations such as pulling and pushing data models.

View Data Model

You can use the following command to list all data models in the cloud and view their basic information:

tcb db list

You will see output similar to the following:

? Please first select a cloud development environment tcb-advanced (tcb-advanced-a656fc) normal
| Name | ID | Creation Time |
|---------------------|-------------------|--------------------|
| Smart Itinerary - Itinerary | itinerary | 2024-07-06T06:11:13.000+0000 |
| User | sys_user | 2024-05-17T08:17:06.000+0000 |
| Department | sys_department | 2024-05-17T08:17:03.000+0000 |

tcb db list Command Reference

Usage: tcb db list [options]

List all data models in the cloud

Options:
-e, --envId <envId> Environment Id
-h, --help Display command help information

Pull Data Model

You can use the following command to pull the data model from the cloud to local:

tcb db pull

You will see output similar to the following:

ℹ Current environment Id: tcb-advanced-a656fc
? Please select data model: sys_department, sys_user, itinerary
✔ Data model synchronized successfully. File name: database-schemas/itinerary.json
✔ Data model synchronized successfully. File name: database-schemas/sys_user.json
✔ Data model synchronized successfully. File name: database-schemas/sys_department.json
✔ Data model type definition file synchronized successfully, enabling intelligent field hints when calling the SDK. File name: cloud-models.d.ts

tcb db pull Command Reference

Usage: tcb db pull [options]

Pulling multiple data models from the cloud to local

Options:
-e, --envId <envId> Environment Id
-d, --dir <dir> Local directory for storing database model definitions, defaults to database-schemas
-n, --name <name> List of English identifiers for models to pull, multiple can be specified separated by commas. Defaults to pulling all models if not specified.
-h, --help Display command help information

Push Data Model

You can use the following command to push the local data model to the cloud:

tcb db push

Can interactively handle the push and publish of data models

ℹ Using environment Id: tcb-advanced-a656fc
ℹ Checking data model itinerary
? The data model itinerary already exists. Update it? Yes
✔ Update data model itinerary succeeded. Click to view https://tcb.cloud.tencent.com/cloud-admin/#/management/data-model/data-3YqErZah7
ℹ Checking data model sys_department
? The data model sys_department already exists. Update it? Yes
✔ Update data model sys_department succeeded. Click to view https://tcb.cloud.tencent.com/cloud-admin/#/management/data-model/data-3RjUdvQzf
ℹ Checking data model sys_user
? The data model sys_user already exists. Update it? Yes
✔ Update data model sys_user succeeded. Click to view https://tcb.cloud.tencent.com/cloud-admin/#/management/data-model/data-3RjUeo6NE
? The data model has been imported successfully. Publish it? Yes

tcb db push Command Reference

Usage: tcb db push [options]

Push the local data model to the cloud

Options:
-e, --envId <envId> Environment Id
-d, --dir <dir> Local directory for storing database model definitions, defaults to database-schemas
-n, --name <name> List of model names to push; multiple can be specified, separated by commas. Defaults to pushing all data models in the local directory if not specified.
-h, --help Display command help information