Commit efcadefc by 曾炯豪

Initial commit

parents
*.log
*.log.*
target
target/*
*/target
*/target/*
*/.project
*/.project/*
*/.settings
*/.settings/*
.idea
*/.idea
*/.idea/*
*.iml
*/*.iml
databases/.skeema
snapshot-repo/*
*.mp4
*/dockerize/*.jar
*/dockerize/lib
*/dockerize/lib/*
本代码库假设了迁移所设计的source mysql-server和destination mysql-server均使用https://gitlab.qida.com/qida-b2b-refactoring-serviceapps/hybrid/tree/case/databases/skeemaBak最新commit所表示的schema.
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.qida</groupId>
<artifactId>dbmigrate</artifactId>
<version>1.0-SNAPSHOT</version>
<name>dbmigrate</name>
<!-- FIXME change it to the project's website -->
<url>http://www.example.com</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
<slf4jVer>1.7.25</slf4jVer>
<logbackVer>1.2.3</logbackVer>
<mysqlConnectorJVer>8.0.20</mysqlConnectorJVer>
<apacheCommonsDbcp2Ver>2.7.0</apacheCommonsDbcp2Ver>
<apacheCommonsPool2Ver>2.8.0</apacheCommonsPool2Ver>
<apacheCommonsLoggingVer>1.2</apacheCommonsLoggingVer>
<apacheCommonsCliVer>1.4</apacheCommonsCliVer>
<fastjson.version>1.2.47</fastjson.version>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<!-- Apache commons cli -->
<dependency>
<groupId>commons-cli</groupId>
<artifactId>commons-cli</artifactId>
<version>${apacheCommonsCliVer}</version>
</dependency>
<!-- MySQL Connector/J driver -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>${mysqlConnectorJVer}</version>
</dependency>
<!-- fastjson -->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>${fastjson.version}</version>
</dependency>
<!-- DBCP2 connection pool. -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-dbcp2</artifactId>
<version>${apacheCommonsDbcp2Ver}</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-pool2</artifactId>
<version>${apacheCommonsPool2Ver}</version>
</dependency>
<!-- Slf4j-api. -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${slf4jVer}</version>
</dependency>
<!-- Logback as Sfl4j-api implementation. -->
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-core</artifactId>
<version>${logbackVer}</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>${logbackVer}</version>
</dependency>
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>mongodb-driver</artifactId>
<version>3.4.1</version>
</dependency>
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>bson</artifactId>
<version>3.4.1</version>
</dependency>
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>Mongodb-driver-core</artifactId>
<version>3.4.1</version>
</dependency>
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
<version>4.6.3</version>
</dependency>
</dependencies>
<build>
<finalName>${project.artifactId}</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>./target/lib</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.1.0</version>
<configuration>
<archive>
<manifest>
<!--
Packages the jar with a default main class "com.mycompany.app.App", and
an "implicit classpath recognition source ./lib/".
-->
<addClasspath>true</addClasspath>
<classpathPrefix>lib/</classpathPrefix>
<mainClass>com.qida.dbmigrate.App</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.3</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<createSourcesJar>true</createSourcesJar>
<shadeSourcesContent>true</shadeSourcesContent>
<createDependencyReducedPom>false</createDependencyReducedPom>
<shadedArtifactAttached>false
</shadedArtifactAttached> <!-- Deliberately replacing the original output jar. -->
<shadedClassifierName>shaded</shadedClassifierName>
<artifactSet>
<excludes>
<exclude>junit:junit</exclude>
<exclude>org.springframework:*</exclude>
</excludes>
</artifactSet>
<relocations>
<relocation>
<pattern>com.qida</pattern>
<shadedPattern>com.qida.${project.artifactId}</shadedPattern>
</relocation>
</relocations>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
package com.qida;
import org.apache.commons.cli.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.commons.dbcp2.BasicDataSource;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
public class App
{
private static final Logger logger = LoggerFactory.getLogger(App.class);
public static void main(String[] args) {
/*
* In this application, there're 2 "DataSource"s with the same set of schemas, e.g. "foo" and "bar".
* Assume that the structure of "foo" is as follows.
* - (schema) qida_management_platform
* - (table) sys_user // 平台管理员/超级管理员记录
* - (schema) qida_cas_platform
* - (table) cas_user // 所有"用户"(包括平台管理员/超级管理员)的账号密码
* - (table) sys_user_audit
* - ...
* - (schema) clm_base_platform
* - (table) org_company
* - (table) org_user
* - (table) sys_user_role
* - ...
*/
final Options options = new Options();
options.addRequiredOption("sh", "srchost", true, "The source mysql server host(including port), e.g. 192.168.56.101:3306.")
.addRequiredOption("dh", "dsthost", true, "The destination mysql server host(including port), e.g. 192.168.56.102:3307.")
.addRequiredOption("su", "srcuser", true, "The source mysql username.")
.addRequiredOption("du", "dstuser", true, "The destination mysql username.")
.addOption("sp", "srcpassword", true, "The source mysql password.")
.addOption("dp", "dstpassword", true, "The destination mysql password.");
final HelpFormatter formatter = new HelpFormatter();
formatter.printHelp("QidaDataExtractor", options);
Connection fooConnection = null;
PreparedStatement fooStatement = null;
ResultSet fooResultSet = null;
Connection barConnection = null;
PreparedStatement barStatement = null;
ResultSet barResultSet = null;
try {
final DefaultParser parser = new DefaultParser();
CommandLine cl = parser.parse(options, args);
final String sh = cl.getOptionValue("sh");
final String su = cl.getOptionValue("su");
final String sp = cl.getOptionValue("sp");
final String dh = cl.getOptionValue("dh");
final String du = cl.getOptionValue("du");
final String dp = cl.getOptionValue("dp");
logger.info("srchost= " + sh + ", dsthost= " + dh);
final BasicDataSource fooBds = new DataSource("jdbc:mysql://" + sh, su, sp).getBds();
final BasicDataSource barBds = new DataSource("jdbc:mysql://" + dh, du, dp).getBds();
fooConnection = fooBds.getConnection();
fooStatement = fooConnection
.prepareStatement("SELECT * FROM `clm_base_platform`.`org_company` LIMIT 10;");
fooResultSet = fooStatement.executeQuery();
logger.info("id, company_name, short_name, company_code");
while (fooResultSet.next()) {
logger.info(fooResultSet.getInt("id") + ", "
+ fooResultSet.getString("company_name") + " "
+ fooResultSet.getString("short_name") + ", "
+ fooResultSet.getString("company_code"));
}
barConnection = barBds.getConnection();
barStatement = barConnection
.prepareStatement("SELECT 1+1 AS sum;");
barResultSet = barStatement.executeQuery();
while (barResultSet.next()) {
logger.info("bar result:" + barResultSet.getInt("sum"));
}
} catch (SQLException e) {
logger.error("Exception while executing query", e);
} catch (ParseException e) {
logger.error("Exception while parsing args", e);
} finally {
try {
if (null != fooResultSet) {
fooResultSet.close();
}
if (null != fooStatement) {
fooStatement.close();
}
if (null != fooConnection) {
fooConnection.close();
}
if (null != barResultSet) {
barResultSet.close();
}
if (null != barStatement) {
barStatement.close();
}
if (null != barConnection) {
barConnection.close();
}
} catch (SQLException e) {
logger.error("Exception while wrapping up", e);
}
}
}
}
package com.qida;
import org.apache.commons.dbcp2.BasicDataSource;
public class DataSource {
// The old driver class "com.mysql.jdbc.Driver" is deprecated in "mysql:mysql-connector-java:8.0.20+", see https://dev.mysql.com/doc/connector-j/8.0/en/connector-j-api-changes.html for more information.
private static final String DRIVER_CLASS_NAME = "com.mysql.cj.jdbc.Driver";
private static final int CONN_POOL_SIZE = 5;
private BasicDataSource bds = new BasicDataSource();
public DataSource(final String dbUrl, final String dbUser, final String dbPassword) {
//Set database driver name
bds.setDriverClassName(DRIVER_CLASS_NAME);
//Set database url
bds.setUrl(dbUrl);
//Set database user
bds.setUsername(dbUser);
//Set database password
bds.setPassword(dbPassword);
//Set the connection pool size
bds.setInitialSize(CONN_POOL_SIZE);
}
public BasicDataSource getBds() {
return bds;
}
}
package com.qida;
import cn.hutool.core.collection.CollUtil;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.mysql.cj.util.StringUtils;
import org.bson.Document;
import java.io.*;
import java.util.ArrayList;
import java.util.List;
public class DemoApp {
public static void main(String[] args) {
List<String> s = new ArrayList<>();
s.add("a");
System.out.println(CollUtil.isNotEmpty(s));
}
}
package com.qida;
import com.alibaba.fastjson.JSONObject;
import com.mongodb.MongoClient;
import com.mongodb.MongoCredential;
import com.mongodb.ServerAddress;
import com.mongodb.client.FindIterable;
import com.mongodb.client.MongoCollection;
import com.mongodb.client.MongoDatabase;
import com.mongodb.client.MongoIterable;
import com.qida.mongoUtils.MongoDBUtil;
import org.bson.Document;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;
public class MongoDBApp {
public static void main(String[] args) {
MongoClient src_mongoClient = null;
MongoClient dst_mongoClient = null;
try {
// 键盘输入需要迁移的数据库
System.out.println("请输入mongodb的库名称,重要的事情说三遍!!!");
System.out.println("请输入mongodb的库名称,重要的事情说三遍!!!");
System.out.println("请输入mongodb的库名称,重要的事情说三遍!!!");
// Scanner sc = new Scanner(System.in);
// String databaseName = sc.next();
String databaseName = "tenant";
// 读取json文件
JSONObject jsonObject = getJsonObject();
// ------------------------ 开始操作数据库------------------------------------------------------------
// 数据源src
MongoCredential src_credential = MongoCredential.createCredential("qida", databaseName, "qida".toCharArray());
ServerAddress src_serverAddress = new ServerAddress("192.168.1.242", 3717);
src_mongoClient = new MongoClient(src_serverAddress, Arrays.asList(src_credential));
MongoDatabase src_mongoDatabase = src_mongoClient.getDatabase(databaseName);
MongoIterable<String> src_collectionNames = src_mongoDatabase.listCollectionNames();
// 迁移到的目标数据库dst
MongoCredential dst_credential = MongoCredential.createCredential("qida", databaseName, "qida".toCharArray());
ServerAddress dst_serverAddress = new ServerAddress("192.168.1.242", 3717);
dst_mongoClient = new MongoClient(dst_serverAddress, Arrays.asList(dst_credential));
MongoDatabase dst_mongoDatabase = dst_mongoClient.getDatabase(databaseName);
MongoIterable<String> dst_collectionNames = src_mongoDatabase.listCollectionNames();
// ----------------------------------------------------------------------------------------------------
String message = "";
for (String collection : src_collectionNames) {
message = message + collection + "、";
}
System.out.println(databaseName + "有如下集合: " + message.substring(0, message.length() - 1) + "!!!");
Thread.sleep(3000);
for (String collectionName : src_collectionNames) {
if (!collectionName.equals("Individuation")) {
continue;
}
MongoCollection<Document> collection = src_mongoDatabase.getCollection(collectionName);
/*long count = collectionName.count();
if (count == 0) {
System.out.println(collection + "集合没有数据,准备开始下一个集合的迁移!!!");
continue;
}
System.out.println(collectionName.getNamespace() + "集合共有" + count + "条数据!!!");*/
FindIterable<Document> documents = collection.find();
List<Document> docList = new ArrayList<>();
int i = 0;
for (Document document : documents) {
/*if (i > 20) {
break;
}*/
i++;
docList.add(document);
System.out.println(document);
}
System.out.println("************************************************************************************");
System.out.println("************************************************************************************");
List<String> fieldsToUpdate = isSpecialCol(jsonObject, databaseName, collectionName);
List<Document> documentList = MongoDBUtil.dealDoc(databaseName + "." + collectionName, docList, fieldsToUpdate);
for (Document item : documentList) {
System.out.println(item);
}
}
} catch (Exception e) {
System.err.println("迁移时发生了错误!!!");
System.err.println(e.getClass().getName() + ": " + e.getMessage());
} finally {
src_mongoClient.close();
dst_mongoClient.close();
}
}
// -------------------------工具类方法---------------------------------------------------------------------
private static JSONObject getJsonObject() throws Exception {
String path = MongoDBApp.class.getClassLoader().getResource("mongodb.json").getPath();
String jsonStr = "";
File jsonFile = new File(path);
Reader reader = new InputStreamReader(new FileInputStream(jsonFile), "utf-8");
int ch = 0;
StringBuffer sb = new StringBuffer();
while ((ch = reader.read()) != -1) {
sb.append((char) ch);
}
reader.close();
jsonStr = sb.toString();
JSONObject jsonObject = JSONObject.parseObject(jsonStr);
return jsonObject;
}
// 特殊列的处理方法
private static List<String> isSpecialCol(JSONObject jsonObject, String databaseName, String collection) {
List<String> fieldsToUpdate = new ArrayList<>();
List<JSONObject> jobajList = (List<JSONObject>) jsonObject.get(databaseName);
if (jobajList != null && jobajList.size() > 0) {
for (JSONObject jobj : jobajList) {
List<String> colList = (List<String>) jobj.get(collection);
if (colList != null && colList.size() > 0) {
for (String col : colList) {
fieldsToUpdate.add(col);
}
}
}
}
return fieldsToUpdate;
}
}
package com.qida;
import com.alibaba.fastjson.JSONObject;
import com.mongodb.*;
import com.mongodb.client.*;
import com.qida.mongoUtils.MongoDBUtil;
import org.bson.Document;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.util.*;
public class MongoDemo {
public static void main(String[] args) {
MongoClient src_mongoClient = null;
MongoClient dst_mongoClient = null;
try {
// 键盘输入需要迁移的数据库
String databaseName = "Survey";
// ------------------------ 开始操作数据库------------------------------------------------------------
// 数据源src
MongoCredential src_credential = MongoCredential.createCredential("qida", databaseName, "qida".toCharArray());
ServerAddress src_serverAddress = new ServerAddress("192.168.1.242", 3717);
src_mongoClient = new MongoClient(src_serverAddress, Arrays.asList(src_credential));
MongoDatabase src_mongoDatabase = src_mongoClient.getDatabase(databaseName);
MongoIterable<String> src_collectionNames = src_mongoDatabase.listCollectionNames();
// 迁移到的目标数据库dst
MongoCredential dst_credential = MongoCredential.createCredential("qida", databaseName, "qida".toCharArray());
ServerAddress dst_serverAddress = new ServerAddress("192.168.1.242", 3717);
dst_mongoClient = new MongoClient(dst_serverAddress, Arrays.asList(dst_credential));
MongoDatabase dst_mongoDatabase = dst_mongoClient.getDatabase(databaseName);
MongoIterable<String> dst_collectionNames = src_mongoDatabase.listCollectionNames();
// ----------------------------------------------------------------------------------------------------
MongoCollection<Document> collection = src_mongoDatabase.getCollection("EvaluationFeedback");
FindIterable<Document> documents = collection.find();
int i = 0;
for (Document document : documents) {
if (i > 10) {
break;
}
i++;
System.out.println(document);
}
} catch (Exception e) {
System.err.println("迁移时发生了错误!!!");
System.err.println(e.getClass().getName() + ": " + e.getMessage());
} finally {
if (src_mongoClient != null) {
src_mongoClient.close();
}
if (dst_mongoClient != null) {
dst_mongoClient.close();
}
}
}
}
package com.qida;
import com.alibaba.fastjson.JSONObject;
import org.apache.commons.cli.*;
import org.apache.commons.dbcp2.BasicDataSource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.sql.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
public class MyApp2 {
private static final Logger logger = LoggerFactory.getLogger(App.class);
public static void main(String[] args) {
final Options options = new Options();
options.addRequiredOption("sh", "srchost", true, "The source mysql server host(including port), e.g. 192.168.56.101:3306.")
.addRequiredOption("dh", "dsthost", true, "The destination mysql server host(including port), e.g. 192.168.56.102:3307.")
.addRequiredOption("su", "srcuser", true, "The source mysql username.")
.addRequiredOption("du", "dstuser", true, "The destination mysql username.")
.addOption("sp", "srcpassword", true, "The source mysql password.")
.addOption("dp", "dstpassword", true, "The destination mysql password.");
final HelpFormatter formatter = new HelpFormatter();
formatter.printHelp("QidaDataExtractor", options);
Connection fooConnection = null;
PreparedStatement fooStatement = null;
ResultSet fooResultSet = null;
PreparedStatement tableStatement = null;
ResultSet tableResultSet = null;
Connection barConnection = null;
Statement barStatement = null;
ResultSet barResultSet = null;
try {
final DefaultParser parser = new DefaultParser();
CommandLine cl = parser.parse(options, args);
final String sh = cl.getOptionValue("sh");
final String su = cl.getOptionValue("su");
final String sp = cl.getOptionValue("sp");
final String dh = cl.getOptionValue("dh");
final String du = cl.getOptionValue("du");
final String dp = cl.getOptionValue("dp");
logger.info("srchost= " + sh + ", dsthost= " + dh);
final BasicDataSource fooBds = new DataSource("jdbc:mysql://" + sh + "?useUnicode=true&characterEncoding=UTF-8", su, sp).getBds();
final BasicDataSource barBds = new DataSource("jdbc:mysql://" + dh + "?useUnicode=true&characterEncoding=UTF-8", du, dp).getBds();
// 键盘输入需要迁移的数据库
System.out.println("请输入需要修改的数据库名称,重要的事情说三遍!!!");
System.out.println("请输入需要修改的数据库名称,重要的事情说三遍!!!");
System.out.println("请输入需要修改的数据库名称,重要的事情说三遍!!!");
Scanner sc = new Scanner(System.in);
String moveDatabase = sc.next();
fooConnection = fooBds.getConnection();
barConnection = barBds.getConnection();
barStatement = barConnection.createStatement();
String select_table_count = "SELECT COUNT(*) as taleCount FROM information_schema.TABLES WHERE table_schema = '" + moveDatabase + "' AND table_type = 'base table' AND table_name NOT LIKE '%_audit'";
String select_table = "SELECT table_name FROM information_schema.TABLES WHERE table_schema = '" + moveDatabase + "' AND table_type = 'base table'";
tableStatement = fooConnection.prepareStatement(select_table_count);
tableResultSet = tableStatement.executeQuery();
int taleCount = 0;
while (tableResultSet.next()) {
taleCount = tableResultSet.getInt("taleCount");
}
if (taleCount <= 0) {
System.out.println("########## " + moveDatabase + "库的表数量是零,无需迁移!!!##########");
return;
}
System.out.println("########## " + moveDatabase + "库的迁移准备开始,共有" + taleCount + "张表需要迁移!!!##########");
// 查出所有表
tableStatement = fooConnection.prepareStatement(select_table);
tableResultSet = tableStatement.executeQuery();
List<String> tableList = new ArrayList<>();
while (tableResultSet.next()) {
String table = tableResultSet.getNString("table_name");
tableList.add(table);
}
for (String tableName : tableList) {
if (tableName.contains("z_dst_")) {
continue;
}
String newTableName = "z_src_" + tableName;
String alert_sql = "alter table " + moveDatabase + "." + tableName + " rename " + newTableName + ";";
System.out.println(alert_sql);
}
/*for (String tableName : tableList) {
if(tableName.contains("z_src_")) {
String newTableName = tableName.replaceAll("z_src_","");
String alert_sql = "alter table " + moveDatabase + "." + tableName +" rename " + newTableName + ";";
System.out.println(alert_sql);
}
}*/
} catch (SQLException e) {
logger.error("Exception while executing query", e);
} catch (ParseException e) {
logger.error("Exception while parsing args", e);
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if (null != tableResultSet) {
tableResultSet.close();
}
if (null != fooResultSet) {
fooResultSet.close();
}
if (null != tableStatement) {
tableStatement.close();
}
if (null != fooStatement) {
fooStatement.close();
}
if (null != fooConnection) {
fooConnection.close();
}
if (null != barResultSet) {
barResultSet.close();
}
if (null != barStatement) {
barStatement.close();
}
if (null != barConnection) {
barConnection.close();
}
} catch (Exception e) {
logger.error("Exception while wrapping up", e);
}
}
}
}
<!-- Kindly note that this file should be put under the application classpath, e.g. in Tomcat the "${catalina.base}/lib/". Reference https://logback.qos.ch/manual/configuration.html. -->
<!-- Variable in "logback.xml" reference http://logback.qos.ch/manual/configuration.html#definingProps. -->
<configuration scan="true" scanPeriod="30 seconds">
<appender name="Console" class="ch.qos.logback.core.ConsoleAppender" withJansi="true">
<layout class="ch.qos.logback.classic.PatternLayout">
<pattern>%date %level %class::%method @line#%line [%thread] %message%n</pattern>
</layout>
</appender>
<appender name="RollingFile" class="ch.qos.logback.core.rolling.RollingFileAppender">
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>debug</level>
</filter>
<file>${logs.home:-./}app.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<fileNamePattern>${logs.home:-./}app-%d{yyyy-MM-dd}.log.%i</fileNamePattern>
<maxFileSize>64MB</maxFileSize>
<totalSizeCap>16GB</totalSizeCap>
<maxHistory>64</maxHistory>
</rollingPolicy>
<append>true</append>
<layout class="ch.qos.logback.classic.PatternLayout">
<pattern>%date %level %class::%method @line#%line [%thread] %message%n</pattern>
</layout>
</appender>
<!-- Level filters of individual appenders below are specified respectively. -->
<root>
<appender-ref ref="RollingFile"/>
<appender-ref ref="Console"/>
</root>
</configuration>
{
"Survey": [
{
"EvaluationFeedback": [
"userId",
"actId",
"companyId",
"feedbackAnswers_inline"
]
},
{
"LecturerEvaluationAct": [
"companyId",
"lecturerId",
"paperId",
"creatorId",
"updaterId",
"paper_inline"
]
},
{
"LecturerEvaluationPaper": [
"lecturerId",
"trainId",
"companyId",
"creatorId",
"updaterId"
]
},
{
"PaperOfEvaluationQuestionReport": [
"lecturerId"
]
},
{
"SurveyAct": [
"companyId",
"paperId",
"creatorId",
"releaserId",
"updaterId",
"paper_inline"
]
},
{
"SurveyFeedback": [
"actId",
"companyId",
"feedbackAnswers_inline"
]
},
{
"SurveyPaper": [
"logoId",
"companyId",
"creatorId"
]
}
],
"clm-custom": [
{
"sundanceLecturer": [
"avatar"
]
}
],
"patch_Examination": [
{
"ExamPaperStaticData": [
"categoryId",
"companyId",
"creatorId",
"updaterId",
"headings_inline"
]
},
{
"ExamTrackingUserAnswerData": [
"paperId",
"answers_inline",
"paperLayout_inline"
]
}
],
"patch_lmstracking": [
{
"lMSItemAttemp": [
"itemId",
"userId",
"crsId"
]
},
{
"lMSSTDPerformance": [
"userId",
"crsId",
"lessonLocation",
"itemPerformances_inline"
]
},
{
"lMSScormPerformance": [
"userId",
"crsId",
"lessonLocation",
"itemPerformances_inline"
]
}
],
"tenant": [
{
"Individuation": [
"companyId",
"corporateIdentity_inline"
]
}
]
}
\ No newline at end of file
{
"qida_cas_platform": [
{
"cas_user_oauth": [
"app_id",
"open_id"
]
}
],
"clm_base_platform": [
{
"org_department": [
"parent_id"
]
},
{
"ext_learn_group_thread": [
"image_ids"
]
},
{
"org_company_config": [
"corp_id",
"agent_id"
]
},
{
"org_user": [
"other_user_id"
]
},
{
"org_user_menu": [
"parent_ids"
]
},
{
"sal_pros_customer": [
"JOB_ID",
"CMP_SCALE_ID"
]
},
{
"sys_menu": [
"parent_ids",
"target"
]
},
{
"sys_role_menu": [
"update_date"
]
}
],
"clm_live": [
{
"billing_info": [
"CompanyId"
]
},
{
"billing_info_log": [
"OperatorCasId",
"CompanyId",
"__#alibaba_rds_row_id#__"
]
},
{
"channel_info": [
"ChannelId",
"TeacherCasId",
"GroupIdList",
"DepartmentIdList",
"UserCasIdList"
]
},
{
"channel_polyv_summary": [
"ChannelId",
"__#alibaba_rds_row_id#__"
]
},
{
"common_config": [
"ConfigKey"
]
},
{
"company_channel_list": [
"CompanyId",
"ChannelId"
]
},
{
"company_channel_list_delete_from_polyv": [
"CompanyId",
"ChannelId"
]
},
{
"company_last_create_channel_time": [
"CompanyId"
]
},
{
"company_polyv_account": [
"CompanyId",
"MainPolyvUserId"
]
},
{
"exceptional_channel": [
"PolyvUserId",
"CompanyId",
"ChannelId",
"OperatorCasId",
"__#alibaba_rds_row_id#__"
]
},
{
"recharge_minutes_log": [
"CompanyId",
"OperatorCasId",
"__#alibaba_rds_row_id#__"
]
},
{
"settle_minutes_log": [
"CompanyId",
"ChannelId",
"OperatorCasId",
"__#alibaba_rds_row_id#__"
]
},
{
"polyv_account": [
"UserId"
]
}
],
"clm_offline": [
{
"train_task": [
"logo_id"
]
}
],
"clm_openfire": [
{
"ofid": [
"id"
]
},
{
"ofmucconversationlog": [
"body",
"id"
]
},
{
"ofmucroom": [
"serviceID",
"roomID"
]
},
{
"ofoffline": [
"username",
"messageID"
]
},
{
"ofpresence": [
"username"
]
},
{
"ofprivacylist": [
"username"
]
},
{
"ofprivate": [
"username"
]
},
{
"ofproperty": [
"name"
]
},
{
"ofpubsubaffiliation": [
"serviceID"
]
},
{
"ofpubsubdefaultconf": [
"serviceID"
]
},
{
"ofpubsubitem": [
"serviceID"
]
},
{
"ofpubsubnode": [
"serviceID"
]
},
{
"ofpubsubnodegroups": [
"serviceID"
]
},
{
"ofpubsubnodejids": [
"serviceID"
]
},
{
"ofremoteserverconf": [
"xmppDomain"
]
},
{
"ofsecurityauditlog": [
"msgID"
]
},
{
"ofuser": [
"username"
]
},
{
"ofuserprop": [
"username"
]
},
{
"ofversion": [
"name"
]
}
],
"clm_survey_platform": [
{
"srv_survey_paper": [
"logo_id"
]
}
],
"sys_app_push": [
{
"push_channel_client": [
"push_user_id",
"push_channel_id"
]
}
],
"sys_platform": [
{
"cloud_attachment_bucket_middle_item": [
"analysis_job_id",
"transcode_job_id"
]
},
{
"cloud_oss_company": [
"access_key_id"
]
},
{
"sys_app_version": [
"version_id",
"app_id",
"fix_id"
]
},
{
"sys_area": [
"area_pid",
"pid_ids",
"id"
]
},
{
"sys_area_pinyin": [
"ID",
"AREA_PID"
]
},
{
"sys_domain": [
"domain_pid",
"pid_ids"
]
},
{
"sys_feed_back": [
"app_id"
]
},
{
"sys_file_resource_temp": [
"__#alibaba_rds_row_id#__"
]
},
{
"sys_industry": [
"industry_pid",
"pid_ids"
]
}
],
"clm_resource_platform": [
{
"crs_course_info": [
"zbx_course_id"
]
},
{
"crs_course_item_scorm": [
"sco_idetifier",
"parent_idetifier"
]
},
{
"crs_course_material": [
"ext_identifer"
]
},
{
"qida_course_item_scorm": [
"sco_idetifier",
"parent_idetifier"
]
},
{
"qida_resource_authorization": [
"library"
]
},
{
"qida_resource_thirdparty": [
"id"
]
},
{
"": [
"library"
]
}
]
}
\ No newline at end of file
package com.qida;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
/**
* Unit test for simple App.
*/
public class AppTest
{
/**
* Rigorous Test :-)
*/
@Test
public void shouldAnswerWithTrue()
{
assertTrue( true );
}
}
FROM mcr.microsoft.com/java/jre:8-zulu-alpine
RUN mkdir -p /app
RUN mkdir -p /app/dbmigrate_cache
VOLUME /app/dbmigrate_cache
COPY docker-entrypoint.sh /usr/local/bin/
RUN ln -s usr/local/bin/docker-entrypoint.sh /entrypoint.sh # backwards compat
# deliberately using "COPY" instead of "ADD", please prepare the source files locally
COPY dbmigrate.jar /app/dbmigrate.jar
COPY lib /app/lib
ENTRYPOINT ["docker-entrypoint.sh"]
#!/bin/sh
# There's no bash support in image "mcr.microsoft.com/java/jre:8-zulu-alpine".
#echo Your container args are: "$@"
java -jar /app/dbmigrate.jar "$@"
#!/bin/bash
basedir=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
cd $basedir && docker build -t qida_dbmigrate .
#!/bin/bash
# docker volume create shared_dbmigrate_cache
#cmd="docker run -d --mount 'type=volume,src=shared_dbmigrate_cache,dst=/app/dbmigrate_cache' --net=host dbmigrate:latest $@"
cmd="docker run -it --mount 'type=volume,src=shared_dbmigrate_cache,dst=/app/dbmigrate_cache' --net=host dbmigrate:latest $@"
eval $cmd
#!/bin/bash
if [ $# -ne 1 ]; then
echo "Usage: $0 <operation code, e.g. \"create_subprojects\" or \"exec_dbmigrate\">"
exit 1
fi
basedir=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
groupId=com.qida
archetypeArtifactId=maven-archetype-quickstart
archetypeVersion=1.4
dbmigrateId=dbmigrate
function create_subprojects () {
subprojects=( $dbmigrateId )
for i in "${subprojects[@]}"
do
if [[ ! -d $basedir/$i ]]; then
echo "Creating subproject $i"
cd $basedir && mvn -X archetype:generate -DgroupId=$groupId -DartifactId=$i -DarchetypeArtifactId=$archetypeArtifactId -DarchetypeVersion=$archetypeVersion -DinteractiveMode=false
fi
done
}
function package_dbmigrate() {
if [[ -d $basedir/$dbmigrateId ]]; then
echo "Packaging subproject $dbmigrateId"
# The property "logs.home" is used in "logback.xml".
cd $basedir/$dbmigrateId && mvn clean package -DskipTests
fi
}
function exec_dbmigrate() {
if [[ -d $basedir/$dbmigrateId ]]; then
echo "Executing subproject $dbmigrateId"
# The property "logs.home" is used in "logback.xml".
package_dbmigrate && cd $basedir/$dbmigrateId/target && java -Dlogs.home=$basedir/$dbmigrateId/logs/ -jar dbmigrate.jar
fi
}
operationCode=$1
$operationCode
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment