Summary: | DB update of bug 31086 fails: Cannot change column 'branchcode': used in a foreign key constraint | ||
---|---|---|---|
Product: | Koha | Reporter: | mohamed <mohamednofal909> |
Component: | Installation and upgrade (command-line installer) | Assignee: | Nick Clemens <nick> |
Status: | CLOSED FIXED | QA Contact: | Testopia <testopia> |
Severity: | blocker | ||
Priority: | P5 - low | CC: | keith, lucas, martin.renvoize, nick, victor |
Version: | 22.05 | ||
Hardware: | All | ||
OS: | All | ||
Change sponsored?: | --- | Patch complexity: | --- |
Documentation contact: | Documentation submission: | ||
Text to go in the release notes: | Version(s) released in: |
22.11.00,22.05.06,21.11.12
|
|
Bug Depends on: | 31086 | ||
Bug Blocks: | |||
Attachments: |
Bug 31673: (bug 31086 follow-up) Drop and constraint to allow updating column
Bug 31673: (bug 31086 follow-up) Drop and constraint to allow updating column Bug 31673: (QA follow-up) Check if FK exists before attempt to remove |
Description
mohamed
2022-10-04 12:25:36 UTC
Created attachment 141336 [details] [review] Bug 31673: (bug 31086 follow-up) Drop and constraint to allow updating column It seems that we cannot edit the column while it has a constraint. If we remove it, update the oclumn, then re-add it, the update succeeds To help those who don't use diff, I have extracted the relevant sql to the following: ALTER TABLE reserves DROP FOREIGN KEY reserves_ibfk_4; ALTER TABLE reserves MODIFY COLUMN `branchcode` VARCHAR(10) COLLATE utf8mb4_unicode_ci NOT NULL; ALTER TABLE reserves ADD CONSTRAINT reserves_ibfk_4 FOREIGN KEY (branchcode) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE; This works.. I'm just marking it PQA as people don't appear to want to put their names to it. SO + QA Done Created attachment 141512 [details] [review] Bug 31673: (bug 31086 follow-up) Drop and constraint to allow updating column It seems that we cannot edit the column while it has a constraint. If we remove it, update the oclumn, then re-add it, the update succeeds Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> Created attachment 141599 [details] [review] Bug 31673: (QA follow-up) Check if FK exists before attempt to remove Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> Pushed to master for 22.11. Nice work everyone, thanks! Backported to 22.05.x for upcoming 22.05.06 release Missing dependencies for 21.05.x, it shouldn't be affected, no backport. Dodged a bullet again :P Thanks! Pushed to 21.11 for 21.11.12 |