6 RemoveFieldbookImageCvterm
10 mx-run RemoveFieldbookImageCvterm [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 removes the fieldbook_image cvterm from the cassavs_trait ontology. This term is not used by the Fieldbook App, and if it is needed in the future should be linked to stock_prop or a "local" cv.
17 This subclass uses L<Moose>. The parent class uses L<MooseX::Runnable>
21 =head1 COPYRIGHT & LICENSE
23 Copyright 2010 Boyce Thompson Institute for Plant Research
25 This program is free software; you can redistribute it and/or modify
26 it under the same terms as Perl itself.
31 package RemoveFieldbookImageCvterm
;
34 use Bio
::Chado
::Schema
;
36 use SGN
::Model
::Cvterm
;
37 extends
'CXGN::Metadata::Dbpatch';
40 has
'+description' => ( default => <<'' );
41 This patch removes the fieldbook_image cvterm from the ontology
.
53 print STDOUT
"Executing the patch:\n " . $self->name . ".\n\nDescription:\n ". $self->description . ".\n\nExecuted by:\n " . $self->username . " .";
55 print STDOUT
"\nChecking if this db_patch was executed before or if previous db_patches have been executed.\n";
57 print STDOUT
"\nExecuting the SQL commands.\n";
58 my $schema = Bio
::Chado
::Schema
->connect( sub { $self->dbh->clone } );
60 print STDERR
"Removing CVTERM fieldbook_image...\n";
66 my $subject = SGN
::Model
::Cvterm
->get_cvterm_row($schema, 'fieldbook_image', 'cassava_trait');
68 $subject_id = $subject->cvterm_id ;
70 print STDERR
"Cvterm fieldbook_image does not exist in the database. Exiting\n";
74 #my $object_id = SGN::Model::Cvterm->get_cvterm_row($schema, 'CGIAR cassava trait ontology', 'cassava_trait')->cvterm_id();
75 my $cvterm_relationship_rs = $schema->resultset("Cv::CvtermRelationship")->search( { subject_id
=> $subject_id });
76 $cvterm_relationship_rs->delete();
78 my $cvterm = $schema->resultset( "Cv::Cvterm" )->find({ cvterm_id
=> $subject_id });
84 $schema->txn_do($coderef);
86 die "Load failed! " . $_ . "\n" ;
89 print "You're done!\n";