Skip to content

Commit

Permalink
pkp#9069 Delegated cleanup of future foreign keys to pkp#8333
Browse files Browse the repository at this point in the history
  • Loading branch information
jonasraoni committed Jun 9, 2023
1 parent b1ba672 commit 3a3de8b
Showing 1 changed file with 0 additions and 46 deletions.
46 changes: 0 additions & 46 deletions classes/migration/upgrade/v3_4_0/PreflightCheckMigration.php
Original file line number Diff line number Diff line change
Expand Up @@ -491,17 +491,6 @@ protected function buildOrphanedEntityProcessor(): void
return $affectedRows;
});

$this->addTableProcessor('user_groups', function (): int {
$affectedRows = 0;
$ignoreAdministratorUserGroup = fn (Builder $q) => $q->where(
fn (Builder $where) => $where->where('s.context_id', '!=', 0)->orWhere('s.role_id', '!=', 1)
);
// Depends directly on ~1 entities: context_id->context_table.context_id
// Custom field (not found in at least one of the softwares)
$affectedRows += $this->deleteRequiredReference('user_groups', 'context_id', $this->getContextTable(), $this->getContextKeyField(), $ignoreAdministratorUserGroup);
return $affectedRows;
});

$this->addTableProcessor('categories', function (): int {
$affectedRows = 0;
// Depends directly on ~2 entities: context_id->context_table.context_id parent_id->categories.category_id
Expand Down Expand Up @@ -557,9 +546,6 @@ protected function buildOrphanedEntityProcessor(): void
$affectedRows = 0;
// Depends directly on ~3 entities: context_id->context_table.context_id filter_group_id->filter_groups.filter_group_id parent_filter_id->filters.filter_id
$affectedRows += $this->deleteRequiredReference('filters', 'filter_group_id', 'filter_groups', 'filter_group_id');
$affectedRows += $this->deleteRequiredReference('filters', 'parent_filter_id', 'filters', 'filter_id', $this->ignoreZero('parent_filter_id'));
// Custom field (not found in at least one of the softwares)
$affectedRows += $this->deleteRequiredReference('filters', 'context_id', $this->getContextTable(), $this->getContextKeyField(), $this->ignoreZero('context_id'));
return $affectedRows;
});

Expand All @@ -576,15 +562,6 @@ protected function buildOrphanedEntityProcessor(): void
// Depends directly on ~3 entities: navigation_menu_id->navigation_menus.navigation_menu_id navigation_menu_item_id->navigation_menu_items.navigation_menu_item_id parent_id->navigation_menu_item_assignments.navigation_menu_item_assignment_id
$affectedRows += $this->deleteRequiredReference('navigation_menu_item_assignments', 'navigation_menu_item_id', 'navigation_menu_items', 'navigation_menu_item_id');
$affectedRows += $this->deleteRequiredReference('navigation_menu_item_assignments', 'navigation_menu_id', 'navigation_menus', 'navigation_menu_id');
$affectedRows += $this->deleteOptionalReference('navigation_menu_item_assignments', 'parent_id', 'navigation_menu_item_assignments', 'navigation_menu_item_assignment_id', $this->ignoreZero('parent_id'));
return $affectedRows;
});

$this->addTableProcessor('navigation_menu_items', function (): int {
$affectedRows = 0;
// Depends directly on ~1 entities: context_id->context_table.context_id
// Custom field (not found in at least one of the softwares)
$affectedRows += $this->deleteRequiredReference('navigation_menu_items', 'context_id', $this->getContextTable(), $this->getContextKeyField(), $this->ignoreZero('context_id'));
return $affectedRows;
});

Expand Down Expand Up @@ -619,13 +596,6 @@ protected function buildOrphanedEntityProcessor(): void
return $affectedRows;
});

$this->addTableProcessor('email_log', function (): int {
$affectedRows = 0;
// Depends directly on ~1 entities: sender_id->users.user_id
$affectedRows += $this->deleteRequiredReference('email_log', 'sender_id', 'users', 'user_id', $this->ignoreZero('sender_id'));
return $affectedRows;
});

$this->addTableProcessor('email_templates', function (): int {
$affectedRows = 0;
// Depends directly on ~1 entities: context_id->context_table.context_id
Expand All @@ -650,14 +620,6 @@ protected function buildOrphanedEntityProcessor(): void
return $affectedRows;
});

$this->addTableProcessor('navigation_menus', function (): int {
$affectedRows = 0;
// Depends directly on ~1 entities: context_id->context_table.context_id
// Custom field (not found in at least one of the softwares)
$affectedRows += $this->deleteRequiredReference('navigation_menus', 'context_id', $this->getContextTable(), $this->getContextKeyField(), $this->ignoreZero('context_id'));
return $affectedRows;
});

$this->addTableProcessor('notifications', function (): int {
$affectedRows = 0;
// Depends directly on ~2 entities: context_id->context_table.context_id user_id->users.user_id
Expand Down Expand Up @@ -834,14 +796,6 @@ protected function buildOrphanedEntityProcessor(): void
return $affectedRows;
});

$this->addTableProcessor('plugin_settings', function (): int {
$affectedRows = 0;
// Depends directly on ~1 entities: context_id->context_table.context_id
// Custom field (not found in at least one of the softwares)
$affectedRows += $this->deleteRequiredReference('plugin_settings', 'context_id', $this->getContextTable(), $this->getContextKeyField(), $this->ignoreZero('context_id'));
return $affectedRows;
});

$this->addTableProcessor('publication_categories', function (): int {
$affectedRows = 0;
// Depends directly on ~2 entities: category_id->categories.category_id publication_id->publications.publication_id
Expand Down

0 comments on commit 3a3de8b

Please sign in to comment.