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

(-)a/Koha/Database/Auditor.pm (-2 / +22 lines)
Lines 51-57 sub new { Link Here
51
51
52
=head3 run
52
=head3 run
53
53
54
Run the database audit with the given arguments, including the filename.
54
Compares the current database schema with the expected schema from the
55
`kohastructure.sql` file. Generates SQL commands to update the database schema
56
if differences are found. Returns a hash reference containing the differences,
57
a flag indicating if differences were found, a message, and a title.
55
58
56
=cut
59
=cut
57
60
Lines 74-80 sub run { Link Here
74
            }
77
            }
75
        )->compute_differences->produce_diff_sql;
78
        )->compute_differences->produce_diff_sql;
76
79
77
        return $diff;
80
        my $diff_found = 1;
81
        my $message = __(
82
            "These commands are only suggestions. They are not a replacement for the database update scripts run during installations and updates.\nReview the database, the atomic update files and the table definitions in kohastructure.sql before running any of the commands below:"
83
        );
84
        my $title = __("Warning!");
85
86
        if ( $diff =~ /No differences found/ ) {
87
            $diff_found = 0;
88
            $message = __("The installed database schema is correct.");
89
            $title   = __("All is well");
90
        }
91
92
        return {
93
            diff       => $diff,
94
            diff_found => $diff_found,
95
            message    => $message,
96
            title      => $title,
97
        };
78
    }
98
    }
79
}
99
}
80
100
(-)a/about.pl (-2 / +2 lines)
Lines 929-935 sub message_broker_check { Link Here
929
if ( $tab eq 'database' ) {
929
if ( $tab eq 'database' ) {
930
    use Koha::Database::Auditor;
930
    use Koha::Database::Auditor;
931
    my $db_auditor = Koha::Database::Auditor->new();
931
    my $db_auditor = Koha::Database::Auditor->new();
932
    my $audit_diff = $db_auditor->run;
932
    my $db_audit = $db_auditor->run;
933
    $template->param( audit_diff => $audit_diff );
933
    $template->param( db_audit => $db_audit );
934
}
934
}
935
output_html_with_http_headers $query, $cookie, $template->output;
935
output_html_with_http_headers $query, $cookie, $template->output;
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/about.tt (-11 / +14 lines)
Lines 798-816 Link Here
798
[% BLOCK database_panel %]
798
[% BLOCK database_panel %]
799
    [% WRAPPER tab_panel tabname= "database" bt_active = 1 %]
799
    [% WRAPPER tab_panel tabname= "database" bt_active = 1 %]
800
        <h2>Database audit</h2>
800
        <h2>Database audit</h2>
801
        [% IF db_audit.diff_found %]
801
        <div class="alert alert-warning">
802
        <div class="alert alert-warning">
802
            <h3>WARNING!!!</h3>
803
        [% ELSE %]
803
            <p>
804
        <div class="alert alert-success">
804
               These commands are only suggestions! They are not a replacement for updatedatabase.pl!<br />
805
        [% END %]
805
               Review the database, updatedatabase.pl, and kohastructure.sql before making any changes!<br />
806
            <h3><strong>[% db_audit.title %]</strong></h3>
806
            </p>
807
            <p><pre>[% db_audit.message %]</pre><p>
807
        </div>
808
        <div>
809
        <p>Run the following SQL to fix the database:</p>
810
        <pre>
811
            <code>[% audit_diff | $raw %]</code>
812
        </pre>
813
        </div>
808
        </div>
809
        [% IF db_audit.diff_found %]
810
            <div>
811
                <p>Run the following SQL to fix the database:</p>
812
                <pre>
813
                    <code>[% db_audit.diff | $raw %]</code>
814
                </pre>
815
            </div>
816
        [% END %]
814
    [% END # tab=database %]
817
    [% END # tab=database %]
815
[% END %]
818
[% END %]
816
819
(-)a/misc/maintenance/audit_database.pl (-10 / +3 lines)
Lines 11-22 GetOptions( Link Here
11
    "filename=s" => \$filename,
11
    "filename=s" => \$filename,
12
) or die("Error in command line arguments\n");
12
) or die("Error in command line arguments\n");
13
13
14
my $auditor = Koha::Database::Auditor->new( { filename => $filename } );
14
my $auditor  = Koha::Database::Auditor->new( { filename => $filename } );
15
my $diff    = $auditor->run;
15
my $db_audit = $auditor->run;
16
16
print $db_audit->{title} . "\n" . $db_audit->{message} . "\n" . ( $db_audit->{diff_found} ? $db_audit->{diff} : '' );
17
my $warning = "\n"
18
    . "WARNING!!!\n"
19
    . "These commands are only suggestions! They are not a replacement for updatedatabase.pl!\n"
20
    . "Review the database, updatedatabase.pl, and kohastructure.sql before making any changes!\n" . "\n";
21
22
print $diff . $warning;
23
- 

Return to bug 36039