Browse Source

add support for postgresql in upgrade database (#801)

* Remove useless dependencies and add jsp-2.1-6.1.14

* Determine if principal is empty in getJdbcUrl method

* fix bug  when register worker but create master node in zookeeper

* Remove useless dependencies such as hive-shims and log4j

* upgrade commons-email from 1.2 to 1.5 and remove mail-1.4.5.jar

* add support for postgresql in upgrade database

* add support for postgresql in upgrade database
pull/2/head
lgcareer 5 years ago committed by dailidong
parent
commit
d5f17f579c
  1. 14
      escheduler-common/src/main/java/cn/escheduler/common/utils/ConnectionUtils.java
  2. 48
      escheduler-dao/src/main/java/cn/escheduler/dao/upgrade/DolphinSchedulerManager.java
  3. 104
      escheduler-dao/src/main/java/cn/escheduler/dao/upgrade/MysqlUpgradeDao.java
  4. 132
      escheduler-dao/src/main/java/cn/escheduler/dao/upgrade/PostgresqlUpgradeDao.java
  5. 131
      escheduler-dao/src/main/java/cn/escheduler/dao/upgrade/UpgradeDao.java
  6. 22
      escheduler-dao/src/main/java/cn/escheduler/dao/upgrade/shell/CreateDolphinScheduler.java
  7. 16
      escheduler-dao/src/main/java/cn/escheduler/dao/upgrade/shell/InitDolphinScheduler.java
  8. 18
      escheduler-dao/src/main/java/cn/escheduler/dao/upgrade/shell/UpgradeDolphinScheduler.java
  9. 2
      script/create_escheduler.sh
  10. 2
      script/upgrade_escheduler.sh
  11. 0
      sql/create/release-1.0.0_schema/mysql/dolphinscheduler_ddl.sql
  12. 0
      sql/create/release-1.0.0_schema/mysql/dolphinscheduler_dml.sql
  13. 804
      sql/create/release-1.2.0_schema/postgresql/dolphinscheduler_ddl.sql
  14. 8
      sql/create/release-1.2.0_schema/postgresql/dolphinscheduler_dml.sql
  15. 2
      sql/soft_version
  16. 0
      sql/upgrade/1.0.1_schema/mysql/dolphinscheduler_ddl.sql
  17. 0
      sql/upgrade/1.0.1_schema/mysql/dolphinscheduler_dml.sql
  18. 0
      sql/upgrade/1.0.2_schema/mysql/dolphinscheduler_ddl.sql
  19. 0
      sql/upgrade/1.0.2_schema/mysql/dolphinscheduler_dml.sql
  20. 0
      sql/upgrade/1.1.0_schema/mysql/dolphinscheduler_ddl.sql
  21. 0
      sql/upgrade/1.1.0_schema/mysql/dolphinscheduler_dml.sql
  22. 0
      sql/upgrade/1.2.0_schema/mysql/dolphinscheduler_ddl.sql
  23. 0
      sql/upgrade/1.2.0_schema/mysql/dolphinscheduler_dml.sql
  24. 0
      sql/upgrade/1.2.0_schema/postgresql/dolphinscheduler_ddl.sql
  25. 0
      sql/upgrade/1.2.0_schema/postgresql/dolphinscheduler_dml.sql

14
escheduler-common/src/main/java/cn/escheduler/common/utils/MysqlUtils.java → escheduler-common/src/main/java/cn/escheduler/common/utils/ConnectionUtils.java

@ -21,16 +21,16 @@ import org.slf4j.LoggerFactory;
import java.sql.*;
public class MysqlUtils {
public class ConnectionUtils {
public static final Logger logger = LoggerFactory.getLogger(MysqlUtils.class);
public static final Logger logger = LoggerFactory.getLogger(ConnectionUtils.class);
private static MysqlUtils instance;
private static ConnectionUtils instance;
MysqlUtils() {
ConnectionUtils() {
}
public static MysqlUtils getInstance() {
public static ConnectionUtils getInstance() {
if (null == instance) {
syncInit();
}
@ -39,7 +39,7 @@ public class MysqlUtils {
private static synchronized void syncInit() {
if (instance == null) {
instance = new MysqlUtils();
instance = new ConnectionUtils();
}
}
@ -76,7 +76,7 @@ public class MysqlUtils {
}
public static void releaseResource(ResultSet rs, PreparedStatement ps, Connection conn) {
MysqlUtils.getInstance().release(rs,ps,conn);
ConnectionUtils.getInstance().release(rs,ps,conn);
if (null != rs) {
try {
rs.close();

48
escheduler-dao/src/main/java/cn/escheduler/dao/upgrade/EschedulerManager.java → escheduler-dao/src/main/java/cn/escheduler/dao/upgrade/DolphinSchedulerManager.java

@ -16,6 +16,7 @@
*/
package cn.escheduler.dao.upgrade;
import cn.escheduler.common.enums.DbType;
import cn.escheduler.common.utils.SchemaUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -25,30 +26,51 @@ import java.util.List;
/**
* upgrade manager
*/
public class EschedulerManager {
private static final Logger logger = LoggerFactory.getLogger(EschedulerManager.class);
UpgradeDao upgradeDao = UpgradeDao.getInstance();
public class DolphinSchedulerManager {
private static final Logger logger = LoggerFactory.getLogger(DolphinSchedulerManager.class);
UpgradeDao upgradeDao;
private void initUpgradeDao() {
DbType dbType = UpgradeDao.getDbType();
if (dbType != null) {
switch (dbType) {
case MYSQL:
upgradeDao = MysqlUpgradeDao.getInstance();
break;
case POSTGRESQL:
upgradeDao = PostgresqlUpgradeDao.getInstance();
break;
default:
logger.error("not support sql type: {},can't upgrade", dbType);
throw new IllegalArgumentException("not support sql type,can't upgrade");
}
}
}
public DolphinSchedulerManager() {
initUpgradeDao();
}
public void initEscheduler() {
public void initDolphinScheduler() {
// Determines whether the escheduler table structure has been init
if(upgradeDao.isExistsTable("t_escheduler_version") || upgradeDao.isExistsTable("t_escheduler_queue")) {
logger.info("The database has been initialized. Skip the initialization step");
return;
}
this.initEschedulerSchema();
this.initDolphinSchedulerSchema();
}
public void initEschedulerSchema() {
public void initDolphinSchedulerSchema() {
logger.info("Start initializing the escheduler manager mysql table structure");
upgradeDao.initEschedulerSchema();
logger.info("Start initializing the DolphinScheduler manager table structure");
upgradeDao.initSchema();
}
/**
* upgrade escheduler
* upgrade DolphinScheduler
*/
public void upgradeEscheduler() throws Exception{
public void upgradeDolphinScheduler() throws Exception{
// Gets a list of all upgrades
List<String> schemaList = SchemaUtils.getAllSchemaList();
@ -76,11 +98,11 @@ public class EschedulerManager {
schemaVersion = schemaDir.split("_")[0];
if(SchemaUtils.isAGreatVersion(schemaVersion , version)) {
logger.info("upgrade escheduler metadata version from " + version + " to " + schemaVersion);
logger.info("upgrade DolphinScheduler metadata version from " + version + " to " + schemaVersion);
logger.info("Begin upgrading escheduler's mysql table structure");
upgradeDao.upgradeEscheduler(schemaDir);
logger.info("Begin upgrading DolphinScheduler's table structure");
upgradeDao.upgradeDolphinScheduler(schemaDir);
if(SchemaUtils.isAGreatVersion(version,"1.0.1")){
version = upgradeDao.getCurrentVersion();
}else {

104
escheduler-dao/src/main/java/cn/escheduler/dao/upgrade/MysqlUpgradeDao.java

@ -0,0 +1,104 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* 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.
*/
package cn.escheduler.dao.upgrade;
import cn.escheduler.common.utils.ConnectionUtils;
import cn.escheduler.dao.datasource.ConnectionFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
public class MysqlUpgradeDao extends UpgradeDao {
public static final Logger logger = LoggerFactory.getLogger(UpgradeDao.class);
private static final String T_VERSION_NAME = "t_escheduler_version";
private static final String rootDir = System.getProperty("user.dir");
@Override
protected void init() {
}
private static class MysqlUpgradeDaoHolder {
private static final MysqlUpgradeDao INSTANCE = new MysqlUpgradeDao();
}
private MysqlUpgradeDao() {
}
public static final MysqlUpgradeDao getInstance() {
return MysqlUpgradeDaoHolder.INSTANCE;
}
/**
* Determines whether a table exists
* @param tableName
* @return
*/
public boolean isExistsTable(String tableName) {
Connection conn = null;
try {
conn = ConnectionFactory.getDataSource().getConnection();
ResultSet rs = conn.getMetaData().getTables(null, null, tableName, null);
if (rs.next()) {
return true;
} else {
return false;
}
} catch (SQLException e) {
logger.error(e.getMessage(),e);
throw new RuntimeException(e.getMessage(),e);
} finally {
ConnectionUtils.releaseResource(null, null, conn);
}
}
/**
* Determines whether a field exists in the specified table
* @param tableName
* @param columnName
* @return
*/
public boolean isExistsColumn(String tableName,String columnName) {
Connection conn = null;
try {
conn = ConnectionFactory.getDataSource().getConnection();
ResultSet rs = conn.getMetaData().getColumns(null,null,tableName,columnName);
if (rs.next()) {
return true;
} else {
return false;
}
} catch (SQLException e) {
logger.error(e.getMessage(),e);
throw new RuntimeException(e.getMessage(),e);
} finally {
ConnectionUtils.releaseResource(null, null, conn);
}
}
}

132
escheduler-dao/src/main/java/cn/escheduler/dao/upgrade/PostgresqlUpgradeDao.java

@ -0,0 +1,132 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* 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.
*/
package cn.escheduler.dao.upgrade;
import cn.escheduler.common.utils.ConnectionUtils;
import cn.escheduler.dao.datasource.ConnectionFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
public class PostgresqlUpgradeDao extends UpgradeDao {
public static final Logger logger = LoggerFactory.getLogger(UpgradeDao.class);
private static final String T_VERSION_NAME = "t_escheduler_version";
private static final String rootDir = System.getProperty("user.dir");
private static final String schema = getSchema();
@Override
protected void init() {
}
private static class PostgresqlUpgradeDaoHolder {
private static final PostgresqlUpgradeDao INSTANCE = new PostgresqlUpgradeDao();
}
private PostgresqlUpgradeDao() {
}
public static final PostgresqlUpgradeDao getInstance() {
return PostgresqlUpgradeDaoHolder.INSTANCE;
}
@Override
public void initSchema(String initSqlPath) {
super.initSchema(initSqlPath);
}
private static String getSchema(){
Connection conn = null;
PreparedStatement pstmt = null;
try {
conn = ConnectionFactory.getDataSource().getConnection();
pstmt = conn.prepareStatement("select current_schema()");
ResultSet resultSet = pstmt.executeQuery();
while (resultSet.next()){
if(resultSet.isFirst()){
return resultSet.getString(1);
}
}
} catch (SQLException e) {
logger.error(e.getMessage(),e);
} finally {
ConnectionUtils.releaseResource(null, null, conn);
}
return "";
}
/**
* Determines whether a table exists
* @param tableName
* @return
*/
public boolean isExistsTable(String tableName) {
Connection conn = null;
try {
conn = ConnectionFactory.getDataSource().getConnection();
ResultSet rs = conn.getMetaData().getTables(null, schema, tableName, null);
if (rs.next()) {
return true;
} else {
return false;
}
} catch (SQLException e) {
logger.error(e.getMessage(),e);
throw new RuntimeException(e.getMessage(),e);
} finally {
ConnectionUtils.releaseResource(null, null, conn);
}
}
/**
* Determines whether a field exists in the specified table
* @param tableName
* @param columnName
* @return
*/
public boolean isExistsColumn(String tableName,String columnName) {
Connection conn = null;
try {
conn = ConnectionFactory.getDataSource().getConnection();
ResultSet rs = conn.getMetaData().getColumns(null,schema,tableName,columnName);
if (rs.next()) {
return true;
} else {
return false;
}
} catch (SQLException e) {
logger.error(e.getMessage(),e);
throw new RuntimeException(e.getMessage(),e);
} finally {
ConnectionUtils.releaseResource(null, null, conn);
}
}
}

131
escheduler-dao/src/main/java/cn/escheduler/dao/upgrade/UpgradeDao.java

@ -16,7 +16,8 @@
*/
package cn.escheduler.dao.upgrade;
import cn.escheduler.common.utils.MysqlUtils;
import cn.escheduler.common.enums.DbType;
import cn.escheduler.common.utils.ConnectionUtils;
import cn.escheduler.common.utils.ScriptRunner;
import cn.escheduler.dao.AbstractBaseDao;
import cn.escheduler.dao.datasource.ConnectionFactory;
@ -29,8 +30,9 @@ import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.text.MessageFormat;
public class UpgradeDao extends AbstractBaseDao {
public abstract class UpgradeDao extends AbstractBaseDao {
public static final Logger logger = LoggerFactory.getLogger(UpgradeDao.class);
private static final String T_VERSION_NAME = "t_escheduler_version";
@ -41,35 +43,59 @@ public class UpgradeDao extends AbstractBaseDao {
}
private static class UpgradeDaoHolder {
private static final UpgradeDao INSTANCE = new UpgradeDao();
}
private UpgradeDao() {
/**
* get db type
* @return
*/
public static DbType getDbType(){
try {
Connection conn = ConnectionFactory.getDataSource().getConnection();
String name = conn.getMetaData().getDatabaseProductName().toUpperCase();
return DbType.valueOf(name);
} catch (Exception e) {
logger.error(e.getMessage(),e);
return null;
}
}
public static final UpgradeDao getInstance() {
return UpgradeDaoHolder.INSTANCE;
public void initSchema(){
DbType dbType = getDbType();
String initSqlPath = "";
if (dbType != null) {
switch (dbType) {
case MYSQL:
initSqlPath = "/sql/create/release-1.0.0_schema/mysql/";
initSchema(initSqlPath);
break;
case POSTGRESQL:
initSqlPath = "/sql/create/release-1.2.0_schema/postgresql/";
initSchema(initSqlPath);
break;
default:
logger.error("not support sql type: {},can't upgrade", dbType);
throw new IllegalArgumentException("not support sql type,can't upgrade");
}
}
}
public void initEschedulerSchema() {
public void initSchema(String initSqlPath) {
// Execute the escheduler DDL, it cannot be rolled back
runInitEschedulerDDL();
runInitDDL(initSqlPath);
// Execute the escheduler DML, it can be rolled back
runInitEschedulerDML();
runInitDML(initSqlPath);
}
private void runInitEschedulerDML() {
private void runInitDML(String initSqlPath) {
Connection conn = null;
if (StringUtils.isEmpty(rootDir)) {
throw new RuntimeException("Environment variable user.dir not found");
}
String mysqlSQLFilePath = rootDir + "/sql/create/release-1.0.0_schema/mysql/escheduler_dml.sql";
//String mysqlSQLFilePath = rootDir + "/sql/create/release-1.0.0_schema/mysql/escheduler_dml.sql";
String mysqlSQLFilePath = rootDir + initSqlPath + "dolphinscheduler_dml.sql";
try {
conn = ConnectionFactory.getDataSource().getConnection();
conn.setAutoCommit(false);
@ -98,18 +124,19 @@ public class UpgradeDao extends AbstractBaseDao {
logger.error(e.getMessage(),e);
throw new RuntimeException(e.getMessage(),e);
} finally {
MysqlUtils.releaseResource(null, null, conn);
ConnectionUtils.releaseResource(null, null, conn);
}
}
private void runInitEschedulerDDL() {
private void runInitDDL(String initSqlPath) {
Connection conn = null;
if (StringUtils.isEmpty(rootDir)) {
throw new RuntimeException("Environment variable user.dir not found");
}
String mysqlSQLFilePath = rootDir + "/sql/create/release-1.0.0_schema/mysql/escheduler_ddl.sql";
//String mysqlSQLFilePath = rootDir + "/sql/create/release-1.0.0_schema/mysql/dolphinscheduler_ddl.sql";
String mysqlSQLFilePath = rootDir + initSqlPath + "dolphinscheduler_ddl.sql";
try {
conn = ConnectionFactory.getDataSource().getConnection();
// Execute the escheduler_ddl.sql script to create the table structure of escheduler
@ -126,7 +153,7 @@ public class UpgradeDao extends AbstractBaseDao {
logger.error(e.getMessage(),e);
throw new RuntimeException(e.getMessage(),e);
} finally {
MysqlUtils.releaseResource(null, null, conn);
ConnectionUtils.releaseResource(null, null, conn);
}
@ -137,26 +164,7 @@ public class UpgradeDao extends AbstractBaseDao {
* @param tableName
* @return
*/
public boolean isExistsTable(String tableName) {
Connection conn = null;
try {
conn = ConnectionFactory.getDataSource().getConnection();
ResultSet rs = conn.getMetaData().getTables(null, null, tableName, null);
if (rs.next()) {
return true;
} else {
return false;
}
} catch (SQLException e) {
logger.error(e.getMessage(),e);
throw new RuntimeException(e.getMessage(),e);
} finally {
MysqlUtils.releaseResource(null, null, conn);
}
}
public abstract boolean isExistsTable(String tableName);
/**
* Determines whether a field exists in the specified table
@ -164,26 +172,7 @@ public class UpgradeDao extends AbstractBaseDao {
* @param columnName
* @return
*/
public boolean isExistsColumn(String tableName,String columnName) {
Connection conn = null;
try {
conn = ConnectionFactory.getDataSource().getConnection();
ResultSet rs = conn.getMetaData().getColumns(null,null,tableName,columnName);
if (rs.next()) {
return true;
} else {
return false;
}
} catch (SQLException e) {
logger.error(e.getMessage(),e);
throw new RuntimeException(e.getMessage(),e);
} finally {
MysqlUtils.releaseResource(null, null, conn);
}
}
public abstract boolean isExistsColumn(String tableName,String columnName);
public String getCurrentVersion() {
@ -207,26 +196,26 @@ public class UpgradeDao extends AbstractBaseDao {
logger.error(e.getMessage(),e);
throw new RuntimeException("sql: " + sql, e);
} finally {
MysqlUtils.releaseResource(rs, pstmt, conn);
ConnectionUtils.releaseResource(rs, pstmt, conn);
}
}
public void upgradeEscheduler(String schemaDir) {
public void upgradeDolphinScheduler(String schemaDir) {
upgradeEschedulerDDL(schemaDir);
upgradeDolphinSchedulerDDL(schemaDir);
upgradeEschedulerDML(schemaDir);
upgradeDolphinSchedulerDML(schemaDir);
}
private void upgradeEschedulerDML(String schemaDir) {
private void upgradeDolphinSchedulerDML(String schemaDir) {
String schemaVersion = schemaDir.split("_")[0];
if (StringUtils.isEmpty(rootDir)) {
throw new RuntimeException("Environment variable user.dir not found");
}
String mysqlSQLFilePath = rootDir + "/sql/upgrade/" + schemaDir + "/mysql/escheduler_dml.sql";
String mysqlSQLFilePath = MessageFormat.format("{0}/sql/upgrade/{1}/{2}/dolphinscheduler_dml.sql",rootDir,schemaDir,getDbType().name().toLowerCase());
logger.info("mysqlSQLFilePath"+mysqlSQLFilePath);
Connection conn = null;
PreparedStatement pstmt = null;
try {
@ -277,16 +266,16 @@ public class UpgradeDao extends AbstractBaseDao {
logger.error(e.getMessage(),e);
throw new RuntimeException(e.getMessage(),e);
} finally {
MysqlUtils.releaseResource(null, pstmt, conn);
ConnectionUtils.releaseResource(null, pstmt, conn);
}
}
private void upgradeEschedulerDDL(String schemaDir) {
private void upgradeDolphinSchedulerDDL(String schemaDir) {
if (StringUtils.isEmpty(rootDir)) {
throw new RuntimeException("Environment variable user.dir not found");
}
String mysqlSQLFilePath = rootDir + "/sql/upgrade/" + schemaDir + "/mysql/escheduler_ddl.sql";
String mysqlSQLFilePath = MessageFormat.format("{0}/sql/upgrade/{1}/{2}/dolphinscheduler_dml.sql",rootDir,schemaDir,getDbType().name().toLowerCase());
Connection conn = null;
PreparedStatement pstmt = null;
try {
@ -316,7 +305,7 @@ public class UpgradeDao extends AbstractBaseDao {
logger.error(e.getMessage(),e);
throw new RuntimeException(e.getMessage(),e);
} finally {
MysqlUtils.releaseResource(null, pstmt, conn);
ConnectionUtils.releaseResource(null, pstmt, conn);
}
}
@ -338,7 +327,7 @@ public class UpgradeDao extends AbstractBaseDao {
logger.error(e.getMessage(),e);
throw new RuntimeException("sql: " + upgradeSQL, e);
} finally {
MysqlUtils.releaseResource(null, pstmt, conn);
ConnectionUtils.releaseResource(null, pstmt, conn);
}
}

22
escheduler-dao/src/main/java/cn/escheduler/dao/upgrade/shell/CreateEscheduler.java → escheduler-dao/src/main/java/cn/escheduler/dao/upgrade/shell/CreateDolphinScheduler.java

@ -16,29 +16,29 @@
*/
package cn.escheduler.dao.upgrade.shell;
import cn.escheduler.dao.upgrade.EschedulerManager;
import cn.escheduler.dao.upgrade.DolphinSchedulerManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* init escheduler
* init DolphinScheduler
*
*/
public class CreateEscheduler {
public class CreateDolphinScheduler {
private static final Logger logger = LoggerFactory.getLogger(CreateEscheduler.class);
private static final Logger logger = LoggerFactory.getLogger(CreateDolphinScheduler.class);
public static void main(String[] args) {
EschedulerManager eschedulerManager = new EschedulerManager();
DolphinSchedulerManager dolphinSchedulerManager = new DolphinSchedulerManager();
try {
eschedulerManager.initEscheduler();
logger.info("init escheduler finished");
eschedulerManager.upgradeEscheduler();
logger.info("upgrade escheduler finished");
logger.info("create escheduler success");
dolphinSchedulerManager.initDolphinScheduler();
logger.info("init DolphinScheduler finished");
dolphinSchedulerManager.upgradeDolphinScheduler();
logger.info("upgrade DolphinScheduler finished");
logger.info("create DolphinScheduler success");
} catch (Exception e) {
logger.error("create escheduler failed",e);
logger.error("create DolphinScheduler failed",e);
}
}

16
escheduler-dao/src/main/java/cn/escheduler/dao/upgrade/shell/InitEscheduler.java → escheduler-dao/src/main/java/cn/escheduler/dao/upgrade/shell/InitDolphinScheduler.java

@ -16,23 +16,23 @@
*/
package cn.escheduler.dao.upgrade.shell;
import cn.escheduler.dao.upgrade.EschedulerManager;
import cn.escheduler.dao.upgrade.DolphinSchedulerManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* init escheduler
* init DolphinScheduler
*
*/
public class InitEscheduler {
public class InitDolphinScheduler {
private static final Logger logger = LoggerFactory.getLogger(InitEscheduler.class);
private static final Logger logger = LoggerFactory.getLogger(InitDolphinScheduler.class);
public static void main(String[] args) {
Thread.currentThread().setName("manager-InitEscheduler");
EschedulerManager eschedulerManager = new EschedulerManager();
eschedulerManager.initEscheduler();
logger.info("init escheduler finished");
Thread.currentThread().setName("manager-InitDolphinScheduler");
DolphinSchedulerManager dolphinSchedulerManager = new DolphinSchedulerManager();
dolphinSchedulerManager.initDolphinScheduler();
logger.info("init DolphinScheduler finished");
}
}

18
escheduler-dao/src/main/java/cn/escheduler/dao/upgrade/shell/UpgradeEscheduler.java → escheduler-dao/src/main/java/cn/escheduler/dao/upgrade/shell/UpgradeDolphinScheduler.java

@ -16,28 +16,26 @@
*/
package cn.escheduler.dao.upgrade.shell;
import cn.escheduler.dao.upgrade.EschedulerManager;
import cn.escheduler.dao.upgrade.DolphinSchedulerManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* upgrade escheduler database
* upgrade DolphinScheduler database
*/
public class UpgradeEscheduler {
private static final Logger logger = LoggerFactory.getLogger(UpgradeEscheduler.class);
public class UpgradeDolphinScheduler {
private static final Logger logger = LoggerFactory.getLogger(UpgradeDolphinScheduler.class);
public static void main(String[] args) {
EschedulerManager eschedulerManager = new EschedulerManager();
DolphinSchedulerManager dolphinSchedulerManager = new DolphinSchedulerManager();
try {
eschedulerManager.upgradeEscheduler();
logger.info("upgrade escheduler success");
dolphinSchedulerManager.upgradeDolphinScheduler();
logger.info("upgrade DolphinScheduler success");
} catch (Exception e) {
logger.error(e.getMessage(),e);
logger.info("Upgrade escheduler failed");
logger.info("Upgrade DolphinScheduler failed");
throw new RuntimeException(e);
}
}

2
script/create_escheduler.sh

@ -13,7 +13,7 @@ export ESCHEDULER_LIB_JARS=$ESCHEDULER_HOME/lib/*
export ESCHEDULER_OPTS="-server -Xmx1g -Xms1g -Xss512k -XX:+DisableExplicitGC -XX:+UseConcMarkSweepGC -XX:+CMSParallelRemarkEnabled -XX:LargePageSizeInBytes=128m -XX:+UseFastAccessorMethods -XX:+UseCMSInitiatingOccupancyOnly -XX:CMSInitiatingOccupancyFraction=70"
export STOP_TIMEOUT=5
CLASS=cn.escheduler.dao.upgrade.shell.CreateEscheduler
CLASS=cn.escheduler.dao.upgrade.shell.CreateDolphinScheduler
exec_command="$ESCHEDULER_OPTS -classpath $ESCHEDULER_CONF_DIR:$ESCHEDULER_LIB_JARS $CLASS"

2
script/upgrade_escheduler.sh

@ -13,7 +13,7 @@ export ESCHEDULER_LIB_JARS=$ESCHEDULER_HOME/lib/*
export ESCHEDULER_OPTS="-server -Xmx1g -Xms1g -Xss512k -XX:+DisableExplicitGC -XX:+UseConcMarkSweepGC -XX:+CMSParallelRemarkEnabled -XX:LargePageSizeInBytes=128m -XX:+UseFastAccessorMethods -XX:+UseCMSInitiatingOccupancyOnly -XX:CMSInitiatingOccupancyFraction=70"
export STOP_TIMEOUT=5
CLASS=cn.escheduler.dao.upgrade.shell.UpgradeEscheduler
CLASS=cn.escheduler.dao.upgrade.shell.UpgradeDolphinScheduler
exec_command="$ESCHEDULER_OPTS -classpath $ESCHEDULER_CONF_DIR:$ESCHEDULER_LIB_JARS $CLASS"

0
sql/create/release-1.0.0_schema/mysql/escheduler_ddl.sql → sql/create/release-1.0.0_schema/mysql/dolphinscheduler_ddl.sql

0
sql/create/release-1.0.0_schema/mysql/escheduler_dml.sql → sql/create/release-1.0.0_schema/mysql/dolphinscheduler_dml.sql

804
sql/create/release-1.2.0_schema/postgresql/dolphinscheduler_ddl.sql

@ -0,0 +1,804 @@
DROP TABLE IF EXISTS QRTZ_BLOB_TRIGGERS;
CREATE TABLE QRTZ_BLOB_TRIGGERS (
SCHED_NAME varchar(120) NOT NULL,
TRIGGER_NAME varchar(200) NOT NULL,
TRIGGER_GROUP varchar(200) NOT NULL,
BLOB_DATA bytea NULL,
PRIMARY KEY (SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP)
);
--
-- Table structure for table QRTZ_CALENDARS
--
DROP TABLE IF EXISTS QRTZ_CALENDARS;
CREATE TABLE QRTZ_CALENDARS (
SCHED_NAME varchar(120) NOT NULL,
CALENDAR_NAME varchar(200) NOT NULL,
CALENDAR bytea NOT NULL,
PRIMARY KEY (SCHED_NAME,CALENDAR_NAME)
);
--
-- Table structure for table QRTZ_CRON_TRIGGERS
--
DROP TABLE IF EXISTS QRTZ_CRON_TRIGGERS;
CREATE TABLE QRTZ_CRON_TRIGGERS (
SCHED_NAME varchar(120) NOT NULL,
TRIGGER_NAME varchar(200) NOT NULL,
TRIGGER_GROUP varchar(200) NOT NULL,
CRON_EXPRESSION varchar(120) NOT NULL,
TIME_ZONE_ID varchar(80) DEFAULT NULL,
PRIMARY KEY (SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP)
);
--
-- Table structure for table QRTZ_FIRED_TRIGGERS
--
DROP TABLE IF EXISTS QRTZ_FIRED_TRIGGERS;
CREATE TABLE QRTZ_FIRED_TRIGGERS (
SCHED_NAME varchar(120) NOT NULL,
ENTRY_ID varchar(95) NOT NULL,
TRIGGER_NAME varchar(200) NOT NULL,
TRIGGER_GROUP varchar(200) NOT NULL,
INSTANCE_NAME varchar(200) NOT NULL,
FIRED_TIME bigint NOT NULL,
SCHED_TIME bigint NOT NULL,
PRIORITY int NOT NULL,
STATE varchar(16) NOT NULL,
JOB_NAME varchar(200) DEFAULT NULL,
JOB_GROUP varchar(200) DEFAULT NULL,
IS_NONCONCURRENT varchar(1) DEFAULT NULL,
REQUESTS_RECOVERY varchar(1) DEFAULT NULL,
PRIMARY KEY (SCHED_NAME,ENTRY_ID)
) ;
create index IDX_QRTZ_FT_TRIG_INST_NAME on QRTZ_FIRED_TRIGGERS (SCHED_NAME,INSTANCE_NAME);
create index IDX_QRTZ_FT_INST_JOB_REQ_RCVRY on QRTZ_FIRED_TRIGGERS(SCHED_NAME,INSTANCE_NAME,REQUESTS_RECOVERY);
create index IDX_QRTZ_FT_J_G on QRTZ_FIRED_TRIGGERS(SCHED_NAME,JOB_NAME,JOB_GROUP);
create index IDX_QRTZ_FT_JG on QRTZ_FIRED_TRIGGERS (SCHED_NAME,JOB_GROUP);
create index IDX_QRTZ_FT_T_G on QRTZ_FIRED_TRIGGERS (SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP);
create index IDX_QRTZ_FT_TG on QRTZ_FIRED_TRIGGERS(SCHED_NAME,TRIGGER_GROUP);
--
-- Table structure for table QRTZ_LOCKS
--
DROP TABLE IF EXISTS QRTZ_LOCKS;
CREATE TABLE QRTZ_LOCKS (
SCHED_NAME varchar(120) NOT NULL,
LOCK_NAME varchar(40) NOT NULL,
PRIMARY KEY (SCHED_NAME,LOCK_NAME)
) ;
--
-- Table structure for table QRTZ_PAUSED_TRIGGER_GRPS
--
DROP TABLE IF EXISTS QRTZ_PAUSED_TRIGGER_GRPS;
CREATE TABLE QRTZ_PAUSED_TRIGGER_GRPS (
SCHED_NAME varchar(120) NOT NULL,
TRIGGER_GROUP varchar(200) NOT NULL,
PRIMARY KEY (SCHED_NAME,TRIGGER_GROUP)
) ;
--
-- Table structure for table QRTZ_SCHEDULER_STATE
--
DROP TABLE IF EXISTS QRTZ_SCHEDULER_STATE;
CREATE TABLE QRTZ_SCHEDULER_STATE (
SCHED_NAME varchar(120) NOT NULL,
INSTANCE_NAME varchar(200) NOT NULL,
LAST_CHECKIN_TIME bigint NOT NULL,
CHECKIN_INTERVAL bigint NOT NULL,
PRIMARY KEY (SCHED_NAME,INSTANCE_NAME)
) ;
--
-- Table structure for table QRTZ_SIMPLE_TRIGGERS
--
DROP TABLE IF EXISTS QRTZ_SIMPLE_TRIGGERS;
CREATE TABLE QRTZ_SIMPLE_TRIGGERS (
SCHED_NAME varchar(120) NOT NULL,
TRIGGER_NAME varchar(200) NOT NULL,
TRIGGER_GROUP varchar(200) NOT NULL,
REPEAT_COUNT bigint NOT NULL,
REPEAT_INTERVAL bigint NOT NULL,
TIMES_TRIGGERED bigint NOT NULL,
PRIMARY KEY (SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP)
) ;
--
-- Table structure for table QRTZ_SIMPROP_TRIGGERS
--
DROP TABLE IF EXISTS QRTZ_SIMPROP_TRIGGERS;
CREATE TABLE QRTZ_SIMPROP_TRIGGERS (
SCHED_NAME varchar(120) NOT NULL,
TRIGGER_NAME varchar(200) NOT NULL,
TRIGGER_GROUP varchar(200) NOT NULL,
STR_PROP_1 varchar(512) DEFAULT NULL,
STR_PROP_2 varchar(512) DEFAULT NULL,
STR_PROP_3 varchar(512) DEFAULT NULL,
INT_PROP_1 int DEFAULT NULL,
INT_PROP_2 int DEFAULT NULL,
LONG_PROP_1 bigint DEFAULT NULL,
LONG_PROP_2 bigint DEFAULT NULL,
DEC_PROP_1 decimal(13,4) DEFAULT NULL,
DEC_PROP_2 decimal(13,4) DEFAULT NULL,
BOOL_PROP_1 varchar(1) DEFAULT NULL,
BOOL_PROP_2 varchar(1) DEFAULT NULL,
PRIMARY KEY (SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP)
) ;
--
-- Table structure for table QRTZ_TRIGGERS
--
DROP TABLE IF EXISTS QRTZ_TRIGGERS;
CREATE TABLE QRTZ_TRIGGERS (
SCHED_NAME varchar(120) NOT NULL,
TRIGGER_NAME varchar(200) NOT NULL,
TRIGGER_GROUP varchar(200) NOT NULL,
JOB_NAME varchar(200) NOT NULL,
JOB_GROUP varchar(200) NOT NULL,
DESCRIPTION varchar(250) DEFAULT NULL,
NEXT_FIRE_TIME bigint DEFAULT NULL,
PREV_FIRE_TIME bigint DEFAULT NULL,
PRIORITY int DEFAULT NULL,
TRIGGER_STATE varchar(16) NOT NULL,
TRIGGER_TYPE varchar(8) NOT NULL,
START_TIME bigint NOT NULL,
END_TIME bigint DEFAULT NULL,
CALENDAR_NAME varchar(200) DEFAULT NULL,
MISFIRE_INSTR smallint DEFAULT NULL,
JOB_DATA bytea,
PRIMARY KEY (SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP)
) ;
create index IDX_QRTZ_T_J on QRTZ_TRIGGERS (SCHED_NAME,JOB_NAME,JOB_GROUP);
create index IDX_QRTZ_T_JG on QRTZ_TRIGGERS (SCHED_NAME,JOB_GROUP);
create index IDX_QRTZ_T_C on QRTZ_TRIGGERS (SCHED_NAME,CALENDAR_NAME);
create index IDX_QRTZ_T_G on QRTZ_TRIGGERS (SCHED_NAME,TRIGGER_GROUP);
create index IDX_QRTZ_T_STATE on QRTZ_TRIGGERS (SCHED_NAME,TRIGGER_STATE);
create index IDX_QRTZ_T_N_STATE on QRTZ_TRIGGERS (SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP,TRIGGER_STATE);
create index IDX_QRTZ_T_N_G_STATE on QRTZ_TRIGGERS (SCHED_NAME,TRIGGER_GROUP,TRIGGER_STATE);
create index IDX_QRTZ_T_NEXT_FIRE_TIME on QRTZ_TRIGGERS (SCHED_NAME,NEXT_FIRE_TIME);
create index IDX_QRTZ_T_NFT_ST on QRTZ_TRIGGERS (SCHED_NAME,TRIGGER_STATE,NEXT_FIRE_TIME);
create index IDX_QRTZ_T_NFT_MISFIRE on QRTZ_TRIGGERS (SCHED_NAME,MISFIRE_INSTR,NEXT_FIRE_TIME);
create index IDX_QRTZ_T_NFT_ST_MISFIRE on QRTZ_TRIGGERS (SCHED_NAME,MISFIRE_INSTR,NEXT_FIRE_TIME,TRIGGER_STATE);
create index IDX_QRTZ_T_NFT_ST_MISFIRE_GRP on QRTZ_TRIGGERS (SCHED_NAME,MISFIRE_INSTR,NEXT_FIRE_TIME,TRIGGER_GROUP,TRIGGER_STATE);
--
-- Table structure for table QRTZ_JOB_DETAILS
--
DROP TABLE IF EXISTS QRTZ_JOB_DETAILS;
CREATE TABLE QRTZ_JOB_DETAILS (
SCHED_NAME varchar(120) NOT NULL,
JOB_NAME varchar(200) NOT NULL,
JOB_GROUP varchar(200) NOT NULL,
DESCRIPTION varchar(250) DEFAULT NULL,
JOB_CLASS_NAME varchar(250) NOT NULL,
IS_DURABLE varchar(1) NOT NULL,
IS_NONCONCURRENT varchar(1) NOT NULL,
IS_UPDATE_DATA varchar(1) NOT NULL,
REQUESTS_RECOVERY varchar(1) NOT NULL,
JOB_DATA bytea,
PRIMARY KEY (SCHED_NAME,JOB_NAME,JOB_GROUP)
) ;
create index IDX_QRTZ_J_REQ_RECOVERY on QRTZ_JOB_DETAILS (SCHED_NAME,REQUESTS_RECOVERY);
create index IDX_QRTZ_J_GRP on QRTZ_JOB_DETAILS (SCHED_NAME,JOB_GROUP);
alter table QRTZ_BLOB_TRIGGERS drop CONSTRAINT if EXISTS QRTZ_BLOB_TRIGGERS_ibfk_1;
alter table QRTZ_BLOB_TRIGGERS add CONSTRAINT QRTZ_BLOB_TRIGGERS_ibfk_1 FOREIGN KEY (SCHED_NAME, TRIGGER_NAME, TRIGGER_GROUP) REFERENCES QRTZ_TRIGGERS (SCHED_NAME, TRIGGER_NAME, TRIGGER_GROUP);
alter table QRTZ_CRON_TRIGGERS drop CONSTRAINT if EXISTS QRTZ_CRON_TRIGGERS_ibfk_1;
alter table QRTZ_CRON_TRIGGERS add CONSTRAINT QRTZ_CRON_TRIGGERS_ibfk_1 FOREIGN KEY (SCHED_NAME, TRIGGER_NAME, TRIGGER_GROUP) REFERENCES QRTZ_TRIGGERS (SCHED_NAME, TRIGGER_NAME, TRIGGER_GROUP);
alter table QRTZ_SIMPLE_TRIGGERS drop CONSTRAINT if EXISTS QRTZ_SIMPLE_TRIGGERS_ibfk_1;
alter table QRTZ_SIMPLE_TRIGGERS add CONSTRAINT QRTZ_SIMPLE_TRIGGERS_ibfk_1 FOREIGN KEY (SCHED_NAME, TRIGGER_NAME, TRIGGER_GROUP) REFERENCES QRTZ_TRIGGERS (SCHED_NAME, TRIGGER_NAME, TRIGGER_GROUP);
alter table QRTZ_SIMPROP_TRIGGERS drop CONSTRAINT if EXISTS QRTZ_SIMPROP_TRIGGERS_ibfk_1;
alter table QRTZ_SIMPROP_TRIGGERS add CONSTRAINT QRTZ_SIMPROP_TRIGGERS_ibfk_1 FOREIGN KEY (SCHED_NAME, TRIGGER_NAME, TRIGGER_GROUP) REFERENCES QRTZ_TRIGGERS (SCHED_NAME, TRIGGER_NAME, TRIGGER_GROUP);
alter table QRTZ_TRIGGERS drop CONSTRAINT if EXISTS QRTZ_TRIGGERS_ibfk_1;
alter table QRTZ_TRIGGERS add CONSTRAINT QRTZ_TRIGGERS_ibfk_1 FOREIGN KEY (SCHED_NAME, JOB_NAME, JOB_GROUP) REFERENCES QRTZ_JOB_DETAILS (SCHED_NAME, JOB_NAME, JOB_GROUP);
--
-- Table structure for table t_escheduler_access_token
--
DROP TABLE IF EXISTS t_escheduler_access_token;
CREATE TABLE t_escheduler_access_token (
id int NOT NULL ,
user_id int DEFAULT NULL ,
token varchar(64) DEFAULT NULL ,
expire_time timestamp DEFAULT NULL ,
create_time timestamp DEFAULT NULL ,
update_time timestamp DEFAULT NULL ,
PRIMARY KEY (id)
) ;
--
-- Table structure for table t_escheduler_alert
--
DROP TABLE IF EXISTS t_escheduler_alert;
CREATE TABLE t_escheduler_alert (
id int NOT NULL ,
title varchar(64) DEFAULT NULL ,
show_type int DEFAULT NULL ,
content text ,
alert_type int DEFAULT NULL ,
alert_status int DEFAULT '0' ,
log text ,
alertgroup_id int DEFAULT NULL ,
receivers text ,
receivers_cc text ,
create_time timestamp DEFAULT NULL ,
update_time timestamp DEFAULT NULL ,
PRIMARY KEY (id)
) ;
--
-- Table structure for table t_escheduler_alertgroup
--
DROP TABLE IF EXISTS t_escheduler_alertgroup;
CREATE TABLE t_escheduler_alertgroup (
id int NOT NULL ,
group_name varchar(255) DEFAULT NULL ,
group_type int DEFAULT NULL ,
"desc" varchar(255) DEFAULT NULL ,
create_time timestamp DEFAULT NULL ,
update_time timestamp DEFAULT NULL ,
PRIMARY KEY (id)
) ;
--
-- Table structure for table t_escheduler_command
--
DROP TABLE IF EXISTS t_escheduler_command;
CREATE TABLE t_escheduler_command (
id int NOT NULL ,
command_type int DEFAULT NULL ,
process_definition_id int DEFAULT NULL ,
command_param text ,
task_depend_type int DEFAULT NULL ,
failure_strategy int DEFAULT '0' ,
warning_type int DEFAULT '0' ,
warning_group_id int DEFAULT NULL ,
schedule_time timestamp DEFAULT NULL ,
start_time timestamp DEFAULT NULL ,
executor_id int DEFAULT NULL ,
dependence varchar(255) DEFAULT NULL ,
update_time timestamp DEFAULT NULL ,
process_instance_priority int DEFAULT NULL ,
worker_group_id int DEFAULT '-1' ,
PRIMARY KEY (id)
) ;
--
-- Table structure for table t_escheduler_datasource
--
DROP TABLE IF EXISTS t_escheduler_datasource;
CREATE TABLE t_escheduler_datasource (
id int NOT NULL ,
name varchar(64) NOT NULL ,
note varchar(256) DEFAULT NULL ,
type int NOT NULL ,
user_id int NOT NULL ,
connection_params text NOT NULL ,
create_time timestamp NOT NULL ,
update_time timestamp DEFAULT NULL ,
PRIMARY KEY (id)
) ;
--
-- Table structure for table t_escheduler_error_command
--
DROP TABLE IF EXISTS t_escheduler_error_command;
CREATE TABLE t_escheduler_error_command (
id int NOT NULL ,
command_type int DEFAULT NULL ,
executor_id int DEFAULT NULL ,
process_definition_id int DEFAULT NULL ,
command_param text ,
task_depend_type int DEFAULT NULL ,
failure_strategy int DEFAULT '0' ,
warning_type int DEFAULT '0' ,
warning_group_id int DEFAULT NULL ,
schedule_time timestamp DEFAULT NULL ,
start_time timestamp DEFAULT NULL ,
update_time timestamp DEFAULT NULL ,
dependence text ,
process_instance_priority int DEFAULT NULL ,
worker_group_id int DEFAULT '-1' ,
message text ,
PRIMARY KEY (id)
);
--
-- Table structure for table t_escheduler_master_server
--
DROP TABLE IF EXISTS t_escheduler_master_server;
CREATE TABLE t_escheduler_master_server (
id int NOT NULL ,
host varchar(45) DEFAULT NULL ,
port int DEFAULT NULL ,
zk_directory varchar(64) DEFAULT NULL ,
res_info varchar(256) DEFAULT NULL ,
create_time timestamp DEFAULT NULL ,
last_heartbeat_time timestamp DEFAULT NULL ,
PRIMARY KEY (id)
) ;
--
-- Table structure for table t_escheduler_process_definition
--
DROP TABLE IF EXISTS t_escheduler_process_definition;
CREATE TABLE t_escheduler_process_definition (
id int NOT NULL ,
name varchar(255) DEFAULT NULL ,
version int DEFAULT NULL ,
release_state int DEFAULT NULL ,
project_id int DEFAULT NULL ,
user_id int DEFAULT NULL ,
process_definition_json text ,
"desc" text ,
global_params text ,
flag int DEFAULT NULL ,
locations text ,
connects text ,
receivers text ,
receivers_cc text ,
create_time timestamp DEFAULT NULL ,
timeout int DEFAULT '0' ,
tenant_id int NOT NULL DEFAULT '-1' ,
update_time timestamp DEFAULT NULL ,
PRIMARY KEY (id)
) ;
create index process_definition_index on t_escheduler_process_definition (project_id,id);
--
-- Table structure for table t_escheduler_process_instance
--
DROP TABLE IF EXISTS t_escheduler_process_instance;
CREATE TABLE t_escheduler_process_instance (
id int NOT NULL ,
name varchar(255) DEFAULT NULL ,
process_definition_id int DEFAULT NULL ,
state int DEFAULT NULL ,
recovery int DEFAULT NULL ,
start_time timestamp DEFAULT NULL ,
end_time timestamp DEFAULT NULL ,
run_times int DEFAULT NULL ,
host varchar(45) DEFAULT NULL ,
command_type int DEFAULT NULL ,
command_param text ,
task_depend_type int DEFAULT NULL ,
max_try_times int DEFAULT '0' ,
failure_strategy int DEFAULT '0' ,
warning_type int DEFAULT '0' ,
warning_group_id int DEFAULT NULL ,
schedule_time timestamp DEFAULT NULL ,
command_start_time timestamp DEFAULT NULL ,
global_params text ,
process_instance_json text ,
flag int DEFAULT '1' ,
update_time timestamp NULL ,
is_sub_process int DEFAULT '0' ,
executor_id int NOT NULL ,
locations text ,
connects text ,
history_cmd text ,
dependence_schedule_times text ,
process_instance_priority int DEFAULT NULL ,
worker_group_id int DEFAULT '-1' ,
timeout int DEFAULT '0' ,
tenant_id int NOT NULL DEFAULT '-1' ,
PRIMARY KEY (id)
) ;
create index process_instance_index on t_escheduler_process_instance (process_definition_id,id);
create index start_time_index on t_escheduler_process_instance (start_time);
--
-- Table structure for table t_escheduler_project
--
DROP TABLE IF EXISTS t_escheduler_project;
CREATE TABLE t_escheduler_project (
id int NOT NULL ,
name varchar(100) DEFAULT NULL ,
desc varchar(200) DEFAULT NULL ,
user_id int DEFAULT NULL ,
flag int DEFAULT '1' ,
create_time timestamp DEFAULT CURRENT_TIMESTAMP ,
update_time timestamp DEFAULT CURRENT_TIMESTAMP ,
PRIMARY KEY (id)
) ;
create index user_id_index on t_escheduler_project (user_id);
--
-- Table structure for table t_escheduler_queue
--
DROP TABLE IF EXISTS t_escheduler_queue;
CREATE TABLE t_escheduler_queue (
id int NOT NULL ,
queue_name varchar(64) DEFAULT NULL ,
queue varchar(64) DEFAULT NULL ,
create_time timestamp DEFAULT NULL ,
update_time timestamp DEFAULT NULL ,
PRIMARY KEY (id)
);
--
-- Table structure for table t_escheduler_relation_datasource_user
--
DROP TABLE IF EXISTS t_escheduler_relation_datasource_user;
CREATE TABLE t_escheduler_relation_datasource_user (
id int NOT NULL ,
user_id int NOT NULL ,
datasource_id int DEFAULT NULL ,
perm int DEFAULT '1' ,
create_time timestamp DEFAULT NULL ,
update_time timestamp DEFAULT NULL ,
PRIMARY KEY (id)
) ;
;
--
-- Table structure for table t_escheduler_relation_process_instance
--
DROP TABLE IF EXISTS t_escheduler_relation_process_instance;
CREATE TABLE t_escheduler_relation_process_instance (
id int NOT NULL ,
parent_process_instance_id int DEFAULT NULL ,
parent_task_instance_id int DEFAULT NULL ,
process_instance_id int DEFAULT NULL ,
PRIMARY KEY (id)
) ;
--
-- Table structure for table t_escheduler_relation_project_user
--
DROP TABLE IF EXISTS t_escheduler_relation_project_user;
CREATE TABLE t_escheduler_relation_project_user (
id int NOT NULL ,
user_id int NOT NULL ,
project_id int DEFAULT NULL ,
perm int DEFAULT '1' ,
create_time timestamp DEFAULT NULL ,
update_time timestamp DEFAULT NULL ,
PRIMARY KEY (id)
) ;
create index relation_project_user_id_index on t_escheduler_relation_project_user (user_id);
--
-- Table structure for table t_escheduler_relation_resources_user
--
DROP TABLE IF EXISTS t_escheduler_relation_resources_user;
CREATE TABLE t_escheduler_relation_resources_user (
id int NOT NULL ,
user_id int NOT NULL ,
resources_id int DEFAULT NULL ,
perm int DEFAULT '1' ,
create_time timestamp DEFAULT NULL ,
update_time timestamp DEFAULT NULL ,
PRIMARY KEY (id)
) ;
--
-- Table structure for table t_escheduler_relation_udfs_user
--
DROP TABLE IF EXISTS t_escheduler_relation_udfs_user;
CREATE TABLE t_escheduler_relation_udfs_user (
id int NOT NULL ,
user_id int NOT NULL ,
udf_id int DEFAULT NULL ,
perm int DEFAULT '1' ,
create_time timestamp DEFAULT NULL ,
update_time timestamp DEFAULT NULL ,
PRIMARY KEY (id)
) ;
;
--
-- Table structure for table t_escheduler_relation_user_alertgroup
--
DROP TABLE IF EXISTS t_escheduler_relation_user_alertgroup;
CREATE TABLE t_escheduler_relation_user_alertgroup (
id int NOT NULL,
alertgroup_id int DEFAULT NULL,
user_id int DEFAULT NULL,
create_time timestamp DEFAULT NULL,
update_time timestamp DEFAULT NULL,
PRIMARY KEY (id)
);
--
-- Table structure for table t_escheduler_resources
--
DROP TABLE IF EXISTS t_escheduler_resources;
CREATE TABLE t_escheduler_resources (
id int NOT NULL ,
alias varchar(64) DEFAULT NULL ,
file_name varchar(64) DEFAULT NULL ,
"desc" varchar(256) DEFAULT NULL ,
user_id int DEFAULT NULL ,
type int DEFAULT NULL ,
size bigint DEFAULT NULL ,
create_time timestamp DEFAULT NULL ,
update_time timestamp DEFAULT NULL ,
PRIMARY KEY (id)
) ;
;
--
-- Table structure for table t_escheduler_schedules
--
DROP TABLE IF EXISTS t_escheduler_schedules;
CREATE TABLE t_escheduler_schedules (
id int NOT NULL ,
process_definition_id int NOT NULL ,
start_time timestamp NOT NULL ,
end_time timestamp NOT NULL ,
crontab varchar(256) NOT NULL ,
failure_strategy int NOT NULL ,
user_id int NOT NULL ,
release_state int NOT NULL ,
warning_type int NOT NULL ,
warning_group_id int DEFAULT NULL ,
process_instance_priority int DEFAULT NULL ,
worker_group_id int DEFAULT '-1' ,
create_time timestamp NOT NULL ,
update_time timestamp NOT NULL ,
PRIMARY KEY (id)
);
--
-- Table structure for table t_escheduler_session
--
DROP TABLE IF EXISTS t_escheduler_session;
CREATE TABLE t_escheduler_session (
id varchar(64) NOT NULL ,
user_id int DEFAULT NULL ,
ip varchar(45) DEFAULT NULL ,
last_login_time timestamp DEFAULT NULL ,
PRIMARY KEY (id)
);
--
-- Table structure for table t_escheduler_task_instance
--
DROP TABLE IF EXISTS t_escheduler_task_instance;
CREATE TABLE t_escheduler_task_instance (
id int NOT NULL ,
name varchar(255) DEFAULT NULL ,
task_type varchar(64) DEFAULT NULL ,
process_definition_id int DEFAULT NULL ,
process_instance_id int DEFAULT NULL ,
task_json text ,
state int DEFAULT NULL ,
submit_time timestamp DEFAULT NULL ,
start_time timestamp DEFAULT NULL ,
end_time timestamp DEFAULT NULL ,
host varchar(45) DEFAULT NULL ,
execute_path varchar(200) DEFAULT NULL ,
log_path varchar(200) DEFAULT NULL ,
alert_flag int DEFAULT NULL ,
retry_times int DEFAULT '0' ,
pid int DEFAULT NULL ,
app_link varchar(255) DEFAULT NULL ,
flag int DEFAULT '1' ,
retry_interval int DEFAULT NULL ,
max_retry_times int DEFAULT NULL ,
task_instance_priority int DEFAULT NULL ,
worker_group_id int DEFAULT '-1' ,
PRIMARY KEY (id)
) ;
--
-- Table structure for table t_escheduler_tenant
--
DROP TABLE IF EXISTS t_escheduler_tenant;
CREATE TABLE t_escheduler_tenant (
id int NOT NULL ,
tenant_code varchar(64) DEFAULT NULL ,
tenant_name varchar(64) DEFAULT NULL ,
"desc" varchar(256) DEFAULT NULL ,
queue_id int DEFAULT NULL ,
create_time timestamp DEFAULT NULL ,
update_time timestamp DEFAULT NULL ,
PRIMARY KEY (id)
) ;
--
-- Table structure for table t_escheduler_udfs
--
DROP TABLE IF EXISTS t_escheduler_udfs;
CREATE TABLE t_escheduler_udfs (
id int NOT NULL ,
user_id int NOT NULL ,
func_name varchar(100) NOT NULL ,
class_name varchar(255) NOT NULL ,
type int NOT NULL ,
arg_types varchar(255) DEFAULT NULL ,
database varchar(255) DEFAULT NULL ,
"desc" varchar(255) DEFAULT NULL ,
resource_id int NOT NULL ,
resource_name varchar(255) NOT NULL ,
create_time timestamp NOT NULL ,
update_time timestamp NOT NULL ,
PRIMARY KEY (id)
) ;
--
-- Table structure for table t_escheduler_user
--
DROP TABLE IF EXISTS t_escheduler_user;
CREATE TABLE t_escheduler_user (
id int NOT NULL ,
user_name varchar(64) DEFAULT NULL ,
user_password varchar(64) DEFAULT NULL ,
user_type int DEFAULT NULL ,
email varchar(64) DEFAULT NULL ,
phone varchar(11) DEFAULT NULL ,
tenant_id int DEFAULT NULL ,
create_time timestamp DEFAULT NULL ,
update_time timestamp DEFAULT NULL ,
queue varchar(64) DEFAULT NULL ,
PRIMARY KEY (id)
);
--
-- Table structure for table t_escheduler_version
--
DROP TABLE IF EXISTS t_escheduler_version;
CREATE TABLE t_escheduler_version (
id int NOT NULL ,
version varchar(200) NOT NULL,
PRIMARY KEY (id)
) ;
create index version_index on t_escheduler_version(version);
--
-- Table structure for table t_escheduler_worker_group
--
DROP TABLE IF EXISTS t_escheduler_worker_group;
CREATE TABLE t_escheduler_worker_group (
id bigint NOT NULL ,
name varchar(256) DEFAULT NULL ,
ip_list varchar(256) DEFAULT NULL ,
create_time timestamp DEFAULT NULL ,
update_time timestamp DEFAULT NULL ,
PRIMARY KEY (id)
) ;
--
-- Table structure for table t_escheduler_worker_server
--
DROP TABLE IF EXISTS t_escheduler_worker_server;
CREATE TABLE t_escheduler_worker_server (
id int NOT NULL ,
host varchar(45) DEFAULT NULL ,
port int DEFAULT NULL ,
zk_directory varchar(64) DEFAULT NULL ,
res_info varchar(255) DEFAULT NULL ,
create_time timestamp DEFAULT NULL ,
last_heartbeat_time timestamp DEFAULT NULL ,
PRIMARY KEY (id)
) ;
DROP SEQUENCE IF EXISTS t_escheduler_access_token_id_sequence;
CREATE SEQUENCE t_escheduler_access_token_id_sequence;
ALTER TABLE t_escheduler_access_token ALTER COLUMN id SET DEFAULT NEXTVAL('t_escheduler_access_token_id_sequence');
DROP SEQUENCE IF EXISTS t_escheduler_alert_id_sequence;
CREATE SEQUENCE t_escheduler_alert_id_sequence;
ALTER TABLE t_escheduler_alert ALTER COLUMN id SET DEFAULT NEXTVAL('t_escheduler_alert_id_sequence');
DROP SEQUENCE IF EXISTS t_escheduler_alertgroup_id_sequence;
CREATE SEQUENCE t_escheduler_alertgroup_id_sequence;
ALTER TABLE t_escheduler_alertgroup ALTER COLUMN id SET DEFAULT NEXTVAL('t_escheduler_alertgroup_id_sequence');
DROP SEQUENCE IF EXISTS t_escheduler_command_id_sequence;
CREATE SEQUENCE t_escheduler_command_id_sequence;
ALTER TABLE t_escheduler_command ALTER COLUMN id SET DEFAULT NEXTVAL('t_escheduler_command_id_sequence');
DROP SEQUENCE IF EXISTS t_escheduler_datasource_id_sequence;
CREATE SEQUENCE t_escheduler_datasource_id_sequence;
ALTER TABLE t_escheduler_datasource ALTER COLUMN id SET DEFAULT NEXTVAL('t_escheduler_datasource_id_sequence');
DROP SEQUENCE IF EXISTS t_escheduler_master_server_id_sequence;
CREATE SEQUENCE t_escheduler_master_server_id_sequence;
ALTER TABLE t_escheduler_master_server ALTER COLUMN id SET DEFAULT NEXTVAL('t_escheduler_master_server_id_sequence');
DROP SEQUENCE IF EXISTS t_escheduler_process_definition_id_sequence;
CREATE SEQUENCE t_escheduler_process_definition_id_sequence;
ALTER TABLE t_escheduler_process_definition ALTER COLUMN id SET DEFAULT NEXTVAL('t_escheduler_process_definition_id_sequence');
DROP SEQUENCE IF EXISTS t_escheduler_process_instance_id_sequence;
CREATE SEQUENCE t_escheduler_process_instance_id_sequence;
ALTER TABLE t_escheduler_process_instance ALTER COLUMN id SET DEFAULT NEXTVAL('t_escheduler_process_instance_id_sequence');
DROP SEQUENCE IF EXISTS t_escheduler_project_id_sequence;
CREATE SEQUENCE t_escheduler_project_id_sequence;
ALTER TABLE t_escheduler_project ALTER COLUMN id SET DEFAULT NEXTVAL('t_escheduler_project_id_sequence');
DROP SEQUENCE IF EXISTS t_escheduler_queue_id_sequence;
CREATE SEQUENCE t_escheduler_queue_id_sequence;
ALTER TABLE t_escheduler_queue ALTER COLUMN id SET DEFAULT NEXTVAL('t_escheduler_queue_id_sequence');
DROP SEQUENCE IF EXISTS t_escheduler_relation_datasource_user_id_sequence;
CREATE SEQUENCE t_escheduler_relation_datasource_user_id_sequence;
ALTER TABLE t_escheduler_relation_datasource_user ALTER COLUMN id SET DEFAULT NEXTVAL('t_escheduler_relation_datasource_user_id_sequence');
DROP SEQUENCE IF EXISTS t_escheduler_relation_process_instance_id_sequence;
CREATE SEQUENCE t_escheduler_relation_process_instance_id_sequence;
ALTER TABLE t_escheduler_relation_process_instance ALTER COLUMN id SET DEFAULT NEXTVAL('t_escheduler_relation_process_instance_id_sequence');
DROP SEQUENCE IF EXISTS t_escheduler_relation_project_user_id_sequence;
CREATE SEQUENCE t_escheduler_relation_project_user_id_sequence;
ALTER TABLE t_escheduler_relation_project_user ALTER COLUMN id SET DEFAULT NEXTVAL('t_escheduler_relation_project_user_id_sequence');
DROP SEQUENCE IF EXISTS t_escheduler_relation_resources_user_id_sequence;
CREATE SEQUENCE t_escheduler_relation_resources_user_id_sequence;
ALTER TABLE t_escheduler_relation_resources_user ALTER COLUMN id SET DEFAULT NEXTVAL('t_escheduler_relation_resources_user_id_sequence');
DROP SEQUENCE IF EXISTS t_escheduler_relation_udfs_user_id_sequence;
CREATE SEQUENCE t_escheduler_relation_udfs_user_id_sequence;
ALTER TABLE t_escheduler_relation_udfs_user ALTER COLUMN id SET DEFAULT NEXTVAL('t_escheduler_relation_udfs_user_id_sequence');
DROP SEQUENCE IF EXISTS t_escheduler_relation_user_alertgroup_id_sequence;
CREATE SEQUENCE t_escheduler_relation_user_alertgroup_id_sequence;
ALTER TABLE t_escheduler_relation_user_alertgroup ALTER COLUMN id SET DEFAULT NEXTVAL('t_escheduler_relation_user_alertgroup_id_sequence');
DROP SEQUENCE IF EXISTS t_escheduler_resources_id_sequence;
CREATE SEQUENCE t_escheduler_resources_id_sequence;
ALTER TABLE t_escheduler_resources ALTER COLUMN id SET DEFAULT NEXTVAL('t_escheduler_resources_id_sequence');
DROP SEQUENCE IF EXISTS t_escheduler_schedules_id_sequence;
CREATE SEQUENCE t_escheduler_schedules_id_sequence;
ALTER TABLE t_escheduler_schedules ALTER COLUMN id SET DEFAULT NEXTVAL('t_escheduler_schedules_id_sequence');
DROP SEQUENCE IF EXISTS t_escheduler_task_instance_id_sequence;
CREATE SEQUENCE t_escheduler_task_instance_id_sequence;
ALTER TABLE t_escheduler_task_instance ALTER COLUMN id SET DEFAULT NEXTVAL('t_escheduler_task_instance_id_sequence');
DROP SEQUENCE IF EXISTS t_escheduler_tenant_id_sequence;
CREATE SEQUENCE t_escheduler_tenant_id_sequence;
ALTER TABLE t_escheduler_tenant ALTER COLUMN id SET DEFAULT NEXTVAL('t_escheduler_tenant_id_sequence');
DROP SEQUENCE IF EXISTS t_escheduler_udfs_id_sequence;
CREATE SEQUENCE t_escheduler_udfs_id_sequence;
ALTER TABLE t_escheduler_udfs ALTER COLUMN id SET DEFAULT NEXTVAL('t_escheduler_udfs_id_sequence');
DROP SEQUENCE IF EXISTS t_escheduler_user_id_sequence;
CREATE SEQUENCE t_escheduler_user_id_sequence;
ALTER TABLE t_escheduler_user ALTER COLUMN id SET DEFAULT NEXTVAL('t_escheduler_user_id_sequence');
DROP SEQUENCE IF EXISTS t_escheduler_version_id_sequence;
CREATE SEQUENCE t_escheduler_version_id_sequence;
ALTER TABLE t_escheduler_version ALTER COLUMN id SET DEFAULT NEXTVAL('t_escheduler_version_id_sequence');
DROP SEQUENCE IF EXISTS t_escheduler_worker_group_id_sequence;
CREATE SEQUENCE t_escheduler_worker_group_id_sequence;
ALTER TABLE t_escheduler_worker_group ALTER COLUMN id SET DEFAULT NEXTVAL('t_escheduler_worker_group_id_sequence');
DROP SEQUENCE IF EXISTS t_escheduler_worker_server_id_sequence;
CREATE SEQUENCE t_escheduler_worker_server_id_sequence;
ALTER TABLE t_escheduler_worker_server ALTER COLUMN id SET DEFAULT NEXTVAL('t_escheduler_worker_server_id_sequence');

8
sql/create/release-1.2.0_schema/postgresql/dolphinscheduler_dml.sql

@ -0,0 +1,8 @@
-- Records of t_escheduler_user,user : admin , password : escheduler123
INSERT INTO "t_escheduler_user" VALUES ('1', 'admin', '055a97b5fcd6d120372ad1976518f371', '0', 'xxx@qq.com', 'xx', '0', '2018-03-27 15:48:50', '2018-10-24 17:40:22');
INSERT INTO "t_escheduler_alertgroup" VALUES (1, 'escheduler管理员告警组', '0', 'escheduler管理员告警组','2018-11-29 10:20:39', '2018-11-29 10:20:39');
INSERT INTO "t_escheduler_relation_user_alertgroup" VALUES ('1', '1', '1', '2018-11-29 10:22:33', '2018-11-29 10:22:33');
-- Records of t_escheduler_queue,default queue name : default
INSERT INTO "t_escheduler_queue" VALUES ('1', 'default', 'default');
INSERT INTO "t_escheduler_version" VALUES ('1', '1.2.0');

2
sql/soft_version

@ -1 +1 @@
1.1.0
1.2.0

0
sql/upgrade/1.0.1_schema/mysql/escheduler_ddl.sql → sql/upgrade/1.0.1_schema/mysql/dolphinscheduler_ddl.sql

0
sql/upgrade/1.0.1_schema/mysql/escheduler_dml.sql → sql/upgrade/1.0.1_schema/mysql/dolphinscheduler_dml.sql

0
sql/upgrade/1.0.2_schema/mysql/escheduler_ddl.sql → sql/upgrade/1.0.2_schema/mysql/dolphinscheduler_ddl.sql

0
sql/upgrade/1.0.2_schema/mysql/escheduler_dml.sql → sql/upgrade/1.0.2_schema/mysql/dolphinscheduler_dml.sql

0
sql/upgrade/1.1.0_schema/mysql/escheduler_ddl.sql → sql/upgrade/1.1.0_schema/mysql/dolphinscheduler_ddl.sql

0
sql/upgrade/1.1.0_schema/mysql/escheduler_dml.sql → sql/upgrade/1.1.0_schema/mysql/dolphinscheduler_dml.sql

0
sql/upgrade/1.2.0_schema/mysql/dolphinscheduler_ddl.sql

0
sql/upgrade/1.2.0_schema/mysql/dolphinscheduler_dml.sql

0
sql/upgrade/1.2.0_schema/postgresql/dolphinscheduler_ddl.sql

0
sql/upgrade/1.2.0_schema/postgresql/dolphinscheduler_dml.sql

Loading…
Cancel
Save