Merge pull request #3326 from solgenomics/topic/remove_date_of
[sgn.git] / db / 00110 / DefaultMdImageCreateDateTimestamp.pm
blob1f3653aebd2df3ad88bc4102cd1c2afdba8a87c2
1 #!/usr/bin/env perl
4 =head1 NAME
6 DefaultMdImageCreateDateTimestamp.pm
8 =head1 SYNOPSIS
10 mx-run DefaultMdImageCreateDateTimestamp [options] -H hostname -D dbname -u username [-F]
12 this is a subclass of L<CXGN::Metadata::Dbpatch>
13 see the perldoc of parent class for more details.
15 =head1 DESCRIPTION
17 This patch sets a default NOW() value for the create_date and modified_date columns in metadata.md_images, metadata.md_tag_image, and metadata.md_tag
18 This subclass uses L<Moose>. The parent class uses L<MooseX::Runnable>
20 =head1 AUTHOR
23 =head1 COPYRIGHT & LICENSE
25 Copyright 2010 Boyce Thompson Institute for Plant Research
27 This program is free software; you can redistribute it and/or modify
28 it under the same terms as Perl itself.
30 =cut
33 package DefaultMdImageCreateDateTimestamp;
35 use Moose;
37 extends 'CXGN::Metadata::Dbpatch';
39 has '+description' => ( default => <<'');
40 This patch sets a default NOW() value for the create_date and modified_date columns in metadata.md_images, metadata.md_tag_image, and metadata.md_tag
43 has '+prereq' => (
44 default => sub {
45 [],
49 sub patch {
50 my $self=shift;
52 print STDOUT "Executing the patch:\n " . $self->name . ".\n\nDescription:\n ". $self->description . ".\n\nExecuted by:\n " . $self->username . " .";
54 print STDOUT "\nChecking if this db_patch was executed before or if previous db_patches have been executed.\n";
56 print STDOUT "\nExecuting the SQL commands.\n";
58 $self->dbh->do(<<EOSQL);
59 --do your SQL here
62 alter table metadata.md_image alter column create_date set default now();
63 alter table metadata.md_image alter column modified_date set default now();
64 alter table metadata.md_tag_image alter column create_date set default now();
65 alter table metadata.md_tag_image alter column modified_date set default now();
66 alter table metadata.md_tag alter column create_date set default now();
67 alter table metadata.md_tag alter column modified_date set default now();
69 EOSQL
71 print "You're done!\n";
75 ####
76 1; #
77 ####