Bug 20754 - Db revision to remove double accepted list shares
Summary: Db revision to remove double accepted list shares
Status: CLOSED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Lists (show other bugs)
Version: master
Hardware: All All
: P5 - low enhancement (vote)
Assignee: Marcel de Rooy
QA Contact: Testopia
URL:
Keywords:
Depends on: 11943
Blocks:
  Show dependency treegraph
 
Reported: 2018-05-11 05:44 UTC by Marcel de Rooy
Modified: 2021-12-03 12:02 UTC (History)
5 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Small patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
20.05.00, 19.11.06, 19.05.11


Attachments
Bug 20754: Db revision to remove double accepted shares (1.86 KB, patch)
2018-05-11 05:48 UTC, Marcel de Rooy
Details | Diff | Splinter Review
Bug 20754: Db revision to remove double accepted shares (1.95 KB, patch)
2020-04-06 06:40 UTC, Marcel de Rooy
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Marcel de Rooy 2018-05-11 05:44:22 UTC
Coming from bug 11943
Comment 1 Marcel de Rooy 2018-05-11 05:48:54 UTC
Created attachment 75245 [details] [review]
Bug 20754: Db revision to remove double accepted shares

[Moved from bug 11943]

Although it is no problem to have them, we could do a cleanup.
This patch just removes duplicate rows from the table.

Note: I considered adding a unique index like:
    ALTER TABLE virtualshelfshares ADD UNIQUE INDEX (shelfnumber, borrowernumber, invitekey);
But the possible NULL values in borrowernumber and/or invitekey require
additional code changes. So I left it alone.

Test plan:
[1] Create two records with same borrowernumber and shelfnumber in the shares
    table, if not present already.
[2] Run updatedatabase.pl

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Comment 2 Katrin Fischer 2020-04-05 01:32:44 UTC
It looks like there is a patch with 2 sign-offs... but the status is new? What happened here?
Comment 3 Marcel de Rooy 2020-04-06 06:40:03 UTC
Created attachment 102431 [details] [review]
Bug 20754: Db revision to remove double accepted shares

[Originally submitted for bug 11943, parked at 20754.]
[Attempt to revive it now.]

Although it is no problem to have them, we could do a cleanup.
This patch just removes duplicate rows from the table.

Note: I considered adding a unique index like:
    ALTER TABLE virtualshelfshares ADD UNIQUE INDEX (shelfnumber, borrowernumber, invitekey);
But the possible NULL values in borrowernumber and/or invitekey require
additional code changes. So I left it alone.

Test plan:
[1] Create two records with same borrowernumber and shelfnumber in the shares
    table, if not present already.
[2] Run updatedatabase.pl

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Comment 4 Marcel de Rooy 2020-04-06 06:42:20 UTC
(In reply to Katrin Fischer from comment #2)
> It looks like there is a patch with 2 sign-offs... but the status is new?
> What happened here?

It came from 11943. Not really clear to me why this really had to be moved at the time. It passed QA.

Passing it to RM now for further judgement.
Comment 5 Jonathan Druart 2020-04-06 09:06:03 UTC
We usually use the following syntax to remove duplicated rows:
  DELETE t1 FROM table_1 t1
  LEFT JOIN table_2 t2 on t1.id=t2.id
  WHERE t2.id IS NULL;
Comment 6 Martin Renvoize 2020-04-06 11:29:16 UTC
Nice work everyone!

Pushed to master for 20.05
Comment 7 Martin Renvoize 2020-04-14 15:07:39 UTC
Nice work everyone!

Pushed to master for 20.05
Comment 8 Joy Nelson 2020-04-29 20:48:45 UTC
Backported to 19.11.x for 19.11.06
Comment 9 Lucas Gass 2020-05-11 21:31:52 UTC
backported to 19.05.x for 19.05.11