[Koha-bugs] [Bug 29426] New: borrower_debarments.created is "ON UPDATE current_timestamp()"

bugzilla-daemon at bugs.koha-community.org bugzilla-daemon at bugs.koha-community.org
Fri Nov 5 15:40:56 CET 2021


https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=29426

            Bug ID: 29426
           Summary: borrower_debarments.created is "ON UPDATE
                    current_timestamp()"
 Change sponsored?: ---
           Product: Koha
           Version: master
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P5 - low
         Component: Database
          Assignee: koha-bugs at lists.koha-community.org
          Reporter: magnus at libriotech.no
        QA Contact: testopia at bugs.koha-community.org

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?

-- 
You are receiving this mail because:
You are the assignee for the bug.
You are watching all bug changes.


More information about the Koha-bugs mailing list