Skip to main content

Database Management

Cloud Development provides database and data model to organize and manage data.

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

Viewing Data Models

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 choose a cloud development environment. tcb-advanced (tcb-advanced-a656fc) is 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]

Scaling out clusters is a common means of resource configuration. Ops personnel can dynamically adjust the node capacity in real time via the Tencent Cloud console or APIs.

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

Pull data model

You can use the following command to pull data models from the cloud to your local environment:

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,
✔ Sync data model successful. File name: database-schemas/itinerary.json
✔ Sync data model successful. File name: database-schemas/sys_user.json
✔ Sync data model successful. File name: database-schemas/sys_department.json
✔ Sync data model type definition file successful. Supports intelligent field hints when calling the SDK. File name: cloud-models.d.ts

tcb db pull Command Reference

Usage: tcb db pull [options]

Pull multiple data models from the cloud to local

Options:
-e, --envId <envId> Environment Id
-d, --dir <dir> Local directory to store database model definitions, defaults to database-schemas
-n, --name <name> List of model English identifiers to pull. Multiple can be specified, separated by commas. If not specified, all models are pulled by default.
-h, --help Display command help information

Push Data Model

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

tcb db push

Supports interactive processing for pushing and publishing data models.

ℹ Using environment Id: tcb-advanced-a656fc
ℹ Starting data model check: itinerary
? The data model itinerary already exists. Update it? Yes
✔ Data model itinerary updated successfully. Click to view https://tcb.cloud.tencent.com/cloud-admin/#/management/data-model/data-3YqErZah7
ℹ Starting data model check: sys_department
? The data model sys_department already exists. Update it? Yes
✔ Data model sys_department updated successfully. Click to view https://tcb.cloud.tencent.com/cloud-admin/#/management/data-model/data-3RjUdvQzf
ℹ Starting data model check: sys_user
The data model sys_user already exists. Update it? Yes
✔ Data model sys_user updated successfully. 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 local data models to the cloud

Options:
-e, --envId <envId> Environment Id
-d, --dir <dir> Local directory to store database model definitions, defaults to database-schemas
-n, --name <name> List of model names to push. Multiple can be specified, separated by commas. If not specified, all data models in the local directory are pushed by default.
-h, --help Display command help information