Merge pull request #10902 from snipe/fixes/added_primary_key_to_custom_fields_pivot

Fixed #10892 - MySQL 8 compatibilty requires primary key
This commit is contained in:
snipe 2022-04-05 20:35:14 +01:00 committed by GitHub
commit 87fc856361
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 42 additions and 2 deletions

View file

@ -14,13 +14,14 @@ class CreateCustomFieldCustomFieldset extends Migration {
{
Schema::create('custom_field_custom_fieldset', function(Blueprint $table)
{
$table->bigIncrements('id')->first();
$table->integer('custom_field_id');
$table->integer('custom_fieldset_id');
$table->integer('order');
$table->boolean('required');
$table->engine = 'InnoDB';
$table->engine = 'InnoDB';
});
}
/**

View file

@ -0,0 +1,39 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddPrimaryKeyToCustomFieldsPivot extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
// Check if the ID primary key already exists, if not, add it
Schema::table('custom_field_custom_fieldset', function (Blueprint $table) {
if (!Schema::hasColumn('custom_field_custom_fieldset', 'id')) {
$table->bigIncrements('id')->first();
}
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('custom_field_custom_fieldset', function (Blueprint $table) {
if (Schema::hasColumn('custom_field_custom_fieldset', 'id')) {
$table->dropColumn('id');
}
});
}
}