rxgx
rxgx

Reputation: 5160

What are the options for Doctrine's addColumn() migration method?

The API gives the code as:

public function up()
{
    $this->addColumn('table_name', 'column_name', 'string', $options);
}

but there's no documentation for what can be included in the options array.

http://www.doctrine-project.org/Doctrine_Migration_Base/1_2#method_addcolumn

Upvotes: 3

Views: 6377

Answers (3)

Daryl Gubler
Daryl Gubler

Reputation: 305

For people coming in: it looks like this is really defined from the Data Access Layer. Here is the list of options for columns from the DBAL docs: http://docs.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/schema-representation.html

Upvotes: 7

Dan Smart
Dan Smart

Reputation: 1052

The documentation is wrong. Looking in Doctrine/Migration/base.php, you can see the following function prototype:

/**
 * Add a add column change.
 *
 * @param string $tableName Name of the table
 * @param string $columnName Name of the column
 * @param string $type Type of the column
 * @param string $length Length of the column
 * @param array $options Array of options for the column
 * @return void
 */
public function addColumn($tableName, $columnName, $type, $length = null, array $options = array())

So to add the length, you give it as the 4th parameter. I'm ignoring the options for the moment.

Upvotes: 1

chelmertz
chelmertz

Reputation: 20601

Following the "browse code" link on the top, you can follow the code to $options['length'] in Doctrine_Migration_Base::column() and the second parameter in Doctrine_Migration_Base::_addChange(). Check out the source code from time to time, it gives you an overview :)

Upvotes: 0

Related Questions