The schema design feature that is provided by Data Management (DMS) allows you to change the schema of a table to make the table in compliance with specific R&D standards. You can customize R&D processes for different lines of business based on your business requirements to ensure the consistency of schemas among multiple environments, such as the development environment, test environment, and production environment.

Prerequisites

  • The physical database is of one of the following types:
    • MySQL: ApsaraDB RDS for MySQL, PolarDB for MySQL, MyBase for MySQL, PolarDB-X, and MySQL databases that are not on Alibaba Cloud
    • ApsaraDB for OceanBase
  • The database instance to which the database belongs is managed in Secure Collaboration mode. For more information, see View the control mode of an instance.

Procedure

  1. Go to the DMS console V5.0.
  2. In the top navigation bar, click Database Development. In the left-side navigation pane, choose Schema Change > Schema Design.
    Note If you are using the previous version of the DMS console, move the pointer over the More icon in the top navigation bar and choose Schemas > Schema Design.
  3. On the Schema DesignTickets page, click Schema Design in the upper-right corner.
  4. On the page that appears, set the parameters that are described in the following table and click Submit.
    Parameter Description
    Project Name The name of the project. Enter a name that can help you identify the project.
    Project description The business background of the project, such as the purpose or objective of the project. This reduces unnecessary communication.
    Change Base Database The database on which you want to perform schema design operations. In this example, select the required database in Secure Collaboration mode. The type of the environment to which the database belongs must conform to the R&D standards corresponding to the security rules of the database. For more information about the R&D process, see Schema Design.
    Security Rules The security rules that you want to apply. DMS automatically selects security rules after you specify a database.
    Associated Iterations The iteration to be associated with the project. To select an iteration, click Select/Change Iteration. In the dialog box that appears, find the required iteration and click Associate in the Actions column.
    Change Stakeholder The stakeholders of the schema design. All the specified stakeholders can view the ticket details and assist developers in accelerating the development and approval processes.
    Note Irrelevant users other than DMS administrators and database administrators (DBAs) are not allowed to view the ticket details.
  5. Create a physical table.
    You can create a physical table in one of the following ways:
    • Use the visualized user interface (UI)
      1. Click Create Physical Table.
      2. Enter the basic information about the table and modify the fields and indexes of the table.
      3. Click Save.
    • Use SQL statements
    1. Click Import SQL Statements.
    2. In the dialog box that appears, enter Create Table or Alter Table statements as required and click OK.

      For example, you can use the following statement to create a table named data_modify:

      CREATE TABLE `data_modify` (
        `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT 'Primary key',
        `name` varchar(256) NOT NULL COMMENT 'Name',
        `phone` varchar(32) DEFAULT NULL COMMENT 'Phone number',
        `sex` varchar(32) DEFAULT NULL COMMENT 'Gender',
        `email` varchar(256) DEFAULT NULL COMMENT 'Email address',
        `remarks` varchar(1024) DEFAULT NULL COMMENT 'Remarks',
        PRIMARY KEY (`id`)
      ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Personal information';
    3. On the Create Physical Table: data_modify tab, confirm the table information and schema and click Save.
  6. In the Precheck Result message, view the precheck result.
    • If the precheck is passed, click Confirm Changes and Submit to Save.
    • If only a warning is displayed, click Ignore the warning and continue to save.. Alternatively, click Close, modify the table schema based on the R&D standards, and then click Save.
    • If an error is reported, check the error cause, click Close, modify the table schema based on the R&D standards, and then click Save.
    Note
    • DMS verifies the preceding SQL statements for table creation or modification based on the R&D standards that are configured in the default security rules, and then reports errors and warnings, if any.
    • DMS provides nearly 40 R&D standards to help you create tables and modify fields and indexes. You can configure the R&D standards in security rules as required.
    After the precheck is passed, you are navigated to the Project Homepage tab. On the Tables Changed in Project tab, you can view the table that you modified or created and modify or delete other tables as required.
  7. Apply the schema changes to the base database.
    1. Click Perform Changes to Base Database.
    2. In the Perform Changes to Base Database pane, view the base database, execution strategy, and scheme change script, and click Submit.
    After the schema change operation is approved, the system automatically applies the schema changes to the base database.
    Note
    • You can check whether the schema changes are as expected on the SQL Console tab of the base database.
    • Based on the default security rules, you must submit tickets for schema changes. You can also use custom security rules. For example, you can specify that no approval is required for schema changes in development databases. You can also specify the users who can approve schema change tickets in production databases.
  8. Click Go to Next Node. In the dialog box that appears, click Go to Next Node.
  9. Apply the schema changes to the production database.
    1. On the Project Homepage tab, click Perform Changes to Target Database.
    2. In the Perform Changes to Target Database pane, select the destination database, enter script in the Script to Execute field, and then click Submit.
      Note You can also click Add Multiple Databases to execute the script in multiple production databases.
      After the schema change operation is approved, the system automatically applies the schema changes to the production database. You can check whether the schema changes are as expected on the SQL Console tab of the production database.
    3. Click Go to Next Node. In the dialog box that appears, click Go to Next Node.
      The ticket is closed. You can click each step to view the change and publishing records.