From e1c6d6f1138cb270e9392e006a5ee5026bcc81a3 Mon Sep 17 00:00:00 2001 From: Witold Brzozowski Date: Fri, 5 Apr 2024 15:57:36 +0200 Subject: [PATCH] Add primary key constraint to presence confirmations table (#241) --- .../scripts/V3_4_0_1__fix_presence_confirmations.sql | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 src/main/resources/scripts/V3_4_0_1__fix_presence_confirmations.sql diff --git a/src/main/resources/scripts/V3_4_0_1__fix_presence_confirmations.sql b/src/main/resources/scripts/V3_4_0_1__fix_presence_confirmations.sql new file mode 100644 index 0000000..645380a --- /dev/null +++ b/src/main/resources/scripts/V3_4_0_1__fix_presence_confirmations.sql @@ -0,0 +1,9 @@ +DELETE FROM presence_confirmations +WHERE id NOT IN ( + SELECT MIN(id) + FROM presence_confirmations + GROUP BY date, user_id +); + +ALTER TABLE presence_confirmations +ADD CONSTRAINT pk_presence_confirmations PRIMARY KEY (date, user_id); \ No newline at end of file