6 AddMdJsonAndLinkingTable.pm
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 subclass uses L<Moose>. The parent class uses L<MooseX::Runnable>
19 =head1 COPYRIGHT & LICENSE
21 Copyright 2010 Boyce Thompson Institute for Plant Research
23 This program is free software; you can redistribute it and/or modify
24 it under the same terms as Perl itself.
29 package AddMdJsonAndLinkingTable
;
32 extends
'CXGN::Metadata::Dbpatch';
35 has
'+description' => ( default => <<'' );
36 Adds md_json table
for storing jsonb to Metadata schema
and a linking table between md_json
and nd_experiment to Phenome schema
47 print STDOUT
"Executing the patch:\n " . $self->name . ".\n\nDescription:\n ". $self->description . ".\n\nExecuted by:\n " . $self->username . " .";
49 print STDOUT
"\nChecking if this db_patch was executed before or if previous db_patches have been executed.\n";
51 print STDOUT
"\nExecuting the SQL commands.\n";
53 $self->dbh->do(<<EOSQL);
57 CREATE TABLE metadata.md_json (
58 json_id SERIAL PRIMARY KEY,
59 json_type character varying(250),
62 ALTER TABLE metadata.md_json OWNER TO postgres;
63 COMMENT ON TABLE md_json IS 'md_json is a table for storing variable json datasets and linking them to related data in other tables. For example storing nirs spectra (wavelength:value pairs) and linking to the relevant nd_experiment which in turn links to the plot and derived phenotype values.';
64 GRANT SELECT,UPDATE,INSERT,DELETE ON metadata.md_json TO web_usr;
65 GRANT USAGE ON md_json_json_id_seq TO web_usr;
67 CREATE TABLE phenome.nd_experiment_md_json (
68 nd_experiment_md_json_id SERIAL PRIMARY KEY,
69 nd_experiment_id integer REFERENCES public.nd_experiment (nd_experiment_id),
70 json_id integer REFERENCES metadata.md_json (json_id)
72 ALTER TABLE phenome.nd_experiment_md_json OWNER TO postgres;
73 GRANT SELECT,UPDATE,INSERT,DELETE ON phenome.nd_experiment_md_json TO web_usr;
74 GRANT USAGE ON phenome.nd_experiment_md_json_nd_experiment_md_json_id_seq TO web_usr;
79 print "You're done!\n";