Merge branch 'master' into topic/row_column_designs
[sgn.git] / db / 00007 / AddQtlMarkers.pm
blob407612bd3a380a2c117fea007fff2d1229ba9187
1 package AddQtlMarkers;
3 use Moose;
4 extends 'CXGN::Metadata::Dbpatch';
6 use Bio::Chado::Schema;
8 sub init_patch {
9 my $self=shift;
10 my $name = __PACKAGE__;
11 print "dbpatch name is ':" . $name . "\n\n";
12 my $description = 'Adding QTL marker and map types, and flanking positions to marker_location';
13 my @previous_requested_patches = (); #ADD HERE
14 $self->name($name);
15 $self->description($description);
16 $self->prereq(\@previous_requested_patches);
19 sub patch {
20 my $self=shift;
22 print STDOUT "Executing the patch:\n " . $self->name . ".\n\nDescription:\n ". $self->description . ".\n\nExecuted by:\n " . $self->username . " .";
24 print STDOUT "\nChecking if this db_patch was executed before or if previous db_patches have been executed.\n";
26 print STDOUT "\nExecuting the SQL commands.\n";
28 $self->dbh->do( <<EOT );
29 ALTER TABLE sgn.map DROP CONSTRAINT map_map_type_check;
30 ALTER TABLE sgn.map ADD CONSTRAINT map_map_type_check CHECK
31 (map_type = 'genetic'::text OR map_type = 'fish'::text OR map_type = 'sequence'::text OR map_type = 'QTL');
33 ALTER TABLE sgn.marker_experiment DROP CONSTRAINT marker_experiment_protocol_check;
34 ALTER TABLE sgn.marker_experiment ADD CONSTRAINT marker_experiment_protocol_check CHECK (protocol = 'AFLP'::text OR protocol = 'CAPS'::text OR protocol = 'RAPD'::text OR protocol = 'SNP'::text OR protocol = 'SSR'::text OR protocol = 'RFLP'::text OR protocol = 'PCR'::text OR protocol = 'dCAPS'::text OR protocol = 'DART'::text OR protocol = 'OPA'::text OR protocol = 'unknown'::text OR protocol = 'ASPE'::text OR protocol = 'INDEL'::text OR protocol = 'QTL'::text);
36 ALTER TABLE sgn.marker_location ADD COLUMN position_north numeric(8,5);
37 ALTER TABLE sgn.marker_location ADD COLUMN position_south numeric(8,5);
39 EOT
41 print "You're done!\n";
46 ####
47 1; #
48 ####