Bug 32334: (follow-up) Fix for bug 31028, introducing IF NOT EXISTS

We need to expect CREATE TABLE IF NOT EXISTS now in kohastructure.

Test plan:
Run misc/maintenance/sync_db_comments.pl -reset

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
Marcel de Rooy 2023-03-16 12:57:13 +00:00 committed by Tomas Cohen Arazi
parent 6a706f0e6a
commit d7e5fb0344
Signed by: tomascohen
GPG key ID: 0A272EA1B2F3C15F

View file

@ -182,9 +182,9 @@ sub _fetch_schema_comments {
my $info = {};
my $current_table = q{};
foreach my $line ( @schema_lines ) {
if( $line =~ /^CREATE TABLE `?(\w+)`?/ ) {
if( $line =~ /^CREATE TABLE\s*(?:IF NOT EXISTS)?\s*`?(\w+)`?/ ) {
$current_table = $1;
} elsif( $line =~ /^\s+`?(\w+)`?.*COMMENT ['"](.+)['"][,)]?$/ ) {
} elsif( $current_table && $line =~ /^\s+`?(\w+)`?.*COMMENT ['"](.+)['"][,)]?$/ ) {
my ( $col, $comment ) = ( $1, $2 );
$comment =~ s/''/'/g; # we call quote later on
$info->{$current_table}->{$col} = $comment;