View | Details | Raw Unified | Return to bug 32334
Collapse All | Expand All

(-)a/Koha/Database/Commenter.pm (-2 / +4 lines)
Lines 77-83 sub new { Link Here
77
        unless ref($self->{dbh}) eq DBI_HANDLE_CLASS;
77
        unless ref($self->{dbh}) eq DBI_HANDLE_CLASS;
78
78
79
    $self->{database} //= ( $self->{dbh}->selectrow_array('SELECT DATABASE()') )[0];
79
    $self->{database} //= ( $self->{dbh}->selectrow_array('SELECT DATABASE()') )[0];
80
    $self->_find_schema unless $self->{schema_file};
80
    $self->_find_schema;
81
    $self->{schema_info} = {};
81
    $self->{schema_info} = {};
82
82
83
    return $self;
83
    return $self;
Lines 159-165 sub renumber { Link Here
159
sub _find_schema {
159
sub _find_schema {
160
    my $self = shift;
160
    my $self = shift;
161
    my $rootdir = C4::Context->config('intranetdir');
161
    my $rootdir = C4::Context->config('intranetdir');
162
    if( -e "$rootdir/". KOHA_STRUCTURE ) {
162
    if( $self->{schema_file} ) {
163
        warn "File ". $self->{schema_file}. " not found!\n" if !-e $self->{schema_file};
164
    } elsif( -e "$rootdir/". KOHA_STRUCTURE ) {
163
        $self->{schema_file} = "$rootdir/". KOHA_STRUCTURE;
165
        $self->{schema_file} = "$rootdir/". KOHA_STRUCTURE;
164
    } elsif( -e "$rootdir/intranet/cgi-bin/". KOHA_STRUCTURE ) {
166
    } elsif( -e "$rootdir/intranet/cgi-bin/". KOHA_STRUCTURE ) {
165
        $self->{schema_file} = "$rootdir/intranet/cgi-bin/". KOHA_STRUCTURE;
167
        $self->{schema_file} = "$rootdir/intranet/cgi-bin/". KOHA_STRUCTURE;
(-)a/misc/maintenance/sync_db_comments.pl (-4 / +9 lines)
Lines 36-47 GetOptions( Link Here
36
  'help|h'     => \$cmd_args->{help},
36
  'help|h'     => \$cmd_args->{help},
37
  'renumber'   => \$cmd_args->{renumber},
37
  'renumber'   => \$cmd_args->{renumber},
38
  'reset'      => \$cmd_args->{reset},
38
  'reset'      => \$cmd_args->{reset},
39
  'schema:s'   => \$cmd_args->{schema_file},
39
  'table:s'    => \$cmd_args->{table},
40
  'table:s'    => \$cmd_args->{table},
40
  'verbose|v'  => \$cmd_args->{verbose},
41
  'verbose|v'  => \$cmd_args->{verbose},
41
);
42
);
42
$cmd_args->{dry_run} = !$cmd_args->{commit};
43
$cmd_args->{dry_run} = !$cmd_args->{commit};
43
44
44
my $commenter = Koha::Database::Commenter->new({ database => delete $cmd_args->{database}, dbh => C4::Context->dbh });
45
my $commenter = Koha::Database::Commenter->new({
46
     database => delete $cmd_args->{database},
47
     dbh => C4::Context->dbh,
48
     schema_file => delete $cmd_args->{schema_file},
49
});
45
my $messages = $cmd_args->{verbose} || $cmd_args->{dry_run} ? [] : undef;
50
my $messages = $cmd_args->{verbose} || $cmd_args->{dry_run} ? [] : undef;
46
if( $cmd_args->{help} ) {
51
if( $cmd_args->{help} ) {
47
    pod2usage( -verbose => 2 );
52
    pod2usage( -verbose => 2 );
Lines 71-77 misc/maintenance/sync_db_comments.pl Link Here
71
76
72
=head1 SYNOPSIS
77
=head1 SYNOPSIS
73
78
74
    perl sync_db_comments.pl [-h] [-v] [-database DB_NAME] [-table TABLE_NAME] [-commit] [-clear|-reset|-renumber]
79
    perl sync_db_comments.pl [-h] [-v] [-database DB_NAME] [-table TABLE_NAME] [-schema SCHEMA_FILE] [-commit] [-clear|-reset|-renumber]
75
80
76
=head1 DESCRIPTION
81
=head1 DESCRIPTION
77
82
Lines 91-99 misc/maintenance/sync_db_comments.pl Link Here
91
    Clear all column comments in database.
96
    Clear all column comments in database.
92
    The verbose flag shows all issued ALTER TABLE statements.
97
    The verbose flag shows all issued ALTER TABLE statements.
93
98
94
    misc/maintance/sync_db_comments.pl -reset -commit -database mydb -table items
99
    misc/maintance/sync_db_comments.pl -reset -commit -database mydb -table items -schema newstructure.sql
95
    Only resets comments in items table.
100
    Only resets comments in items table.
96
    Operates on specific database instead of the one from $KOHA_CONF.
101
    Operates on specific database instead of the one from $KOHA_CONF.
102
    Reads the schema from the specified file instead of default one.
97
103
98
    misc/maintance/sync_db_comments.pl -renumber
104
    misc/maintance/sync_db_comments.pl -renumber
99
    Renumbers all comments like Comment_1,2,..
105
    Renumbers all comments like Comment_1,2,..
100
- 

Return to bug 32334