sql for granting web_usr roles to breedbase db. Useful when the roles get messed...
[sgn-devtools.git] / dbic_tool_make_schema_at.pl
blob9dad787581799439492cbe58430d8509f5a75784
1 #!/usr/bin/perl
3 =head1 NAME
5 dbic_tool_make_schema_at.pl.
6 A script to create the DBIx::Class objects using the DBIx::Class::Schema::Loader (version.1.0.).
8 =cut
10 =head1 SYPNOSIS
12 dbic_tool_make_schema_at.pl [-h] -p <module_path> -d <dir> -s <schema> -D <dbname> -H <dbhost>
14 =head2 I<Flags:>
16 =over
18 =item -p
20 B<module_path> the module path used to create the different DBIx::Class objects (example: CXGN::SEDM::Schema) (mandatory)
22 =item -d
24 B<directory> the directory where the objects will be created (example: /data/local/perllib/CXGN) (mandatory)
26 =item -s
28 B<schema> the schema of the database that will be used to create the DBIx::Class objects (example: sed) (mandatory)
30 =item -D
32 B<db_name> the database name to access to the database (mandatory)
34 =item -H
36 B<db_hostname> the database hostname to access to the database (mandatory)
38 =item -h
40 B<help> show the help
42 =back
44 =cut
46 =head1 DESCRIPTION
48 This script create the objects for the DBIx::Class
50 =cut
52 =head1 AUTHORS
54 Aureliano Bombarely Gomez.
55 (ab782@cornell.edu).
57 =cut
59 =head1 METHODS
61 dbic_tool_make_schema_at.pl
64 =cut
66 use strict;
67 use warnings;
69 use Getopt::Std;
70 use CXGN::DB::InsertDBH;
71 use DBIx::Class::Schema::Loader qw/ make_schema_at /;
73 our ($opt_p, $opt_d, $opt_s, $opt_D, $opt_H, $opt_h);
74 getopts("p:d:s:D:H:h");
75 if (!$opt_p && !$opt_d && !$opt_s && !$opt_D && !$opt_H && !$opt_h) {
76 print "There are n\'t any tags. Print help\n\n";
77 help();
80 my $path = $opt_p || die("None module path was supplied as -p <module_structure_path> argument.\n");
81 my $dir = $opt_d || die("None directory was supplied as -d <directory> argument.\n");
82 my $schema = $opt_s || die("None database schema was supplied as -s <dbschema> argument.\n");
83 my $db = $opt_D || die("None database name was supplied as -D <dbname> argument.\n");
84 #my $user = $opt_U || die("None database username was supplied as -U <dbuser> argument.\n");
85 #my $pass = $opt_P || die("None database password was supplied as -P <dbpass> argument.\n");
86 my $host = $opt_H || die("None database hostname was supplied as -H <dbhost> argument.\n");
89 print "\n\nParameters:\n\tPATH: $path\n\tDIR: $dir\n\tSCHEMA: $schema\n\tDB_NAME: $db\n\tDB_HOST: $host\n\n";
90 my $dbh = CXGN::DB::InsertDBH->new({ dbname => $db, dbhost => $host })->get_actual_dbh();
93 make_schema_at(
94 $path,
95 { debug => 1, dump_directory => $dir, db_schema => $schema },
96 [ sub {$dbh }],
100 =head2 help
102 Usage: help()
103 Desc: print help of this script
104 Ret: none
105 Args: none
106 Side_Effects: exit of the script
107 Example: if (!@ARGV) {
108 help();
111 =cut
113 sub help {
114 print STDERR <<EOF;
117 Description:
118 A script to create the DBIx::Class objects using the DBIx::Class::Schema::Loader
120 Usage:
121 dbic_tool_make_schema_at.pl [-h] -p <module_path> -d <dir> -s <schema> -U <username> -D <dbname> -H <dbhost> -P <dbpass>
123 Flags:
124 -p <module_path> the module path used to create the different DBIx::Class objects (example: CXGN::SEDM::Schema) (mandatory)
125 -d <directory> the directory where the objects will be created (example: /data/local/perllib/CXGN) (mandatory)
126 -s <schema> the schema of the database that will be used to create the DBIx::Class objects (example: sed) (mandatory)
127 -D <db_name> the database name to access to the database (mandatory)
128 -H <db_hostname> the database hostname to access to the database (mandatory)
129 -h <help> show the help
133 exit (1);