mirror of
https://gitee.com/dromara/dbswitch.git
synced 2025-09-20 02:58:48 +00:00
I5QFVD:支持选择视图表迁移同步
This commit is contained in:
@@ -10,6 +10,7 @@
|
||||
package com.gitee.dbswitch.data.entity;
|
||||
|
||||
import com.gitee.dbswitch.common.entity.PatternMapper;
|
||||
import com.gitee.dbswitch.common.type.DBTableType;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import lombok.Data;
|
||||
@@ -26,6 +27,7 @@ public class SourceDataSourceProperties {
|
||||
|
||||
private Integer fetchSize = 5000;
|
||||
private String sourceSchema = "";
|
||||
private String tableType = "TABLE";
|
||||
private String sourceIncludes = "";
|
||||
private String sourceExcludes = "";
|
||||
private List<PatternMapper> regexTableMapper;
|
||||
|
@@ -9,7 +9,7 @@
|
||||
/////////////////////////////////////////////////////////////
|
||||
package com.gitee.dbswitch.data.handler;
|
||||
|
||||
import com.gitee.dbswitch.common.type.DatabaseTypeEnum;
|
||||
import com.gitee.dbswitch.common.type.ProductTypeEnum;
|
||||
import com.gitee.dbswitch.common.util.DatabaseAwareUtils;
|
||||
import com.gitee.dbswitch.common.util.PatterNameUtils;
|
||||
import com.gitee.dbswitch.core.model.ColumnDescription;
|
||||
@@ -64,7 +64,7 @@ public class MigrationHandler implements Supplier<Long> {
|
||||
|
||||
// 来源端
|
||||
private final HikariDataSource sourceDataSource;
|
||||
private DatabaseTypeEnum sourceProductType;
|
||||
private ProductTypeEnum sourceProductType;
|
||||
private String sourceSchemaName;
|
||||
private String sourceTableName;
|
||||
private String sourceTableRemarks;
|
||||
@@ -75,7 +75,7 @@ public class MigrationHandler implements Supplier<Long> {
|
||||
|
||||
// 目的端
|
||||
private final HikariDataSource targetDataSource;
|
||||
private DatabaseTypeEnum targetProductType;
|
||||
private ProductTypeEnum targetProductType;
|
||||
private String targetSchemaName;
|
||||
private String targetTableName;
|
||||
private List<ColumnDescription> targetColumnDescriptions;
|
||||
@@ -247,7 +247,7 @@ public class MigrationHandler implements Supplier<Long> {
|
||||
if (!targetPrimaryKeys.isEmpty() && !dbTargetPks.isEmpty()
|
||||
&& targetPrimaryKeys.containsAll(dbTargetPks)
|
||||
&& dbTargetPks.containsAll(targetPrimaryKeys)) {
|
||||
if (targetProductType == DatabaseTypeEnum.MYSQL
|
||||
if (targetProductType == ProductTypeEnum.MYSQL
|
||||
&& !DatabaseAwareUtils.isMysqlInnodbStorageEngine(
|
||||
targetSchemaName, targetTableName, targetDataSource)) {
|
||||
return doFullCoverSynchronize(writer);
|
||||
|
@@ -33,6 +33,7 @@ import java.util.regex.Pattern;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.StopWatch;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* 数据迁移主逻辑类
|
||||
@@ -119,10 +120,13 @@ public class MigrationService {
|
||||
if (tableList.isEmpty()) {
|
||||
log.warn("### Find source database table list empty for schema name is : {}", schema);
|
||||
} else {
|
||||
String allTableType = sourceProperties.getTableType();
|
||||
for (TableDescription td : tableList) {
|
||||
// 当没有配置迁移的表是,默认为所有物理表(不含有视图表)
|
||||
if (includes.isEmpty() && DBTableType.VIEW.name().equals(td.getTableType())) {
|
||||
continue;
|
||||
// 当没有配置迁移的表名时,默认为根据类型同步所有
|
||||
if (includes.isEmpty()) {
|
||||
if (null != allTableType && !allTableType.equals(td.getTableType())) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
String tableName = td.getTableName();
|
||||
|
@@ -1,8 +1,8 @@
|
||||
dbswitch:
|
||||
source:
|
||||
# source database connection information
|
||||
## support MySQL/MariaDB/DB2/DM/Kingbase8/Oracle/SQLServer/PostgreSQL/Greenplum
|
||||
## support mutiple source database connection
|
||||
## support MySQL/MariaDB/DB2/DM/Kingbase8/Oracle/SQLServer/PostgreSQL/Greenplum etc.
|
||||
## support multiple source database connection
|
||||
- url: jdbc:oracle:thin:@172.17.2.10:1521:ORCL
|
||||
driver-class-name: 'oracle.jdbc.driver.OracleDriver'
|
||||
username: 'system'
|
||||
@@ -12,20 +12,22 @@ dbswitch:
|
||||
fetch-size: 10000
|
||||
## schema name for query source schemas, separate by ','
|
||||
source-schema: 'TANG'
|
||||
## table type which include or exclude,option: TABLE,VIEW
|
||||
table-type: 'TABLE'
|
||||
## table name include from table lists, separate by ','
|
||||
source-includes: ''
|
||||
## table name exclude from table lists, separate by ','
|
||||
source-excludes: ''
|
||||
## table name convert mapper by regular expression
|
||||
regex-table-mapper:
|
||||
- 'from-pattern': '^'
|
||||
'to-value': 'T_'
|
||||
- from-pattern: '^'
|
||||
to-value: 'T_'
|
||||
## columns name convert mapper by regular expression like regex-table-mapper
|
||||
regex-column-mapper:
|
||||
|
||||
target:
|
||||
# target database connection information
|
||||
## Best support for Oracle/PostgreSQL/Greenplum/DM/Kingbase8
|
||||
## Best support for Oracle/PostgreSQL/Greenplum/DM etc.
|
||||
url: jdbc:postgresql://172.17.2.10:5432/test
|
||||
driver-class-name: org.postgresql.Driver
|
||||
username: tang
|
||||
|
Reference in New Issue
Block a user