Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions classes/TableMigrationCodeGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,10 @@ protected function generateSchemaTableMethodEnd()

protected function generateColumnDrop($column)
{
return sprintf('\t\t$table->dropColumn(\'%s\');', $column->getName()).$this->eol;
$code = sprintf('\t\tif (Schema::hasColumn($table->getTable(), \'%s\' )) {', $column->getName()).$this->eol;
$code .= sprintf('\t\t\t$table->dropColumn(\'%s\');', $column->getName()).$this->eol;
$code .= '\t\t};'.$this->eol;
return $code;
}

protected function generateIndexDrop($index)
Expand Down Expand Up @@ -408,7 +411,10 @@ protected function generateTableDropCode($name)

protected function generateColumnRemoveCode($name)
{
return sprintf('\t\t$table->dropColumn(\'%s\');', $name).$this->eol;
$code = sprintf('\t\tif (Schema::hasColumn($table->getTable(), \'%s\' )) {', $column->getName()).$this->eol;
$code .= sprintf('\t\t\t$table->dropColumn(\'%s\');', $column->getName()).$this->eol;
$code .= '\t\t};'.$this->eol;
return $code;
}

protected function generateColumnMethodCall($column)
Expand Down