Bugzilla – Attachment 148299 Details for
Bug 32334
Sync comments in database with schema
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 32334: (follow-up) Add the -schema parameter to script too
Bug-32334-follow-up-Add-the--schema-parameter-to-s.patch (text/plain), 3.65 KB, created by
Marcel de Rooy
on 2023-03-17 07:52:43 UTC
(
hide
)
Description:
Bug 32334: (follow-up) Add the -schema parameter to script too
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2023-03-17 07:52:43 UTC
Size:
3.65 KB
patch
obsolete
>From 118ca7ac41fdc40a3ac0d144a003312492830580 Mon Sep 17 00:00:00 2001 >From: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Date: Fri, 17 Mar 2023 07:46:44 +0000 >Subject: [PATCH] Bug 32334: (follow-up) Add the -schema parameter to script > too >Content-Type: text/plain; charset=utf-8 > >Finally adding it here too. > >Test plan: >Copy your kohastructure to xx.sql. >Run sync_db_comments.pl -schema xx.sql. You will see usage. >Run sync_db_comments.pl -schema xyz.sql. You will see a warn and >the usage statement. > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >--- > Koha/Database/Commenter.pm | 6 ++++-- > misc/maintenance/sync_db_comments.pl | 12 +++++++++--- > 2 files changed, 13 insertions(+), 5 deletions(-) > >diff --git a/Koha/Database/Commenter.pm b/Koha/Database/Commenter.pm >index 2b37067c76..fb4048f1dc 100644 >--- a/Koha/Database/Commenter.pm >+++ b/Koha/Database/Commenter.pm >@@ -77,7 +77,7 @@ sub new { > unless ref($self->{dbh}) eq DBI_HANDLE_CLASS; > > $self->{database} //= ( $self->{dbh}->selectrow_array('SELECT DATABASE()') )[0]; >- $self->_find_schema unless $self->{schema_file}; >+ $self->_find_schema; > $self->{schema_info} = {}; > > return $self; >@@ -159,7 +159,9 @@ sub renumber { > sub _find_schema { > my $self = shift; > my $rootdir = C4::Context->config('intranetdir'); >- if( -e "$rootdir/". KOHA_STRUCTURE ) { >+ if( $self->{schema_file} ) { >+ warn "File ". $self->{schema_file}. " not found!\n" if !-e $self->{schema_file}; >+ } elsif( -e "$rootdir/". KOHA_STRUCTURE ) { > $self->{schema_file} = "$rootdir/". KOHA_STRUCTURE; > } elsif( -e "$rootdir/intranet/cgi-bin/". KOHA_STRUCTURE ) { > $self->{schema_file} = "$rootdir/intranet/cgi-bin/". KOHA_STRUCTURE; >diff --git a/misc/maintenance/sync_db_comments.pl b/misc/maintenance/sync_db_comments.pl >index 5014c4ac68..bded6945fd 100755 >--- a/misc/maintenance/sync_db_comments.pl >+++ b/misc/maintenance/sync_db_comments.pl >@@ -36,12 +36,17 @@ GetOptions( > 'help|h' => \$cmd_args->{help}, > 'renumber' => \$cmd_args->{renumber}, > 'reset' => \$cmd_args->{reset}, >+ 'schema:s' => \$cmd_args->{schema_file}, > 'table:s' => \$cmd_args->{table}, > 'verbose|v' => \$cmd_args->{verbose}, > ); > $cmd_args->{dry_run} = !$cmd_args->{commit}; > >-my $commenter = Koha::Database::Commenter->new({ database => delete $cmd_args->{database}, dbh => C4::Context->dbh }); >+my $commenter = Koha::Database::Commenter->new({ >+ database => delete $cmd_args->{database}, >+ dbh => C4::Context->dbh, >+ schema_file => delete $cmd_args->{schema_file}, >+}); > my $messages = $cmd_args->{verbose} || $cmd_args->{dry_run} ? [] : undef; > if( $cmd_args->{help} ) { > pod2usage( -verbose => 2 ); >@@ -71,7 +76,7 @@ misc/maintenance/sync_db_comments.pl > > =head1 SYNOPSIS > >- perl sync_db_comments.pl [-h] [-v] [-database DB_NAME] [-table TABLE_NAME] [-commit] [-clear|-reset|-renumber] >+ perl sync_db_comments.pl [-h] [-v] [-database DB_NAME] [-table TABLE_NAME] [-schema SCHEMA_FILE] [-commit] [-clear|-reset|-renumber] > > =head1 DESCRIPTION > >@@ -91,9 +96,10 @@ misc/maintenance/sync_db_comments.pl > Clear all column comments in database. > The verbose flag shows all issued ALTER TABLE statements. > >- misc/maintance/sync_db_comments.pl -reset -commit -database mydb -table items >+ misc/maintance/sync_db_comments.pl -reset -commit -database mydb -table items -schema newstructure.sql > Only resets comments in items table. > Operates on specific database instead of the one from $KOHA_CONF. >+ Reads the schema from the specified file instead of default one. > > misc/maintance/sync_db_comments.pl -renumber > Renumbers all comments like Comment_1,2,.. >-- >2.30.2
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 32334
:
144391
|
144392
|
144393
|
144394
|
146712
|
146713
|
146714
|
146715
|
146716
|
146717
|
146718
|
146719
|
146720
|
148266
|
148299
|
148335
|
148338
|
148339
|
148340
|
148341
|
148342
|
148343
|
148344
|
148345
|
148346
|
148347
|
148348
|
149259
|
149260
|
149261
|
149262
|
149263
|
149264
|
149265
|
149266
|
149267
|
149268
|
149269
|
149270