Bugzilla – Attachment 143565 Details for
Bug 32154
Missing primary key on erm_user_roles table
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 32154: Missing primary key on erm_user_roles table
Bug-32154-Missing-primary-key-on-ermuserroles-tabl.patch (text/plain), 3.69 KB, created by
Pedro Amorim
on 2022-11-09 17:56:10 UTC
(
hide
)
Description:
Bug 32154: Missing primary key on erm_user_roles table
Filename:
MIME Type:
Creator:
Pedro Amorim
Created:
2022-11-09 17:56:10 UTC
Size:
3.69 KB
patch
obsolete
>From 864e93d10f813966e9c10aba7aaab91c106dfffa Mon Sep 17 00:00:00 2001 >From: Pedro Amorim <pedro.amorim@ptfs-europe.com> >Date: Wed, 9 Nov 2022 16:55:20 -0100 >Subject: [PATCH] Bug 32154: Missing primary key on erm_user_roles table > >The aforementioned TestBuilder should display "Koha::ERM::UserRole", not be empty. This patch adds a primary key to the erm_user_roles table and fixes that. >Also includes atomicupdate file to update database schema as well as updates to kohastructure.sql provided by Jonathan Druart. >Looked into the vue files but didn't find anywhere or a need to include the new primary key in any of the requests as there is no request of users by role_user_id being made. >Erm users are being created/updated as a relationship through licenceses/agreements. Furthermore, when editing a role of an existing user, this new primary key is already being supplied embeded in the license/agreement. >--- > api/v1/swagger/definitions/erm_user_role.yaml | 3 +++ > installer/data/mysql/atomicupdate/erm.pl | 18 ++++++++++++++++++ > installer/data/mysql/kohastructure.sql | 4 +++- > 3 files changed, 24 insertions(+), 1 deletion(-) > create mode 100644 installer/data/mysql/atomicupdate/erm.pl > >diff --git a/api/v1/swagger/definitions/erm_user_role.yaml b/api/v1/swagger/definitions/erm_user_role.yaml >index 7256542ce0..1f84f6516c 100644 >--- a/api/v1/swagger/definitions/erm_user_role.yaml >+++ b/api/v1/swagger/definitions/erm_user_role.yaml >@@ -1,6 +1,9 @@ > --- > type: object > properties: >+ user_role_id: >+ type: integer >+ description: Internal user_role identifier > agreement_id: > type: > - integer >diff --git a/installer/data/mysql/atomicupdate/erm.pl b/installer/data/mysql/atomicupdate/erm.pl >new file mode 100644 >index 0000000000..582a1c42ae >--- /dev/null >+++ b/installer/data/mysql/atomicupdate/erm.pl >@@ -0,0 +1,18 @@ >+use Modern::Perl; >+ >+return { >+ bug_number => "32030", >+ description => "Add primary key to erm_user_roles", >+ up => sub { >+ my ($args) = @_; >+ my ($dbh, $out) = @$args{qw(dbh out)}; >+ >+ unless ( column_exists('erm_user_roles', 'user_role_id') ) { >+ $dbh->do(q{ >+ ALTER TABLE `erm_user_roles` >+ ADD COLUMN `user_role_id` INT(11) NOT NULL AUTO_INCREMENT COMMENT 'primary key' FIRST, >+ ADD PRIMARY KEY(`user_role_id`); >+ }); >+ } >+ } >+}; >diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql >index 54ed708304..33e2980576 100644 >--- a/installer/data/mysql/kohastructure.sql >+++ b/installer/data/mysql/kohastructure.sql >@@ -2865,13 +2865,15 @@ CREATE TABLE `erm_agreement_periods` ( > > DROP TABLE IF EXISTS `erm_user_roles`; > CREATE TABLE `erm_user_roles` ( >+ `user_role_id` INT(11) NOT NULL AUTO_INCREMENT COMMENT 'primary key', > `agreement_id` INT(11) NULL COMMENT 'link to the agreement', > `license_id` INT(11) NULL COMMENT 'link to the license', > `user_id` INT(11) NOT NULL COMMENT 'link to the user', > `role` VARCHAR(80) NOT NULL COMMENT 'role of the user', > CONSTRAINT `erm_user_roles_ibfk_1` FOREIGN KEY (`agreement_id`) REFERENCES `erm_agreements` (`agreement_id`) ON DELETE CASCADE ON UPDATE CASCADE, > CONSTRAINT `erm_user_roles_ibfk_2` FOREIGN KEY (`license_id`) REFERENCES `erm_licenses` (`license_id`) ON DELETE CASCADE ON UPDATE CASCADE, >- CONSTRAINT `erm_user_roles_ibfk_3` FOREIGN KEY (`user_id`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE >+ CONSTRAINT `erm_user_roles_ibfk_3` FOREIGN KEY (`user_id`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE, >+ PRIMARY KEY(`user_role_id`) > ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; > > -- >-- >2.25.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 32154
:
143565
|
143620
|
143773
|
144061