From 6e1252d7118d19c403a3649ea1d8928888acf7e5 Mon Sep 17 00:00:00 2001 From: Olli-Antti Kivilahti Date: Wed, 8 Mar 2017 17:35:44 +0200 Subject: [PATCH] Bug 18231 - Add the missing id-column to koha.issuingrules-table for DBIC fixtures Many DBIx-stuffs depend on last_insert_id --- Koha/Schema/Result/Issuingrule.pm | 31 +++++++++++++++++++--- .../atomicupdate/Bug-18226-Remove_mock_dbh.sql | 3 +++ installer/data/mysql/kohastructure.sql | 4 ++- 3 files changed, 34 insertions(+), 4 deletions(-) create mode 100644 installer/data/mysql/atomicupdate/Bug-18226-Remove_mock_dbh.sql diff --git a/Koha/Schema/Result/Issuingrule.pm b/Koha/Schema/Result/Issuingrule.pm index 62f35f2..b1fb2f1 100644 --- a/Koha/Schema/Result/Issuingrule.pm +++ b/Koha/Schema/Result/Issuingrule.pm @@ -23,6 +23,12 @@ __PACKAGE__->table("issuingrules"); =head1 ACCESSORS +=head2 issuingrules_id + + data_type: 'integer' + is_auto_increment: 1 + is_nullable: 0 + =head2 categorycode data_type: 'varchar' @@ -212,6 +218,8 @@ __PACKAGE__->table("issuingrules"); =cut __PACKAGE__->add_columns( + "issuingrules_id", + { data_type => "integer", is_auto_increment => 1, is_nullable => 0 }, "categorycode", { data_type => "varchar", default_value => "", is_nullable => 0, size => 10 }, "itemtype", @@ -292,6 +300,20 @@ __PACKAGE__->add_columns( =over 4 +=item * L + +=back + +=cut + +__PACKAGE__->set_primary_key("issuingrules_id"); + +=head1 UNIQUE CONSTRAINTS + +=head2 C + +=over 4 + =item * L =item * L @@ -302,11 +324,14 @@ __PACKAGE__->add_columns( =cut -__PACKAGE__->set_primary_key("branchcode", "categorycode", "itemtype"); +__PACKAGE__->add_unique_constraint( + "issuingrules_selects", + ["branchcode", "categorycode", "itemtype"], +); -# Created by DBIx::Class::Schema::Loader v0.07042 @ 2016-11-02 10:33:37 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:t9AhZLbm4SE7mx25LAyhGA +# Created by DBIx::Class::Schema::Loader v0.07045 @ 2017-03-08 15:49:48 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:714V5KtlVyeDUidAdc2m/g # You can replace this text with custom code or comments, and it will be preserved on regeneration diff --git a/installer/data/mysql/atomicupdate/Bug-18226-Remove_mock_dbh.sql b/installer/data/mysql/atomicupdate/Bug-18226-Remove_mock_dbh.sql new file mode 100644 index 0000000..a7cd8a7 --- /dev/null +++ b/installer/data/mysql/atomicupdate/Bug-18226-Remove_mock_dbh.sql @@ -0,0 +1,3 @@ +ALTER TABLE `issuingrules` DROP PRIMARY KEY; +ALTER TABLE `issuingrules` ADD `issuingrules_id` INT( 11 ) NOT NULL auto_increment PRIMARY KEY FIRST; +ALTER TABLE `issuingrules` ADD CONSTRAINT UNIQUE `issuingrules_id` (`branchcode`,`categorycode`,`itemtype`); diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index 7ca59ee..ca98ee9 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -848,6 +848,7 @@ CREATE TABLE `import_items` ( DROP TABLE IF EXISTS `issuingrules`; CREATE TABLE `issuingrules` ( -- circulation and fine rules + `issuingrules_id` int(11) NOT NULL auto_increment, `categorycode` varchar(10) NOT NULL default '', -- patron category this rule is for (categories.categorycode) `itemtype` varchar(10) NOT NULL default '', -- item type this rule is for (itemtypes.itemtype) `restrictedtype` tinyint(1) default NULL, -- not used? always NULL @@ -880,7 +881,8 @@ CREATE TABLE `issuingrules` ( -- circulation and fine rules onshelfholds tinyint(1) NOT NULL default 0, -- allow holds for items that are on shelf opacitemholds char(1) NOT NULL default 'N', -- allow opac users to place specific items on hold article_requests enum('no','yes','bib_only','item_only') NOT NULL DEFAULT 'no', -- allow article requests to be placed, - PRIMARY KEY (`branchcode`,`categorycode`,`itemtype`), + PRIMARY KEY (`issuingrules_id`), + UNIQUE KEY `issuingrules_selects` (`branchcode`,`categorycode`,`itemtype`), KEY `categorycode` (`categorycode`), KEY `itemtype` (`itemtype`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; -- 2.7.4