.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.43) .\" .\" 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" '' . ds C` . ds C' '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 >0, 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. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "SQL::Translator::Schema 3pm" .TH SQL::Translator::Schema 3pm "2022-11-19" "perl v5.36.0" "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 SQL::Translator::Schema::Table 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 SQL::Translator::Schema::Procedure 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 SQL::Translator::Schema::Trigger 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 SQL::Translator::Schema::View 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 foreign 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 determines 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 .