Created
October 28, 2021 07:45
-
-
Save chris-cmsoft/73fe7c284c927c016458aa2801508fc5 to your computer and use it in GitHub Desktop.
Laravel - Switch off sql_require_primary_key for DigitalOcean managed database
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
# app/Providers/AppServiceProvider.php | |
public function register() | |
{ | |
// https://github.com/laravel/framework/issues/33238#issuecomment-897063577 | |
Event::listen(MigrationsStarted::class, function () { | |
DB::statement('SET SESSION sql_require_primary_key=0'); | |
}); | |
Event::listen(MigrationsEnded::class, function () { | |
DB::statement('SET SESSION sql_require_primary_key=1'); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment