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.
17 This patch updates cvterm name from
18 Genetic Gain to genetic_gain_trial,
19 Health Status to health_status_trial,
20 Heterosis to heterosis_trial
21 Storage to storage_trial
23 This subclass uses L<Moose>. The parent class uses L<MooseX::Runnable>
27 Alex Ogbonna<aco46@cornell.edu>
29 =head1 COPYRIGHT & LICENSE
31 Copyright 2010 Boyce Thompson Institute for Plant Research
33 This program is free software; you can redistribute it and/or modify
34 it under the same terms as Perl itself.
39 package UpdateNewProjectProps
;
42 use Bio
::Chado
::Schema
;
45 extends
'CXGN::Metadata::Dbpatch';
48 has
'+description' => ( default => <<'' );
49 This patch will update the cvterm name of
50 Genetic Gain
-> genetic_gain_trial
51 Health Status
-> health_status_trial
52 Heterosis
-> heterosis_trial
53 Storage
-> storage_trial
58 ['AddNewProjectType'],
65 print STDOUT
"Executing the patch:\n " . $self->name . ".\n\nDescription:\n ". $self->description . ".\n\nExecuted by:\n " . $self->username . " .";
67 print STDOUT
"\nChecking if this db_patch was executed before or if previous db_patches have been executed.\n";
69 print STDOUT
"\nExecuting the SQL commands.\n";
70 my $schema = Bio
::Chado
::Schema
->connect( sub { $self->dbh->clone } );
73 my $cvterm_rs = $schema->resultset("Cv::Cvterm");
74 my $cv_rs = $schema->resultset("Cv::Cv");
75 my $project_type_cv = $cv_rs->find( { name
=> 'project_type' });
78 'Genetic Gain' => 'genetic_gain_trial',
79 'Health Status' => 'health_status_trial',
80 'Heterosis' => 'heterosis_trial',
81 'Storage' => 'storage_trial',
84 foreach my $key (keys %cvterm_hash) {
85 my $cvterm = $cvterm_rs->search( { name
=> $key , cv_id
=> $project_type_cv->cv_id() });
87 print STDERR
"Updating cvterm $key to " . $cvterm_hash{$key} . "\n";
88 my $cvterm_row = $cvterm->first();
89 $cvterm->update( { name
=> $cvterm_hash{$key} } ) ;
91 else { print "Cannot find cvterm $key in the database \n" ; }
95 print "Trial mode! Rolling back transaction\n\n";
96 $schema->txn_rollback;
103 $schema->txn_do($coderef);
106 die "Load failed! " . $_ . "\n" ;
110 print "You're done!\n";