Skip to content

Commit

Permalink
Optimize relationship dumping
Browse files Browse the repository at this point in the history
  • Loading branch information
IlyaLisov committed Jul 2, 2023
1 parent 7f52286 commit 4377f53
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,10 @@ public MigrationData dumpWithForeignKeys(String tableName, String columnFrom, St
skip += String.format(" AND %s NOT IN (%s)", key, valuesString);
}
}
String fromNotNull = columnFrom + " IS NOT NULL ";
String toNotNull = columnTo + " IS NOT NULL ";
try (PrintWriter writer = new PrintWriter(dumpScript)) {
writer.printf("psql -U %s -c \"COPY (SELECT %s as %s, %s as %s FROM %s WHERE %s AND %s) TO STDOUT WITH CSV DELIMITER '%s' HEADER\" %s > %s.csv",
writer.printf("psql -U %s -c \"COPY (SELECT %s as %s, %s as %s FROM %s WHERE %s AND %s AND %s AND %s) TO STDOUT WITH CSV DELIMITER '%s' HEADER\" %s > %s.csv",
postgresRepository.getUsername(),
columnFrom,
foreignColumnFrom,
Expand All @@ -101,6 +103,8 @@ public MigrationData dumpWithForeignKeys(String tableName, String columnFrom, St
tableName,
follow,
skip,
fromNotNull,
toNotNull,
delimiter,
postgresRepository.getDatabaseName(),
tableName);
Expand Down

0 comments on commit 4377f53

Please sign in to comment.