From 883e59b73425922bc3b5432c0f547d26d070163e Mon Sep 17 00:00:00 2001 From: Kyle Hall Date: Thu, 29 Sep 2022 09:03:55 -0400 Subject: [PATCH] Bug 24606: Update database, add new schema file Signed-off-by: David Nind --- Koha/Schema/Result/ItemEditorTemplate.pm | 124 ++++++++++++++++++ .../data/mysql/atomicupdate/bug_24606.pl | 24 ++++ installer/data/mysql/kohastructure.sql | 15 +++ 3 files changed, 163 insertions(+) create mode 100644 Koha/Schema/Result/ItemEditorTemplate.pm create mode 100755 installer/data/mysql/atomicupdate/bug_24606.pl diff --git a/Koha/Schema/Result/ItemEditorTemplate.pm b/Koha/Schema/Result/ItemEditorTemplate.pm new file mode 100644 index 0000000000..5ac366c172 --- /dev/null +++ b/Koha/Schema/Result/ItemEditorTemplate.pm @@ -0,0 +1,124 @@ +use utf8; +package Koha::Schema::Result::ItemEditorTemplate; + +# Created by DBIx::Class::Schema::Loader +# DO NOT MODIFY THE FIRST PART OF THIS FILE + +=head1 NAME + +Koha::Schema::Result::ItemEditorTemplate + +=cut + +use strict; +use warnings; + +use base 'DBIx::Class::Core'; + +=head1 TABLE: C + +=cut + +__PACKAGE__->table("item_editor_templates"); + +=head1 ACCESSORS + +=head2 id + + data_type: 'integer' + is_auto_increment: 1 + is_nullable: 0 + +id for the template + +=head2 borrowernumber + + data_type: 'integer' + is_foreign_key: 1 + is_nullable: 1 + +creator of this template + +=head2 name + + data_type: 'mediumtext' + is_nullable: 0 + +template name + +=head2 is_shared + + data_type: 'tinyint' + default_value: 0 + is_nullable: 0 + +controls if template is shared + +=head2 contents + + data_type: 'longtext' + is_nullable: 0 + +json encoded template data + +=cut + +__PACKAGE__->add_columns( + "id", + { data_type => "integer", is_auto_increment => 1, is_nullable => 0 }, + "borrowernumber", + { data_type => "integer", is_foreign_key => 1, is_nullable => 1 }, + "name", + { data_type => "mediumtext", is_nullable => 0 }, + "is_shared", + { data_type => "tinyint", default_value => 0, is_nullable => 0 }, + "contents", + { data_type => "longtext", is_nullable => 0 }, +); + +=head1 PRIMARY KEY + +=over 4 + +=item * L + +=back + +=cut + +__PACKAGE__->set_primary_key("id"); + +=head1 RELATIONS + +=head2 borrowernumber + +Type: belongs_to + +Related object: L + +=cut + +__PACKAGE__->belongs_to( + "borrowernumber", + "Koha::Schema::Result::Borrower", + { borrowernumber => "borrowernumber" }, + { + is_deferrable => 1, + join_type => "LEFT", + on_delete => "SET NULL", + on_update => "CASCADE", + }, +); + + +# Created by DBIx::Class::Schema::Loader v0.07049 @ 2022-09-28 16:49:35 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:7JIe4z78F9oMOAnAZdqmtA + +sub koha_object_class { + 'Koha::Item::Template'; +} +sub koha_objects_class { + 'Koha::Item::Templates'; +} + +1; diff --git a/installer/data/mysql/atomicupdate/bug_24606.pl b/installer/data/mysql/atomicupdate/bug_24606.pl new file mode 100755 index 0000000000..76406122d9 --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_24606.pl @@ -0,0 +1,24 @@ +use Modern::Perl; + +return { + bug_number => "24606", + description => "Add new table item_editor_templates", + up => sub { + my ($args) = @_; + my ($dbh, $out) = @$args{qw(dbh out)}; + + unless( TableExists( 'item_editor_templates' ) ) { + $dbh->do(q{ + CREATE TABLE `item_editor_templates` ( + `id` INT(11) NOT NULL auto_increment COMMENT "id for the template", + `borrowernumber` int(11) DEFAULT NULL COMMENT "creator of this template", + `name` MEDIUMTEXT NOT NULL COMMENT "template name", + `is_shared` TINYINT(1) NOT NULL DEFAULT 0 COMMENT "controls if template is shared", + `contents` LONGTEXT NOT NULL COMMENT "json encoded template data", + PRIMARY KEY (`id`), + CONSTRAINT `bn` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE CASCADE + ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; + }); + } + }, +}; diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index 3d8a5efea2..24cd86617e 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -1915,6 +1915,21 @@ CREATE TABLE `item_group_items` ( CONSTRAINT `item_group_items_gifk_1` FOREIGN KEY (`item_group_id`) REFERENCES `item_groups` (`item_group_id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +-- +-- Table structure for table `item_editor_templates` +-- + +DROP TABLE IF EXISTS `item_editor_templates`; +CREATE TABLE `item_editor_templates` ( + `id` INT(11) NOT NULL auto_increment COMMENT "id for the template", + `borrowernumber` int(11) DEFAULT NULL COMMENT "creator of this template", + `name` MEDIUMTEXT NOT NULL COMMENT "template name", + `is_shared` TINYINT(1) NOT NULL DEFAULT 0 COMMENT "controls if template is shared", + `contents` LONGTEXT NOT NULL COMMENT "json encoded template data", + PRIMARY KEY (`id`), + CONSTRAINT `bn` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; + -- -- Table structure for table `club_holds` -- -- 2.30.2