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 is a test dummy patch.
18 This subclass uses L<Moose>. The parent class uses L<MooseX::Runnable>
22 Naama Menda<nm249@cornell.edu>
24 =head1 COPYRIGHT & LICENSE
26 Copyright 2010 Boyce Thompson Institute for Plant Research
28 This program is free software; you can redistribute it and/or modify
29 it under the same terms as Perl itself.
34 package AddMarkerExpAccession
;
37 extends
'CXGN::Metadata::Dbpatch';
42 my $name = __PACKAGE__
;
43 print "dbpatch name is ':" . $name . "\n\n";
44 my $description = 'Adds a stock_id column to pcr_exp_accession and populates it.';
45 my @previous_requested_patches = (); #ADD HERE
48 $self->description($description);
49 $self->prereq(\
@previous_requested_patches);
57 print STDOUT
"Executing the patch:\n " . $self->name . ".\n\nDescription:\n ". $self->description . ".\n\nExecuted by:\n " . $self->username . " .";
59 print STDOUT
"\nChecking if this db_patch was executed before or if previous db_patches have been executed.\n";
63 print STDOUT
"\nExecuting the SQL commands.\n";
65 $self->dbh->do(<<EOSQL);
68 -- add a stock_id column to pcr_exp_accession
70 set search_path=public,sgn;
72 alter table sgn.pcr_exp_accession add column stock_id bigint references public.stock;
74 -- copy the stock to accession mapping from sgn.accession
76 update sgn.pcr_exp_accession set stock_id=sgn.accession.stock_id FROM sgn.accession where sgn.accession.accession_id=pcr_exp_accession.accession_id;
78 alter table sgn.map add column parent1_stock_id bigint references public.stock;
80 alter table sgn.map add column parent2_stock_id bigint references public.stock;
82 alter table sgn.map add column population_stock_id bigint references public.stock;
84 update sgn.map set parent1_stock_id=accession.stock_id FROM sgn.accession where sgn.accession.accession_id=map.parent_1;
86 update sgn.map set parent2_stock_id=accession.stock_id FROM sgn.accession where sgn.accession.accession_id=map.parent_2;
88 update sgn.map set population_stock_id=phenome.population.stock_id FROM phenome.population WHERE sgn.map.population_id=phenome.population.population_id;
91 drop trigger pcr_accession_check_trigger on sgn.pcr_exp_accession;;
93 alter table sgn.pcr_exp_accession drop constraint accession_id_check;
97 print "You're done!\n";