Skip to content

Commit

Permalink
Merge pull request #7 from maheshp/support_db_sync
Browse files Browse the repository at this point in the history
Do not sync all changelog tables
  • Loading branch information
maheshp committed Oct 12, 2020
2 parents 42555b2 + d8076df commit 31bc0c6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ Know more about GoCD support for multiple databases [here](https://docs.gocd.org

* As part of migrating data from a older GoCD `v20.4.0` (or below) to the GoCD `v20.5.0` database, users can convert/sync data from one database to another. This allows GoCD users to switch from any of the existing database to `H2`, `PostgreSQL` or `MySQL` database.

### Note: This tool currently supports only migration of data from older GoCD database `v20.4.0` (or below) to the GoCD `v20.5.0` compatible database. Post migration, you cannot use this tool to sync data between different databases.
* For databases which are already migrated and are GoCD `v20.5.0` compliant, this tool can be used to sync data to a new database post the initial migration to GoCD `v20.5.0`.
E.g Sync data from a GoCD `v20.5.0` H2 database to a new PostgreSQL database. Verifyied to work till GoCD `v20.8.0`.

## Supported Databases

* H2 (`1.3.xxx` and above)
* PostgreSQL (`9.6` and above)
* MySQL (`8.0`)


## Installation

#### 1. From The Source:
Expand Down
12 changes: 9 additions & 3 deletions src/main/java/com/thoughtworks/go/dbsync/DbSync.java
Original file line number Diff line number Diff line change
Expand Up @@ -395,14 +395,20 @@ private static Map<String, Integer> listTables(BasicDataSource sourceDataSource)
.fetch();

for (Record1<String> record : result) {
String value = record.getValue(field);
if (!value.equalsIgnoreCase("CHANGELOG")) {
tables.put(value, using(connection).fetchCount(table(value)));
String tableName = record.getValue(field);

if (!isChangeLogTable(tableName)) {
tables.put(tableName, using(connection).fetchCount(table(tableName)));
}
}
});

return tables;
}

private static boolean isChangeLogTable(String tableName) {
return tableName.equalsIgnoreCase("CHANGELOG") ||
tableName.equalsIgnoreCase("DATABASECHANGELOG") ||
tableName.equalsIgnoreCase("DATABASECHANGELOGLOCK");
}
}

0 comments on commit 31bc0c6

Please sign in to comment.