10 mx-run RedefineStockViews [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 the materialized views that store stocks (accessions, plots, plants) to exclude obsolete stocks
21 Bryan Ellerbrock<bje24@cornell.edu>
23 =head1 COPYRIGHT & LICENSE
25 Copyright 2010 Boyce Thompson Institute for Plant Research
27 This program is free software; you can redistribute it and/or modify
28 it under the same terms as Perl itself.
33 package RedefineStockViews
;
36 extends
'CXGN::Metadata::Dbpatch';
39 has
'+description' => ( default => <<'' );
40 This patch updates the materialized view that stores traits
45 print STDOUT
"Executing the patch:\n " . $self->name . ".\n\nDescription:\n ". $self->description . ".\n\nExecuted by:\n " . $self->username . " .";
47 print STDOUT
"\nChecking if this db_patch was executed before or if previous db_patches have been executed.\n";
49 print STDOUT
"\nExecuting the SQL commands.\n";
51 $self->dbh->do(<<EOSQL);
54 DROP MATERIALIZED VIEW public.accessions;
56 CREATE MATERIALIZED VIEW public.accessions AS
57 SELECT stock.stock_id AS accession_id,
58 stock.uniquename AS accession_name
60 WHERE stock.type_id = (SELECT cvterm_id from cvterm where cvterm.name = 'accession') AND is_obsolete = 'f'
61 GROUP BY stock.stock_id, stock.uniquename
63 CREATE UNIQUE INDEX accessions_idx ON public.accessions(accession_id) WITH (fillfactor=100);
64 ALTER MATERIALIZED VIEW accessions OWNER TO web_usr;
66 DROP MATERIALIZED VIEW public.plots;
68 CREATE MATERIALIZED VIEW public.plots AS
69 SELECT stock.stock_id AS plot_id,
70 stock.uniquename AS plot_name
72 WHERE stock.type_id = (SELECT cvterm_id from cvterm where cvterm.name = 'plot') AND is_obsolete = 'f'
73 GROUP BY public.stock.stock_id, public.stock.uniquename
75 CREATE UNIQUE INDEX plots_idx ON public.plots(plot_id) WITH (fillfactor=100);
76 ALTER MATERIALIZED VIEW plots OWNER TO web_usr;
78 DROP MATERIALIZED VIEW public.plants;
80 CREATE MATERIALIZED VIEW public.plants AS
81 SELECT stock.stock_id AS plant_id,
82 stock.uniquename AS plant_name
84 WHERE stock.type_id = (SELECT cvterm_id from cvterm where cvterm.name = 'plant') AND is_obsolete = 'f'
85 GROUP BY public.stock.stock_id, public.stock.uniquename
87 CREATE UNIQUE INDEX plants_idx ON public.plants(plant_id) WITH (fillfactor=100);
88 ALTER MATERIALIZED VIEW plants OWNER TO web_usr;
94 print "You're done!\n";