From affa3164eb475ff09654c690c9df810be8dc670f Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Wed, 18 Nov 2020 17:08:11 +0000 Subject: [PATCH] Bug 26947: (follow-up) Set key checks to disabled for kohastructure This patch adds sql calls to disable foreign key checks for the initial kohastructure schema load and then re-enables them again for subsequent actions. Signed-off-by: Martin Renvoize Signed-off-by: Victor Grousset/tuxayo Signed-off-by: Kyle M Hall Signed-off-by: Jonathan Druart --- C4/Installer.pm | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/C4/Installer.pm b/C4/Installer.pm index 1c5dc8f1ec..e87109574b 100644 --- a/C4/Installer.pm +++ b/C4/Installer.pm @@ -279,7 +279,23 @@ sub load_db_schema { my $self = shift; my $datadir = C4::Context->config('intranetdir') . "/installer/data/$self->{dbms}"; + + # Disable checks before load + $self->{'dbh'}->do(q{SET NAMES utf8mb4}); + $self->{'dbh'}->do(q{SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0}); + $self->{'dbh'}->do(q{SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0}); + $self->{'dbh'}->do(q{SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO'}); + $self->{'dbh'}->do(q{SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0}); + + # Load kohastructure my $error = $self->load_sql("$datadir/kohastructure.sql"); + + # Re-enable checks after load + $self->{'dbh'}->do(q{SET SQL_MODE=@OLD_SQL_MODE}); + $self->{'dbh'}->do(q{SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS}); + $self->{'dbh'}->do(q{SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS}); + $self->{'dbh'}->do(q{SET SQL_NOTES=@OLD_SQL_NOTES}); + return $error; } -- 2.39.5