Skip to content

Commit

Permalink
Fix for issue systopia#145
Browse files Browse the repository at this point in the history
  • Loading branch information
jaapjansma committed Apr 12, 2022
1 parent 24dbb49 commit 8b35489
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
15 changes: 15 additions & 0 deletions CRM/Donrec/Upgrader.php
Original file line number Diff line number Diff line change
Expand Up @@ -513,4 +513,19 @@ public function upgrade_0220() {
return TRUE;
}

/**
* Change the primary key of the table. See https://github.com/systopia/de.systopia.donrec/issues/145
*
* @return bool
*/
public function upgrade_0221() {
\CRM_Core_DAO::executeQuery("
ALTER TABLE `donrec_snapshot`
DROP PRIMARY KEY,
ADD PRIMARY KEY (`id`),
ADD UNIQUE `snapshot_contrib_line_item` (`snapshot_id`, `contribution_id`, `line_item_id`);
");
return TRUE;
}

}
3 changes: 2 additions & 1 deletion sql/donrec.sql
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ CREATE TABLE IF NOT EXISTS `donrec_snapshot` (
`receive_date` datetime NOT NULL,
`date_from` datetime NOT NULL,
`date_to` datetime NOT NULL,
PRIMARY KEY (`snapshot_id`,`contribution_id`),
PRIMARY KEY (`id`),
UNIQUE `snapshot_contrib_line_item` (`snapshot_id`,`contribution_id`, `line_item_id`),
KEY `id` (`id`),
KEY `snapshot_id` (`snapshot_id`),
KEY `contribution_id` (`contribution_id`),
Expand Down

0 comments on commit 8b35489

Please sign in to comment.