Without primary key DBIC is failing with something like: GET /api/v1/suggestions/managers: unhandled exception (DBIx::Class::Exception)<<DBIx::Class::ResultSource::RowParser::_resolve_collapse(): Unable to calculate a definitive collapse co lumn set for UserPermission (last member of the Borrower -> user_permissions chain): fetch more unique non-nullable columns at /kohadevbox/koha/Koha/Objects.pm line 394>> Koha::REST::Plugin::Exceptions::__ANON__ / kohadevbox/koha/Koha/REST/Plugin/Exceptions.pm (73)
Created attachment 130356 [details] [review] Bug 30060: Add primary key to user_permissions table
Test plan: Execute the atomic update and confirm that the new PK has been added to the user_permissions table.
Created attachment 130360 [details] [review] Bug 30060: Add primary key to user_permissions table Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Created attachment 130533 [details] [review] Bug 30060: Add primary key to user_permissions table Without primary key DBIC is failing with something like: GET /api/v1/suggestions/managers: unhandled exception (DBIx::Class::Exception)<<DBIx::Class::ResultSource::RowParser::_resolve_collapse(): Unable to calculate a definitive collapse co lumn set for UserPermission (last member of the Borrower -> user_permissions chain): fetch more unique non-nullable columns at /kohadevbox/koha/Koha/Objects.pm line 394>> Koha::REST::Plugin::Exceptions::__ANON__ / kohadevbox/koha/Koha/REST/Plugin/Exceptions.pm (73) Test plan: Execute the atomic update and confirm that the new PK has been added to the user_permissions table. Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Please remember guidelines for commit messages :) Do we need to worry about potentially doubled up entries? I recently managed to do that with SQL manipulations, but haven't seen it happen from within Koha
Created attachment 130616 [details] [review] Bug 30060: Add primary key to user_permissions table Without primary key DBIC is failing with something like: GET /api/v1/suggestions/managers: unhandled exception (DBIx::Class::Exception)<<DBIx::Class::ResultSource::RowParser::_resolve_collapse(): Unable to calculate a definitive collapse co lumn set for UserPermission (last member of the Borrower -> user_permissions chain): fetch more unique non-nullable columns at /kohadevbox/koha/Koha/Objects.pm line 394>> Koha::REST::Plugin::Exceptions::__ANON__ / kohadevbox/koha/Koha/REST/Plugin/Exceptions.pm (73) Test plan: Execute the atomic update and confirm that the new PK has been added to the user_permissions table. Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de> Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Created attachment 130617 [details] [review] Bug 30060: (follow-up) Remove duplicate prior to adding key I had issues with this update as somehow my user_permissions table contained duplicate rows which throws an error when adding the new primary key. This follow-up patch adds SQL to remove any duplicate rows prior to adding the new primary key. Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Thanks for the follow-up, Martin. However I don't think the "temp" column is needed. See installer/data/mysql/db_revs/210600012.pl where we delete duplicate from language tables.
(In reply to Jonathan Druart from comment #9) > Thanks for the follow-up, Martin. However I don't think the "temp" column is > needed. See installer/data/mysql/db_revs/210600012.pl where we delete > duplicate from language tables. Hmm, the difference here is that there is no incrementing key field in the table to start with.. I couldn't work out how to do it without creating the temporary field. More than happy to be corrected, but the approach in update you point to matches the approach I have here.. it relies on an incrementing key field which we don't have here until I add it temporarily.
(In reply to Martin Renvoize from comment #10) > (In reply to Jonathan Druart from comment #9) > > Thanks for the follow-up, Martin. However I don't think the "temp" column is > > needed. See installer/data/mysql/db_revs/210600012.pl where we delete > > duplicate from language tables. > > Hmm, the difference here is that there is no incrementing key field in the > table to start with.. I couldn't work out how to do it without creating the > temporary field. More than happy to be corrected, but the approach in update > you point to matches the approach I have here.. it relies on an incrementing > key field which we don't have here until I add it temporarily. Indeed!
Pushed to master for 22.05, thanks to everybody involved [U+1F984]
This db update is giving me an error when I try to upgrade a gitified install to current master. Reported as bug 30276.
DBrev does not work, please have a look at bug 30276.
From ML: - Upgrade to 21.12.00.016 [04:05:32]: Bug 30060 - Update user_permissions to add primary key and remove null option from code column ERROR: {UNKNOWN}: DBI Exception: DBD::mysql::db do failed: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'IF EXISTS `PRIMARY`' at line 1 at /usr/share/koha/lib/C4/Installer.pm line 739
(In reply to Marcel de Rooy from comment #15) > From ML: > > - Upgrade to 21.12.00.016 [04:05:32]: Bug 30060 - Update > user_permissions to add primary key and remove null option from code > column > ERROR: {UNKNOWN}: DBI Exception: DBD::mysql::db do failed: You have an > error in your SQL syntax; check the manual that corresponds to your MySQL > server version for the right syntax to use near 'IF EXISTS `PRIMARY`' at > line 1 at /usr/share/koha/lib/C4/Installer.pm line 739 See bug 30912.