Skip to content

Commit

Permalink
Revert "[11.x] Added dropColumnsIfExists, dropColumnIfExists and …
Browse files Browse the repository at this point in the history
…`dropFor…"

This reverts commit b6e478d.
  • Loading branch information
taylorotwell authored Oct 29, 2024
1 parent a8363e4 commit a28656e
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 53 deletions.
39 changes: 0 additions & 39 deletions src/Illuminate/Database/Schema/Blueprint.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
use Illuminate\Database\Schema\Grammars\Grammar;
use Illuminate\Database\Schema\Grammars\MySqlGrammar;
use Illuminate\Database\Schema\Grammars\SQLiteGrammar;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Fluent;
use Illuminate\Support\Traits\Macroable;

Expand Down Expand Up @@ -428,25 +427,6 @@ public function dropColumn($columns)
return $this->addCommand('dropColumn', compact('columns'));
}

/**
* Indicate that the given columns should be dropped if they exist.
*
* @param array|mixed $columns
* @return \Illuminate\Support\Fluent
*/
public function dropColumnIfExists($columns)
{
$columns = is_array($columns) ? $columns : func_get_args();

$columns = array_intersect($columns, Schema::getColumnListing($this->getTable()));

if (empty($columns)) {
return new Fluent;
}

return $this->dropColumn($columns);
}

/**
* Indicate that the given columns should be renamed.
*
Expand Down Expand Up @@ -525,25 +505,6 @@ public function dropForeign($index)
return $this->dropIndexCommand('dropForeign', 'foreign', $index);
}

/**
* Indicate that the given foreign key should be dropped if it exists.
*
* @param string|array $index
* @return \Illuminate\Support\Fluent
*/
public function dropForeignIfExists($index)
{
if (is_array($index)) {
$index = $this->createIndexName('foreign', $index);
}

if (! in_array($index, Schema::getForeignKeys($this->getTable()))) {
return new Fluent;
}

return $this->dropIndexCommand('dropForeign', 'foreign', $index);
}

/**
* Indicate that the given column and foreign key should be dropped.
*
Expand Down
14 changes: 0 additions & 14 deletions src/Illuminate/Database/Schema/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -462,20 +462,6 @@ public function dropColumns($table, $columns)
});
}

/**
* Drop columns from a table schema if they exist.
*
* @param string $table
* @param string|array $columns
* @return void
*/
public function dropColumnsIfExists($table, $columns)
{
$this->table($table, function (Blueprint $blueprint) use ($columns) {
$blueprint->dropColumnIfExists($columns);
});
}

/**
* Drop all tables from the database.
*
Expand Down

0 comments on commit a28656e

Please sign in to comment.