Skip to main content

Data Model Management

TCB provides a powerful "data model" feature, enabling efficient data model management through CloudBase CLI. This article details how to use the CLI tool to view, pull, and push data models.

For a detailed introduction to the data model feature, see Data Model Overview.

Command Change Notice

The following top-level commands have been deprecated. Please migrate to the new db model subcommand:

Old Command (Deprecated)New Command (Recommended)
tcb db listtcb db model list
tcb db pulltcb db model pull
tcb db pushtcb db model push

The old commands retain backward compatibility but will display a deprecated warning in the output.

View Data Model

Basic Usage

Use the following command to list all data models in the cloud and view their basic information.

# Recommended Usage
tcb db model list -e your-env-id

# Compatibility with Old Commands (Deprecated)
tcb db list -e your-env-id

Command Parameters

Usage: tcb db list [options]

List all data models in the cloud

Options:
-e, --env-id <envId> Specify the environment Id
-h, --help Display command help information

Parameter Description:

  • -e, --env-id: Specify the TCB environment ID to query. If not specified, the system will prompt for selection.

Pulling Data Models

Basic Usage

Use the following command to pull data models from the cloud to local:

# Recommended Usage
tcb db model pull -e your-env-id

# Pulling the Specified Model
tcb db model pull -n sys_user,itinerary -e your-env-id

# Pulling to the specified directory
tcb db model pull -d ./models -e your-env-id

# Compatibility with Old Commands (Deprecated)
tcb db pull -e your-env-id

Generated Files

After pulling is completed, the following files will be generated in the project:

  • Model definition file: database-schemas/{model identifier}.json - Contains the complete definition of the data model
  • Type definition file: cloud-models.d.ts - TypeScript type definitions, supports IDE intelligent hints

Command Parameters

Usage: tcb db pull [options]

Pull multiple data models from the cloud to local

Options:
-e, --env-id <envId> Environment Id
-d, --dir <dir> Directory for locally storing database model definitions, defaults to database-schemas
-n, --name <name> List of model identifiers to pull, multiple can be specified, comma-separated. Pulls all models by default when not specified.
-h, --help Display command help information

Pushing Data Models

Basic Usage

Use the following command to push local data models to the cloud:

# Recommended Usage
tcb db model push -e your-env-id

# Pushing Specified Models
tcb db model push -n sys_user,product -e your-env-id

# Pushing from the specified directory
tcb db model push -d ./models -e your-env-id

# Compatibility with Old Commands (Deprecated)
tcb db push -e your-env-id

Command Parameters

Usage: tcb db push [options]

Pushing local data models to the cloud

Options:
-e, --env-id <envId> Environment Id
-d, --dir <dir> Directory for locally storing database model definitions, defaults to database-schemas
-n, --name <name> List of model names to push, multiple can be specified, comma-separated. Pushes all data models in the local directory by default when not specified.
-h, --help Display command help information

Parameter Description:

  • -d, --dir: Specify the local model files directory
  • -n, --name: Specify the models to push, supports batch push