Bugzilla – Attachment 130356 Details for
Bug 30060
Missing primary key on user_permissions
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 30060: Add primary key to user_permissions table
Bug-30060-Add-primary-key-to-userpermissions-table.patch (text/plain), 2.54 KB, created by
Jonathan Druart
on 2022-02-09 12:55:58 UTC
(
hide
)
Description:
Bug 30060: Add primary key to user_permissions table
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2022-02-09 12:55:58 UTC
Size:
2.54 KB
patch
obsolete
>From 5044e377d004d4560a993cf7883a6313b065c79c Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Mon, 27 Sep 2021 18:34:17 +0000 >Subject: [PATCH] Bug 30060: Add primary key to user_permissions table > >--- > .../update_user_permissions_table.pl | 26 +++++++++++++++++++ > installer/data/mysql/kohastructure.sql | 1 + > 2 files changed, 27 insertions(+) > create mode 100755 installer/data/mysql/atomicupdate/update_user_permissions_table.pl > >diff --git a/installer/data/mysql/atomicupdate/update_user_permissions_table.pl b/installer/data/mysql/atomicupdate/update_user_permissions_table.pl >new file mode 100755 >index 00000000000..6d732720e1a >--- /dev/null >+++ b/installer/data/mysql/atomicupdate/update_user_permissions_table.pl >@@ -0,0 +1,26 @@ >+use Modern::Perl; >+ >+return { >+ bug_number => "BUG_NUMBER", >+ description => "Update user_permissions to add primary key and remove null option from code column", >+ up => sub { >+ my ($args) = @_; >+ my ($dbh, $out) = @$args{qw(dbh out)}; >+ unless( >+ primary_key_exists( 'user_permissions', 'borrowernumber') && >+ primary_key_exists( 'user_permissions', 'module_bit' ) && >+ primary_key_exists( 'user_permissions', 'code') >+ ){ >+ $dbh->do(q{ >+ ALTER TABLE user_permissions DROP INDEX IF EXISTS `PRIMARY` >+ }); >+ say $out "Drop any previously created keys"; >+ $dbh->do(q{ >+ ALTER TABLE user_permissions ADD CONSTRAINT PK_borrowernumber_module_code PRIMARY KEY (borrowernumber,module_bit,code) >+ }); >+ say $out "Add a primary key to user_permissions on borrowernumber, module_bit, code"; >+ } >+ # Print useful stuff here >+ say $out "Update is going well so far"; >+ }, >+} >diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql >index 4411ae76047..427f1310c47 100644 >--- a/installer/data/mysql/kohastructure.sql >+++ b/installer/data/mysql/kohastructure.sql >@@ -5189,6 +5189,7 @@ CREATE TABLE `user_permissions` ( > `borrowernumber` int(11) NOT NULL DEFAULT 0, > `module_bit` int(11) NOT NULL DEFAULT 0, > `code` varchar(64) COLLATE utf8mb4_unicode_ci DEFAULT NULL, >+ PRIMARY KEY (`borrowernumber`,`module_bit`,`code`), > KEY `user_permissions_ibfk_1` (`borrowernumber`), > KEY `user_permissions_ibfk_2` (`module_bit`,`code`), > CONSTRAINT `user_permissions_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE, >-- >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 30060
:
130356
|
130360
|
130533
|
130616
|
130617