From 7c43f3f73fd015be4f72c930a483099b98ffc676 Mon Sep 17 00:00:00 2001 From: Vitalii Bezsheiko Date: Sat, 20 May 2023 17:43:14 +0300 Subject: [PATCH] pkp/pkp-lib#8933 Fix migration errors --- .../migration/upgrade/v3_4_0/I8933_EventLogLocalized.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/classes/migration/upgrade/v3_4_0/I8933_EventLogLocalized.php b/classes/migration/upgrade/v3_4_0/I8933_EventLogLocalized.php index 031ee766ead..17fe9d78523 100644 --- a/classes/migration/upgrade/v3_4_0/I8933_EventLogLocalized.php +++ b/classes/migration/upgrade/v3_4_0/I8933_EventLogLocalized.php @@ -45,8 +45,10 @@ public function up(): void // Events can be triggered without a user, e.g., in schedule tasks Schema::table('event_log', function (Blueprint $table) { + $table->dropForeign('event_log_user_id_foreign'); $table->dropIndex('event_log_user_id'); $table->bigInteger('user_id')->nullable()->change(); + $table->foreign('user_id')->references('user_id')->on('users')->onDelete('cascade'); $table->index(['user_id'], 'event_log_user_id'); }); @@ -161,8 +163,10 @@ protected function isEventTypeToMigrateFileName(string $typeToCheck): bool */ protected function renameSettings() { + $eventTypes = $this->mapSettings()->keys()->toArray(); DB::table('event_log') - ->whereIn('event_type', [$this->mapSettings()->keys()->all()]) + ->whereIn('event_type', $eventTypes) + ->orderBy('date_logged') ->each(function (object $row) { // resolve conflict between 'name' and 'originalFileName'