10 mx-run ThisPackageName [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.
16 This patch updates the cvterms phenotypeing_trial and genotyping_trial with cv = project_type to be consistent with other projectprops in the database
17 cvterm crossing_trial is redundant and is now deleted, as well as the cv.name trial_type. All trial types in the database should use the project_type cvterm since these are stored in the project table
20 This subclass uses L<Moose>. The parent class uses L<MooseX::Runnable>
24 Naama Menda<nm249@cornell.edu>
26 =head1 COPYRIGHT & LICENSE
28 Copyright 2010 Boyce Thompson Institute for Plant Research
30 This program is free software; you can redistribute it and/or modify
31 it under the same terms as Perl itself.
36 package UpdateProjectTypes
;
39 use Bio
::Chado
::Schema
;
40 use SGN
::Model
::Cvterm
;
42 extends
'CXGN::Metadata::Dbpatch';
46 has
'+description' => ( default => <<'' );
47 This patch updates the cvterms phenotypeing_trial
and genotyping_trial with cv
= project_type to be consistent with other projectprops
in the database
48 cvterm crossing_trial is redundant
and is now deleted
, as well as the cv
.name trial_type
. All trial types
in the database should
use the project_type cvterm since these are stored
in the project table
52 ['AddGraftingCvterms', 'AddTrialTypes'],
60 print STDOUT
"Executing the patch:\n " . $self->name . ".\n\nDescription:\n ". $self->description . ".\n\nExecuted by:\n " . $self->username . " .";
62 print STDOUT
"\nChecking if this db_patch was executed before or if previous db_patches have been executed.\n";
64 print STDOUT
"\nExecuting the SQL commands.\n";
65 my $schema = Bio
::Chado
::Schema
->connect( sub { $self->dbh->clone } );
69 my $phenotyping_cvterm = SGN
::Model
::Cvterm
->get_cvterm_row($schema, 'phenotyping_trial', 'trial_type');
70 my $genotyping_cvterm = SGN
::Model
::Cvterm
->get_cvterm_row($schema, 'genotyping_trial' , 'trial_type' ) ;
71 my $crossing_cvterm = SGN
::Model
::Cvterm
->get_cvterm_row($schema, 'crossing_trial' , 'trial_type' ) ;
72 my $trial_type_cv = $schema->resultset("Cv::Cv")->find(
73 { name
=> 'trial_type' });
74 my $project_type_cv = $schema->resultset("Cv::Cv")->find(
75 { name
=> 'project_type' } );
77 $phenotyping_cvterm->update( { cv_id
=> $project_type_cv->cv_id } );
78 $genotyping_cvterm->update( { cv_id
=> $project_type_cv->cv_id } );
79 $crossing_cvterm->delete;
80 $trial_type_cv->delete;
82 print "You're done!\n";