Skip to content

Commit

Permalink
pkp#8333 Do not rename index due to MariaDB/MySQL requirements and co…
Browse files Browse the repository at this point in the history
…nsistency with index creation migration
  • Loading branch information
asmecher committed Sep 20, 2024
1 parent dadb922 commit 0bbc4e5
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions classes/migration/upgrade/v3_5_0/I8333_AddMissingForeignKeys.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,6 @@ protected function setupFieldSchema(): void
}

Schema::table('email_log', fn (Blueprint $table) => $table->bigInteger('sender_id')->nullable()->default(null)->change());
Schema::table('notification_subscription_settings', function (Blueprint $table) {
$table->renameIndex('notification_subscription_settings_context', 'notification_subscription_settings_context_id');
$table->renameColumn('context', 'context_id');
});
}

/**
Expand Down Expand Up @@ -147,11 +143,12 @@ protected function clearOrphanedEntities(): void
/**
* Resets optional/nullable foreign key fields from the source table to NULL when the field contains invalid values
* Used for NULLABLE relationships
*
* @param $filter callable(Builder): Builder
*/
protected function cleanOptionalReference(string $sourceTable, string $sourceColumn, string $referenceTable, string $referenceColumn, ?callable $filter = null): int
{
$filter ??= fn(Builder $q) => $q;
$filter ??= fn (Builder $q) => $q;
$ids = $filter(
DB::table("{$sourceTable} AS s")
->leftJoin("{$referenceTable} AS r", "s.{$sourceColumn}", '=', "r.{$referenceColumn}")
Expand Down Expand Up @@ -179,11 +176,12 @@ protected function cleanOptionalReference(string $sourceTable, string $sourceCol
/**
* Deletes rows from the source table where the foreign key field contains invalid values
* Used for NULLABLE relationships, where the source record lose the meaning without its relationship
*
* @param $filter callable(Builder): Builder
*/
protected function deleteOptionalReference(string $sourceTable, string $sourceColumn, string $referenceTable, string $referenceColumn, ?callable $filter = null): int
{
$filter ??= fn(Builder $q) => $q;
$filter ??= fn (Builder $q) => $q;
$ids = $filter(
DB::table("{$sourceTable} AS s")
->leftJoin("{$referenceTable} AS r", "s.{$sourceColumn}", '=', "r.{$referenceColumn}")
Expand Down

0 comments on commit 0bbc4e5

Please sign in to comment.