Skip to content

Commit 40f738d

Browse files
committed
Override renameColumn method;
1 parent 1c2d1fe commit 40f738d

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/Schema/Blueprint.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
namespace MongoDB\Laravel\Schema;
66

77
use Illuminate\Database\Connection;
8+
use Illuminate\Database\Schema\Blueprint as SchemaBlueprint;
89
use MongoDB\Laravel\Collection;
910

1011
use function array_flip;
@@ -15,7 +16,7 @@
1516
use function is_string;
1617
use function key;
1718

18-
class Blueprint extends \Illuminate\Database\Schema\Blueprint
19+
class Blueprint extends SchemaBlueprint
1920
{
2021
/**
2122
* The MongoConnection object for this blueprint.
@@ -276,6 +277,14 @@ public function drop()
276277
$this->collection->drop();
277278
}
278279

280+
/** @inheritdoc */
281+
public function renameColumn($from, $to)
282+
{
283+
$this->collection->updateMany([$from => ['$exists' => true]], ['$rename' => [$from => $to]]);
284+
285+
return $this;
286+
}
287+
279288
/** @inheritdoc */
280289
public function addColumn($type, $name, array $parameters = [])
281290
{

0 commit comments

Comments
 (0)