From c12ef19fcc9c313a45d7dee09fec67e4f8a30619 Mon Sep 17 00:00:00 2001 From: snipe Date: Tue, 5 Apr 2022 18:58:14 +0100 Subject: [PATCH 1/2] Fixed #10892 - MySQL 8 compatibilty requires primary key Signed-off-by: snipe --- ...add_primary_key_to_custom_fields_pivot.php | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 database/migrations/2022_04_05_135340_add_primary_key_to_custom_fields_pivot.php diff --git a/database/migrations/2022_04_05_135340_add_primary_key_to_custom_fields_pivot.php b/database/migrations/2022_04_05_135340_add_primary_key_to_custom_fields_pivot.php new file mode 100644 index 0000000000..44a879b1ee --- /dev/null +++ b/database/migrations/2022_04_05_135340_add_primary_key_to_custom_fields_pivot.php @@ -0,0 +1,34 @@ +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'); + } + }); + } +} From 3dd7c00a0bc6c0177e43d18706135a116bfbafbf Mon Sep 17 00:00:00 2001 From: snipe Date: Tue, 5 Apr 2022 20:31:17 +0100 Subject: [PATCH 2/2] Update migration back in time Signed-off-by: snipe --- ...15_09_21_235926_create_custom_field_custom_fieldset.php | 5 +++-- ...04_05_135340_add_primary_key_to_custom_fields_pivot.php | 7 ++++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/database/migrations/2015_09_21_235926_create_custom_field_custom_fieldset.php b/database/migrations/2015_09_21_235926_create_custom_field_custom_fieldset.php index acf920ce73..b96ac2ce52 100644 --- a/database/migrations/2015_09_21_235926_create_custom_field_custom_fieldset.php +++ b/database/migrations/2015_09_21_235926_create_custom_field_custom_fieldset.php @@ -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'; }); + } /** diff --git a/database/migrations/2022_04_05_135340_add_primary_key_to_custom_fields_pivot.php b/database/migrations/2022_04_05_135340_add_primary_key_to_custom_fields_pivot.php index 44a879b1ee..35f2f15415 100644 --- a/database/migrations/2022_04_05_135340_add_primary_key_to_custom_fields_pivot.php +++ b/database/migrations/2022_04_05_135340_add_primary_key_to_custom_fields_pivot.php @@ -13,9 +13,14 @@ class AddPrimaryKeyToCustomFieldsPivot extends Migration */ public function up() { + + // Check if the ID primary key already exists, if not, add it Schema::table('custom_field_custom_fieldset', function (Blueprint $table) { - $table->bigIncrements('id')->first(); + if (!Schema::hasColumn('custom_field_custom_fieldset', 'id')) { + $table->bigIncrements('id')->first(); + } }); + } /**