-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add DisablePrimaryKeyRequirement listener
- Loading branch information
1 parent
8d44aae
commit a9a745c
Showing
2 changed files
with
43 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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 characters
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
|
||
namespace Danieletulone\LaravelToolkit\Listeners; | ||
|
||
use Illuminate\Support\Facades\DB; | ||
|
||
/** | ||
* This event listener is used to disable the requirement | ||
* for tables in the database to have a primary key defined. | ||
* Required by DigitalOcean to work correctly. | ||
*/ | ||
class DisablePrimaryKeyRequirement | ||
{ | ||
/** | ||
* Handle the event. | ||
* | ||
* @param object $event | ||
* @return void | ||
*/ | ||
public function handle($event) | ||
{ | ||
if (app()->environment('production')) { | ||
DB::statement('SET SESSION sql_require_primary_key=0'); | ||
} | ||
} | ||
} |