From 6d6f049f21dcffb782aadedad2c0b58740e3c03f Mon Sep 17 00:00:00 2001 From: Pauline Date: Mon, 20 May 2024 12:01:25 +0100 Subject: [PATCH 1/4] fix: ensure subject protocol map has unique values --- .../questionnaire/protocol/GithubProtocolFetcherStrategy.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/org/radarbase/appserver/service/questionnaire/protocol/GithubProtocolFetcherStrategy.java b/src/main/java/org/radarbase/appserver/service/questionnaire/protocol/GithubProtocolFetcherStrategy.java index 22777e9f..428d5d51 100644 --- a/src/main/java/org/radarbase/appserver/service/questionnaire/protocol/GithubProtocolFetcherStrategy.java +++ b/src/main/java/org/radarbase/appserver/service/questionnaire/protocol/GithubProtocolFetcherStrategy.java @@ -125,6 +125,7 @@ public synchronized Map fetchProtocols() { Map subjectProtocolMap = users.parallelStream() .map(u -> this.fetchProtocolForSingleUser(u, u.getProject().getProjectId(), protocolPaths)) .filter(c -> c.getProtocol() != null) + .distinct() .collect(Collectors.toMap(ProtocolCacheEntry::getId, ProtocolCacheEntry::getProtocol)); log.info("Refreshed Protocols from Github"); From b9a8d83e8b00ea72168bd292f35af3d173617150 Mon Sep 17 00:00:00 2001 From: Pauline Date: Wed, 22 May 2024 19:02:10 +0100 Subject: [PATCH 2/4] Update users entiy and table unique constraints --- .../org/radarbase/appserver/entity/User.java | 3 ++- ...update_schema-20240522185927_changelog.yml | 24 +++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 src/main/resources/db/changelog/changes/00000000000002_update_schema-20240522185927_changelog.yml diff --git a/src/main/java/org/radarbase/appserver/entity/User.java b/src/main/java/org/radarbase/appserver/entity/User.java index f59f95a5..fc9c32f3 100644 --- a/src/main/java/org/radarbase/appserver/entity/User.java +++ b/src/main/java/org/radarbase/appserver/entity/User.java @@ -61,7 +61,8 @@ @Table( name = "users", uniqueConstraints = { - @UniqueConstraint(columnNames = {"subject_id", "fcm_token", "project_id"}) + @UniqueConstraint(columnNames = {"subject_id", "project_id"}), + @UniqueConstraint(columnNames = {"fcm_token"}) }) @Entity @Getter diff --git a/src/main/resources/db/changelog/changes/00000000000002_update_schema-20240522185927_changelog.yml b/src/main/resources/db/changelog/changes/00000000000002_update_schema-20240522185927_changelog.yml new file mode 100644 index 00000000..d0bcdf19 --- /dev/null +++ b/src/main/resources/db/changelog/changes/00000000000002_update_schema-20240522185927_changelog.yml @@ -0,0 +1,24 @@ +databaseChangeLog: + - changeSet: + id: 1543511610622-8 + author: pauline + changes: + - dropUniqueConstraint: + tableName: users + constraintName: UKmm6u3xspqfqoolkjhsvdrqefq + - changeSet: + id: 1716400827373-1 + author: pauline + changes: + - addUniqueConstraint: + columnNames: subject_id, project_id + constraintName: UK_subject_project + tableName: users + - changeSet: + id: 1716400827373-2 + author: pauline + changes: + - addUniqueConstraint: + columnNames: fcm_token + constraintName: UK_fcm_token + tableName: users From 119c3389dedcb4724d9857de120fcf4b784c4360 Mon Sep 17 00:00:00 2001 From: Pauline Date: Fri, 24 May 2024 19:30:59 +0800 Subject: [PATCH 3/4] fix: update liquibase changelog constrain names --- .../00000000000002_update_schema-20240522185927_changelog.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/resources/db/changelog/changes/00000000000002_update_schema-20240522185927_changelog.yml b/src/main/resources/db/changelog/changes/00000000000002_update_schema-20240522185927_changelog.yml index d0bcdf19..ca12f7fe 100644 --- a/src/main/resources/db/changelog/changes/00000000000002_update_schema-20240522185927_changelog.yml +++ b/src/main/resources/db/changelog/changes/00000000000002_update_schema-20240522185927_changelog.yml @@ -12,7 +12,7 @@ databaseChangeLog: changes: - addUniqueConstraint: columnNames: subject_id, project_id - constraintName: UK_subject_project + constraintName: UKg6m4nzwvxqpwtrbeynasdcplo tableName: users - changeSet: id: 1716400827373-2 @@ -20,5 +20,5 @@ databaseChangeLog: changes: - addUniqueConstraint: columnNames: fcm_token - constraintName: UK_fcm_token + constraintName: UKtt8k2ufjqryoomkjxsebufgtr tableName: users From 3b6283458bcc3b63359a255e9aadda5780e639aa Mon Sep 17 00:00:00 2001 From: Pauline Date: Fri, 24 May 2024 19:42:28 +0800 Subject: [PATCH 4/4] fix: remove existing fmc_token unique constraint --- ...00000000002_update_schema-20240522185927_changelog.yml | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/main/resources/db/changelog/changes/00000000000002_update_schema-20240522185927_changelog.yml b/src/main/resources/db/changelog/changes/00000000000002_update_schema-20240522185927_changelog.yml index ca12f7fe..499e2984 100644 --- a/src/main/resources/db/changelog/changes/00000000000002_update_schema-20240522185927_changelog.yml +++ b/src/main/resources/db/changelog/changes/00000000000002_update_schema-20240522185927_changelog.yml @@ -14,11 +14,3 @@ databaseChangeLog: columnNames: subject_id, project_id constraintName: UKg6m4nzwvxqpwtrbeynasdcplo tableName: users - - changeSet: - id: 1716400827373-2 - author: pauline - changes: - - addUniqueConstraint: - columnNames: fcm_token - constraintName: UKtt8k2ufjqryoomkjxsebufgtr - tableName: users