Bug 29426 - borrower_debarments.created is "ON UPDATE current_timestamp()"
Summary: borrower_debarments.created is "ON UPDATE current_timestamp()"
Status: NEW
Alias: None
Product: Koha
Classification: Unclassified
Component: Database (show other bugs)
Version: Main
Hardware: All All
: P5 - low normal
Assignee: Bugs List
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-11-05 14:40 UTC by Magnus Enger
Modified: 2021-11-16 13:03 UTC (History)
1 user (show)

See Also:
Change sponsored?: ---
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Magnus Enger 2021-11-05 14:40:56 UTC
https://git.koha-community.org/Koha-community/Koha/src/branch/master/installer/data/mysql/kohastructure.sql

Currently, the table borrower_debarments is created like this:

CREATE TABLE `borrower_debarments` (
  `borrower_debarment_id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'unique key for the restriction',
  `borrowernumber` int(11) NOT NULL COMMENT 'foreign key for borrowers.borrowernumber for patron who is restricted',
  `expiration` date DEFAULT NULL COMMENT 'expiration date of the restriction',
  `type` enum('SUSPENSION','OVERDUES','MANUAL','DISCHARGE') COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'MANUAL' COMMENT 'type of restriction',
  `comment` mediumtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'comments about the restriction',
  `manager_id` int(11) DEFAULT NULL COMMENT 'foreign key for borrowers.borrowernumber for the librarian managing the restriction',
  `created` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp() COMMENT 'date the restriction was added',
  `updated` timestamp NULL DEFAULT NULL COMMENT 'date the restriction was updated',
  PRIMARY KEY (`borrower_debarment_id`),
  KEY `borrowernumber` (`borrowernumber`),
  CONSTRAINT `borrower_debarments_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

Looks like there has been a mixup between the created and the updated columns? We have this:

  `created` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp() COMMENT 'date the restriction was added',
  `updated` timestamp NULL DEFAULT NULL COMMENT 'date the restriction was updated',

Would it not make more sense to have this:

  `created` timestamp NOT NULL DEFAULT current_timestamp() COMMENT 'date the restriction was added',
  `updated` timestamp NULL DEFAULT NULL ON UPDATE current_timestamp() COMMENT 'date the restriction was updated',

...so that the updated column is actually updated when the row is updated?
Comment 1 Jonathan Druart 2021-11-16 13:03:03 UTC
Yes it does, can you provide a patch please?