Merge pull request #1890 from solgenomics/topic/UpdateBrapiSearchDBlist
[sgn.git] / db / 00071 / AddNewFolderCvterms.pm
blob85abfa0cfa363399ac4747ebbdd9ba9197e0249c
1 #!/usr/bin/env perl
3 =head1 NAME
4 AddNewFolderCvterms.pm
5 =head1 SYNOPSIS
6 mx-run AddNewFolderCvterms [options] -H hostname -D dbname -u username [-F]
7 this is a subclass of L<CXGN::Metadata::Dbpatch>
8 see the perldoc of parent class for more details.
9 =head1 DESCRIPTION
10 This patch adds new project_property cvterms for classifying folders
11 =head1 AUTHOR
12 Nicolas Morales <nm529@cornell.edu>
13 =head1 COPYRIGHT & LICENSE
14 Copyright 2010 Boyce Thompson Institute for Plant Research
15 This program is free software; you can redistribute it and/or modify
16 it under the same terms as Perl itself.
17 =cut
20 package AddNewFolderCvterms;
22 use Moose;
23 use Bio::Chado::Schema;
24 use Try::Tiny;
25 extends 'CXGN::Metadata::Dbpatch';
28 has '+description' => ( default => <<'' );
29 This patch adds new cross cvterms so that they can be stored in the nd_experimentprop table.
31 sub patch {
32 my $self=shift;
34 print STDOUT "Executing the patch:\n " . $self->name . ".\n\nDescription:\n ". $self->description . ".\n\nExecuted by:\n " . $self->username . " .";
36 print STDOUT "\nChecking if this db_patch was executed before or if previous db_patches have been executed.\n";
38 print STDOUT "\nExecuting the SQL commands.\n";
40 my $schema = Bio::Chado::Schema->connect( sub { $self->dbh->clone } );
42 my $coderef = sub {
44 my $folder_for_trials = $schema->resultset("Cv::Cvterm")->create_with({
45 name => 'folder_for_trials',
46 cv => 'project_property',
47 });
49 my $folder_for_crosses = $schema->resultset("Cv::Cvterm")->create_with({
50 name => 'folder_for_crosses',
51 cv => 'project_property',
52 });
56 try {
57 $schema->txn_do($coderef);
58 } catch {
59 die "Load failed! " . $_ . "\n" ;
62 print "You're done!\n";
66 ####
67 1; #
68 ####