Streamline table schema deployment to enforce enterprise design specifications, maintain schema consistency across database environments, and improve the success rate of production releases. This topic uses a custom three-node workflow — Develop (Dev), Test, and Production — as an example.
Background information
|
Benefit |
Description |
|
Improves the success rate of production deployments |
Before you deploy a new table schema to a production environment, the system validates it at each node of the R&D process. This practice prevents unverified scripts from causing deployment failures and ensures a high success rate for production deployments. |
|
Ensures schema consistency across environments |
The system applies schema changes to each database environment according to the R&D process. This helps prevent project delays caused by failed changes or testing interruptions in specific environments. |
|
Enforces schema design standards |
Schema design specifications cover nearly 40 standards for operations such as creating tables and modifying fields and indexes. These standards help prevent production failures from non-compliant deployments and reduce manual effort for operations teams, supporting rapid iteration. For more information, see Schema design specifications. |
Solution overview
-
Customize the R&D process (optional): The default R&D process is Develop > Production. You can customize the process to meet your business requirements.
-
Set a security rule for a database instance (optional): Associate the custom R&D process with a database instance by using a security rule.
-
Design a database schema: Submit a schema design ticket to ensure schema consistency across multiple databases and successful deployment to the production environment.
Prerequisites
-
Create three ApsaraDB RDS for MySQL database instances, and then create an account and a database in each instance. For more information, see Quickly create an ApsaraDB RDS for MySQL instance.
In this example, the database instances are named Schema_Design-dev, Schema_Design-test, and Schema_Design-product.
In this example, the databases are named dev_database, test_database, and product_database.
-
Use an Alibaba Cloud account with administrator or DBA permissions to register the three database instances in Data Management Service (DMS). Set the control mode of all instances to Security Collaboration and set their database environment types to Development (Dev), Test, and Production, respectively. For more information, see Register a cloud database.
Instance-to-node mapping
Step 1: Customize the R&D process
Create a security rule and configure the schema design process. The R&D process includes the Develop, Test, and Production nodes.
Step 1.1: Access the security rules page
-
Log on to the Data Management Service (DMS) 5.0 console.
-
In the upper-left corner of the console, click the
icon and choose .
If you are using the console in normal mode, choose in the top navigation bar.
Step 1.2: (Optional) Create a security rule
On the Security Rules page, click Create Rule Set in the upper-left corner to add a rule set. This example uses SD-DT.
After you create the security rule, DMS navigates to its details page.
In the dialog box, set Engine Type to MySQL, enter a name and description for the rule set, and then click Submit.
Step 1.3: Customize the R&D process
Configure the R&D process in the security rule to define the steps for schema design and the operations allowed in each step.
-
(Optional) To the right of the security rule, click Edit to go to its Details page.
NoteIf you just created the security rule, you can skip this step.
-
In the left-side navigation pane of the Details page, click Schema Design.
-
On the Schema Design tab, find the R&D process and click Edit in the Actions column.
-
Change the name of the second node to
Testand change the database environment totest. -
Add a third node. Change the name of the third node to
Production, change the database environment toproduct, and set this node as an anchor.NoteAn anchor is a freeze point for editing a ticket. After a step with an anchor is successfully deployed, the ticket's status changes to published and it becomes uneditable.
After configuring all nodes, click Submit.
-
Click Submit.
-
Step 2: Assign the security rule to an instance
Set the control mode of the Schema_Design-dev instance (Dev environment) to Security Collaboration and select the SD-DT security rule.
-
In the instance list on the left side of the console homepage, right-click the Schema_Design-dev database instance.
-
From the shortcut menu, choose .
Step 3: Design the database schema
Create a table schema for a database by using a three-node (Develop, Test, Production) schema design project.
Step 3.1: Go to the DMS schema design page
Log in to DMS 5.0.
In the top navigation bar, choose .
NoteIf you use the DMS console in simple mode, move the pointer over the
icon in the upper-left corner of the console and choose . -
In the upper-right corner of the page, click Schema Design.
Step 3.2: Configure the schema design ticket
-
Create a schema design ticket.
On the Create Ticket page, set Base Database for Change to the database in the development environment. Configure other parameters as required.
In this example, dev_database is selected as the base database.
Other parameters in the form include Project Name, Project Background, Security Rule, Associated Iteration, and Stakeholders. After you fill them out, click Submit.
-
In the Develop node, create a table in the dev_database database.
-
Click Import SQL Statements, enter the SQL for creating the table, and then click OK.
-
Click Save. In the Precheck Result dialog box, click Confirm Changes and Submit to Save.
-
Click Perform Changes to Base Database.
-
In the panel that appears, select an execution strategy, confirm that the SQL statement is correct, and then click OK.
-
After the change is manually approved, the system writes the new table schema to the dev_database database.
On the Change Execution History tab, you can view the execution result for the teacher table. The status is Success, the progress is 100%, and the execution strategy is Execute Now.
-
Click Go to Next Node.
NoteBefore proceeding, perform multiple design changes and validations on the dev_database database in this node. The system will eventually generate a single
createscript to be deployed to the next node.
-
-
In the Test node, synchronize the table schema created in the previous node to the test database.
-
Click Perform Changes to Target Database.
-
Select the test_database database, set the execution strategy to Execute Now, and click OK.
The Execution Script area displays the SQL statement for creating the
teachertable. The statement defines three fields (teacher_id,teacher_name, andphonenumber), setsteacher_idas the primary key, uses the utf8 character set, and includes the comment "Teacher table". -
After the change is approved, the system applies the schema to the test_database database.
ImportantThe next node, Production, is an anchor. After you proceed to an anchor node, you cannot roll back to a previous node to perform design or deployment operations.
-
Click Go to Next Node.
-
-
In the Production (anchor) node, synchronize the table schema to the production database.
-
Click Perform Changes to Target Database.
-
Select the product_database database, set the execution strategy to Execute Now, and click OK.
-
After you submit the change, it must be approved.
Once approved, the system applies the schema to the product_database database, after which you can write data to it.
-
After you click Go to Next Node, the schema design process ends and DMS automatically closes the ticket.
-
Related operations
-
For details about the specific rules in the schema design module of security rules, see Security rules for the schema design module.
-
For more information about use cases and features of schema design, see Schema design.
-
You can also use an API to get the deployment status of a schema design ticket: