You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@inlong.apache.org by he...@apache.org on 2022/07/28 00:05:39 UTC

[inlong] branch master updated: [INLONG-5232][Manager] Unify the user and role tables (#5233)

This is an automated email from the ASF dual-hosted git repository.

healchow pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/inlong.git


The following commit(s) were added to refs/heads/master by this push:
     new 9415a9c7d [INLONG-5232][Manager] Unify the user and role tables (#5233)
9415a9c7d is described below

commit 9415a9c7db3c56587f9fcd2c50c62a5969b59f57
Author: healchow <he...@gmail.com>
AuthorDate: Thu Jul 28 08:05:34 2022 +0800

    [INLONG-5232][Manager] Unify the user and role tables (#5233)
---
 .../inlong/manager/dao/entity/RoleEntity.java      |  14 +-
 .../inlong/manager/dao/entity/UserRoleEntity.java  |  14 +-
 .../manager/dao/mapper/RoleEntityMapper.java       |   9 +-
 .../manager/dao/mapper/UserRoleEntityMapper.java   |  14 +-
 .../main/resources/mappers/RoleEntityMapper.xml    | 141 +++++--------------
 .../resources/mappers/UserRoleEntityMapper.xml     | 150 +++++----------------
 .../main/resources/h2/apache_inlong_manager.sql    |  58 ++++----
 .../manager-web/sql/apache_inlong_manager.sql      |  68 +++++-----
 8 files changed, 159 insertions(+), 309 deletions(-)

diff --git a/inlong-manager/manager-dao/src/main/java/org/apache/inlong/manager/dao/entity/RoleEntity.java b/inlong-manager/manager-dao/src/main/java/org/apache/inlong/manager/dao/entity/RoleEntity.java
index 3492b84e2..0dc41de9c 100644
--- a/inlong-manager/manager-dao/src/main/java/org/apache/inlong/manager/dao/entity/RoleEntity.java
+++ b/inlong-manager/manager-dao/src/main/java/org/apache/inlong/manager/dao/entity/RoleEntity.java
@@ -17,9 +17,10 @@
 
 package org.apache.inlong.manager.dao.entity;
 
+import lombok.Data;
+
 import java.io.Serializable;
 import java.util.Date;
-import lombok.Data;
 
 /**
  * Role entity, including role code, role name, etc.
@@ -31,10 +32,13 @@ public class RoleEntity implements Serializable {
     private Integer id;
     private String roleCode;
     private String roleName;
+
+    private Integer disabled;
+    private Integer isDeleted;
+    private String creator;
+    private String modifier;
     private Date createTime;
-    private Date updateTime;
-    private String createBy;
-    private String updateBy;
-    private Boolean disabled;
+    private Date modifyTime;
+    private Integer version;
 
 }
diff --git a/inlong-manager/manager-dao/src/main/java/org/apache/inlong/manager/dao/entity/UserRoleEntity.java b/inlong-manager/manager-dao/src/main/java/org/apache/inlong/manager/dao/entity/UserRoleEntity.java
index 04bcbca01..07b3d86cc 100644
--- a/inlong-manager/manager-dao/src/main/java/org/apache/inlong/manager/dao/entity/UserRoleEntity.java
+++ b/inlong-manager/manager-dao/src/main/java/org/apache/inlong/manager/dao/entity/UserRoleEntity.java
@@ -17,9 +17,10 @@
 
 package org.apache.inlong.manager.dao.entity;
 
+import lombok.Data;
+
 import java.io.Serializable;
 import java.util.Date;
-import lombok.Data;
 
 /**
  * User role entity, including username, role code, etc.
@@ -31,10 +32,13 @@ public class UserRoleEntity implements Serializable {
     private Integer id;
     private String username;
     private String roleCode;
+
+    private Integer disabled;
+    private Integer isDeleted;
+    private String creator;
+    private String modifier;
     private Date createTime;
-    private Date updateTime;
-    private String createBy;
-    private String updateBy;
-    private Boolean disabled;
+    private Date modifyTime;
+    private Integer version;
 
 }
diff --git a/inlong-manager/manager-dao/src/main/java/org/apache/inlong/manager/dao/mapper/RoleEntityMapper.java b/inlong-manager/manager-dao/src/main/java/org/apache/inlong/manager/dao/mapper/RoleEntityMapper.java
index 9e66e9e59..0b464c62b 100644
--- a/inlong-manager/manager-dao/src/main/java/org/apache/inlong/manager/dao/mapper/RoleEntityMapper.java
+++ b/inlong-manager/manager-dao/src/main/java/org/apache/inlong/manager/dao/mapper/RoleEntityMapper.java
@@ -23,15 +23,12 @@ import org.springframework.stereotype.Repository;
 @Repository
 public interface RoleEntityMapper {
 
-    int deleteByPrimaryKey(Integer id);
-
     int insert(RoleEntity record);
 
-    int insertSelective(RoleEntity record);
+    RoleEntity selectById(Integer id);
 
-    RoleEntity selectByPrimaryKey(Integer id);
+    int updateById(RoleEntity record);
 
-    int updateByPrimaryKeySelective(RoleEntity record);
+    int deleteById(Integer id);
 
-    int updateByPrimaryKey(RoleEntity record);
 }
diff --git a/inlong-manager/manager-dao/src/main/java/org/apache/inlong/manager/dao/mapper/UserRoleEntityMapper.java b/inlong-manager/manager-dao/src/main/java/org/apache/inlong/manager/dao/mapper/UserRoleEntityMapper.java
index 292afe791..5aee3eb12 100644
--- a/inlong-manager/manager-dao/src/main/java/org/apache/inlong/manager/dao/mapper/UserRoleEntityMapper.java
+++ b/inlong-manager/manager-dao/src/main/java/org/apache/inlong/manager/dao/mapper/UserRoleEntityMapper.java
@@ -18,25 +18,21 @@
 package org.apache.inlong.manager.dao.mapper;
 
 import org.apache.inlong.manager.dao.entity.UserRoleEntity;
+import org.springframework.stereotype.Repository;
 
 import java.util.List;
 
-import org.springframework.stereotype.Repository;
-
 @Repository
 public interface UserRoleEntityMapper {
 
-    int deleteByPrimaryKey(Integer id);
-
     int insert(UserRoleEntity record);
 
-    int insertSelective(UserRoleEntity record);
+    UserRoleEntity selectById(Integer id);
 
-    UserRoleEntity selectByPrimaryKey(Integer id);
+    List<UserRoleEntity> listByUsername(String username);
 
-    int updateByPrimaryKeySelective(UserRoleEntity record);
+    int updateById(UserRoleEntity record);
 
-    int updateByPrimaryKey(UserRoleEntity record);
+    int deleteById(Integer id);
 
-    List<UserRoleEntity> listByUsername(String username);
 }
diff --git a/inlong-manager/manager-dao/src/main/resources/mappers/RoleEntityMapper.xml b/inlong-manager/manager-dao/src/main/resources/mappers/RoleEntityMapper.xml
index efc350779..224906f06 100644
--- a/inlong-manager/manager-dao/src/main/resources/mappers/RoleEntityMapper.xml
+++ b/inlong-manager/manager-dao/src/main/resources/mappers/RoleEntityMapper.xml
@@ -24,127 +24,48 @@
         <id column="id" jdbcType="INTEGER" property="id"/>
         <result column="role_code" jdbcType="VARCHAR" property="roleCode"/>
         <result column="role_name" jdbcType="VARCHAR" property="roleName"/>
+        <result column="disabled" jdbcType="SMALLINT" property="disabled"/>
+        <result column="is_deleted" jdbcType="INTEGER" property="isDeleted"/>
+        <result column="creator" jdbcType="VARCHAR" property="creator"/>
+        <result column="modifier" jdbcType="VARCHAR" property="modifier"/>
         <result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
-        <result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
-        <result column="create_by" jdbcType="VARCHAR" property="createBy"/>
-        <result column="update_by" jdbcType="VARCHAR" property="updateBy"/>
-        <result column="disabled" jdbcType="BIT" property="disabled"/>
+        <result column="modify_time" jdbcType="TIMESTAMP" property="modifyTime"/>
+        <result column="version" jdbcType="INTEGER" property="version"/>
     </resultMap>
     <sql id="Base_Column_List">
-        id, role_code, role_name, create_time, update_time, create_by, update_by, disabled
+        id, role_code, role_name, disabled, is_deleted, creator, modifier, create_time, modify_time, version
     </sql>
-    <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
+
+    <insert id="insert" useGeneratedKeys="true" keyProperty="id"
+            parameterType="org.apache.inlong.manager.dao.entity.RoleEntity">
+        insert into role (id, role_code, role_name,
+                          disabled, creator, modifier)
+        values (#{id,jdbcType=INTEGER}, #{roleCode,jdbcType=VARCHAR}, #{roleName,jdbcType=VARCHAR},
+                #{disabled,jdbcType=SMALLINT}, #{creator,jdbcType=VARCHAR}, #{modifier,jdbcType=VARCHAR})
+    </insert>
+
+    <select id="selectById" parameterType="java.lang.Integer" resultMap="BaseResultMap">
         select
         <include refid="Base_Column_List"/>
         from role
         where id = #{id,jdbcType=INTEGER}
     </select>
-    <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
-        delete
-        from role
-        where id = #{id,jdbcType=INTEGER}
-    </delete>
-    <insert id="insert" parameterType="org.apache.inlong.manager.dao.entity.RoleEntity">
-        insert into role (id, role_code, role_name,
-                          create_time, update_time, create_by,
-                          update_by, disabled)
-        values (#{id,jdbcType=INTEGER}, #{roleCode,jdbcType=VARCHAR}, #{roleName,jdbcType=VARCHAR},
-                #{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP}, #{createBy,jdbcType=VARCHAR},
-                #{updateBy,jdbcType=VARCHAR}, #{disabled,jdbcType=INTEGER})
-    </insert>
-    <insert id="insertSelective" parameterType="org.apache.inlong.manager.dao.entity.RoleEntity">
-        insert into role
-        <trim prefix="(" suffix=")" suffixOverrides=",">
-            <if test="id != null">
-                id,
-            </if>
-            <if test="roleCode != null">
-                role_code,
-            </if>
-            <if test="roleName != null">
-                role_name,
-            </if>
-            <if test="createTime != null">
-                create_time,
-            </if>
-            <if test="updateTime != null">
-                update_time,
-            </if>
-            <if test="createBy != null">
-                create_by,
-            </if>
-            <if test="updateBy != null">
-                update_by,
-            </if>
-            <if test="disabled != null">
-                disabled,
-            </if>
-        </trim>
-        <trim prefix="values (" suffix=")" suffixOverrides=",">
-            <if test="id != null">
-                #{id,jdbcType=INTEGER},
-            </if>
-            <if test="roleCode != null">
-                #{roleCode,jdbcType=VARCHAR},
-            </if>
-            <if test="roleName != null">
-                #{roleName,jdbcType=VARCHAR},
-            </if>
-            <if test="createTime != null">
-                #{createTime,jdbcType=TIMESTAMP},
-            </if>
-            <if test="updateTime != null">
-                #{updateTime,jdbcType=TIMESTAMP},
-            </if>
-            <if test="createBy != null">
-                #{createBy,jdbcType=VARCHAR},
-            </if>
-            <if test="updateBy != null">
-                #{updateBy,jdbcType=VARCHAR},
-            </if>
-            <if test="disabled != null">
-                #{disabled,jdbcType=INTEGER},
-            </if>
-        </trim>
-    </insert>
-    <update id="updateByPrimaryKeySelective"
-            parameterType="org.apache.inlong.manager.dao.entity.RoleEntity">
+
+    <update id="updateById" parameterType="org.apache.inlong.manager.dao.entity.RoleEntity">
         update role
-        <set>
-            <if test="roleCode != null">
-                role_code = #{roleCode,jdbcType=VARCHAR},
-            </if>
-            <if test="roleName != null">
-                role_name = #{roleName,jdbcType=VARCHAR},
-            </if>
-            <if test="createTime != null">
-                create_time = #{createTime,jdbcType=TIMESTAMP},
-            </if>
-            <if test="updateTime != null">
-                update_time = #{updateTime,jdbcType=TIMESTAMP},
-            </if>
-            <if test="createBy != null">
-                create_by = #{createBy,jdbcType=VARCHAR},
-            </if>
-            <if test="updateBy != null">
-                update_by = #{updateBy,jdbcType=VARCHAR},
-            </if>
-            <if test="disabled != null">
-                disabled = #{disabled,jdbcType=INTEGER},
-            </if>
-        </set>
+        set role_code  = #{roleCode,jdbcType=VARCHAR},
+            role_name  = #{roleName,jdbcType=VARCHAR},
+            disabled   = #{disabled,jdbcType=SMALLINT},
+            is_deleted = #{isDeleted,jdbcType=INTEGER},
+            modifier   = #{modifier,jdbcType=VARCHAR},
+            version    = #{version,jdbcType=INTEGER} + 1
         where id = #{id,jdbcType=INTEGER}
+          and version = #{version,jdbcType=INTEGER}
     </update>
-    <update id="updateByPrimaryKey"
-            parameterType="org.apache.inlong.manager.dao.entity.RoleEntity">
-        update role
-        set role_code   = #{roleCode,jdbcType=VARCHAR},
-            role_name   = #{roleName,jdbcType=VARCHAR},
-            create_time = #{createTime,jdbcType=TIMESTAMP},
-            update_time = #{updateTime,jdbcType=TIMESTAMP},
-            create_by   = #{createBy,jdbcType=VARCHAR},
-            update_by   = #{updateBy,jdbcType=VARCHAR},
-            disabled    = #{disabled,jdbcType=INTEGER}
+
+    <delete id="deleteById" parameterType="java.lang.Integer">
+        delete
+        from role
         where id = #{id,jdbcType=INTEGER}
-    </update>
+    </delete>
 </mapper>
diff --git a/inlong-manager/manager-dao/src/main/resources/mappers/UserRoleEntityMapper.xml b/inlong-manager/manager-dao/src/main/resources/mappers/UserRoleEntityMapper.xml
index 334a92a66..7408fa352 100644
--- a/inlong-manager/manager-dao/src/main/resources/mappers/UserRoleEntityMapper.xml
+++ b/inlong-manager/manager-dao/src/main/resources/mappers/UserRoleEntityMapper.xml
@@ -24,135 +24,53 @@
         <id column="id" jdbcType="INTEGER" property="id"/>
         <result column="user_name" jdbcType="VARCHAR" property="username"/>
         <result column="role_code" jdbcType="VARCHAR" property="roleCode"/>
+        <result column="disabled" jdbcType="SMALLINT" property="disabled"/>
+        <result column="is_deleted" jdbcType="INTEGER" property="isDeleted"/>
+        <result column="creator" jdbcType="VARCHAR" property="creator"/>
+        <result column="modifier" jdbcType="VARCHAR" property="modifier"/>
         <result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
-        <result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
-        <result column="create_by" jdbcType="VARCHAR" property="createBy"/>
-        <result column="update_by" jdbcType="VARCHAR" property="updateBy"/>
-        <result column="disabled" jdbcType="BIT" property="disabled"/>
+        <result column="modify_time" jdbcType="TIMESTAMP" property="modifyTime"/>
+        <result column="version" jdbcType="INTEGER" property="version"/>
     </resultMap>
     <sql id="Base_Column_List">
-        id, user_name, role_code, create_time, update_time, create_by, update_by, disabled
+        id, user_name, role_code, disabled, is_deleted, creator, modifier, create_time, modify_time, version
     </sql>
-    <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
+
+    <insert id="insert" useGeneratedKeys="true" keyProperty="id"
+            parameterType="org.apache.inlong.manager.dao.entity.UserRoleEntity">
+        insert into user_role (id, user_name, role_code,
+                               disabled, creator, modifier)
+        values (#{id,jdbcType=INTEGER}, #{username,jdbcType=VARCHAR}, #{roleCode,jdbcType=VARCHAR},
+                #{disabled,jdbcType=SMALLINT}, #{creator,jdbcType=VARCHAR}, #{modifier,jdbcType=VARCHAR})
+    </insert>
+    <select id="selectById" parameterType="java.lang.Integer" resultMap="BaseResultMap">
         select
         <include refid="Base_Column_List"/>
         from user_role
         where id = #{id,jdbcType=INTEGER}
     </select>
-    <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
-        delete
-        from user_role
-        where id = #{id,jdbcType=INTEGER}
-    </delete>
-    <insert id="insert" parameterType="org.apache.inlong.manager.dao.entity.UserRoleEntity">
-        insert into user_role (id, user_name, role_code,
-                               create_time, update_time, create_by,
-                               update_by, disabled)
-        values (#{id,jdbcType=INTEGER}, #{username,jdbcType=VARCHAR}, #{roleCode,jdbcType=VARCHAR},
-                #{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP}, #{createBy,jdbcType=VARCHAR},
-                #{updateBy,jdbcType=VARCHAR}, #{disabled,jdbcType=INTEGER})
-    </insert>
-    <insert id="insertSelective"
-            parameterType="org.apache.inlong.manager.dao.entity.UserRoleEntity">
-        insert into user_role
-        <trim prefix="(" suffix=")" suffixOverrides=",">
-            <if test="id != null">
-                id,
-            </if>
-            <if test="username != null">
-                user_name,
-            </if>
-            <if test="roleCode != null">
-                role_code,
-            </if>
-            <if test="createTime != null">
-                create_time,
-            </if>
-            <if test="updateTime != null">
-                update_time,
-            </if>
-            <if test="createBy != null">
-                create_by,
-            </if>
-            <if test="updateBy != null">
-                update_by,
-            </if>
-            <if test="disabled != null">
-                disabled,
-            </if>
-        </trim>
-        <trim prefix="values (" suffix=")" suffixOverrides=",">
-            <if test="id != null">
-                #{id,jdbcType=INTEGER},
-            </if>
-            <if test="username != null">
-                #{username,jdbcType=VARCHAR},
-            </if>
-            <if test="roleCode != null">
-                #{roleCode,jdbcType=VARCHAR},
-            </if>
-            <if test="createTime != null">
-                #{createTime,jdbcType=TIMESTAMP},
-            </if>
-            <if test="updateTime != null">
-                #{updateTime,jdbcType=TIMESTAMP},
-            </if>
-            <if test="createBy != null">
-                #{createBy,jdbcType=VARCHAR},
-            </if>
-            <if test="updateBy != null">
-                #{updateBy,jdbcType=VARCHAR},
-            </if>
-            <if test="disabled != null">
-                #{disabled,jdbcType=INTEGER},
-            </if>
-        </trim>
-    </insert>
-    <update id="updateByPrimaryKeySelective"
-            parameterType="org.apache.inlong.manager.dao.entity.UserRoleEntity">
-        update user_role
-        <set>
-            <if test="username != null">
-                user_name = #{username,jdbcType=VARCHAR},
-            </if>
-            <if test="roleCode != null">
-                role_code = #{roleCode,jdbcType=VARCHAR},
-            </if>
-            <if test="createTime != null">
-                create_time = #{createTime,jdbcType=TIMESTAMP},
-            </if>
-            <if test="updateTime != null">
-                update_time = #{updateTime,jdbcType=TIMESTAMP},
-            </if>
-            <if test="createBy != null">
-                create_by = #{createBy,jdbcType=VARCHAR},
-            </if>
-            <if test="updateBy != null">
-                update_by = #{updateBy,jdbcType=VARCHAR},
-            </if>
-            <if test="disabled != null">
-                disabled = #{disabled,jdbcType=INTEGER},
-            </if>
-        </set>
-        where id = #{id,jdbcType=INTEGER}
-    </update>
-    <update id="updateByPrimaryKey"
-            parameterType="org.apache.inlong.manager.dao.entity.UserRoleEntity">
-        update user_role
-        set user_name   = #{username,jdbcType=VARCHAR},
-            role_code   = #{roleCode,jdbcType=VARCHAR},
-            create_time = #{createTime,jdbcType=TIMESTAMP},
-            update_time = #{updateTime,jdbcType=TIMESTAMP},
-            create_by   = #{createBy,jdbcType=VARCHAR},
-            update_by   = #{updateBy,jdbcType=VARCHAR},
-            disabled    = #{disabled,jdbcType=INTEGER}
-        where id = #{id,jdbcType=INTEGER}
-    </update>
-
     <select id="listByUsername" parameterType="java.lang.String" resultMap="BaseResultMap">
         select
         <include refid="Base_Column_List"/>
         from user_role
         where user_name = #{username,jdbcType=VARCHAR}
     </select>
+
+    <update id="updateById" parameterType="org.apache.inlong.manager.dao.entity.UserRoleEntity">
+        update user_role
+        set user_name  = #{username,jdbcType=VARCHAR},
+            role_code  = #{roleCode,jdbcType=VARCHAR},
+            disabled   = #{disabled,jdbcType=SMALLINT},
+            is_deleted = #{isDeleted,jdbcType=INTEGER},
+            modifier   = #{modifier,jdbcType=VARCHAR},
+            version    = #{version,jdbcType=INTEGER} + 1
+        where id = #{id,jdbcType=INTEGER}
+          and version = #{version,jdbcType=INTEGER}
+    </update>
+
+    <delete id="deleteById" parameterType="java.lang.Integer">
+        delete
+        from user_role
+        where id = #{id,jdbcType=INTEGER}
+    </delete>
 </mapper>
diff --git a/inlong-manager/manager-test/src/main/resources/h2/apache_inlong_manager.sql b/inlong-manager/manager-test/src/main/resources/h2/apache_inlong_manager.sql
index a3217db98..e35a1aa9a 100644
--- a/inlong-manager/manager-test/src/main/resources/h2/apache_inlong_manager.sql
+++ b/inlong-manager/manager-test/src/main/resources/h2/apache_inlong_manager.sql
@@ -33,9 +33,9 @@ CREATE TABLE IF NOT EXISTS `inlong_group`
     `daily_storage`          int(11)               DEFAULT '10' COMMENT 'Access size by day, unit: GB per day',
     `peak_records`           int(11)               DEFAULT '1000' COMMENT 'Access peak per second, unit: records per second',
     `max_length`             int(11)               DEFAULT '10240' COMMENT 'The maximum length of a single piece of data, unit: Byte',
-    `enable_zookeeper`       tinyint(2)            DEFAULT '0' COMMENT 'Whether to enable the zookeeper, 0-disable, 1-enable',
-    `enable_create_resource` tinyint(2)            DEFAULT '1' COMMENT 'Whether to enable create resource? 0-disable, 1-enable',
-    `lightweight`            tinyint(2)            DEFAULT '0' COMMENT 'Whether to use lightweight mode, 0-false, 1-true',
+    `enable_zookeeper`       tinyint(1)            DEFAULT '0' COMMENT 'Whether to enable the zookeeper, 0-disable, 1-enable',
+    `enable_create_resource` tinyint(1)            DEFAULT '1' COMMENT 'Whether to enable create resource? 0-disable, 1-enable',
+    `lightweight`            tinyint(1)            DEFAULT '0' COMMENT 'Whether to use lightweight mode, 0-false, 1-true',
     `inlong_cluster_tag`     varchar(128)          DEFAULT NULL COMMENT 'The cluster tag, which links to inlong_cluster table',
     `ext_params`             text                  DEFAULT NULL COMMENT 'Extended params, will be saved as JSON string, such as queue_module, partition_num',
     `in_charges`             varchar(512) NOT NULL COMMENT 'Name of responsible person, separated by commas',
@@ -315,24 +315,6 @@ CREATE TABLE IF NOT EXISTS `operation_log`
     PRIMARY KEY (`id`)
 );
 
--- ----------------------------
--- Table structure for role
--- ----------------------------
-CREATE TABLE IF NOT EXISTS `role`
-(
-    `id`          int(11)      NOT NULL AUTO_INCREMENT,
-    `role_code`   varchar(100) NOT NULL COMMENT 'Role code',
-    `role_name`   varchar(256) NOT NULL COMMENT 'Role Chinese name',
-    `create_time` datetime     NOT NULL,
-    `update_time` datetime     NOT NULL DEFAULT CURRENT_TIMESTAMP,
-    `create_by`   varchar(256) NOT NULL,
-    `update_by`   varchar(256) NOT NULL,
-    `disabled`    tinyint(1)   NOT NULL DEFAULT '0' COMMENT 'Is it disabled?',
-    PRIMARY KEY (`id`),
-    UNIQUE KEY `unique_role_code` (`role_code`),
-    UNIQUE KEY `unique_role_name` (`role_name`)
-);
-
 -- ----------------------------
 -- Table structure for source_file_basic
 -- ----------------------------
@@ -451,7 +433,7 @@ CREATE TABLE IF NOT EXISTS `stream_sink`
     `sink_type`              varchar(15)           DEFAULT 'HIVE' COMMENT 'Sink type, including: HIVE, ES, etc',
     `sink_name`              varchar(128) NOT NULL DEFAULT '' COMMENT 'Sink name',
     `description`            varchar(500) NULL COMMENT 'Sink description',
-    `enable_create_resource` tinyint(2)            DEFAULT '1' COMMENT 'Whether to enable create sink resource? 0-disable, 1-enable',
+    `enable_create_resource` tinyint(1)            DEFAULT '1' COMMENT 'Whether to enable create sink resource? 0-disable, 1-enable',
     `inlong_cluster_name`    varchar(128)          DEFAULT NULL COMMENT 'Cluster name, which links to inlong_cluster table',
     `data_node_name`         varchar(128)          DEFAULT NULL COMMENT 'Node name, which links to data_node table',
     `sort_task_name`         varchar(512)          DEFAULT NULL COMMENT 'Sort task name or task ID',
@@ -570,6 +552,26 @@ CREATE TABLE IF NOT EXISTS `user`
     UNIQUE KEY `unique_user_name` (`name`)
 );
 
+-- ----------------------------
+-- Table structure for role
+-- ----------------------------
+CREATE TABLE IF NOT EXISTS `role`
+(
+    `id`          int(11)      NOT NULL AUTO_INCREMENT,
+    `role_code`   varchar(100) NOT NULL COMMENT 'Role code',
+    `role_name`   varchar(256) NOT NULL COMMENT 'Role Chinese name',
+    `disabled`    tinyint(1)  NOT NULL DEFAULT '0' COMMENT 'Whether to disabled, 0: enabled, 1: disabled',
+    `is_deleted`  int(11)               DEFAULT '0' COMMENT 'Whether to delete, 0 is not deleted, if greater than 0, delete',
+    `creator`     varchar(256) NOT NULL COMMENT 'Creator name',
+    `modifier`    varchar(256)          DEFAULT NULL COMMENT 'Modifier name',
+    `create_time` datetime     NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'Create time',
+    `modify_time` datetime     NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'Modify time',
+    `version`     int(11)      NOT NULL DEFAULT '1' COMMENT 'Version number, which will be incremented by 1 after modification',
+    PRIMARY KEY (`id`),
+    UNIQUE KEY `unique_role_code` (`role_code`),
+    UNIQUE KEY `unique_role_name` (`role_name`)
+);
+
 -- ----------------------------
 -- Table structure for user_role
 -- ----------------------------
@@ -578,11 +580,13 @@ CREATE TABLE IF NOT EXISTS `user_role`
     `id`          int(11)      NOT NULL AUTO_INCREMENT,
     `user_name`   varchar(256) NOT NULL COMMENT 'Username',
     `role_code`   varchar(256) NOT NULL COMMENT 'User role code',
-    `create_time` datetime     NOT NULL,
-    `update_time` datetime     NOT NULL DEFAULT CURRENT_TIMESTAMP,
-    `create_by`   varchar(256) NOT NULL,
-    `update_by`   varchar(256) NOT NULL,
-    `disabled`    tinyint(1)   NOT NULL DEFAULT '0' COMMENT 'Is it disabled, 0-enabled, 1-disabled',
+    `disabled`    tinyint(1)  NOT NULL DEFAULT '0' COMMENT 'Whether to disabled, 0: enabled, 1: disabled',
+    `is_deleted`  int(11)               DEFAULT '0' COMMENT 'Whether to delete, 0 is not deleted, if greater than 0, delete',
+    `creator`     varchar(256) NOT NULL COMMENT 'Creator name',
+    `modifier`    varchar(256)          DEFAULT NULL COMMENT 'Modifier name',
+    `create_time` datetime     NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'Create time',
+    `modify_time` datetime     NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'Modify time',
+    `version`     int(11)      NOT NULL DEFAULT '1' COMMENT 'Version number, which will be incremented by 1 after modification',
     PRIMARY KEY (`id`)
 );
 
diff --git a/inlong-manager/manager-web/sql/apache_inlong_manager.sql b/inlong-manager/manager-web/sql/apache_inlong_manager.sql
index 8b451fbc5..e4c2b1904 100644
--- a/inlong-manager/manager-web/sql/apache_inlong_manager.sql
+++ b/inlong-manager/manager-web/sql/apache_inlong_manager.sql
@@ -39,9 +39,9 @@ CREATE TABLE IF NOT EXISTS `inlong_group`
     `daily_storage`          int(11)               DEFAULT '10' COMMENT 'Access size by day, unit: GB per day',
     `peak_records`           int(11)               DEFAULT '1000' COMMENT 'Access peak per second, unit: records per second',
     `max_length`             int(11)               DEFAULT '10240' COMMENT 'The maximum length of a single piece of data, unit: Byte',
-    `enable_zookeeper`       tinyint(2)            DEFAULT '0' COMMENT 'Whether to enable the zookeeper, 0-disable, 1-enable',
-    `enable_create_resource` tinyint(2)            DEFAULT '1' COMMENT 'Whether to enable create resource? 0-disable, 1-enable',
-    `lightweight`            tinyint(2)            DEFAULT '0' COMMENT 'Whether to use lightweight mode, 0-false, 1-true',
+    `enable_zookeeper`       tinyint(1)            DEFAULT '0' COMMENT 'Whether to enable the zookeeper, 0-disable, 1-enable',
+    `enable_create_resource` tinyint(1)            DEFAULT '1' COMMENT 'Whether to enable create resource? 0-disable, 1-enable',
+    `lightweight`            tinyint(1)            DEFAULT '0' COMMENT 'Whether to use lightweight mode, 0-false, 1-true',
     `inlong_cluster_tag`     varchar(128)          DEFAULT NULL COMMENT 'The cluster tag, which links to inlong_cluster table',
     `ext_params`             text                  DEFAULT NULL COMMENT 'Extended params, will be saved as JSON string, such as queue_module, partition_num',
     `in_charges`             varchar(512) NOT NULL COMMENT 'Name of responsible person, separated by commas',
@@ -334,25 +334,6 @@ CREATE TABLE IF NOT EXISTS `operation_log`
 ) ENGINE = InnoDB
   DEFAULT CHARSET = utf8mb4;
 
--- ----------------------------
--- Table structure for role
--- ----------------------------
-CREATE TABLE IF NOT EXISTS `role`
-(
-    `id`          int(11)      NOT NULL AUTO_INCREMENT,
-    `role_code`   varchar(100) NOT NULL COMMENT 'Role code',
-    `role_name`   varchar(256) NOT NULL COMMENT 'Role Chinese name',
-    `create_time` datetime     NOT NULL,
-    `update_time` datetime     NOT NULL DEFAULT CURRENT_TIMESTAMP,
-    `create_by`   varchar(256) NOT NULL,
-    `update_by`   varchar(256) NOT NULL,
-    `disabled`    tinyint(1)   NOT NULL DEFAULT '0' COMMENT 'Is it disabled?',
-    PRIMARY KEY (`id`),
-    UNIQUE KEY `unique_role_code` (`role_code`),
-    UNIQUE KEY `unique_role_name` (`role_name`)
-) ENGINE = InnoDB
-  DEFAULT CHARSET = utf8mb4 COMMENT ='Role Table';
-
 -- ----------------------------
 -- Table structure for source_file_basic
 -- ----------------------------
@@ -475,7 +456,7 @@ CREATE TABLE IF NOT EXISTS `stream_sink`
     `sink_type`              varchar(15)           DEFAULT 'HIVE' COMMENT 'Sink type, including: HIVE, ES, etc',
     `sink_name`              varchar(128) NOT NULL DEFAULT '' COMMENT 'Sink name',
     `description`            varchar(500) NULL COMMENT 'Sink description',
-    `enable_create_resource` tinyint(2)            DEFAULT '1' COMMENT 'Whether to enable create sink resource? 0-disable, 1-enable',
+    `enable_create_resource` tinyint(1)            DEFAULT '1' COMMENT 'Whether to enable create sink resource? 0-disable, 1-enable',
     `inlong_cluster_name`    varchar(128)          DEFAULT NULL COMMENT 'Cluster name, which links to inlong_cluster table',
     `data_node_name`         varchar(128)          DEFAULT NULL COMMENT 'Node name, which links to data_node table',
     `sort_task_name`         varchar(512)          DEFAULT NULL COMMENT 'Sort task name or task ID',
@@ -600,10 +581,33 @@ CREATE TABLE IF NOT EXISTS `user`
   DEFAULT CHARSET = utf8mb4 COMMENT ='User table';
 
 -- create default admin user, username is 'admin', password is 'inlong'
-INSERT INTO `user` (name, password, secret_key, account_type, encrypt_version,
+INSERT INTO `user` (name, password,
+                    secret_key, account_type, encrypt_version,
                     due_date, creator, modifier)
-VALUES ('admin', '1976e096b31cfda81269d0df2775466aac6dd809e3ada1d5ba7831d85e80f109', '9B5DCE950F284141D5493A2DAFEBD1BFEECE075FC5F426E8B67F33F14876E2D0',
-        0, 1, '2099-12-31 23:59:59', 'inlong_init', 'inlong_init');
+VALUES ('admin', '1976e096b31cfda81269d0df2775466aac6dd809e3ada1d5ba7831d85e80f109',
+        '9B5DCE950F284141D5493A2DAFEBD1BFEECE075FC5F426E8B67F33F14876E2D0', 0, 1,
+        '2099-12-31 23:59:59', 'inlong_init', 'inlong_init');
+
+-- ----------------------------
+-- Table structure for role
+-- ----------------------------
+CREATE TABLE IF NOT EXISTS `role`
+(
+    `id`          int(11)      NOT NULL AUTO_INCREMENT,
+    `role_code`   varchar(100) NOT NULL COMMENT 'Role code',
+    `role_name`   varchar(256) NOT NULL COMMENT 'Role Chinese name',
+    `disabled`    tinyint(1)  NOT NULL DEFAULT '0' COMMENT 'Whether to disabled, 0: enabled, 1: disabled',
+    `is_deleted`  int(11)               DEFAULT '0' COMMENT 'Whether to delete, 0 is not deleted, if greater than 0, delete',
+    `creator`     varchar(256) NOT NULL COMMENT 'Creator name',
+    `modifier`    varchar(256)          DEFAULT NULL COMMENT 'Modifier name',
+    `create_time` datetime     NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'Create time',
+    `modify_time` datetime     NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'Modify time',
+    `version`     int(11)      NOT NULL DEFAULT '1' COMMENT 'Version number, which will be incremented by 1 after modification',
+    PRIMARY KEY (`id`),
+    UNIQUE KEY `unique_role_code` (`role_code`),
+    UNIQUE KEY `unique_role_name` (`role_name`)
+) ENGINE = InnoDB
+  DEFAULT CHARSET = utf8mb4 COMMENT ='Role Table';
 
 -- ----------------------------
 -- Table structure for user_role
@@ -613,11 +617,13 @@ CREATE TABLE IF NOT EXISTS `user_role`
     `id`          int(11)      NOT NULL AUTO_INCREMENT,
     `user_name`   varchar(256) NOT NULL COMMENT 'Username',
     `role_code`   varchar(256) NOT NULL COMMENT 'User role code',
-    `create_time` datetime     NOT NULL,
-    `update_time` datetime     NOT NULL DEFAULT CURRENT_TIMESTAMP,
-    `create_by`   varchar(256) NOT NULL,
-    `update_by`   varchar(256) NOT NULL,
-    `disabled`    tinyint(1)   NOT NULL DEFAULT '0' COMMENT 'Is it disabled, 0-enabled, 1-disabled',
+    `disabled`    tinyint(1)  NOT NULL DEFAULT '0' COMMENT 'Whether to disabled, 0: enabled, 1: disabled',
+    `is_deleted`  int(11)               DEFAULT '0' COMMENT 'Whether to delete, 0 is not deleted, if greater than 0, delete',
+    `creator`     varchar(256) NOT NULL COMMENT 'Creator name',
+    `modifier`    varchar(256)          DEFAULT NULL COMMENT 'Modifier name',
+    `create_time` datetime     NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'Create time',
+    `modify_time` datetime     NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'Modify time',
+    `version`     int(11)      NOT NULL DEFAULT '1' COMMENT 'Version number, which will be incremented by 1 after modification',
     PRIMARY KEY (`id`)
 ) ENGINE = InnoDB
   DEFAULT CHARSET = utf8mb4 COMMENT ='User Role Table';