You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dolphinscheduler.apache.org by lg...@apache.org on 2021/02/25 02:36:04 UTC

[incubator-dolphinscheduler] branch dev updated: [Improvement][SQL] Place the upgraded schema to the correct version directory and check schema errors (#4806)

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

lgcareer pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/incubator-dolphinscheduler.git


The following commit(s) were added to refs/heads/dev by this push:
     new f975489  [Improvement][SQL] Place the upgraded schema to the correct version directory and check schema errors (#4806)
f975489 is described below

commit f9754893747ec64b7fe86f73bf0f45f86def8b77
Author: Shiwen Cheng <ch...@gmail.com>
AuthorDate: Thu Feb 25 10:35:55 2021 +0800

    [Improvement][SQL] Place the upgraded schema to the correct version directory and check schema errors (#4806)
    
    * [Improvement][sql] Keep same with 1.3.5-release
    
    * [Improvement][sql] Move the sql at the wrong version to 1.4.0 and fix issue #4650
    
    * [Improvement][sql] Fix ci error
---
 .github/workflows/ci_ut.yml                        |   2 +-
 .../mysql/dolphinscheduler_ddl.sql                 |   1 +
 .../postgresql/dolphinscheduler_ddl.sql            |   1 +
 sql/dolphinscheduler_mysql.sql                     |  28 ++-
 ...er-postgre.sql => dolphinscheduler_postgre.sql} |  62 +++----
 sql/soft_version                                   |   2 +-
 .../1.3.0_schema/mysql/dolphinscheduler_ddl.sql    |  21 ---
 .../postgresql/dolphinscheduler_ddl.sql            |  23 ---
 .../1.3.2_schema/mysql/dolphinscheduler_ddl.sql    |   2 +-
 .../postgresql/dolphinscheduler_ddl.sql            |   2 +-
 .../1.3.3_schema/mysql/dolphinscheduler_ddl.sql    | 115 ------------
 .../1.3.3_schema/mysql/dolphinscheduler_dml.sql    |   2 +-
 .../postgresql/dolphinscheduler_ddl.sql            | 117 +-----------
 .../postgresql/dolphinscheduler_dml.sql            |   2 +-
 .../1.4.0_schema/mysql/dolphinscheduler_ddl.sql    | 198 ++++++++++++++++++---
 .../1.4.0_schema/mysql/dolphinscheduler_dml.sql    |   4 +-
 .../postgresql/dolphinscheduler_ddl.sql            | 186 +++++++++++++++++--
 .../postgresql/dolphinscheduler_dml.sql            |   2 +-
 18 files changed, 391 insertions(+), 379 deletions(-)

diff --git a/.github/workflows/ci_ut.yml b/.github/workflows/ci_ut.yml
index bb1e8c8..583874c 100644
--- a/.github/workflows/ci_ut.yml
+++ b/.github/workflows/ci_ut.yml
@@ -49,7 +49,7 @@ jobs:
         run: |
           sed -i "s/: root/: test/g" $(pwd)/docker/docker-swarm/docker-compose.yml
           docker-compose -f $(pwd)/docker/docker-swarm/docker-compose.yml create --force-recreate dolphinscheduler-zookeeper dolphinscheduler-postgresql
-          sudo cp $(pwd)/sql/dolphinscheduler-postgre.sql $(docker volume inspect docker-swarm_dolphinscheduler-postgresql-initdb | grep "Mountpoint" | awk -F "\"" '{print $4}')
+          sudo cp $(pwd)/sql/dolphinscheduler_postgre.sql $(docker volume inspect docker-swarm_dolphinscheduler-postgresql-initdb | grep "Mountpoint" | awk -F "\"" '{print $4}')
           docker-compose -f $(pwd)/docker/docker-swarm/docker-compose.yml up -d dolphinscheduler-zookeeper dolphinscheduler-postgresql
       - name: Set up JDK 1.8
         uses: actions/setup-java@v1
diff --git a/sql/create/release-1.0.0_schema/mysql/dolphinscheduler_ddl.sql b/sql/create/release-1.0.0_schema/mysql/dolphinscheduler_ddl.sql
index 86b474d..ac0851a 100644
--- a/sql/create/release-1.0.0_schema/mysql/dolphinscheduler_ddl.sql
+++ b/sql/create/release-1.0.0_schema/mysql/dolphinscheduler_ddl.sql
@@ -381,6 +381,7 @@ DROP TABLE IF EXISTS `t_escheduler_tenant`;
 CREATE TABLE `t_escheduler_tenant` (
   `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'key',
   `tenant_code` varchar(64) DEFAULT NULL COMMENT 'tenant code',
+  `tenant_name` varchar(64) DEFAULT NULL COMMENT 'tenant name',
   `desc` varchar(256) DEFAULT NULL COMMENT 'description',
   `queue_id` int(11) DEFAULT NULL COMMENT 'queue id',
   `create_time` datetime DEFAULT NULL COMMENT 'create time',
diff --git a/sql/create/release-1.2.0_schema/postgresql/dolphinscheduler_ddl.sql b/sql/create/release-1.2.0_schema/postgresql/dolphinscheduler_ddl.sql
index 14d99e1..75a5d56 100644
--- a/sql/create/release-1.2.0_schema/postgresql/dolphinscheduler_ddl.sql
+++ b/sql/create/release-1.2.0_schema/postgresql/dolphinscheduler_ddl.sql
@@ -584,6 +584,7 @@ DROP TABLE IF EXISTS t_ds_tenant;
 CREATE TABLE t_ds_tenant (
   id int NOT NULL  ,
   tenant_code varchar(64) DEFAULT NULL ,
+  tenant_name varchar(64) DEFAULT NULL ,
   description varchar(256) DEFAULT NULL ,
   queue_id int DEFAULT NULL ,
   create_time timestamp DEFAULT NULL ,
diff --git a/sql/dolphinscheduler_mysql.sql b/sql/dolphinscheduler_mysql.sql
index 2ce4156..1da5c8a 100644
--- a/sql/dolphinscheduler_mysql.sql
+++ b/sql/dolphinscheduler_mysql.sql
@@ -297,14 +297,14 @@ CREATE TABLE `t_ds_alert` (
 -- ----------------------------
 DROP TABLE IF EXISTS `t_ds_alertgroup`;
 CREATE TABLE `t_ds_alertgroup`(
-                                  `id`             int(11) NOT NULL AUTO_INCREMENT COMMENT 'key',
-                                  `alert_instance_ids` varchar (255) DEFAULT NULL COMMENT 'alert instance ids',
-                                  `create_user_id` int(11) DEFAULT NULL COMMENT 'create user id',
-                                  `group_name`     varchar(255) DEFAULT NULL COMMENT 'group name',
-                                  `description`    varchar(255) DEFAULT NULL,
-                                  `create_time`    datetime     DEFAULT NULL COMMENT 'create time',
-                                  `update_time`    datetime     DEFAULT NULL COMMENT 'update time',
-                                  PRIMARY KEY (`id`)
+  `id`             int(11) NOT NULL AUTO_INCREMENT COMMENT 'key',
+  `alert_instance_ids` varchar (255) DEFAULT NULL COMMENT 'alert instance ids',
+  `create_user_id` int(11) DEFAULT NULL COMMENT 'create user id',
+  `group_name`     varchar(255) DEFAULT NULL COMMENT 'group name',
+  `description`    varchar(255) DEFAULT NULL,
+  `create_time`    datetime     DEFAULT NULL COMMENT 'create time',
+  `update_time`    datetime     DEFAULT NULL COMMENT 'update time',
+  PRIMARY KEY (`id`)
 ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
 
 -- ----------------------------
@@ -804,29 +804,25 @@ CREATE TABLE `t_ds_version` (
 -- ----------------------------
 -- Records of t_ds_version
 -- ----------------------------
-INSERT INTO `t_ds_version`
-VALUES ('1', '1.3.0');
+INSERT INTO `t_ds_version` VALUES ('1', '1.4.0');
 
 
 -- ----------------------------
 -- Records of t_ds_alertgroup
 -- ----------------------------
 INSERT INTO `t_ds_alertgroup`(alert_instance_ids, create_user_id, group_name, description, create_time, update_time)
-VALUES ("1,2", 1, 'default admin warning group', 'default admin warning group', '2018-11-29 10:20:39',
-        '2018-11-29 10:20:39');
+VALUES ("1,2", 1, 'default admin warning group', 'default admin warning group', '2018-11-29 10:20:39', '2018-11-29 10:20:39');
 
 -- ----------------------------
 -- Records of t_ds_user
 -- ----------------------------
 INSERT INTO `t_ds_user`
-VALUES ('1', 'admin', '7ad2410b2f4c074479a8937a28a22b8f', '0', 'xxx@qq.com', '', '0', '2018-03-27 15:48:50',
-        '2018-10-24 17:40:22', null, 1);
+VALUES ('1', 'admin', '7ad2410b2f4c074479a8937a28a22b8f', '0', 'xxx@qq.com', '', '0', '2018-03-27 15:48:50', '2018-10-24 17:40:22', null, 1);
 
 -- ----------------------------
 -- Table structure for t_ds_plugin_define
 -- ----------------------------
-SET
-sql_mode=(SELECT REPLACE(@@sql_mode,'ONLY_FULL_GROUP_BY',''));
+SET sql_mode=(SELECT REPLACE(@@sql_mode,'ONLY_FULL_GROUP_BY',''));
 DROP TABLE IF EXISTS `t_ds_plugin_define`;
 CREATE TABLE `t_ds_plugin_define` (
   `id` int NOT NULL AUTO_INCREMENT,
diff --git a/sql/dolphinscheduler-postgre.sql b/sql/dolphinscheduler_postgre.sql
similarity index 94%
rename from sql/dolphinscheduler-postgre.sql
rename to sql/dolphinscheduler_postgre.sql
index 6d6d60b..97b2e94 100644
--- a/sql/dolphinscheduler-postgre.sql
+++ b/sql/dolphinscheduler_postgre.sql
@@ -201,14 +201,14 @@ CREATE TABLE t_ds_alert (
 
 DROP TABLE IF EXISTS t_ds_alertgroup;
 CREATE TABLE t_ds_alertgroup(
-                                id             int NOT NULL,
-                                alert_instance_ids varchar (255) DEFAULT NULL,
-                                create_user_id int4         DEFAULT NULL,
-                                group_name     varchar(255) DEFAULT NULL,
-                                description    varchar(255) DEFAULT NULL,
-                                create_time    timestamp    DEFAULT NULL,
-                                update_time    timestamp    DEFAULT NULL,
-                                PRIMARY KEY (id)
+  id             int NOT NULL,
+  alert_instance_ids varchar (255) DEFAULT NULL,
+  create_user_id int4         DEFAULT NULL,
+  group_name     varchar(255) DEFAULT NULL,
+  description    varchar(255) DEFAULT NULL,
+  create_time    timestamp    DEFAULT NULL,
+  update_time    timestamp    DEFAULT NULL,
+  PRIMARY KEY (id)
 ) ;
 
 --
@@ -568,7 +568,7 @@ CREATE TABLE t_ds_task_instance (
   alert_flag int DEFAULT NULL ,
   retry_times int DEFAULT '0' ,
   pid int DEFAULT NULL ,
-  app_link varchar(255) DEFAULT NULL ,
+  app_link text ,
   flag int DEFAULT '1' ,
   retry_interval int DEFAULT NULL ,
   max_retry_times int DEFAULT NULL ,
@@ -754,44 +754,40 @@ ALTER TABLE t_ds_version ALTER COLUMN id SET DEFAULT NEXTVAL('t_ds_version_id_se
 
 DROP SEQUENCE IF EXISTS t_ds_worker_group_id_sequence;
 CREATE SEQUENCE  t_ds_worker_group_id_sequence;
-ALTER TABLE t_ds_worker_group
-    ALTER COLUMN id SET DEFAULT NEXTVAL('t_ds_worker_group_id_sequence');
+ALTER TABLE t_ds_worker_group ALTER COLUMN id SET DEFAULT NEXTVAL('t_ds_worker_group_id_sequence');
 DROP SEQUENCE IF EXISTS t_ds_worker_server_id_sequence;
 CREATE SEQUENCE t_ds_worker_server_id_sequence;
-ALTER TABLE t_ds_worker_server
-    ALTER COLUMN id SET DEFAULT NEXTVAL('t_ds_worker_server_id_sequence');
+ALTER TABLE t_ds_worker_server ALTER COLUMN id SET DEFAULT NEXTVAL('t_ds_worker_server_id_sequence');
 
 
 -- Records of t_ds_user?user : admin , password : dolphinscheduler123
 INSERT INTO t_ds_user(user_name, user_password, user_type, email, phone, tenant_id, state, create_time, update_time)
-VALUES ('admin', '7ad2410b2f4c074479a8937a28a22b8f', '0', 'xxx@qq.com', '', '0', 1, '2018-03-27 15:48:50',
-        '2018-10-24 17:40:22');
+VALUES ('admin', '7ad2410b2f4c074479a8937a28a22b8f', '0', 'xxx@qq.com', '', '0', 1, '2018-03-27 15:48:50', '2018-10-24 17:40:22');
 
 -- Records of t_ds_alertgroup, default admin warning group
 INSERT INTO t_ds_alertgroup(alert_instance_ids, create_user_id, group_name, description, create_time, update_time)
-VALUES ('1,2', 1, 'default admin warning group', 'default admin warning group', '2018-11-29 10:20:39',
-        '2018-11-29 10:20:39');
+VALUES ('1,2', 1, 'default admin warning group', 'default admin warning group', '2018-11-29 10:20:39', '2018-11-29 10:20:39');
 
 -- Records of t_ds_queue,default queue name : default
 INSERT INTO t_ds_queue(queue_name, queue, create_time, update_time)
 VALUES ('default', 'default', '2018-11-29 10:22:33', '2018-11-29 10:22:33');
 
 -- Records of t_ds_queue,default queue name : default
-INSERT INTO t_ds_version(version) VALUES ('1.3.0');
+INSERT INTO t_ds_version(version) VALUES ('1.4.0');
 
 --
 -- Table structure for table t_ds_plugin_define
 --
 DROP TABLE IF EXISTS t_ds_plugin_define;
 CREATE TABLE t_ds_plugin_define (
-	id serial NOT NULL,
-	plugin_name varchar(100) NOT NULL,
-	plugin_type varchar(100) NOT NULL,
-	plugin_params text NULL,
-	create_time timestamp NULL,
-	update_time timestamp NULL,
-	CONSTRAINT t_ds_plugin_define_pk PRIMARY KEY (id),
-	CONSTRAINT t_ds_plugin_define_un UNIQUE (plugin_name, plugin_type)
+  id serial NOT NULL,
+  plugin_name varchar(100) NOT NULL,
+  plugin_type varchar(100) NOT NULL,
+  plugin_params text NULL,
+  create_time timestamp NULL,
+  update_time timestamp NULL,
+  CONSTRAINT t_ds_plugin_define_pk PRIMARY KEY (id),
+  CONSTRAINT t_ds_plugin_define_un UNIQUE (plugin_name, plugin_type)
 );
 
 --
@@ -799,11 +795,11 @@ CREATE TABLE t_ds_plugin_define (
 --
 DROP TABLE IF EXISTS t_ds_alert_plugin_instance;
 CREATE TABLE t_ds_alert_plugin_instance (
-	id serial NOT NULL,
-	plugin_define_id int4 NOT NULL,
-	plugin_instance_params text NULL,
-	create_time timestamp NULL,
-	update_time timestamp NULL,
-	instance_name varchar(200) NULL,
-	CONSTRAINT t_ds_alert_plugin_instance_pk PRIMARY KEY (id)
+  id serial NOT NULL,
+  plugin_define_id int4 NOT NULL,
+  plugin_instance_params text NULL,
+  create_time timestamp NULL,
+  update_time timestamp NULL,
+  instance_name varchar(200) NULL,
+  CONSTRAINT t_ds_alert_plugin_instance_pk PRIMARY KEY (id)
 );
\ No newline at end of file
diff --git a/sql/soft_version b/sql/soft_version
index 6261a05..e21e727 100644
--- a/sql/soft_version
+++ b/sql/soft_version
@@ -1 +1 @@
-1.3.1
\ No newline at end of file
+1.4.0
\ No newline at end of file
diff --git a/sql/upgrade/1.3.0_schema/mysql/dolphinscheduler_ddl.sql b/sql/upgrade/1.3.0_schema/mysql/dolphinscheduler_ddl.sql
index a24c9bc..de6a518 100644
--- a/sql/upgrade/1.3.0_schema/mysql/dolphinscheduler_ddl.sql
+++ b/sql/upgrade/1.3.0_schema/mysql/dolphinscheduler_ddl.sql
@@ -276,24 +276,3 @@ d//
 delimiter ;
 CALL uc_dolphin_T_t_ds_process_definition_A_process_definition_unique;
 DROP PROCEDURE uc_dolphin_T_t_ds_process_definition_A_process_definition_unique;
-
--- ac_dolphin_T_t_ds_user_A_state
-drop PROCEDURE if EXISTS ac_dolphin_T_t_ds_user_A_state;
-delimiter d//
-CREATE PROCEDURE ac_dolphin_T_t_ds_user_A_state()
-   BEGIN
-       IF NOT EXISTS (SELECT 1 FROM information_schema.COLUMNS
-           WHERE TABLE_NAME='t_ds_user'
-           AND TABLE_SCHEMA=(SELECT DATABASE())
-           AND COLUMN_NAME ='state')
-   THEN
-         ALTER TABLE t_ds_user ADD `state` int(1) DEFAULT 1 COMMENT 'state 0:disable 1:enable';
-       END IF;
- END;
-
-d//
-
-delimiter ;
-CALL ac_dolphin_T_t_ds_user_A_state;
-DROP PROCEDURE ac_dolphin_T_t_ds_user_A_state;
-
diff --git a/sql/upgrade/1.3.0_schema/postgresql/dolphinscheduler_ddl.sql b/sql/upgrade/1.3.0_schema/postgresql/dolphinscheduler_ddl.sql
index a9e7525..4762fbd 100644
--- a/sql/upgrade/1.3.0_schema/postgresql/dolphinscheduler_ddl.sql
+++ b/sql/upgrade/1.3.0_schema/postgresql/dolphinscheduler_ddl.sql
@@ -281,26 +281,3 @@ d//
 delimiter ;
 SELECT uc_dolphin_T_t_ds_process_definition_A_process_definition_unique();
 DROP FUNCTION IF EXISTS uc_dolphin_T_t_ds_process_definition_A_process_definition_unique();
-
-
--- ac_dolphin_T_t_ds_user_A_state
-delimiter ;
-DROP FUNCTION IF EXISTS ac_dolphin_T_t_ds_user_A_state();
-delimiter d//
-CREATE FUNCTION ac_dolphin_T_t_ds_user_A_state() RETURNS void AS $$
-BEGIN
-       IF NOT EXISTS (SELECT 1 FROM information_schema.COLUMNS
-          WHERE TABLE_CATALOG=current_database()
-          AND TABLE_SCHEMA=current_schema()
-          AND TABLE_NAME='t_ds_user'
-          AND COLUMN_NAME ='state')
-      THEN
-         ALTER TABLE t_ds_user ADD COLUMN state int DEFAULT 1;
-         comment on column t_ds_user.state is 'state 0:disable 1:enable';
-       END IF;
-END;
-$$ LANGUAGE plpgsql;
-d//
-delimiter ;
-select ac_dolphin_T_t_ds_user_A_state();
-DROP FUNCTION ac_dolphin_T_t_ds_user_A_state();
\ No newline at end of file
diff --git a/sql/upgrade/1.3.2_schema/mysql/dolphinscheduler_ddl.sql b/sql/upgrade/1.3.2_schema/mysql/dolphinscheduler_ddl.sql
index 4a14f32..38964cc 100644
--- a/sql/upgrade/1.3.2_schema/mysql/dolphinscheduler_ddl.sql
+++ b/sql/upgrade/1.3.2_schema/mysql/dolphinscheduler_ddl.sql
@@ -13,4 +13,4 @@
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
-*/
+*/
\ No newline at end of file
diff --git a/sql/upgrade/1.3.2_schema/postgresql/dolphinscheduler_ddl.sql b/sql/upgrade/1.3.2_schema/postgresql/dolphinscheduler_ddl.sql
index 4a14f32..38964cc 100644
--- a/sql/upgrade/1.3.2_schema/postgresql/dolphinscheduler_ddl.sql
+++ b/sql/upgrade/1.3.2_schema/postgresql/dolphinscheduler_ddl.sql
@@ -13,4 +13,4 @@
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
-*/
+*/
\ No newline at end of file
diff --git a/sql/upgrade/1.3.3_schema/mysql/dolphinscheduler_ddl.sql b/sql/upgrade/1.3.3_schema/mysql/dolphinscheduler_ddl.sql
index f7b3bbc..a447cc0 100644
--- a/sql/upgrade/1.3.3_schema/mysql/dolphinscheduler_ddl.sql
+++ b/sql/upgrade/1.3.3_schema/mysql/dolphinscheduler_ddl.sql
@@ -16,118 +16,6 @@
 */
 
 SET sql_mode=(SELECT REPLACE(@@sql_mode,'ONLY_FULL_GROUP_BY',''));
--- uc_dolphin_T_t_ds_task_instance_A_first_submit_time
-drop PROCEDURE if EXISTS uc_dolphin_T_t_ds_task_instance_A_first_submit_time;
-delimiter d//
-CREATE PROCEDURE uc_dolphin_T_t_ds_task_instance_A_first_submit_time()
-   BEGIN
-       IF NOT EXISTS (SELECT 1 FROM information_schema.COLUMNS
-           WHERE TABLE_NAME='t_ds_task_instance'
-           AND TABLE_SCHEMA=(SELECT DATABASE())
-           AND COLUMN_NAME ='first_submit_time')
-   THEN
-         ALTER TABLE t_ds_task_instance ADD `first_submit_time` datetime DEFAULT NULL COMMENT 'task first submit time';
-       END IF;
- END;
-
-d//
-
-delimiter ;
-CALL uc_dolphin_T_t_ds_task_instance_A_first_submit_time();
-DROP PROCEDURE uc_dolphin_T_t_ds_task_instance_A_first_submit_time;
-
--- uc_dolphin_T_t_ds_task_instance_A_delay_time
-drop PROCEDURE if EXISTS uc_dolphin_T_t_ds_task_instance_A_delay_time;
-delimiter d//
-CREATE PROCEDURE uc_dolphin_T_t_ds_task_instance_A_delay_time()
-   BEGIN
-       IF NOT EXISTS (SELECT 1 FROM information_schema.COLUMNS
-           WHERE TABLE_NAME='t_ds_task_instance'
-           AND TABLE_SCHEMA=(SELECT DATABASE())
-           AND COLUMN_NAME ='delay_time')
-   THEN
-         ALTER TABLE t_ds_task_instance ADD `delay_time` int(4) DEFAULT '0' COMMENT 'task delay execution time';
-       END IF;
- END;
-
-d//
-
-delimiter ;
-CALL uc_dolphin_T_t_ds_task_instance_A_delay_time();
-DROP PROCEDURE uc_dolphin_T_t_ds_task_instance_A_delay_time;
-
--- uc_dolphin_T_t_ds_task_instance_A_var_pool
-drop PROCEDURE if EXISTS uc_dolphin_T_t_ds_task_instance_A_var_pool;
-delimiter d//
-CREATE PROCEDURE uc_dolphin_T_t_ds_task_instance_A_var_pool()
-   BEGIN
-       IF NOT EXISTS (SELECT 1 FROM information_schema.COLUMNS
-           WHERE TABLE_NAME='t_ds_task_instance'
-           AND TABLE_SCHEMA=(SELECT DATABASE())
-           AND COLUMN_NAME ='var_pool')
-   THEN
-         ALTER TABLE t_ds_task_instance ADD `var_pool` longtext NULL;
-       END IF;
- END;
-
-d//
-
-delimiter ;
-CALL uc_dolphin_T_t_ds_task_instance_A_var_pool();
-DROP PROCEDURE uc_dolphin_T_t_ds_task_instance_A_var_pool;
-
--- uc_dolphin_T_t_ds_process_instance_A_var_pool
-drop PROCEDURE if EXISTS uc_dolphin_T_t_ds_process_instance_A_var_pool;
-delimiter d//
-CREATE PROCEDURE uc_dolphin_T_t_ds_process_instance_A_var_pool()
-   BEGIN
-       IF NOT EXISTS (SELECT 1 FROM information_schema.COLUMNS
-           WHERE TABLE_NAME='t_ds_process_instance'
-           AND TABLE_SCHEMA=(SELECT DATABASE())
-           AND COLUMN_NAME ='var_pool')
-   THEN
-         ALTER TABLE t_ds_process_instance ADD `var_pool` longtext NULL;
-       END IF;
- END;
-
-d//
-
-delimiter ;
-CALL uc_dolphin_T_t_ds_process_instance_A_var_pool();
-DROP PROCEDURE uc_dolphin_T_t_ds_process_instance_A_var_pool;
-
--- uc_dolphin_T_t_ds_process_definition_A_modify_by
-drop PROCEDURE if EXISTS ct_dolphin_T_t_ds_process_definition_version;
-delimiter d//
-CREATE PROCEDURE ct_dolphin_T_t_ds_process_definition_version()
-BEGIN
-    CREATE TABLE IF NOT EXISTS `t_ds_process_definition_version` (
-                                                       `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'key',
-                                                       `process_definition_id` int(11) NOT NULL COMMENT 'process definition id',
-                                                       `version` int(11) DEFAULT NULL COMMENT 'process definition version',
-                                                       `process_definition_json` longtext COMMENT 'process definition json content',
-                                                       `description` text,
-                                                       `global_params` text COMMENT 'global parameters',
-                                                       `locations` text COMMENT 'Node location information',
-                                                       `connects` text COMMENT 'Node connection information',
-                                                       `receivers` text COMMENT 'receivers',
-                                                       `receivers_cc` text COMMENT 'cc',
-                                                       `create_time` datetime DEFAULT NULL COMMENT 'create time',
-                                                       `timeout` int(11) DEFAULT '0' COMMENT 'time out',
-                                                       `resource_ids` varchar(255) DEFAULT NULL COMMENT 'resource ids',
-                                                       PRIMARY KEY (`id`),
-                                                       UNIQUE KEY `process_definition_id_and_version` (`process_definition_id`,`version`) USING BTREE,
-                                                       KEY `process_definition_index` (`id`) USING BTREE
-    ) ENGINE=InnoDB AUTO_INCREMENT=84 DEFAULT CHARSET=utf8;
-END;
-
-d//
-
-delimiter ;
-CALL ct_dolphin_T_t_ds_process_definition_version;
-DROP PROCEDURE ct_dolphin_T_t_ds_process_definition_version;
-
-
 
 
 --    add t_ds_resources_un
@@ -150,6 +38,3 @@ d//
 delimiter ;
 CALL uc_dolphin_T_t_ds_resources_un();
 DROP PROCEDURE IF EXISTS uc_dolphin_T_t_ds_resources_un;
-
-
-
diff --git a/sql/upgrade/1.3.3_schema/mysql/dolphinscheduler_dml.sql b/sql/upgrade/1.3.3_schema/mysql/dolphinscheduler_dml.sql
index 4a14f32..38964cc 100644
--- a/sql/upgrade/1.3.3_schema/mysql/dolphinscheduler_dml.sql
+++ b/sql/upgrade/1.3.3_schema/mysql/dolphinscheduler_dml.sql
@@ -13,4 +13,4 @@
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
-*/
+*/
\ No newline at end of file
diff --git a/sql/upgrade/1.3.3_schema/postgresql/dolphinscheduler_ddl.sql b/sql/upgrade/1.3.3_schema/postgresql/dolphinscheduler_ddl.sql
index 50f560a..bb7d9f0 100644
--- a/sql/upgrade/1.3.3_schema/postgresql/dolphinscheduler_ddl.sql
+++ b/sql/upgrade/1.3.3_schema/postgresql/dolphinscheduler_ddl.sql
@@ -14,121 +14,14 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
 */
--- uc_dolphin_T_t_ds_task_instance_A_first_submit_time
-delimiter d//
-CREATE OR REPLACE FUNCTION uc_dolphin_T_t_ds_task_instance_A_first_submit_time() RETURNS void AS $$
-BEGIN
-       IF NOT EXISTS (SELECT 1 FROM information_schema.COLUMNS
-          WHERE TABLE_NAME='t_ds_task_instance'
-                            AND COLUMN_NAME ='first_submit_time')
-      THEN
-         ALTER TABLE t_ds_task_instance ADD COLUMN first_submit_time timestamp DEFAULT NULL;
-       END IF;
-END;
-$$ LANGUAGE plpgsql;
-d//
-
-delimiter ;
-SELECT uc_dolphin_T_t_ds_task_instance_A_first_submit_time();
-DROP FUNCTION IF EXISTS uc_dolphin_T_t_ds_task_instance_A_first_submit_time();
-
-
--- uc_dolphin_T_t_ds_task_instance_A_delay_time
-delimiter d//
-CREATE OR REPLACE FUNCTION uc_dolphin_T_t_ds_task_instance_A_delay_time() RETURNS void AS $$
-BEGIN
-       IF NOT EXISTS (SELECT 1 FROM information_schema.COLUMNS
-          WHERE TABLE_NAME='t_ds_task_instance'
-                            AND COLUMN_NAME ='delay_time')
-      THEN
-         ALTER TABLE t_ds_task_instance ADD COLUMN delay_time int DEFAULT '0';
-       END IF;
-END;
-$$ LANGUAGE plpgsql;
-d//
-
-delimiter ;
-SELECT uc_dolphin_T_t_ds_task_instance_A_delay_time();
-DROP FUNCTION IF EXISTS uc_dolphin_T_t_ds_task_instance_A_delay_time();
-
--- uc_dolphin_T_t_ds_process_instance_A_var_pool
-delimiter d//
-CREATE OR REPLACE FUNCTION uc_dolphin_T_t_ds_process_instance_A_var_pool() RETURNS void AS $$
-BEGIN
-       IF NOT EXISTS (SELECT 1 FROM information_schema.COLUMNS
-          WHERE TABLE_NAME='t_ds_process_instance'
-                            AND COLUMN_NAME ='var_pool')
-      THEN
-         ALTER TABLE t_ds_process_instance ADD COLUMN var_pool text;
-       END IF;
-END;
-$$ LANGUAGE plpgsql;
-d//
-
-delimiter ;
-SELECT uc_dolphin_T_t_ds_process_instance_A_var_pool();
-DROP FUNCTION IF EXISTS uc_dolphin_T_t_ds_process_instance_A_var_pool();
-
--- uc_dolphin_T_t_ds_task_instance_A_var_pool
-delimiter d//
-CREATE OR REPLACE FUNCTION uc_dolphin_T_t_ds_task_instance_A_var_pool() RETURNS void AS $$
-BEGIN
-       IF NOT EXISTS (SELECT 1 FROM information_schema.COLUMNS
-          WHERE TABLE_NAME='t_ds_task_instance'
-                            AND COLUMN_NAME ='var_pool')
-      THEN
-         ALTER TABLE t_ds_task_instance ADD COLUMN var_pool text;
-       END IF;
-END;
-$$ LANGUAGE plpgsql;
-d//
-
-delimiter ;
-SELECT uc_dolphin_T_t_ds_task_instance_A_var_pool();
-DROP FUNCTION IF EXISTS uc_dolphin_T_t_ds_task_instance_A_var_pool();
-
--- uc_dolphin_T_t_ds_process_definition_A_modify_by
-delimiter d//
-CREATE OR REPLACE FUNCTION ct_dolphin_T_t_ds_process_definition_version() RETURNS void AS $$
-BEGIN
-CREATE TABLE IF NOT EXISTS t_ds_process_definition_version (
-                                                 id int NOT NULL  ,
-                                                 process_definition_id int NOT NULL  ,
-                                                 version int DEFAULT NULL ,
-                                                 process_definition_json text ,
-                                                 description text ,
-                                                 global_params text ,
-                                                 locations text ,
-                                                 connects text ,
-                                                 receivers text ,
-                                                 receivers_cc text ,
-                                                 create_time timestamp DEFAULT NULL ,
-                                                 timeout int DEFAULT '0' ,
-                                                 resource_ids varchar(64),
-                                                 PRIMARY KEY (id)
-) ;
-create index process_definition_id_and_version on t_ds_process_definition_version (process_definition_id,version);
-
-END;
-$$ LANGUAGE plpgsql;
-d//
-
-delimiter ;
-SELECT ct_dolphin_T_t_ds_process_definition_version();
-DROP FUNCTION IF EXISTS ct_dolphin_T_t_ds_process_definition_version();
-
-
-
 
 --  add t_ds_resources_un
 delimiter d//
 CREATE OR REPLACE FUNCTION uc_dolphin_T_t_ds_resources_un() RETURNS void AS $$
 BEGIN
-    IF NOT EXISTS (
-                    SELECT 1 FROM information_schema.KEY_COLUMN_USAGE
-                    WHERE  TABLE_NAME = 't_ds_resources'
-                    AND CONSTRAINT_NAME = 't_ds_resources_un'
-                )
+    IF NOT EXISTS (SELECT 1 FROM information_schema.KEY_COLUMN_USAGE
+        WHERE  TABLE_NAME = 't_ds_resources'
+        AND CONSTRAINT_NAME = 't_ds_resources_un')
     THEN
         ALTER TABLE t_ds_resources ADD CONSTRAINT t_ds_resources_un UNIQUE (full_name,"type");
     END IF;
@@ -139,7 +32,3 @@ d//
 delimiter ;
 SELECT uc_dolphin_T_t_ds_resources_un();
 DROP FUNCTION IF EXISTS uc_dolphin_T_t_ds_resources_un();
-
-
-
-
diff --git a/sql/upgrade/1.3.3_schema/postgresql/dolphinscheduler_dml.sql b/sql/upgrade/1.3.3_schema/postgresql/dolphinscheduler_dml.sql
index 4a14f32..38964cc 100644
--- a/sql/upgrade/1.3.3_schema/postgresql/dolphinscheduler_dml.sql
+++ b/sql/upgrade/1.3.3_schema/postgresql/dolphinscheduler_dml.sql
@@ -13,4 +13,4 @@
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
-*/
+*/
\ No newline at end of file
diff --git a/sql/upgrade/1.4.0_schema/mysql/dolphinscheduler_ddl.sql b/sql/upgrade/1.4.0_schema/mysql/dolphinscheduler_ddl.sql
index b92b5cf..7fdac07 100644
--- a/sql/upgrade/1.4.0_schema/mysql/dolphinscheduler_ddl.sql
+++ b/sql/upgrade/1.4.0_schema/mysql/dolphinscheduler_ddl.sql
@@ -17,43 +17,186 @@
 
 SET sql_mode=(SELECT REPLACE(@@sql_mode,'ONLY_FULL_GROUP_BY',''));
 
+-- uc_dolphin_T_t_ds_user_A_state
+drop PROCEDURE if EXISTS uc_dolphin_T_t_ds_user_A_state;
+delimiter d//
+CREATE PROCEDURE uc_dolphin_T_t_ds_user_A_state()
+   BEGIN
+       IF NOT EXISTS (SELECT 1 FROM information_schema.COLUMNS
+           WHERE TABLE_NAME='t_ds_user'
+           AND TABLE_SCHEMA=(SELECT DATABASE())
+           AND COLUMN_NAME ='state')
+   THEN
+         ALTER TABLE t_ds_user ADD `state` int(1) DEFAULT 1 COMMENT 'state 0:disable 1:enable';
+       END IF;
+ END;
+
+d//
+
+delimiter ;
+CALL uc_dolphin_T_t_ds_user_A_state;
+DROP PROCEDURE uc_dolphin_T_t_ds_user_A_state;
+
+-- uc_dolphin_T_t_ds_tenant_A_tenant_name
+drop PROCEDURE if EXISTS uc_dolphin_T_t_ds_tenant_A_tenant_name;
+delimiter d//
+CREATE PROCEDURE uc_dolphin_T_t_ds_tenant_A_tenant_name()
+   BEGIN
+       IF EXISTS (SELECT 1 FROM information_schema.COLUMNS
+           WHERE TABLE_NAME='t_ds_tenant'
+           AND TABLE_SCHEMA=(SELECT DATABASE())
+           AND COLUMN_NAME ='tenant_name')
+   THEN
+         ALTER TABLE t_ds_tenant DROP `tenant_name`;
+       END IF;
+ END;
+
+d//
+
+delimiter ;
+CALL uc_dolphin_T_t_ds_tenant_A_tenant_name;
+DROP PROCEDURE uc_dolphin_T_t_ds_tenant_A_tenant_name;
+
+-- uc_dolphin_T_t_ds_task_instance_A_first_submit_time
+drop PROCEDURE if EXISTS uc_dolphin_T_t_ds_task_instance_A_first_submit_time;
+delimiter d//
+CREATE PROCEDURE uc_dolphin_T_t_ds_task_instance_A_first_submit_time()
+   BEGIN
+       IF NOT EXISTS (SELECT 1 FROM information_schema.COLUMNS
+           WHERE TABLE_NAME='t_ds_task_instance'
+           AND TABLE_SCHEMA=(SELECT DATABASE())
+           AND COLUMN_NAME ='first_submit_time')
+   THEN
+         ALTER TABLE t_ds_task_instance ADD `first_submit_time` datetime DEFAULT NULL COMMENT 'task first submit time';
+       END IF;
+ END;
+
+d//
+
+delimiter ;
+CALL uc_dolphin_T_t_ds_task_instance_A_first_submit_time();
+DROP PROCEDURE uc_dolphin_T_t_ds_task_instance_A_first_submit_time;
+
+-- uc_dolphin_T_t_ds_task_instance_A_delay_time
+drop PROCEDURE if EXISTS uc_dolphin_T_t_ds_task_instance_A_delay_time;
+delimiter d//
+CREATE PROCEDURE uc_dolphin_T_t_ds_task_instance_A_delay_time()
+   BEGIN
+       IF NOT EXISTS (SELECT 1 FROM information_schema.COLUMNS
+           WHERE TABLE_NAME='t_ds_task_instance'
+           AND TABLE_SCHEMA=(SELECT DATABASE())
+           AND COLUMN_NAME ='delay_time')
+   THEN
+         ALTER TABLE t_ds_task_instance ADD `delay_time` int(4) DEFAULT '0' COMMENT 'task delay execution time';
+       END IF;
+ END;
+
+d//
+
+delimiter ;
+CALL uc_dolphin_T_t_ds_task_instance_A_delay_time();
+DROP PROCEDURE uc_dolphin_T_t_ds_task_instance_A_delay_time;
+
+-- uc_dolphin_T_t_ds_task_instance_A_var_pool
+drop PROCEDURE if EXISTS uc_dolphin_T_t_ds_task_instance_A_var_pool;
+delimiter d//
+CREATE PROCEDURE uc_dolphin_T_t_ds_task_instance_A_var_pool()
+   BEGIN
+       IF NOT EXISTS (SELECT 1 FROM information_schema.COLUMNS
+           WHERE TABLE_NAME='t_ds_task_instance'
+           AND TABLE_SCHEMA=(SELECT DATABASE())
+           AND COLUMN_NAME ='var_pool')
+   THEN
+         ALTER TABLE t_ds_task_instance ADD `var_pool` longtext NULL;
+       END IF;
+ END;
+
+d//
+
+delimiter ;
+CALL uc_dolphin_T_t_ds_task_instance_A_var_pool();
+DROP PROCEDURE uc_dolphin_T_t_ds_task_instance_A_var_pool;
+
+-- uc_dolphin_T_t_ds_process_instance_A_var_pool
+drop PROCEDURE if EXISTS uc_dolphin_T_t_ds_process_instance_A_var_pool;
+delimiter d//
+CREATE PROCEDURE uc_dolphin_T_t_ds_process_instance_A_var_pool()
+   BEGIN
+       IF NOT EXISTS (SELECT 1 FROM information_schema.COLUMNS
+           WHERE TABLE_NAME='t_ds_process_instance'
+           AND TABLE_SCHEMA=(SELECT DATABASE())
+           AND COLUMN_NAME ='var_pool')
+   THEN
+         ALTER TABLE t_ds_process_instance ADD `var_pool` longtext NULL;
+       END IF;
+ END;
+
+d//
+
+delimiter ;
+CALL uc_dolphin_T_t_ds_process_instance_A_var_pool();
+DROP PROCEDURE uc_dolphin_T_t_ds_process_instance_A_var_pool;
+
+-- uc_dolphin_T_t_ds_process_definition_A_modify_by
+drop PROCEDURE if EXISTS ct_dolphin_T_t_ds_process_definition_version;
+delimiter d//
+CREATE PROCEDURE ct_dolphin_T_t_ds_process_definition_version()
+BEGIN
+    CREATE TABLE IF NOT EXISTS `t_ds_process_definition_version` (
+        `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'key',
+        `process_definition_id` int(11) NOT NULL COMMENT 'process definition id',
+        `version` int(11) DEFAULT NULL COMMENT 'process definition version',
+        `process_definition_json` longtext COMMENT 'process definition json content',
+        `description` text,
+        `global_params` text COMMENT 'global parameters',
+        `locations` text COMMENT 'Node location information',
+        `connects` text COMMENT 'Node connection information',
+        `receivers` text COMMENT 'receivers',
+        `receivers_cc` text COMMENT 'cc',
+        `create_time` datetime DEFAULT NULL COMMENT 'create time',
+        `timeout` int(11) DEFAULT '0' COMMENT 'time out',
+        `resource_ids` varchar(255) DEFAULT NULL COMMENT 'resource ids',
+        PRIMARY KEY (`id`),
+        UNIQUE KEY `process_definition_id_and_version` (`process_definition_id`,`version`) USING BTREE,
+        KEY `process_definition_index` (`id`) USING BTREE
+    ) ENGINE=InnoDB AUTO_INCREMENT=84 DEFAULT CHARSET=utf8;
+END;
+
+d//
+
+delimiter ;
+CALL ct_dolphin_T_t_ds_process_definition_version;
+DROP PROCEDURE ct_dolphin_T_t_ds_process_definition_version;
+
 -- ----------------------------
 -- Table structure for t_ds_plugin_define
 -- ----------------------------
 DROP TABLE IF EXISTS `t_ds_plugin_define`;
 CREATE TABLE `t_ds_plugin_define` (
-  `id` int NOT NULL AUTO_INCREMENT,
-  `plugin_name` varchar(100) NOT NULL COMMENT 'the name of plugin eg: email',
-  `plugin_type` varchar(100) NOT NULL COMMENT 'plugin type . alert=alert plugin, job=job plugin',
-  `plugin_params` text COMMENT 'plugin params',
-  `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
-  `update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
-  PRIMARY KEY (`id`),
-  UNIQUE KEY `t_ds_plugin_define_UN` (`plugin_name`,`plugin_type`)
+    `id` int NOT NULL AUTO_INCREMENT,
+    `plugin_name` varchar(100) NOT NULL COMMENT 'the name of plugin eg: email',
+    `plugin_type` varchar(100) NOT NULL COMMENT 'plugin type . alert=alert plugin, job=job plugin',
+    `plugin_params` text COMMENT 'plugin params',
+    `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
+    `update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
+    PRIMARY KEY (`id`),
+    UNIQUE KEY `t_ds_plugin_define_UN` (`plugin_name`,`plugin_type`)
 ) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;
 
 -- ----------------------------
--- Records of t_ds_plugin_define
--- ----------------------------
-
--- ----------------------------
 -- Table structure for t_ds_alert_plugin_instance
 -- ----------------------------
 DROP TABLE IF EXISTS `t_ds_alert_plugin_instance`;
 CREATE TABLE `t_ds_alert_plugin_instance` (
-                                              `id`                     int NOT NULL AUTO_INCREMENT,
-                                              `plugin_define_id`       int NOT NULL,
-                                              `plugin_instance_params` text COMMENT 'plugin instance params. Also contain the params value which user input in web ui.',
-                                              `create_time`            timestamp NULL DEFAULT CURRENT_TIMESTAMP,
-                                              `update_time`            timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
-                                              `instance_name`          varchar(200) DEFAULT NULL COMMENT 'alert instance name',
-                                              PRIMARY KEY (`id`)
+    `id`                     int NOT NULL AUTO_INCREMENT,
+    `plugin_define_id`       int NOT NULL,
+    `plugin_instance_params` text COMMENT 'plugin instance params. Also contain the params value which user input in web ui.',
+    `create_time`            timestamp NULL DEFAULT CURRENT_TIMESTAMP,
+    `update_time`            timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
+    `instance_name`          varchar(200) DEFAULT NULL COMMENT 'alert instance name',
+    PRIMARY KEY (`id`)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
 
--- ----------------------------
--- Records of t_ds_alert_plugin_instance
--- ----------------------------
-
 -- uc_dolphin_T_t_ds_process_definition_A_warning_group_id
 drop PROCEDURE if EXISTS uc_dolphin_T_t_ds_process_definition_A_warning_group_id;
 delimiter d//
@@ -138,13 +281,12 @@ DROP PROCEDURE uc_dolphin_T_t_ds_alertgroup_A_create_user_id;
 -- These columns will not be used in the new version,if you determine that the historical data is useless, you can delete it using the sql below
 -- ----------------------------
 
--- ALTER TABLE t_ds_process_definition DROP receivers, DROP receivers_cc;
+-- ALTER TABLE t_ds_alert DROP `show_type`, DROP `alert_type`, DROP `receivers`, DROP `receivers_cc`;
 
--- ALTER TABLE t_ds_process_definition_version DROP receivers, DROP receivers_cc;
+-- ALTER TABLE t_ds_alertgroup DROP `group_type`;
 
--- ALTER TABLE  t_ds_alert DROP show_type,DROP alert_type,DROP receivers,DROP receivers_cc;
+-- ALTER TABLE t_ds_process_definition DROP `receivers`, DROP `receivers_cc`;
 
--- ALTER TABLE  t_ds_alertgroup DROP group_type;
+-- ALTER TABLE t_ds_process_definition_version DROP `receivers`, DROP `receivers_cc`;
 
 -- DROP TABLE IF EXISTS t_ds_relation_user_alertgroup;
-
diff --git a/sql/upgrade/1.4.0_schema/mysql/dolphinscheduler_dml.sql b/sql/upgrade/1.4.0_schema/mysql/dolphinscheduler_dml.sql
index 57ed4d9..38964cc 100644
--- a/sql/upgrade/1.4.0_schema/mysql/dolphinscheduler_dml.sql
+++ b/sql/upgrade/1.4.0_schema/mysql/dolphinscheduler_dml.sql
@@ -13,6 +13,4 @@
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
-*/
-SET sql_mode=(SELECT REPLACE(@@sql_mode,'ONLY_FULL_GROUP_BY',''));
-SET FOREIGN_KEY_CHECKS=0;
+*/
\ No newline at end of file
diff --git a/sql/upgrade/1.4.0_schema/postgresql/dolphinscheduler_ddl.sql b/sql/upgrade/1.4.0_schema/postgresql/dolphinscheduler_ddl.sql
index e940cfa..390556b 100644
--- a/sql/upgrade/1.4.0_schema/postgresql/dolphinscheduler_ddl.sql
+++ b/sql/upgrade/1.4.0_schema/postgresql/dolphinscheduler_ddl.sql
@@ -15,19 +15,167 @@
  * limitations under the License.
 */
 
+-- uc_dolphin_T_t_ds_user_A_state
+delimiter ;
+DROP FUNCTION IF EXISTS uc_dolphin_T_t_ds_user_A_state();
+delimiter d//
+CREATE FUNCTION uc_dolphin_T_t_ds_user_A_state() RETURNS void AS $$
+BEGIN
+       IF NOT EXISTS (SELECT 1 FROM information_schema.COLUMNS
+          WHERE TABLE_CATALOG=current_database()
+          AND TABLE_SCHEMA=current_schema()
+          AND TABLE_NAME='t_ds_user'
+          AND COLUMN_NAME ='state')
+      THEN
+         ALTER TABLE t_ds_user ADD COLUMN state int DEFAULT 1;
+         comment on column t_ds_user.state is 'state 0:disable 1:enable';
+       END IF;
+END;
+$$ LANGUAGE plpgsql;
+d//
+delimiter ;
+select uc_dolphin_T_t_ds_user_A_state();
+DROP FUNCTION uc_dolphin_T_t_ds_user_A_state();
+
+-- uc_dolphin_T_t_ds_tenant_A_tenant_name
+delimiter ;
+DROP FUNCTION IF EXISTS uc_dolphin_T_t_ds_tenant_A_tenant_name();
+delimiter d//
+CREATE FUNCTION uc_dolphin_T_t_ds_tenant_A_tenant_name() RETURNS void AS $$
+BEGIN
+       IF EXISTS (SELECT 1 FROM information_schema.COLUMNS
+          WHERE TABLE_CATALOG=current_database()
+          AND TABLE_SCHEMA=current_schema()
+          AND TABLE_NAME='t_ds_tenant'
+          AND COLUMN_NAME ='tenant_name')
+      THEN
+         ALTER TABLE t_ds_tenant DROP COLUMN "tenant_name";
+       END IF;
+END;
+$$ LANGUAGE plpgsql;
+d//
+delimiter ;
+select uc_dolphin_T_t_ds_tenant_A_tenant_name();
+DROP FUNCTION uc_dolphin_T_t_ds_tenant_A_tenant_name();
+
+-- uc_dolphin_T_t_ds_task_instance_A_first_submit_time
+delimiter d//
+CREATE OR REPLACE FUNCTION uc_dolphin_T_t_ds_task_instance_A_first_submit_time() RETURNS void AS $$
+BEGIN
+       IF NOT EXISTS (SELECT 1 FROM information_schema.COLUMNS
+          WHERE TABLE_NAME='t_ds_task_instance'
+                            AND COLUMN_NAME ='first_submit_time')
+      THEN
+         ALTER TABLE t_ds_task_instance ADD COLUMN first_submit_time timestamp DEFAULT NULL;
+       END IF;
+END;
+$$ LANGUAGE plpgsql;
+d//
+
+delimiter ;
+SELECT uc_dolphin_T_t_ds_task_instance_A_first_submit_time();
+DROP FUNCTION IF EXISTS uc_dolphin_T_t_ds_task_instance_A_first_submit_time();
+
+-- uc_dolphin_T_t_ds_task_instance_A_delay_time
+delimiter d//
+CREATE OR REPLACE FUNCTION uc_dolphin_T_t_ds_task_instance_A_delay_time() RETURNS void AS $$
+BEGIN
+       IF NOT EXISTS (SELECT 1 FROM information_schema.COLUMNS
+          WHERE TABLE_NAME='t_ds_task_instance'
+                            AND COLUMN_NAME ='delay_time')
+      THEN
+         ALTER TABLE t_ds_task_instance ADD COLUMN delay_time int DEFAULT '0';
+       END IF;
+END;
+$$ LANGUAGE plpgsql;
+d//
+
+delimiter ;
+SELECT uc_dolphin_T_t_ds_task_instance_A_delay_time();
+DROP FUNCTION IF EXISTS uc_dolphin_T_t_ds_task_instance_A_delay_time();
+
+-- uc_dolphin_T_t_ds_task_instance_A_var_pool
+delimiter d//
+CREATE OR REPLACE FUNCTION uc_dolphin_T_t_ds_task_instance_A_var_pool() RETURNS void AS $$
+BEGIN
+       IF NOT EXISTS (SELECT 1 FROM information_schema.COLUMNS
+          WHERE TABLE_NAME='t_ds_task_instance'
+                            AND COLUMN_NAME ='var_pool')
+      THEN
+         ALTER TABLE t_ds_task_instance ADD COLUMN var_pool text;
+       END IF;
+END;
+$$ LANGUAGE plpgsql;
+d//
+
+delimiter ;
+SELECT uc_dolphin_T_t_ds_task_instance_A_var_pool();
+DROP FUNCTION IF EXISTS uc_dolphin_T_t_ds_task_instance_A_var_pool();
+
+-- uc_dolphin_T_t_ds_process_instance_A_var_pool
+delimiter d//
+CREATE OR REPLACE FUNCTION uc_dolphin_T_t_ds_process_instance_A_var_pool() RETURNS void AS $$
+BEGIN
+       IF NOT EXISTS (SELECT 1 FROM information_schema.COLUMNS
+          WHERE TABLE_NAME='t_ds_process_instance'
+                            AND COLUMN_NAME ='var_pool')
+      THEN
+         ALTER TABLE t_ds_process_instance ADD COLUMN var_pool text;
+       END IF;
+END;
+$$ LANGUAGE plpgsql;
+d//
+
+delimiter ;
+SELECT uc_dolphin_T_t_ds_process_instance_A_var_pool();
+DROP FUNCTION IF EXISTS uc_dolphin_T_t_ds_process_instance_A_var_pool();
+
+-- uc_dolphin_T_t_ds_process_definition_A_modify_by
+delimiter d//
+CREATE OR REPLACE FUNCTION ct_dolphin_T_t_ds_process_definition_version() RETURNS void AS $$
+BEGIN
+    CREATE TABLE IF NOT EXISTS t_ds_process_definition_version (
+        id int NOT NULL  ,
+        process_definition_id int NOT NULL  ,
+        version int DEFAULT NULL ,
+        process_definition_json text ,
+        description text ,
+        global_params text ,
+        locations text ,
+        connects text ,
+        receivers text ,
+        receivers_cc text ,
+        create_time timestamp DEFAULT NULL ,
+        timeout int DEFAULT '0' ,
+        resource_ids varchar(64),
+        PRIMARY KEY (id)
+    ) ;
+    create index process_definition_id_and_version on t_ds_process_definition_version (process_definition_id,version);
+
+    DROP SEQUENCE IF EXISTS t_ds_process_definition_version_id_sequence;
+    CREATE SEQUENCE  t_ds_process_definition_version_id_sequence;
+    ALTER TABLE t_ds_process_definition_version ALTER COLUMN id SET DEFAULT NEXTVAL('t_ds_process_definition_version_id_sequence');
+END;
+$$ LANGUAGE plpgsql;
+d//
+
+delimiter ;
+SELECT ct_dolphin_T_t_ds_process_definition_version();
+DROP FUNCTION IF EXISTS ct_dolphin_T_t_ds_process_definition_version();
+
 -- ----------------------------
 -- Table structure for t_ds_plugin_define
 -- ----------------------------
 DROP TABLE IF EXISTS t_ds_plugin_define;
 CREATE TABLE t_ds_plugin_define (
-	id serial NOT NULL,
-	plugin_name varchar(100) NOT NULL,
-	plugin_type varchar(100) NOT NULL,
-	plugin_params text NULL,
-	create_time timestamp NULL,
-	update_time timestamp NULL,
-	CONSTRAINT t_ds_plugin_define_pk PRIMARY KEY (id),
-	CONSTRAINT t_ds_plugin_define_un UNIQUE (plugin_name, plugin_type)
+    id serial NOT NULL,
+    plugin_name varchar(100) NOT NULL,
+    plugin_type varchar(100) NOT NULL,
+    plugin_params text NULL,
+    create_time timestamp NULL,
+    update_time timestamp NULL,
+    CONSTRAINT t_ds_plugin_define_pk PRIMARY KEY (id),
+    CONSTRAINT t_ds_plugin_define_un UNIQUE (plugin_name, plugin_type)
 );
 
 -- ----------------------------
@@ -35,13 +183,13 @@ CREATE TABLE t_ds_plugin_define (
 -- ----------------------------
 DROP TABLE IF EXISTS t_ds_alert_plugin_instance;
 CREATE TABLE t_ds_alert_plugin_instance (
-                                            id                     serial NOT NULL,
-                                            plugin_define_id       int4 NOT NULL,
-                                            plugin_instance_params text NULL,
-                                            create_time            timestamp NULL,
-                                            update_time            timestamp NULL,
-                                            instance_name          varchar(200) NULL,
-                                            CONSTRAINT t_ds_alert_plugin_instance_pk PRIMARY KEY (id)
+    id                     serial NOT NULL,
+    plugin_define_id       int4 NOT NULL,
+    plugin_instance_params text NULL,
+    create_time            timestamp NULL,
+    update_time            timestamp NULL,
+    instance_name          varchar(200) NULL,
+    CONSTRAINT t_ds_alert_plugin_instance_pk PRIMARY KEY (id)
 );
 
 -- uc_dolphin_T_t_ds_process_definition_A_warning_group_id
@@ -124,12 +272,12 @@ DROP FUNCTION IF EXISTS uc_dolphin_T_t_ds_alertgroup_A_create_user_id();
 -- These columns will not be used in the new version,if you determine that the historical data is useless, you can delete it using the sql below
 -- ----------------------------
 
--- ALTER TABLE t_ds_process_definition DROP COLUMN "receivers", DROP COLUMN "receivers_cc";
+-- ALTER TABLE t_ds_alert DROP COLUMN "show_type", DROP COLUMN "alert_type", DROP COLUMN "receivers", DROP COLUMN "receivers_cc";
 
--- ALTER TABLE t_ds_process_definition_version DROP COLUMN "receivers", DROP COLUMN "receivers_cc";
+-- ALTER TABLE t_ds_alertgroup DROP COLUMN "group_type";
 
--- ALTER TABLE  t_ds_alert DROP COLUMN "show_type",DROP COLUMN "alert_type",DROP COLUMN "receivers",DROP COLUMN "receivers_cc";
+-- ALTER TABLE t_ds_process_definition DROP COLUMN "receivers", DROP COLUMN "receivers_cc";
 
--- ALTER TABLE  t_ds_alertgroup DROP COLUMN "group_type";
+-- ALTER TABLE t_ds_process_definition_version DROP COLUMN "receivers", DROP COLUMN "receivers_cc";
 
 -- DROP TABLE IF EXISTS t_ds_relation_user_alertgroup;
diff --git a/sql/upgrade/1.4.0_schema/postgresql/dolphinscheduler_dml.sql b/sql/upgrade/1.4.0_schema/postgresql/dolphinscheduler_dml.sql
index 4a14f32..38964cc 100644
--- a/sql/upgrade/1.4.0_schema/postgresql/dolphinscheduler_dml.sql
+++ b/sql/upgrade/1.4.0_schema/postgresql/dolphinscheduler_dml.sql
@@ -13,4 +13,4 @@
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
-*/
+*/
\ No newline at end of file