From b185750f0e2cb96cfbdd851cf061e846ef288899 Mon Sep 17 00:00:00 2001 From: David Cook Date: Mon, 1 Dec 2014 10:45:07 +1100 Subject: [PATCH] Latest work http://bugs.koha-community.org/show_bug.cgi?id=11390 --- Koha/Schema/Result/Accountline.pm | 3 +++ installer/dbic_controller.pl | 1 - misc/devel/update_dbix_class_files.pl | 28 +++++++++++++++++++++++++--- 3 files changed, 28 insertions(+), 4 deletions(-) mode change 100644 => 100755 Koha/Schema/Result/Accountline.pm diff --git a/Koha/Schema/Result/Accountline.pm b/Koha/Schema/Result/Accountline.pm old mode 100644 new mode 100755 index e83ef40..7011204 --- a/Koha/Schema/Result/Accountline.pm +++ b/Koha/Schema/Result/Accountline.pm @@ -153,6 +153,9 @@ __PACKAGE__->add_columns( datetime_undef_if_invalid => 1, default_value => \"current_timestamp", is_nullable => 0, + extra => { + "on update" => \"current_timestamp", + }, }, "notify_id", { data_type => "integer", default_value => 0, is_nullable => 0 }, diff --git a/installer/dbic_controller.pl b/installer/dbic_controller.pl index d74dc70..9bd62c6 100644 --- a/installer/dbic_controller.pl +++ b/installer/dbic_controller.pl @@ -5,7 +5,6 @@ use Data::Dumper; my $schema = Koha::Database->new()->schema(); - $schema->deploy({quote_identifiers => 1, producer_args => {mysql_version => '5.5.33'}, }); #my $statements = $schema->deployment_statements(undef,'2.0',undef,{quote_identifiers => 1, producer_args => {mysql_version => '5.5.33'},}); #print Dumper($statements); diff --git a/misc/devel/update_dbix_class_files.pl b/misc/devel/update_dbix_class_files.pl index a291cef..b3fbf12 100755 --- a/misc/devel/update_dbix_class_files.pl +++ b/misc/devel/update_dbix_class_files.pl @@ -24,6 +24,7 @@ use DBIx::Class::Schema::Loader qw/ make_schema_at /; use Getopt::Long; use Pod::Usage; +use Data::Dumper; my $path = "./"; my $db_driver = 'mysql'; @@ -53,11 +54,32 @@ if (! defined $db_name ) { pod2usage(1); } else { - make_schema_at( +my $test = make_schema_at( "Koha::Schema", - { debug => 1, dump_directory => $path, preserve_case => 1 }, + { debug => 1, dump_directory => $path, preserve_case => 1, + skip_load_external => 1, + custom_column_info => sub { + my ($table, $column_name, $column_info) = @_; + + if ($table eq 'accountlines' && $column_name eq 'timestamp'){ + return { extra => { "on update" => \"CURRENT_TIMESTAMP" } }; + } + }, + + + filter_generated_code => sub { + my ($type, $class, $text) = @_; + $text =~ s/(\\"current_timestamp"|\scurrent_timestamp\s)/\U$1\E/g; + $text =~ s/"double precision"/"double"/g; + return $text; + } + + + }, ["DBI:$db_driver:dbname=$db_name;host=$db_host;port=$db_port",$db_user, $db_passwd ] ); + + } 1; @@ -111,4 +133,4 @@ path into which create the schema files. (defaults to './') prints this help text -=back \ No newline at end of file +=back -- 2.1.4