Skip to content

Commit

Permalink
DKAN-4287 Make harvest_run id not a primary key.
Browse files Browse the repository at this point in the history
  • Loading branch information
Steve Wirt authored and Steve Wirt committed Nov 20, 2024
1 parent 61e73f4 commit 59ea0a1
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 8 deletions.
26 changes: 25 additions & 1 deletion modules/harvest/harvest.install
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,32 @@ function harvest_update_8007(&$sandbox) {
* This finishes the process started by harvest_update_8007.
*/
function harvest_update_8008(&$sandbox) {
// Repeated in 8009.
}

/**
* Update schema to make timestamp based harvest id un-unique.
*
* @see https://github.com/GetDKAN/dkan/issues/4287
*/
function harvest_update_8009(&$sandbox) {
$table_name = 'harvest_runs ';
// Harvest runs currently has an id field marked as key. It needs to not
// be a key so that it can contain duplicate values.
$dropped = \Drupal::database()->schema()->dropPrimaryKey($table_name);
if ($dropped) {
$msg = "Primary key removed from table {$table_name}. ";
}
else {
$msg = "No primary key found to drop from table {$table_name}. ";
}

$msg = 'Table harvest_runs had primary key removed. ';

/** @var \Drupal\harvest\HarvestUtility $harvest_utility */
$harvest_utility = \Drupal::service('dkan.harvest.utility');
$harvest_utility->harvestRunsUpdate();
return 'Harvest runs coalesced into table harvest_runs.';
$msg .= 'Harvest runs coalesced into table harvest_runs.';

return $msg;
}
8 changes: 1 addition & 7 deletions modules/harvest/src/Entity/HarvestRun.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,11 @@
* },
* base_table = "harvest_runs",
* admin_permission = "administer harvest_run",
* entity_keys = {
* "id" = "id",
* "label" = "id",
* },
* entity_keys = {},
* links = {
* "canonical" = "/harvest-run/{harvest_run}",
* },
* )
*
* @todo Convert to using microtime() or other better system for the timestamp/
* id.
*/
final class HarvestRun extends HarvestEntityBase implements HarvestRunInterface {

Expand Down

0 comments on commit 59ea0a1

Please sign in to comment.