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

(-)a/Koha/Schema/Loader/mysql.pm (+59 lines)
Line 0 Link Here
1
use utf8;
2
3
package Koha::Schema::Loader::mysql;
4
5
# Copyright 2020 PTFS Europe
6
#
7
# This file is part of Koha.
8
#
9
# Koha is free software; you can redistribute it and/or modify it
10
# under the terms of the GNU General Public License as published by
11
# the Free Software Foundation; either version 3 of the License, or
12
# (at your option) any later version.
13
#
14
# Koha is distributed in the hope that it will be useful, but
15
# WITHOUT ANY WARRANTY; without even the implied warranty of
16
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
# GNU General Public License for more details.
18
#
19
# You should have received a copy of the GNU General Public License
20
# along with Koha; if not, see <http://www.gnu.org/licenses>.
21
22
use Modern::Perl;
23
24
use base 'DBIx::Class::Schema::Loader::DBI::mysql';
25
use mro 'c3';
26
27
use Scalar::Util 'blessed';
28
29
# This is being upstreamed, but for now lets make sure whatever version of DBIx::Class::Schema::Loader you are using,
30
# we will catch MariaDB current_timestamp() and convert it to \"current_timestamp" correctly.
31
sub _extra_column_info {
32
    no warnings 'uninitialized';
33
    my ( $self, $table, $col, $info, $dbi_info ) = @_;
34
    my %extra_info;
35
36
    if ( $dbi_info->{mysql_is_auto_increment} ) {
37
        $extra_info{is_auto_increment} = 1;
38
    }
39
    if ( $dbi_info->{mysql_type_name} =~ /\bunsigned\b/i ) {
40
        $extra_info{extra}{unsigned} = 1;
41
    }
42
    if ( $dbi_info->{mysql_values} ) {
43
        $extra_info{extra}{list} = $dbi_info->{mysql_values};
44
    }
45
    if (
46
        ( not blessed $dbi_info)    # isa $sth
47
        && lc( $dbi_info->{COLUMN_DEF} ) =~ m/^current_timestamp/
48
        && lc( $dbi_info->{mysql_type_name} ) eq 'timestamp'
49
      )
50
    {
51
52
        my $current_timestamp = 'current_timestamp';
53
        $extra_info{default_value} = \$current_timestamp;
54
    }
55
56
    return \%extra_info;
57
}
58
59
1;
(-)a/misc/devel/update_dbix_class_files.pl (-3 / +6 lines)
Lines 19-25 Link Here
19
# along with Koha; if not, see <http://www.gnu.org/licenses>.
19
# along with Koha; if not, see <http://www.gnu.org/licenses>.
20
20
21
use Modern::Perl;
21
use Modern::Perl;
22
23
use DBIx::Class::Schema::Loader qw/ make_schema_at /;
22
use DBIx::Class::Schema::Loader qw/ make_schema_at /;
24
23
25
use Getopt::Long;
24
use Getopt::Long;
Lines 99-105 if (! defined $db_name ) { Link Here
99
    make_schema_at(
98
    make_schema_at(
100
        "Koha::Schema",
99
        "Koha::Schema",
101
        { debug => 1, dump_directory => $path, preserve_case => 1 },
100
        { debug => 1, dump_directory => $path, preserve_case => 1 },
102
        ["DBI:$db_driver:dbname=$db_name;host=$db_host;port=$db_port",$db_user, $db_passwd ]
101
        [
102
            "DBI:$db_driver:dbname=$db_name;host=$db_host;port=$db_port",
103
            $db_user,
104
            $db_passwd,
105
            { loader_class => 'Koha::Schema::Loader::mysql' }
106
        ]
103
    );
107
    );
104
}
108
}
105
109
106
- 

Return to bug 25040