Bug 24606: Update database, add new schema file

Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
Kyle Hall 2022-09-29 09:03:55 -04:00 committed by Tomas Cohen Arazi
parent 3fab32632f
commit 16f0117e55
Signed by: tomascohen
GPG key ID: 0A272EA1B2F3C15F
3 changed files with 163 additions and 0 deletions

View file

@ -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<item_editor_templates>
=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</id>
=back
=cut
__PACKAGE__->set_primary_key("id");
=head1 RELATIONS
=head2 borrowernumber
Type: belongs_to
Related object: L<Koha::Schema::Result::Borrower>
=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;

View file

@ -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;
});
}
},
};

View file

@ -1965,6 +1965,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`
--