mirror of
https://gitlab.linphone.org/BC/public/flexisip-account-manager.git
synced 2026-01-17 10:08:05 +00:00
First idea to fix primary key issue in old db migration
This commit is contained in:
parent
29fc1744a3
commit
d15376cb5e
1 changed files with 24 additions and 0 deletions
|
|
@ -8,6 +8,30 @@ class CreatePasswordResetsTable extends Migration
|
|||
{
|
||||
public function up()
|
||||
{
|
||||
if (config('database.default') == 'mysql'){
|
||||
//Need to execute the workaround only if the variable sql_require_primary_key exists (>= mysql 8) and if it is set to true
|
||||
$mysql_version = DB::statement("SHOW VARIABLES LIKE 'version'");
|
||||
if (0 !== preg_match('/(\d+\.?)+$/', $mysql_version, $matches)) {
|
||||
echo 'original: ' . $version . '; extracted: ' . $matches[0] . PHP_EOL;
|
||||
if (0 !== preg_match('/(^\d)/', $matches[0], $matches_start){
|
||||
if ($matches_start >= 8){
|
||||
DB::statement('SET SESSION sql_require_primary_key=0');
|
||||
}
|
||||
else{
|
||||
//mysql isn't the version 8
|
||||
}
|
||||
}
|
||||
else{
|
||||
//error or no match found for first number in version string
|
||||
}
|
||||
}
|
||||
else{
|
||||
//error or no match found for version number in string
|
||||
}
|
||||
}
|
||||
else {
|
||||
//database default isn't mysql
|
||||
}
|
||||
Schema::create('password_resets', function (Blueprint $table) {
|
||||
$table->string('email')->index();
|
||||
$table->string('token');
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue