Skip to content

Commit

Permalink
Avoid schema duplication. Similar to fordfrog#265 from jschaf
Browse files Browse the repository at this point in the history
  • Loading branch information
jalisson committed Aug 21, 2020
1 parent 40698e2 commit c5574f1
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/main/java/cz/startnet/utils/pgdiff/schema/PgDatabase.java
Original file line number Diff line number Diff line change
Expand Up @@ -137,14 +137,12 @@ public List<PgSchema> getSchemas() {
* Adds {@code schema} to the lists of schemas.
*
* @param schema schema
* @throws ParserException Thrown if schema was already added to the database.
*/
public void addSchema(final PgSchema schema) {
if (Objects.nonNull(schemas) && !schemas.isEmpty()) {
if (!schemas.contains(schema)) {
schemas.add(schema);
}
} else {

if (schemas.isEmpty()) {
schemas.add(schema);
} else if (!schemas.stream().filter(o -> o.getName().equals(schema.getName())).findFirst().isPresent()) {
schemas.add(schema);
}
}
Expand Down
1 change: 1 addition & 0 deletions src/test/java/cz/startnet/utils/pgdiff/PgDiffTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@ public static Collection<?> parameters() {
, {"alter_view_owner", false, false, false, false}
, {"grant_on_table_cols_mixed", false, false, false, false}
, {"grant_on_view_cols_mixed", false, false, false, false}
, {"create_schema_no_change_table", false, false, false, false}
});
}
/**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@


Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
CREATE SCHEMA public;
CREATE TABLE public.node (instance_id text);

Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
CREATE SCHEMA public;
CREATE TABLE public.node (instance_id text);

0 comments on commit c5574f1

Please sign in to comment.