Bug 31383: Fix dbrevs

We need to remove duplicate entries.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
Jonathan Druart 2023-07-04 13:58:34 +02:00 committed by Tomas Cohen Arazi
parent 84368f6d39
commit 9c5d09172d
Signed by: tomascohen
GPG key ID: 0A272EA1B2F3C15F

View file

@ -44,6 +44,14 @@ return {
for my $translated_content ( @$translated_contents ) {
$sth_insert->execute($content->{id}, $translated_content->{title}, $translated_content->{content}, $translated_content->{lang}, $translated_content->{updated_on});
}
# Delete duplicates
$q = q{
DELETE FROM additional_contents
WHERE category=? AND code=? AND id<>? AND
};
$q .= defined $content->{branchcode} ? " branchcode = ?" : " branchcode IS NULL";
$dbh->do($q, undef, $content->{category}, $content->{code}, $content->{id}, $content->{branchcode});
}
$dbh->do(q{
ALTER TABLE additional_contents