add legend
[sgn.git] / db / 00021 / MarkerPositionSize.pm
blob34628b15b951658267ccbf35dac19b03141b2962
1 #!/usr/bin/env perl
4 =head1 NAME
6 MarkerPositionSize.pm
8 =head1 SYNOPSIS
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.
15 =head1 DESCRIPTION
17 Change the sgn.marker_location.position type from numeric(8,5) to numeric(9,6)
18 to accomodate full genome location in bp
20 This subclass uses L<Moose>. The parent class uses L<MooseX::Runnable>
22 =head1 AUTHOR
24 Naama Menda<nm249@cornell.edu>
26 =head1 COPYRIGHT & LICENSE
28 Copyright 2012 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 MarkerPositionSize;
38 use Moose;
39 extends 'CXGN::Metadata::Dbpatch';
42 has '+description' => ( default => <<'' );
43 Change the sgn.marker_location.position type from numeric(8,5) to numeric(9,6)
44 to accomodate full genome location in bp
47 sub patch {
48 my $self=shift;
50 print STDOUT "Executing the patch:\n " . $self->name . ".\n\nDescription:\n ". $self->description . ".\n\nExecuted by:\n " . $self->username . " .";
52 print STDOUT "\nChecking if this db_patch was executed before or if previous db_patches have been executed.\n";
54 print STDOUT "\nExecuting the SQL commands.\n";
56 $self->dbh->do(<<EOSQL);
57 DROP VIEW sgn.marker_to_map;
58 ALTER TABLE sgn.marker_location ALTER COLUMN position TYPE numeric(9,6);
60 CREATE VIEW sgn.marker_to_map AS
61 SELECT m.marker_id, me.protocol, ml.location_id, linkage_group.lg_name, linkage_group.lg_order, ml."position", ml.confidence_id, ml.subscript, ml.map_version_id, map.map_id, map.parent_1, map.parent_2, map_version.current_version
62 FROM marker m
63 LEFT JOIN marker_experiment me USING (marker_id)
64 LEFT JOIN marker_location ml USING (location_id)
65 LEFT JOIN map_version USING (map_version_id)
66 LEFT JOIN map USING (map_id)
67 LEFT JOIN linkage_group USING (lg_id)
68 WHERE map_version.current_version = true;
70 GRANT select ON sgn.marker_to_map TO web_usr;
72 EOSQL
74 print "You're done!\n";
78 ####
79 1; #
80 ####