From 9fa4f19b6695b6236f4cd8f06bdb7de44714baef Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Fri, 3 Mar 2017 13:52:09 +0000 Subject: [PATCH] Bug 17361: Update database --- Koha/Schema/Result/ItemMessage.pm | 111 +++++++++++++++++++++++ installer/data/mysql/atomicupdate/bug_17361.perl | 17 ++++ installer/data/mysql/kohastructure.sql | 14 +++ 3 files changed, 142 insertions(+) create mode 100644 Koha/Schema/Result/ItemMessage.pm create mode 100644 installer/data/mysql/atomicupdate/bug_17361.perl diff --git a/Koha/Schema/Result/ItemMessage.pm b/Koha/Schema/Result/ItemMessage.pm new file mode 100644 index 0000000000..7fa4d62c80 --- /dev/null +++ b/Koha/Schema/Result/ItemMessage.pm @@ -0,0 +1,111 @@ +use utf8; +package Koha::Schema::Result::ItemMessage; + +# Created by DBIx::Class::Schema::Loader +# DO NOT MODIFY THE FIRST PART OF THIS FILE + +=head1 NAME + +Koha::Schema::Result::ItemMessage + +=cut + +use strict; +use warnings; + +use base 'DBIx::Class::Core'; + +=head1 TABLE: C + +=cut + +__PACKAGE__->table("item_messages"); + +=head1 ACCESSORS + +=head2 item_message_id + + data_type: 'integer' + is_auto_increment: 1 + is_nullable: 0 + +=head2 itemnumber + + data_type: 'integer' + is_foreign_key: 1 + is_nullable: 0 + +=head2 type + + data_type: 'varchar' + is_nullable: 1 + size: 80 + +=head2 message + + data_type: 'text' + is_nullable: 0 + +=head2 created_on + + data_type: 'timestamp' + datetime_undef_if_invalid: 1 + default_value: current_timestamp + is_nullable: 0 + +=cut + +__PACKAGE__->add_columns( + "item_message_id", + { data_type => "integer", is_auto_increment => 1, is_nullable => 0 }, + "itemnumber", + { data_type => "integer", is_foreign_key => 1, is_nullable => 0 }, + "type", + { data_type => "varchar", is_nullable => 1, size => 80 }, + "message", + { data_type => "text", is_nullable => 0 }, + "created_on", + { + data_type => "timestamp", + datetime_undef_if_invalid => 1, + default_value => \"current_timestamp", + is_nullable => 0, + }, +); + +=head1 PRIMARY KEY + +=over 4 + +=item * L + +=back + +=cut + +__PACKAGE__->set_primary_key("item_message_id"); + +=head1 RELATIONS + +=head2 itemnumber + +Type: belongs_to + +Related object: L + +=cut + +__PACKAGE__->belongs_to( + "itemnumber", + "Koha::Schema::Result::Item", + { itemnumber => "itemnumber" }, + { is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" }, +); + + +# Created by DBIx::Class::Schema::Loader v0.07042 @ 2017-03-03 14:03:01 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:uoirWwh61T/8Y4XqgQoa1w + + +# You can replace this text with custom code or comments, and it will be preserved on regeneration +1; diff --git a/installer/data/mysql/atomicupdate/bug_17361.perl b/installer/data/mysql/atomicupdate/bug_17361.perl new file mode 100644 index 0000000000..df4ef01b68 --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_17361.perl @@ -0,0 +1,17 @@ +$DBversion = "XXX"; +if ( CheckVersion($DBversion) ) { + $dbh->do(q{ + CREATE TABLE `item_messages` ( + `item_message_id` INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY, + `itemnumber` INT( 11 ) NOT NULL, + `type` VARCHAR( 80 ) NULL, -- ITEM_MESSAGE authorised value + `message` TEXT NOT NULL, + `created_on` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, + INDEX ( `itemnumber` ), + CONSTRAINT `message_item_fk` FOREIGN KEY (itemnumber) REFERENCES items (itemnumber) ON DELETE CASCADE ON UPDATE CASCADE + ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; + }); + + print "Upgrade to $DBversion done (Bug 17361: Give librarians the ability to add messages to an item)\n"; + SetVersion ($DBversion); +} diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index 91e6119d36..a586d71e29 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -3955,6 +3955,20 @@ CREATE TABLE deletedbiblio_metadata ( CONSTRAINT `deletedrecord_metadata_fk_1` FOREIGN KEY (biblionumber) REFERENCES deletedbiblio (biblionumber) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +-- +-- Table structure for table `item_messages` +-- + +CREATE TABLE `item_messages` ( + `item_message_id` INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY, + `itemnumber` INT( 11 ) NOT NULL, + `type` VARCHAR( 80 ) NULL, -- ITEM_MESSAGE authorised value + `message` TEXT NOT NULL, + `created_on` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, + INDEX ( `itemnumber` ), + CONSTRAINT `message_item_fk` FOREIGN KEY (itemnumber) REFERENCES items (itemnumber) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; + /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; /*!40101 SET SQL_MODE=@OLD_SQL_MODE */; /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; -- 2.12.0