Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "[11.x] Added dropColumnsIfExists, dropColumnIfExists and dropForeignIfExists" #53338

Merged
merged 1 commit into from
Oct 29, 2024
Merged
Show file tree
Hide file tree
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
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