Bug 24606: Update database, add new schema file
authorKyle Hall <kyle@bywatersolutions.com>
Thu, 29 Sep 2022 13:03:55 +0000 (09:03 -0400)
committerTomas Cohen Arazi <tomascohen@theke.io>
Thu, 10 Nov 2022 17:25:06 +0000 (14:25 -0300)
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>
Koha/Schema/Result/ItemEditorTemplate.pm [new file with mode: 0644]
installer/data/mysql/atomicupdate/bug_24606.pl [new file with mode: 0755]
installer/data/mysql/kohastructure.sql

diff --git a/Koha/Schema/Result/ItemEditorTemplate.pm b/Koha/Schema/Result/ItemEditorTemplate.pm
new file mode 100644 (file)
index 0000000..5ac366c
--- /dev/null
@@ -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;
diff --git a/installer/data/mysql/atomicupdate/bug_24606.pl b/installer/data/mysql/atomicupdate/bug_24606.pl
new file mode 100755 (executable)
index 0000000..7640612
--- /dev/null
@@ -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;
+            });
+        }
+    },
+};
index 54ed708..216e2e2 100644 (file)
@@ -1966,6 +1966,21 @@ CREATE TABLE `item_group_items` (
 ) 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`
 --