Add on delete cascade to foreign key constraints. Fixes #1
parent
07b9b0a399
commit
5b402e8847
@ -0,0 +1,30 @@ |
|||||||
|
<?php |
||||||
|
namespace Application\Migrations; |
||||||
|
|
||||||
|
use Doctrine\DBAL\Migrations\AbstractMigration; |
||||||
|
use Doctrine\DBAL\Schema\Schema; |
||||||
|
|
||||||
|
class VersionTos20180615080524 extends AbstractMigration |
||||||
|
{ |
||||||
|
|
||||||
|
public function up(Schema $schema) |
||||||
|
{ |
||||||
|
$tos = $schema->getTable('vierbergenlars_tos'); |
||||||
|
|
||||||
|
foreach ($tos->getForeignKeys() as $fk) { |
||||||
|
$tos->removeForeignKey($fk->getName()); |
||||||
|
$tos->addForeignKeyConstraint($fk->getForeignTableName(), $fk->getColumns(), $fk->getForeignColumns(), [ |
||||||
|
'onDelete' => 'CASCADE' |
||||||
|
]); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public function down(Schema $schema) |
||||||
|
{ |
||||||
|
$tos = $schema->getTable('vierbergenlars_tos'); |
||||||
|
foreach ($tos->getForeignKeys() as $fk) { |
||||||
|
$tos->removeForeignKey($fk->getName()); |
||||||
|
$tos->addForeignKeyConstraint($fk->getForeignTableName(), $fk->getColumns(), $fk->getForeignColumns()); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
Reference in new issue