@@ -, +, @@ --- Koha/Schema/Result/Configuration.pm | 212 ++++++++++++++++++ .../bug_26129_configurations_table.pl | 36 +++ installer/data/mysql/kohastructure.sql | 26 +++ 3 files changed, 274 insertions(+) create mode 100644 Koha/Schema/Result/Configuration.pm create mode 100755 installer/data/mysql/atomicupdate/bug_26129_configurations_table.pl --- a/Koha/Schema/Result/Configuration.pm +++ a/Koha/Schema/Result/Configuration.pm @@ -0,0 +1,212 @@ +use utf8; +package Koha::Schema::Result::Configuration; + +# Created by DBIx::Class::Schema::Loader +# DO NOT MODIFY THE FIRST PART OF THIS FILE + +=head1 NAME + +Koha::Schema::Result::Configuration + +=cut + +use strict; +use warnings; + +use base 'DBIx::Class::Core'; + +=head1 TABLE: C + +=cut + +__PACKAGE__->table("configurations"); + +=head1 ACCESSORS + +=head2 id + + data_type: 'integer' + is_auto_increment: 1 + is_nullable: 0 + +Unique ID of the configuration entry + +=head2 library_id + + data_type: 'varchar' + is_foreign_key: 1 + is_nullable: 1 + size: 10 + +Internal identifier for the library the config applies to. NULL means global + +=head2 category_id + + data_type: 'varchar' + is_foreign_key: 1 + is_nullable: 1 + size: 10 + +Internal identifier for the category the config applies to. NULL means global + +=head2 item_type + + data_type: 'varchar' + is_foreign_key: 1 + is_nullable: 1 + size: 10 + +Internal identifier for the item type the config applies to. NULL means global + +=head2 name + + data_type: 'varchar' + is_nullable: 0 + size: 32 + +Configuration entry name + +=head2 value + + data_type: 'mediumtext' + is_nullable: 1 + +Configuration entry value + +=head2 type + + data_type: 'enum' + default_value: 'text' + extra: {list => ["text","boolean","integer"]} + is_nullable: 0 + +Configuration entry type + +=cut + +__PACKAGE__->add_columns( + "id", + { data_type => "integer", is_auto_increment => 1, is_nullable => 0 }, + "library_id", + { data_type => "varchar", is_foreign_key => 1, is_nullable => 1, size => 10 }, + "category_id", + { data_type => "varchar", is_foreign_key => 1, is_nullable => 1, size => 10 }, + "item_type", + { data_type => "varchar", is_foreign_key => 1, is_nullable => 1, size => 10 }, + "name", + { data_type => "varchar", is_nullable => 0, size => 32 }, + "value", + { data_type => "mediumtext", is_nullable => 1 }, + "type", + { + data_type => "enum", + default_value => "text", + extra => { list => ["text", "boolean", "integer"] }, + is_nullable => 0, + }, +); + +=head1 PRIMARY KEY + +=over 4 + +=item * L + +=back + +=cut + +__PACKAGE__->set_primary_key("id"); + +=head1 UNIQUE CONSTRAINTS + +=head2 C + +=over 4 + +=item * L + +=item * L + +=item * L + +=item * L + +=back + +=cut + +__PACKAGE__->add_unique_constraint( + "library_id", + ["library_id", "category_id", "item_type", "name"], +); + +=head1 RELATIONS + +=head2 category + +Type: belongs_to + +Related object: L + +=cut + +__PACKAGE__->belongs_to( + "category", + "Koha::Schema::Result::Category", + { categorycode => "category_id" }, + { + is_deferrable => 1, + join_type => "LEFT", + on_delete => "CASCADE", + on_update => "CASCADE", + }, +); + +=head2 item_type + +Type: belongs_to + +Related object: L + +=cut + +__PACKAGE__->belongs_to( + "item_type", + "Koha::Schema::Result::Itemtype", + { itemtype => "item_type" }, + { + is_deferrable => 1, + join_type => "LEFT", + on_delete => "CASCADE", + on_update => "CASCADE", + }, +); + +=head2 library + +Type: belongs_to + +Related object: L + +=cut + +__PACKAGE__->belongs_to( + "library", + "Koha::Schema::Result::Branch", + { branchcode => "library_id" }, + { + is_deferrable => 1, + join_type => "LEFT", + on_delete => "CASCADE", + on_update => "CASCADE", + }, +); + + +# Created by DBIx::Class::Schema::Loader v0.07049 @ 2021-12-23 17:55:18 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:1MY5Ng3sr+38JUx1MtKWIA + + +# You can replace this text with custom code or comments, and it will be preserved on regeneration +1; --- a/installer/data/mysql/atomicupdate/bug_26129_configurations_table.pl +++ a/installer/data/mysql/atomicupdate/bug_26129_configurations_table.pl @@ -0,0 +1,36 @@ +use Modern::Perl; + +return { + bug_number => "26129", + description => "Add a new 'configurations' table", + up => sub { + my ($args) = @_; + my ($dbh) = @$args{qw(dbh out)}; + + unless ( TableExists('configurations') ) { + $dbh->do( + q{ + CREATE TABLE `configurations` ( + `id` INT(11) NOT NULL AUTO_INCREMENT COMMENT 'Unique ID of the configuration entry', + `library_id` VARCHAR(10) NULL DEFAULT NULL COMMENT 'Internal identifier for the library the config applies to. NULL means global', + `category_id` VARCHAR(10) NULL DEFAULT NULL COMMENT 'Internal identifier for the category the config applies to. NULL means global', + `item_type` VARCHAR(10) NULL DEFAULT NULL COMMENT 'Internal identifier for the item type the config applies to. NULL means global', + `name` VARCHAR(32) NOT NULL COMMENT 'Configuration entry name', + `value` MEDIUMTEXT NULL DEFAULT NULL COMMENT 'Configuration entry value', + `type` ENUM('text', 'boolean', 'integer') NOT NULL DEFAULT 'text' COMMENT 'Configuration entry type', + PRIMARY KEY (`id`), + KEY `library_id_idx` (`library_id`), + KEY `category_id_idx` (`category_id`), + KEY `item_type_idx` (`item_type`), + KEY `name_idx` (`name`), + KEY `type_idx` (`type`), + UNIQUE (`library_id`, `category_id`, `item_type`, `name`), + CONSTRAINT `library_id_fk` FOREIGN KEY (`library_id`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `category_id_fk` FOREIGN KEY (`category_id`) REFERENCES `categories` (`categorycode`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `item_type_fk` FOREIGN KEY (`item_type`) REFERENCES `itemtypes` (`itemtype`) ON DELETE CASCADE ON UPDATE CASCADE + ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; + } + ); + } + }, +}; --- a/installer/data/mysql/kohastructure.sql +++ a/installer/data/mysql/kohastructure.sql @@ -2028,6 +2028,31 @@ CREATE TABLE `columns_settings` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Table structure for table `configurations` +-- + +DROP TABLE IF EXISTS `configurations`; +CREATE TABLE `configurations` ( + `id` INT(11) NOT NULL AUTO_INCREMENT COMMENT 'Unique ID of the configuration entry', + `library_id` VARCHAR(10) NULL DEFAULT NULL COMMENT 'Internal identifier for the library the config applies to. NULL means global', + `category_id` VARCHAR(10) NULL DEFAULT NULL COMMENT 'Internal identifier for the category the config applies to. NULL means global', + `item_type` VARCHAR(10) NULL DEFAULT NULL COMMENT 'Internal identifier for the item type the config applies to. NULL means global', + `name` VARCHAR(32) NOT NULL COMMENT 'Configuration entry name', + `value` MEDIUMTEXT NULL DEFAULT NULL COMMENT 'Configuration entry value', + `type` ENUM('text', 'boolean', 'integer') NOT NULL DEFAULT 'text' COMMENT 'Configuration entry type', + PRIMARY KEY (`id`), + KEY `library_id_idx` (`library_id`), + KEY `category_id_idx` (`category_id`), + KEY `item_type_idx` (`item_type`), + KEY `name_idx` (`name`), + KEY `type_idx` (`type`), + UNIQUE (`library_id`, `category_id`, `item_type`, `name`), + CONSTRAINT `library_id_fk` FOREIGN KEY (`library_id`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `category_id_fk` FOREIGN KEY (`category_id`) REFERENCES `categories` (`categorycode`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `item_type_fk` FOREIGN KEY (`item_type`) REFERENCES `itemtypes` (`itemtype`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; + -- -- Table structure for table `course_instructors` -- @@ -5360,6 +5385,7 @@ CREATE TABLE `zebraqueue` ( PRIMARY KEY (`id`), KEY `zebraqueue_lookup` (`server`,`biblio_auth_number`,`operation`,`done`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; + /*!40101 SET character_set_client = @saved_cs_client */; /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; --