Create a process

Updated at:

Create a process that automates PolarDB database initialization, including Create user, Create database, Authorize users to access the database, and Execute SQL statements.

Prerequisites

  • You are on the allowlist for the process feature of Cloud Architect Design Tools (CADT).

Procedure

Step 1: Create a blank process

On the CADT main page, choose Create > Process.

Step 2: Edit the process

  1. In the left panel, click BPMN Event. Drag a Start Event and an End Event node onto the canvas.

  2. In the left panel, find PolarDB. Drag the Create user, Create database, Authorize users to access the database, and Execute SQL statements nodes onto the canvas. Connect them in sequence and make sure the arrows point in the correct direction.

  3. In the upper-right corner, click Save and follow the prompts to save the process.

    Click Process. In the Create Process dialog box, set the process name to polardb-initialize and then click OK.

  4. Double-click each PolarDB-related node to configure it, and then click Save.

    Important

    To execute SQL statements, you must configure a security rule. For instructions, see Create a DMS security rule.

    In the Create user node, set Username to user01 and Account Type to standard account.

    On the configuration panel for the Authorize users to access the database node, set Database Name to db01, Permission to Read/Write, and Username to user01. On the Create database configuration panel, set Character Set to utf8 and Database Name to db01.

    In the Execute SQL statements configuration panel, set Login Password, Database Name (for example, db01), Security Rule Set Name (for example, test01), and Username (for example, user01). In the SQL Statement text box, enter a table creation statement, such as CREATE TABLE db01.tbl_a (id int NOT NULL AUTO_INCREMENT, name varchar(20) DEFAULT NULL, address varchar(50) DEFAULT NULL, PRIMARY KEY (id)) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;.

  5. Click Execute Task, bind an instance, review the configuration, and then click Execute Task again to run the process.

    In the Bind Instance panel, Step 1 is Name the task and bind an instance. Select the target instance from the Bind Instance drop-down list and enter a Task ID/Task Name. The remaining steps correspond to the PolarDB actions you configured: Create user, Create database, Authorize users to access the database, and Execute SQL statements.

    Note

    You can bind a running PolarDB instance. To bind an uncreated instance from an application or template, see Bind a process.

  6. When the task completes, a Run successfully pop-up appears, and Code : 200 confirms success. Go to the PolarDB console and log on to the database to verify the results. You can also click View task records to see detailed execution information.

    After you log on to DMS, the connection information displays test_01@xxx.mysql.polardb.rds.aliyuncs.com:3306 (polardb). In the instance tree on the left, expand the test_01 database and find the tbl_a table. It contains three columns: id (int(11)), name (varchar(20)), and address (varchar(50)).