Merge pull request #1890 from solgenomics/topic/UpdateBrapiSearchDBlist
[sgn.git] / db / 00078 / AddPlantListType.pm
blobc3c1f4f6616fc9fa933fe26e3eafa3c8f09940c9
1 #!/usr/bin/env perl
4 =head1 NAME
6 AddPlantListType.pm
8 =head1 SYNOPSIS
10 mx-run AddNewListTypes [options] -H hostname -D dbname -u username [-F]
12 Adds the list type "Plants" required for validation of list containing plants.
14 this is a subclass of L<CXGN::Metadata::Dbpatch>
15 see the perldoc of parent class for more details.
17 =head1 DESCRIPTION
19 This is a test dummy patch.
20 This subclass uses L<Moose>. The parent class uses L<MooseX::Runnable>
22 =head1 AUTHOR
24 Lukas Mueller <lam87@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.
33 =cut
36 package AddPlantListType;
38 use Moose;
39 use Bio::Chado::Schema;
40 use Try::Tiny;
41 extends 'CXGN::Metadata::Dbpatch';
44 has '+description' => ( default => <<'' );
45 This patch will create the cvterm 'plant'.
48 sub patch {
49 my $self=shift;
51 print STDOUT "Executing the patch:\n " . $self->name . ".\n\nDescription:\n ". $self->description . ".\n\nExecuted by:\n " . $self->username . " .";
53 print STDOUT "\nChecking if this db_patch was executed before or if previous db_patches have been executed.\n";
55 print STDOUT "\nExecuting the SQL commands.\n";
57 my $schema = Bio::Chado::Schema->connect( sub { $self->dbh->clone } );
59 my $coderef = sub {
61 my $numbers_list_type_cvterm = $schema->resultset("Cv::Cvterm")->create_with({
62 name => 'plants',
63 definition => 'plants',
64 cv => 'list_types',
65 });
69 try {
70 $schema->txn_do($coderef);
72 } catch {
73 die "Load failed! " . $_ . "\n" ;
76 print "You're done!\n";
80 ####
81 1; #
82 ####