.\" Automatically generated by Pod::Man 2.28 (Pod::Simple 3.28) .\" .\" 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 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. .\" .\" 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 .\" .\" 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 "Alzabo::Create::Table 3pm" .TH Alzabo::Create::Table 3pm "2015-05-24" "perl v5.20.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" Alzabo::Create::Table \- Table objects for schema creation .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& use Alzabo::Create::Table; .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" This class represents tables in the schema. It contains column, index, and foreign key objects. .SH "INHERITS FROM" .IX Header "INHERITS FROM" \&\f(CW\*(C`Alzabo::Table\*(C'\fR .PP Note: all relevant documentation from the superclass has been merged into this document. .SH "METHODS" .IX Header "METHODS" .SS "new" .IX Subsection "new" The constructor takes the following parameters: .IP "\(bu" 4 schema => \f(CW\*(C`Alzabo::Create::Schema\*(C'\fR object .Sp The schema to which this table belongs. .IP "\(bu" 4 name => \f(CW$name\fR .IP "\(bu" 4 attributes => \e@attributes .IP "\(bu" 4 comment => \f(CW$comment\fR .Sp An optional comment. .PP It returns a new \f(CW\*(C`Alzabo::Create::Table\*(C'\fR object. .PP Throws: \f(CW\*(C`Alzabo::Exception::Params\*(C'\fR .SS "schema" .IX Subsection "schema" Returns the \f(CW\*(C`Alzabo::Create::Schema\*(C'\fR object to which this table belongs. .SS "name" .IX Subsection "name" Returns the name of the table. .SS "set_name ($name)" .IX Subsection "set_name ($name)" Changes the name of the table. .PP Throws: \f(CW\*(C`Alzabo::Exception::Params\*(C'\fR, \&\f(CW\*(C`Alzabo::Exception::RDBMSRules\*(C'\fR .SS "column ($name)" .IX Subsection "column ($name)" Returns the \f(CW\*(C`Alzabo::Create::Column\*(C'\fR object that matches the name given. .PP An \f(CW\*(C`Alzabo::Exception::Params\*(C'\fR exception is throws if the table does not contain the column. .SS "columns (@optional_list_of_column_names)" .IX Subsection "columns (@optional_list_of_column_names)" If no arguments are given, returns a list of all \&\f(CW\*(C`Alzabo::Create::Column\*(C'\fR objects in the schema, or in a scalar context the number of such tables. If one or more arguments are given, returns a list of table objects with those names, in the same order given. .PP An \f(CW\*(C`Alzabo::Exception::Params\*(C'\fR exception is throws if the table does not contain one or more of the specified columns. .SS "has_column ($name)" .IX Subsection "has_column ($name)" Returns a voolean value indicating whether the column exists in the table. .SS "make_column" .IX Subsection "make_column" Creates a new \f(CW\*(C`Alzabo::Create::Column\*(C'\fR object and adds it to the table. This object is the function's return value. .PP In addition, if a \*(L"before\*(R" or \*(L"after\*(R" parameter is given, the \&\f(CW\*(C`move_column()\*(C'\fR method is called to move the new column. .PP This method takes all of the same parameters as the \f(CW\*(C`Alzabo::Create::Column\->new()\*(C'\fR method except the \*(L"table\*(R" parameter, which is automatically supplied. .PP This method also accepts an additional parameter, \*(L"primary_key\*(R", indicating whether or not the column is part of the table's primary key. .PP Returns a new \f(CW\*(C`Alzabo::Create::Column\*(C'\fR object. .PP Throws: \f(CW\*(C`Alzabo::Exception::Params\*(C'\fR, \&\f(CW\*(C`Alzabo::Exception::RDBMSRules\*(C'\fR .SS "add_column" .IX Subsection "add_column" Adds a column to the table. If a \*(L"before\*(R" or \*(L"after\*(R" parameter is given then the \f(CW\*(C`move_column()\*(C'\fR method will be called to move the new column to the appropriate position. .PP It takes the following parameters: .IP "\(bu" 4 column => \f(CW\*(C`Alzabo::Create::Column\*(C'\fR object .IP "\(bu" 4 after => \f(CW\*(C`Alzabo::Create::Column\*(C'\fR object (optional) .Sp \&... or ... .IP "\(bu" 4 before => \f(CW\*(C`Alzabo::Create::Column\*(C'\fR object (optional) .PP Throws: \f(CW\*(C`Alzabo::Exception::Params\*(C'\fR, \&\f(CW\*(C`Alzabo::Exception::RDBMSRules\*(C'\fR .ie n .SS "delete_column (""Alzabo::Create::Column"" object)" .el .SS "delete_column (\f(CWAlzabo::Create::Column\fP object)" .IX Subsection "delete_column (Alzabo::Create::Column object)" Deletes a column from the table. .PP Throws: \f(CW\*(C`Alzabo::Exception::Params\*(C'\fR .SS "move_column" .IX Subsection "move_column" This method takes the following parameters: .IP "\(bu" 4 column => \f(CW\*(C`Alzabo::Create::Column\*(C'\fR object .Sp The column to move. .Sp and either ... .IP "\(bu" 4 before => \f(CW\*(C`Alzabo::Create::Column\*(C'\fR object .Sp Move the column before this column .Sp \&... or ... .IP "\(bu" 4 after => \f(CW\*(C`Alzabo::Create::Column\*(C'\fR object .Sp Move the column after this column. .PP Throws: \f(CW\*(C`Alzabo::Exception::Params\*(C'\fR .SS "primary_key" .IX Subsection "primary_key" In array context, return an ordered list of column objects that make up the primary key for the table. In scalar context, it returns the first element of that list. .SS "primary_key_size" .IX Subsection "primary_key_size" The number of columns in the table's primary key. .ie n .SS "add_primary_key (""Alzabo::Create::Column"" object)" .el .SS "add_primary_key (\f(CWAlzabo::Create::Column\fP object)" .IX Subsection "add_primary_key (Alzabo::Create::Column object)" Make the given column part of the table's primary key. The primary key is an ordered list of columns. The given column will be added to the end of this list. .PP Throws: \f(CW\*(C`Alzabo::Exception::Params\*(C'\fR .ie n .SS "delete_primary_key (""Alzabo::Create::Column"" object)" .el .SS "delete_primary_key (\f(CWAlzabo::Create::Column\fP object)" .IX Subsection "delete_primary_key (Alzabo::Create::Column object)" Delete the given column from the primary key. .PP Throws: \f(CW\*(C`Alzabo::Exception::Params\*(C'\fR .SS "foreign_keys" .IX Subsection "foreign_keys" Thie method takes two parameters: .IP "\(bu" 4 column => \f(CW\*(C`Alzabo::Create::Column\*(C'\fR object .IP "\(bu" 4 table => \f(CW\*(C`Alzabo::Create::Table\*(C'\fR object .PP It returns a list of \f(CW\*(C`Alzabo::Create::ForeignKey\*(C'\fR objects \fBfrom\fR the given column \fBto\fR the given table, if they exist. In scalar context, it returns the first item in the list. There is no guarantee as to what the first item will be. .PP An \f(CW\*(C`Alzabo::Exception::Params\*(C'\fR exception is throws if the table does not contain the specified column. .ie n .SS "foreign_keys_by_table (""Alzabo::Create::Table"" object)" .el .SS "foreign_keys_by_table (\f(CWAlzabo::Create::Table\fP object)" .IX Subsection "foreign_keys_by_table (Alzabo::Create::Table object)" Returns a list of all the \f(CW\*(C`Alzabo::Create::ForeignKey\*(C'\fR objects \fBto\fR the given table. In scalar context, it returns the first item in the list. There is no guarantee as to what the first item will be. .ie n .SS "foreign_keys_by_column (""Alzabo::Create::Column"" object)" .el .SS "foreign_keys_by_column (\f(CWAlzabo::Create::Column\fP object)" .IX Subsection "foreign_keys_by_column (Alzabo::Create::Column object)" Returns a list of all the \f(CW\*(C`Alzabo::Create::ForeignKey\*(C'\fR objects that the given column is a part of, if any. In scalar context, it returns the first item in the list. There is no guarantee as to what the first item will be. .PP An \f(CW\*(C`Alzabo::Exception::Params\*(C'\fR exception is throws if the table does not contain the specified column. .SS "all_foreign_keys" .IX Subsection "all_foreign_keys" Returns a list of all the \f(CW\*(C`Alzabo::Create::ForeignKey\*(C'\fR objects for this table. In scalar context, it returns the first item in the list. There is no guarantee as to what the first item will be. .SS "make_foreign_key (see below)" .IX Subsection "make_foreign_key (see below)" Takes the same parameters as the \&\f(CW\*(C`Alzabo::Create::ForeignKey\->new\*(C'\fR method except for the table parameter, which is automatically added. The foreign key object that is created is then added to the table. .PP If the foreign key being made is 1..1 or 1..n, then a unique index will be created on the columns involved in the \*(L"1\*(R" side of the foreign key, unless they are the table's primary key. .PP Returns a new \&\f(CW\*(C`Alzabo::Create::ForeignKey\*(C'\fR object. .PP Throws: \f(CW\*(C`Alzabo::Exception::Params\*(C'\fR .ie n .SS "add_foreign_key (""Alzabo::Create::ForeignKey"" object)" .el .SS "add_foreign_key (\f(CWAlzabo::Create::ForeignKey\fP object)" .IX Subsection "add_foreign_key (Alzabo::Create::ForeignKey object)" Adds the given foreign key to the table. .PP Throws: \f(CW\*(C`Alzabo::Exception::Params\*(C'\fR .ie n .SS "delete_foreign_key (""Alzabo::Create::ForeignKey"" object)" .el .SS "delete_foreign_key (\f(CWAlzabo::Create::ForeignKey\fP object)" .IX Subsection "delete_foreign_key (Alzabo::Create::ForeignKey object)" Deletes the given foreign key from the table .PP Throws: \f(CW\*(C`Alzabo::Exception::Params\*(C'\fR .SS "index ($index_id)" .IX Subsection "index ($index_id)" This method expects an index id as returned by the \&\f(CW\*(C`Alzabo::Create::Index\->id\*(C'\fR method as its parameter. .PP The \f(CW\*(C`Alzabo::Create::Index\*(C'\fR object matching this id, if it exists in the table. .PP An \f(CW\*(C`Alzabo::Exception::Params\*(C'\fR exception is throws if the table does not contain the specified index. .SS "has_index ($index_id)" .IX Subsection "has_index ($index_id)" This method expects an index id as returned by the \&\f(CW\*(C`Alzabo::Create::Index\->id\*(C'\fR method as its parameter. .PP Returns a boolean indicating whether the table has an index with the same id. .SS "indexes" .IX Subsection "indexes" Returns all the \f(CW\*(C`Alzabo::Create::Index\*(C'\fR objects for the table. .SS "make_index" .IX Subsection "make_index" Takes the same parameters as the \f(CW\*(C`Alzabo::Create::Index\->new()\*(C'\fR method except for the \*(L"table\*(R" parameter, which is automatically added. The index object that is created is then added to the table. .PP Returns the new \f(CW\*(C`Alzabo::Create::Index\*(C'\fR object. .PP Throws: \f(CW\*(C`Alzabo::Exception::Params\*(C'\fR .ie n .SS "add_index (""Alzabo::Create::Index"" object)" .el .SS "add_index (\f(CWAlzabo::Create::Index\fP object)" .IX Subsection "add_index (Alzabo::Create::Index object)" Adds the given index to the table. .PP Throws: \f(CW\*(C`Alzabo::Exception::Params\*(C'\fR .ie n .SS "delete_index (""Alzabo::Create::Index"" object)" .el .SS "delete_index (\f(CWAlzabo::Create::Index\fP object)" .IX Subsection "delete_index (Alzabo::Create::Index object)" Deletes the specified index from the table. .PP Throws: \f(CW\*(C`Alzabo::Exception::Params\*(C'\fR .SS "attributes" .IX Subsection "attributes" A table's attributes are strings describing the table (for example, valid attributes in MySQL are thing like \*(L"\s-1TYPE\s0 = \s-1INNODB\*(R".\s0 .PP Returns a list of strings. .SS "has_attribute" .IX Subsection "has_attribute" This method can be used to test whether or not a table has a particular attribute. By default, the check is case-insensitive. .IP "\(bu" 4 attribute => \f(CW$attribute\fR .IP "\(bu" 4 case_sensitive => 0 or 1 (defaults to 0) .PP Returns a boolean value indicating whether the table has this particular attribute. .SS "set_attributes (@attributes)" .IX Subsection "set_attributes (@attributes)" Sets the tables's attributes. These are strings describing the table (for example, valid attributes in MySQL are \*(L"\s-1TYPE\s0 = \s-1INNODB\*(R"\s0 or \&\*(L"\s-1AUTO_INCREMENT\s0 = 100\*(R"). .PP You can also set table constraints as attributes. Alzabo will generate correct \s-1SQL\s0 for both actual attributes and constraints. .SS "add_attribute ($attribute)" .IX Subsection "add_attribute ($attribute)" Add an attribute to the column's list of attributes. .SS "delete_attribute ($attribute)" .IX Subsection "delete_attribute ($attribute)" Delete the given attribute from the column's list of attributes. .PP \&\f(CW\*(C`Alzabo::Exception::Params\*(C'\fR .SS "former_name" .IX Subsection "former_name" If the table's name has been changed since the last time the schema was instantiated, this method returns the table's previous name. .SS "comment" .IX Subsection "comment" Returns the comment associated with the table object, if any. .SS "set_comment ($comment)" .IX Subsection "set_comment ($comment)" Set the comment for the table object. .SH "AUTHOR" .IX Header "AUTHOR" Dave Rolsky,