Merge branch 'master' into topic/tracking_transformation
[sgn.git] / db / 00082 / AddDistributedSeedCrossCvterm.pm
blobd839874439c01ab4d8dee5d6ab10397f76db05d6
1 #!/usr/bin/env perl
3 =head1 NAME
5 AddDistributedSeedCrossCvterm.pm
7 =head1 SYNOPSIS
9 mx-run AddDistributedSeedCrossCvterm [options] -H hostname -D dbname -u username [-F]
11 this is a subclass of L<CXGN::Metadata::Dbpatch>
12 see the perldoc of parent class for more details.
14 =head1 DESCRIPTION
16 This patch adds number of seeds distributed cvterms that can be stored in the nd_experimentprop table.
18 =head1 AUTHOR
20 Alex Ogbonna<baco46@cornell.edu>
22 =head1 COPYRIGHT & LICENSE
24 Copyright 2010 Boyce Thompson Institute for Plant Research
26 This program is free software; you can redistribute it and/or modify
27 it under the same terms as Perl itself.
29 =cut
32 package AddDistributedSeedCrossCvterm;
34 use Moose;
35 use Bio::Chado::Schema;
36 use Try::Tiny;
37 extends 'CXGN::Metadata::Dbpatch';
40 has '+description' => ( default => <<'' );
41 This patch adds number of seeds distributed cvterms that can be stored in the nd_experimentprop table.
44 sub patch {
45 my $self=shift;
47 print STDOUT "Executing the patch:\n " . $self->name . ".\n\nDescription:\n ". $self->description . ".\n\nExecuted by:\n " . $self->username . " .";
49 print STDOUT "\nChecking if this db_patch was executed before or if previous db_patches have been executed.\n";
51 print STDOUT "\nExecuting the SQL commands.\n";
53 my $schema = Bio::Chado::Schema->connect( sub { $self->dbh->clone } );
55 my $coderef = sub {
57 my $no_seeds_distrubuted = $schema->resultset("Cv::Cvterm")->create_with({
58 name => 'number_of_seeds_distributed',
59 cv => 'nd_experiment_property',
60 });
64 try {
65 $schema->txn_do($coderef);
66 } catch {
67 die "Load failed! " . $_ . "\n" ;
70 print "You're done!\n";
74 ####
75 1; #
76 ####