Merge branch 'topic/image_upload'
[sgn.git] / db / ImageAddMD5sum.pm
blob999dbe2409182fbbb3b07fa0655f3a1041656a7e
1 =head1 NAME
3 ImageAddMD5sum.pm
5 =head1 SYNOPSIS
7 mx-run ImageAddMD5sum [options] -H hostname -D dbname -u username [-F]
9 this is a subclass of L<CXGN::Metadata::Dbpatch>
10 see the perldoc of parent class for more details.
12 =head1 DESCRIPTION
14 Adds a md5sum field to the metadata.md_image table.
16 This subclass uses L<Moose>. The parent class uses L<MooseX::Runnable>
18 =head1 AUTHOR
20 Lukas Mueller <lam87@cornell.edu>
21 Naama Menda<nm249@cornell.edu>
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 ImageAddMD5sum;
35 use Moose;
36 extends 'CXGN::Metadata::Dbpatch';
39 sub init_patch {
40 my $self=shift;
41 my $name = __PACKAGE__;
42 print "dbpatch name is ':" . $name . "\n\n";
43 my $description = 'Testing a Moose dbpatch';
44 my @previous_requested_patches = (); #ADD HERE
46 $self->name($name);
47 $self->description("Adds a md5sum field to the metadata.md_image table");
48 $self->prereq(\@previous_requested_patches);
52 sub patch {
53 my $self=shift;
56 print STDOUT "Executing the patch:\n " . $self->name . ".\n\nDescription:\n ". $self->description . ".\n\nExecuted by:\n " . $self->username . " .";
58 print STDOUT "\nChecking if this db_patch was executed before or if previous db_patches have been executed.\n";
62 print STDOUT "\nExecuting the SQL commands.\n";
64 $self->dbh->do(<<EOSQL);
65 --do your SQL here
68 GRANT SELECT, UPDATE, INSERT, DELETE ON metadata.md_image TO web_usr;
70 ALTER TABLE metadata.md_image ADD COLUMN md5sum text
72 EOSQL
75 print "You're done!\n";
80 ####
81 1; #
82 ####