.\" Automatically generated by Pod::Man 2.25 (Pod::Simple 3.16) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .ie \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . nr % 0 . rr F .\} .el \{\ . de IX .. .\} .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "SQL::Translator::Schema 3pm" .TH SQL::Translator::Schema 3pm "2012-01-20" "perl v5.14.2" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" SQL::Translator::Schema \- SQL::Translator schema object .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 7 \& use SQL::Translator::Schema; \& my $schema = SQL::Translator::Schema\->new( \& name => \*(AqFoo\*(Aq, \& database => \*(AqMySQL\*(Aq, \& ); \& my $table = $schema\->add_table( name => \*(Aqfoo\*(Aq ); \& my $view = $schema\->add_view( name => \*(Aqbar\*(Aq, sql => \*(Aq...\*(Aq ); .Ve .SH "DESCSIPTION" .IX Header "DESCSIPTION" \&\f(CW\*(C`SQL::Translator::Schema\*(C'\fR is the object that accepts, validates, and returns the database structure. .SH "METHODS" .IX Header "METHODS" .SS "as_graph_pm" .IX Subsection "as_graph_pm" Returns a Graph::Directed object with the table names for nodes. .SS "add_table" .IX Subsection "add_table" Add a table object. Returns the new SQL::Translator::Schema::Table object. The \*(L"name\*(R" parameter is required. If you try to create a table with the same name as an existing table, you will get an error and the table will not be created. .PP .Vb 3 \& my $t1 = $schema\->add_table( name => \*(Aqfoo\*(Aq ) or die $schema\->error; \& my $t2 = SQL::Translator::Schema::Table\->new( name => \*(Aqbar\*(Aq ); \& $t2 = $schema\->add_table( $table_bar ) or die $schema\->error; .Ve .SS "drop_table" .IX Subsection "drop_table" Remove a table from the schema. Returns the table object if the table was found and removed, an error otherwise. The single parameter can be either a table name or an \f(CW\*(C`SQL::Translator::Schema::Table\*(C'\fR object. The \*(L"cascade\*(R" parameter can be set to 1 to also drop all triggers on the table, default is 0. .PP .Vb 2 \& $schema\->drop_table(\*(Aqmytable\*(Aq); \& $schema\->drop_table(\*(Aqmytable\*(Aq, cascade => 1); .Ve .SS "add_procedure" .IX Subsection "add_procedure" Add a procedure object. Returns the new SQL::Translator::Schema::Procedure object. The \*(L"name\*(R" parameter is required. If you try to create a procedure with the same name as an existing procedure, you will get an error and the procedure will not be created. .PP .Vb 3 \& my $p1 = $schema\->add_procedure( name => \*(Aqfoo\*(Aq ); \& my $p2 = SQL::Translator::Schema::Procedure\->new( name => \*(Aqbar\*(Aq ); \& $p2 = $schema\->add_procedure( $procedure_bar ) or die $schema\->error; .Ve .SS "drop_procedure" .IX Subsection "drop_procedure" Remove a procedure from the schema. Returns the procedure object if the procedure was found and removed, an error otherwise. The single parameter can be either a procedure name or an \f(CW\*(C`SQL::Translator::Schema::Procedure\*(C'\fR object. .PP .Vb 1 \& $schema\->drop_procedure(\*(Aqmyprocedure\*(Aq); .Ve .SS "add_trigger" .IX Subsection "add_trigger" Add a trigger object. Returns the new SQL::Translator::Schema::Trigger object. The \*(L"name\*(R" parameter is required. If you try to create a trigger with the same name as an existing trigger, you will get an error and the trigger will not be created. .PP .Vb 3 \& my $t1 = $schema\->add_trigger( name => \*(Aqfoo\*(Aq ); \& my $t2 = SQL::Translator::Schema::Trigger\->new( name => \*(Aqbar\*(Aq ); \& $t2 = $schema\->add_trigger( $trigger_bar ) or die $schema\->error; .Ve .SS "drop_trigger" .IX Subsection "drop_trigger" Remove a trigger from the schema. Returns the trigger object if the trigger was found and removed, an error otherwise. The single parameter can be either a trigger name or an \f(CW\*(C`SQL::Translator::Schema::Trigger\*(C'\fR object. .PP .Vb 1 \& $schema\->drop_trigger(\*(Aqmytrigger\*(Aq); .Ve .SS "add_view" .IX Subsection "add_view" Add a view object. Returns the new SQL::Translator::Schema::View object. The \*(L"name\*(R" parameter is required. If you try to create a view with the same name as an existing view, you will get an error and the view will not be created. .PP .Vb 3 \& my $v1 = $schema\->add_view( name => \*(Aqfoo\*(Aq ); \& my $v2 = SQL::Translator::Schema::View\->new( name => \*(Aqbar\*(Aq ); \& $v2 = $schema\->add_view( $view_bar ) or die $schema\->error; .Ve .SS "drop_view" .IX Subsection "drop_view" Remove a view from the schema. Returns the view object if the view was found and removed, an error otherwise. The single parameter can be either a view name or an \f(CW\*(C`SQL::Translator::Schema::View\*(C'\fR object. .PP .Vb 1 \& $schema\->drop_view(\*(Aqmyview\*(Aq); .Ve .SS "database" .IX Subsection "database" Get or set the schema's database. (optional) .PP .Vb 1 \& my $database = $schema\->database(\*(AqPostgreSQL\*(Aq); .Ve .SS "is_valid" .IX Subsection "is_valid" Returns true if all the tables and views are valid. .PP .Vb 1 \& my $ok = $schema\->is_valid or die $schema\->error; .Ve .SS "get_procedure" .IX Subsection "get_procedure" Returns a procedure by the name provided. .PP .Vb 1 \& my $procedure = $schema\->get_procedure(\*(Aqfoo\*(Aq); .Ve .SS "get_procedures" .IX Subsection "get_procedures" Returns all the procedures as an array or array reference. .PP .Vb 1 \& my @procedures = $schema\->get_procedures; .Ve .SS "get_table" .IX Subsection "get_table" Returns a table by the name provided. .PP .Vb 1 \& my $table = $schema\->get_table(\*(Aqfoo\*(Aq); .Ve .SS "get_tables" .IX Subsection "get_tables" Returns all the tables as an array or array reference. .PP .Vb 1 \& my @tables = $schema\->get_tables; .Ve .SS "get_trigger" .IX Subsection "get_trigger" Returns a trigger by the name provided. .PP .Vb 1 \& my $trigger = $schema\->get_trigger(\*(Aqfoo\*(Aq); .Ve .SS "get_triggers" .IX Subsection "get_triggers" Returns all the triggers as an array or array reference. .PP .Vb 1 \& my @triggers = $schema\->get_triggers; .Ve .SS "get_view" .IX Subsection "get_view" Returns a view by the name provided. .PP .Vb 1 \& my $view = $schema\->get_view(\*(Aqfoo\*(Aq); .Ve .SS "get_views" .IX Subsection "get_views" Returns all the views as an array or array reference. .PP .Vb 1 \& my @views = $schema\->get_views; .Ve .SS "make_natural_joins" .IX Subsection "make_natural_joins" Creates foriegn key relationships among like-named fields in different tables. Accepts the following arguments: .IP "\(bu" 4 join_pk_only .Sp A True or False argument which determins whether or not to perform the joins from primary keys to fields of the same name in other tables .IP "\(bu" 4 skip_fields .Sp A list of fields to skip in the joins .PP .Vb 4 \& $schema\->make_natural_joins( \& join_pk_only => 1, \& skip_fields => \*(Aqname,department_id\*(Aq, \& ); .Ve .SS "name" .IX Subsection "name" Get or set the schema's name. (optional) .PP .Vb 1 \& my $schema_name = $schema\->name(\*(AqFoo Database\*(Aq); .Ve .SS "translator" .IX Subsection "translator" Get the SQL::Translator instance that instantiated the parser. .SH "AUTHOR" .IX Header "AUTHOR" Ken Youens-Clark .