.\" 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::Table 3pm" .TH SQL::Translator::Schema::Table 3pm "2012-05-01" "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::Table \- SQL::Translator table object .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 2 \& use SQL::Translator::Schema::Table; \& my $table = SQL::Translator::Schema::Table\->new( name => \*(Aqfoo\*(Aq ); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\f(CW\*(C`SQL::Translator::Schema::Table\*(C'\fR is the table object. .SH "METHODS" .IX Header "METHODS" .SS "new" .IX Subsection "new" Object constructor. .PP .Vb 4 \& my $table = SQL::Translator::Schema::Table\->new( \& schema => $schema, \& name => \*(Aqfoo\*(Aq, \& ); .Ve .SS "add_constraint" .IX Subsection "add_constraint" Add a constraint to the table. Returns the newly created \&\f(CW\*(C`SQL::Translator::Schema::Constraint\*(C'\fR object. .PP .Vb 5 \& my $c1 = $table\->add_constraint( \& name => \*(Aqpk\*(Aq, \& type => PRIMARY_KEY, \& fields => [ \*(Aqfoo_id\*(Aq ], \& ); \& \& my $c2 = SQL::Translator::Schema::Constraint\->new( name => \*(Aquniq\*(Aq ); \& $c2 = $table\->add_constraint( $constraint ); .Ve .SS "drop_constraint" .IX Subsection "drop_constraint" Remove a constraint from the table. Returns the constraint object if the index was found and removed, an error otherwise. The single parameter can be either an index name or an \f(CW\*(C`SQL::Translator::Schema::Constraint\*(C'\fR object. .PP .Vb 1 \& $table\->drop_constraint(\*(Aqmyconstraint\*(Aq); .Ve .SS "add_index" .IX Subsection "add_index" Add an index to the table. Returns the newly created \&\f(CW\*(C`SQL::Translator::Schema::Index\*(C'\fR object. .PP .Vb 5 \& my $i1 = $table\->add_index( \& name => \*(Aqname\*(Aq, \& fields => [ \*(Aqname\*(Aq ], \& type => \*(Aqnormal\*(Aq, \& ); \& \& my $i2 = SQL::Translator::Schema::Index\->new( name => \*(Aqid\*(Aq ); \& $i2 = $table\->add_index( $index ); .Ve .SS "drop_index" .IX Subsection "drop_index" Remove an index from the table. Returns the index object if the index was found and removed, an error otherwise. The single parameter can be either an index name of an \f(CW\*(C`SQL::Translator::Schema::Index\*(C'\fR object. .PP .Vb 1 \& $table\->drop_index(\*(Aqmyindex\*(Aq); .Ve .SS "add_field" .IX Subsection "add_field" Add an field to the table. Returns the newly created \&\f(CW\*(C`SQL::Translator::Schema::Field\*(C'\fR object. The \*(L"name\*(R" parameter is required. If you try to create a field with the same name as an existing field, you will get an error and the field will not be created. .PP .Vb 5 \& my $f1 = $table\->add_field( \& name => \*(Aqfoo_id\*(Aq, \& data_type => \*(Aqinteger\*(Aq, \& size => 11, \& ); \& \& my $f2 = SQL::Translator::Schema::Field\->new( \& name => \*(Aqname\*(Aq, \& table => $table, \& ); \& $f2 = $table\->add_field( $field2 ) or die $table\->error; .Ve .SS "drop_field" .IX Subsection "drop_field" Remove a field from the table. Returns the field object if the field was found and removed, an error otherwise. The single parameter can be either a field name or an \f(CW\*(C`SQL::Translator::Schema::Field\*(C'\fR object. .PP .Vb 1 \& $table\->drop_field(\*(Aqmyfield\*(Aq); .Ve .SS "comments" .IX Subsection "comments" Get or set the comments on a table. May be called several times to set and it will accumulate the comments. Called in an array context, returns each comment individually; called in a scalar context, returns all the comments joined on newlines. .PP .Vb 3 \& $table\->comments(\*(Aqfoo\*(Aq); \& $table\->comments(\*(Aqbar\*(Aq); \& print join( \*(Aq, \*(Aq, $table\->comments ); # prints "foo, bar" .Ve .SS "get_constraints" .IX Subsection "get_constraints" Returns all the constraint objects as an array or array reference. .PP .Vb 1 \& my @constraints = $table\->get_constraints; .Ve .SS "get_indices" .IX Subsection "get_indices" Returns all the index objects as an array or array reference. .PP .Vb 1 \& my @indices = $table\->get_indices; .Ve .SS "get_field" .IX Subsection "get_field" Returns a field by the name provided. .PP .Vb 1 \& my $field = $table\->get_field(\*(Aqfoo\*(Aq); .Ve .SS "get_fields" .IX Subsection "get_fields" Returns all the field objects as an array or array reference. .PP .Vb 1 \& my @fields = $table\->get_fields; .Ve .SS "is_valid" .IX Subsection "is_valid" Determine whether the view is valid or not. .PP .Vb 1 \& my $ok = $view\->is_valid; .Ve .SS "is_trivial_link" .IX Subsection "is_trivial_link" True if table has no data (non-key) fields and only uses single key joins. .SS "is_data" .IX Subsection "is_data" Returns true if the table has some non-key fields. .SS "can_link" .IX Subsection "can_link" Determine whether the table can link two arg tables via many-to-many. .PP .Vb 1 \& my $ok = $table\->can_link($table1,$table2); .Ve .SS "name" .IX Subsection "name" Get or set the table's name. .PP Errors (\*(L"No table name\*(R") if you try to set a blank name. .PP If provided an argument, checks the schema object for a table of that name and disallows the change if one exists (setting the error to \&\*(L"Can't use table name \*(R"%s\*(L": table exists\*(R"). .PP .Vb 1 \& my $table_name = $table\->name(\*(Aqfoo\*(Aq); .Ve .SS "schema" .IX Subsection "schema" Get or set the table's schema object. .PP .Vb 1 \& my $schema = $table\->schema; .Ve .SS "primary_key" .IX Subsection "primary_key" Gets or sets the table's primary key(s). Takes one or more field names (as a string, list or array[ref]) as an argument. If the field names are present, it will create a new \s-1PK\s0 if none exists, or it will add to the fields of an existing \s-1PK\s0 (and will unique the field names). Returns the \f(CW\*(C`SQL::Translator::Schema::Constraint\*(C'\fR object representing the primary key. .PP These are eqivalent: .PP .Vb 6 \& $table\->primary_key(\*(Aqid\*(Aq); \& $table\->primary_key([\*(Aqname\*(Aq]); \& $table\->primary_key(\*(Aqid\*(Aq,\*(Aqname\*(Aq]); \& $table\->primary_key([\*(Aqid\*(Aq,\*(Aqname\*(Aq]); \& $table\->primary_key(\*(Aqid,name\*(Aq); \& $table\->primary_key(qw[ id name ]); \& \& my $pk = $table\->primary_key; .Ve .SS "options" .IX Subsection "options" Get or set the table's options (e.g., table types for MySQL). Returns an array or array reference. .PP .Vb 1 \& my @options = $table\->options; .Ve .SS "order" .IX Subsection "order" Get or set the table's order. .PP .Vb 1 \& my $order = $table\->order(3); .Ve .SS "field_names" .IX Subsection "field_names" Read-only method to return a list or array ref of the field names. Returns undef or an empty list if the table has no fields set. Useful if you want to avoid the overload magic of the Field objects returned by the get_fields method. .PP .Vb 1 \& my @names = $constraint\->field_names; .Ve .SS "equals" .IX Subsection "equals" Determines if this table is the same as another .PP .Vb 1 \& my $isIdentical = $table1\->equals( $table2 ); .Ve .SH "LOOKUP METHODS" .IX Header "LOOKUP METHODS" The following are a set of shortcut methods for getting commonly used lists of fields and constraints. They all return lists or array refs of Field or Constraint objects. .IP "pkey_fields" 4 .IX Item "pkey_fields" The primary key fields. .IP "fkey_fields" 4 .IX Item "fkey_fields" All foreign key fields. .IP "nonpkey_fields" 4 .IX Item "nonpkey_fields" All the fields except the primary key. .IP "data_fields" 4 .IX Item "data_fields" All non key fields. .IP "unique_fields" 4 .IX Item "unique_fields" All fields with unique constraints. .IP "unique_constraints" 4 .IX Item "unique_constraints" All this tables unique constraints. .IP "fkey_constraints" 4 .IX Item "fkey_constraints" All this tables foreign key constraints. (See primary_key method to get the primary key constraint) .SH "AUTHORS" .IX Header "AUTHORS" Ken Youens-Clark , Allen Day .