.\" Automatically generated by Pod::Man v1.37, Pod::Parser v1.32 .\" .\" Standard preamble: .\" ======================================================================== .de Sh \" Subsection heading .br .if t .Sp .ne 5 .PP \fB\\$1\fR .PP .. .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. | will give a .\" real vertical bar. \*(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-|\(bv\*(Tr .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\} .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . nr % 0 . rr F .\} .\" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .hy 0 .if n .na .\" .\" 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 3" .TH SQL::Translator::Schema 3 "2008-01-01" "perl v5.8.8" "User Contributed Perl Documentation" .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 => 'Foo', \& database => 'MySQL', \& ); \& my $table = $schema->add_table( name => 'foo' ); \& my $view = $schema->add_view( name => 'bar', sql => '...' ); .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" .Sh "as_graph" .IX Subsection "as_graph" Returns the schema as an SQL::Translator::Schema::Graph object. .Sh "as_grap_pmh" .IX Subsection "as_grap_pmh" Returns a Graph::Directed object with the table names for nodes. .Sh "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 => 'foo' ) or die $schema->error; \& my $t2 = SQL::Translator::Schema::Table->new( name => 'bar' ); \& $t2 = $schema->add_table( $table_bar ) or die $schema->error; .Ve .Sh "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('mytable'); \& $schema->drop_table('mytable', cascade => 1); .Ve .Sh "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 => 'foo' ); \& my $p2 = SQL::Translator::Schema::Procedure->new( name => 'bar' ); \& $p2 = $schema->add_procedure( $procedure_bar ) or die $schema->error; .Ve .Sh "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('myprocedure'); .Ve .Sh "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 => 'foo' ); \& my $t2 = SQL::Translator::Schema::Trigger->new( name => 'bar' ); \& $t2 = $schema->add_trigger( $trigger_bar ) or die $schema->error; .Ve .Sh "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('mytrigger'); .Ve .Sh "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 => 'foo' ); \& my $v2 = SQL::Translator::Schema::View->new( name => 'bar' ); \& $v2 = $schema->add_view( $view_bar ) or die $schema->error; .Ve .Sh "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('myview'); .Ve .Sh "database" .IX Subsection "database" Get or set the schema's database. (optional) .PP .Vb 1 \& my $database = $schema->database('PostgreSQL'); .Ve .Sh "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 .Sh "get_procedure" .IX Subsection "get_procedure" Returns a procedure by the name provided. .PP .Vb 1 \& my $procedure = $schema->get_procedure('foo'); .Ve .Sh "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 .Sh "get_table" .IX Subsection "get_table" Returns a table by the name provided. .PP .Vb 1 \& my $table = $schema->get_table('foo'); .Ve .Sh "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 .Sh "get_trigger" .IX Subsection "get_trigger" Returns a trigger by the name provided. .PP .Vb 1 \& my $trigger = $schema->get_trigger('foo'); .Ve .Sh "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 .Sh "get_view" .IX Subsection "get_view" Returns a view by the name provided. .PP .Vb 1 \& my $view = $schema->get_view('foo'); .Ve .Sh "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 .Sh "make_natural_joins" .IX Subsection "make_natural_joins" Creates foriegn key relationships among like-named fields in different tables. Accepts the following arguments: .IP "* join_pk_only" 4 .IX Item "join_pk_only" 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 "* skip_fields" 4 .IX Item "skip_fields" A list of fields to skip in the joins .PP .Vb 4 \& $schema->make_natural_joins( \& join_pk_only => 1, \& skip_fields => 'name,department_id', \& ); .Ve .Sh "name" .IX Subsection "name" Get or set the schema's name. (optional) .PP .Vb 1 \& my $schema_name = $schema->name('Foo Database'); .Ve .Sh "translator" .IX Subsection "translator" Get the SQL::Translator instance that instantiated the parser. .SH "AUTHOR" .IX Header "AUTHOR" Ken Youens-Clark .