Last active
June 15, 2022 07:37
-
-
Save royteusink/d660f9936aed6d3d87f4b85ee63d67c8 to your computer and use it in GitHub Desktop.
Revisions
-
royteusink revised this gist
Jun 15, 2022 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -10,9 +10,9 @@ public function boot() /** @var Blueprint $this */ $schema = Schema::getConnection()->getDoctrineSchemaManager(); $tableDetails = $schema->listTableDetails($this->getTable()); if ($tableDetails->hasIndex($index)) { $this->dropIndex($index); } }); -
royteusink renamed this gist
Jun 15, 2022 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,4 @@ <?php // app/Providers/AppServiceProvider.php use Illuminate\Database\Schema\Blueprint; -
royteusink created this gist
Jun 15, 2022 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,22 @@ // app/Providers/AppServiceProvider.php use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; public function boot() { Blueprint::macro('dropIndexIfExists', function ($index) { /** @var Blueprint $this */ $schema = Schema::getConnection()->getDoctrineSchemaManager(); $tableDetils = $schema->listTableDetails($this->getTable()); if ($tableDetils->hasIndex($index)) { $this->dropIndex($index); } }); } // Migration usage $table->dropIndexIfExists('indexname');