for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php namespace Xethron\MigrationsGenerator\Syntax;
/**
* Class RemoveForeignKeysFromTable
* @package Xethron\MigrationsGenerator\Syntax
*/
class RemoveForeignKeysFromTable extends Table
{
* Return string for dropping a foreign key
*
* @param array $foreignKey
* @return string
protected function getItem(array $foreignKey): string
$name = empty($foreignKey['name']) ? $this->createIndexName($foreignKey['field']) : $foreignKey['name'];
return sprintf("\$table->dropForeign('%s');", $name);
}
* Create a default index name for the table.
* @param string $column
protected function createIndexName(string $column): string
$index = strtolower($this->table.'_'.$column.'_foreign');
return str_replace(['-', '.'], '_', $index);