man Alzabo::Create::Table () - Table objects for schema creation

NAME

Alzabo::Create::Table - Table objects for schema creation

SYNOPSIS

  use Alzabo::Create::Table;

DESCRIPTION

This class represents tables in the schema. It contains column, index, and foreign key objects.

INHERITS FROM

CWAlzabo::Table

Note: all relevant documentation from the superclass has been merged into this document.

METHODS

new

The constructor takes the following parameters: The schema to which this table belongs.

* attributes => \@attributes
An optional comment.

It returns a new CWAlzabo::Create::Table object.

Throws: CWAlzabo::Exception::Params

schema

Returns the CWAlzabo::Create::Schema object to which this table belongs.

name

Returns the name of the table.

set_name ($name)

Changes the name of the table.

Throws: CWAlzabo::Exception::Params, CWAlzabo::Exception::RDBMSRules

column ($name)

Returns the CWAlzabo::Create::Column object that matches the name given.

An CWAlzabo::Exception::Params exception is throws if the table does not contain the column.

columns (@optional_list_of_column_names)

If no arguments are given, returns a list of all CWAlzabo::Create::Column 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.

An CWAlzabo::Exception::Params exception is throws if the table does not contain one or more of the specified columns.

has_column ($name)

Returns a voolean value indicating whether the column exists in the table.

make_column

Creates a new CWAlzabo::Create::Column object and adds it to the table. This object is the function's return value.

In addition, if a before or after parameter is given, the CWmove_column() method is called to move the new column.

This method takes all of the same parameters as the CWAlzabo::Create::Column->new() method except the table parameter, which is automatically supplied.

This method also accepts an additional parameter, primary_key, indicating whether or not the column is part of the table's primary key.

Returns a new CWAlzabo::Create::Column object.

Throws: CWAlzabo::Exception::Params, CWAlzabo::Exception::RDBMSRules

add_column

Adds a column to the table. If a before or after parameter is given then the CWmove_column() method will be called to move the new column to the appropriate position.

It takes the following parameters: ... or ...

Throws: CWAlzabo::Exception::Params, CWAlzabo::Exception::RDBMSRules Deletes a column from the table.

Throws: CWAlzabo::Exception::Params

move_column

This method takes the following parameters: The column to move. and either ... Move the column before this column ... or ... Move the column after this column.

Throws: CWAlzabo::Exception::Params

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.

primary_key_size

The number of columns in the table's primary key. 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.

Throws: CWAlzabo::Exception::Params Delete the given column from the primary key.

Throws: CWAlzabo::Exception::Params

foreign_keys

Thie method takes two parameters:

It returns a list of CWAlzabo::Create::ForeignKey objects from the given column to 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.

An CWAlzabo::Exception::Params exception is throws if the table does not contain the specified column. Returns a list of all the CWAlzabo::Create::ForeignKey objects to 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. Returns a list of all the CWAlzabo::Create::ForeignKey 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.

An CWAlzabo::Exception::Params exception is throws if the table does not contain the specified column.

all_foreign_keys

Returns a list of all the CWAlzabo::Create::ForeignKey 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.

make_foreign_key (see below)

Takes the same parameters as the CWAlzabo::Create::ForeignKey->new method except for the table parameter, which is automatically added. The foreign key object that is created is then added to the table.

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 1 side of the foreign key, unless they are the table's primary key.

Returns a new CWAlzabo::Create::ForeignKey object.

Throws: CWAlzabo::Exception::Params Adds the given foreign key to the table.

Throws: CWAlzabo::Exception::Params Deletes the given foreign key from the table

Throws: CWAlzabo::Exception::Params

index ($index_id)

This method expects an index id as returned by the CWAlzabo::Create::Index->id method as its parameter.

The CWAlzabo::Create::Index object matching this id, if it exists in the table.

An CWAlzabo::Exception::Params exception is throws if the table does not contain the specified index.

has_index ($index_id)

This method expects an index id as returned by the CWAlzabo::Create::Index->id method as its parameter.

Returns a boolean indicating whether the table has an index with the same id.

indexes

Returns all the CWAlzabo::Create::Index objects for the table.

make_index

Takes the same parameters as the CWAlzabo::Create::Index->new() method except for the table parameter, which is automatically added. The index object that is created is then added to the table.

Returns the new CWAlzabo::Create::Index object.

Throws: CWAlzabo::Exception::Params Adds the given index to the table.

Throws: CWAlzabo::Exception::Params Deletes the specified index from the table.

Throws: CWAlzabo::Exception::Params

attributes

A table's attributes are strings describing the table (for example, valid attributes in MySQL are thing like TYPE = INNODB.

Returns a list of strings.

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.

* case_sensitive => 0 or 1 (defaults to 0)

Returns a boolean value indicating whether the table has this particular attribute.

set_attributes (@attributes)

Sets the tables's attributes. These are strings describing the table (for example, valid attributes in MySQL are TYPE = INNODB or AUTO_INCREMENT = 100).

You can also set table constraints as attributes. Alzabo will generate correct SQL for both actual attributes and constraints.

add_attribute ($attribute)

Add an attribute to the column's list of attributes.

delete_attribute ($attribute)

Delete the given attribute from the column's list of attributes.

CWAlzabo::Exception::Params

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.

comment

Returns the comment associated with the table object, if any.

set_comment ($comment)

Set the comment for the table object.

AUTHOR

Dave Rolsky, <autarch@urth.org>