10.04.2018 Views

Doctrine_manual-1-2-en

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Chapter 24: Migrations 332<br />

Listing<br />

24-20<br />

}<br />

// ...<br />

The valid options for the $definition are:<br />

Name<br />

name<br />

local<br />

foreign<br />

Description<br />

Optional constraint name<br />

The local field(s)<br />

The foreign refer<strong>en</strong>ce field(s)<br />

foreignTable The name of the foreign table<br />

onDelete<br />

onUpdate<br />

deferred<br />

Drop Foreign Key<br />

Refer<strong>en</strong>tial delete action<br />

Refer<strong>en</strong>tial update action<br />

Deferred constraint checking<br />

// ...<br />

public function down()<br />

{<br />

$this->dropForeignKey('table_name', 'email_foreign_key');<br />

}<br />

// ...<br />

Listing<br />

24-21<br />

Add Column<br />

// ...<br />

public function up()<br />

{<br />

$this->addColumn('table_name', 'column_name', 'string', $options);<br />

}<br />

// ...<br />

R<strong>en</strong>ame Column<br />

Some DBMS like sqlite do not implem<strong>en</strong>t the r<strong>en</strong>ame column operation. An exception is<br />

thrown if you try and r<strong>en</strong>ame a column wh<strong>en</strong> using a sqlite connection.<br />

Listing<br />

24-22<br />

// ...<br />

public function up()<br />

{<br />

$this->r<strong>en</strong>ameColumn('table_name', 'old_column_name',<br />

'new_column_name');<br />

}<br />

// ...<br />

Change Column<br />

Change any aspect of an existing column:<br />

Listing<br />

24-23<br />

// ...<br />

public function up()<br />

{<br />

----------------- Brought to you by

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!