Bugzilla – Attachment 118970 Details for
Bug 26129
Add a new 'configurations' table
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 26129: Add new 'configurations' table
Bug-26129-Add-new-configurations-table.patch (text/plain), 8.61 KB, created by
Agustín Moyano
on 2021-03-29 15:51:50 UTC
(
hide
)
Description:
Bug 26129: Add new 'configurations' table
Filename:
MIME Type:
Creator:
Agustín Moyano
Created:
2021-03-29 15:51:50 UTC
Size:
8.61 KB
patch
obsolete
>From 957a3b7f436b578e107610d8d57ee5532135c115 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Mon, 3 Aug 2020 14:22:19 -0300 >Subject: [PATCH] Bug 26129: Add new 'configurations' table > >This patch introduces a new table to kohastructure.sql and an atomic >update script to add the table on update. It also includes the >corresponding schema file. > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> >--- > Koha/Schema/Result/Configuration.pm | 198 ++++++++++++++++++ > .../bug_26129_configurations_table.perl | 30 +++ > installer/data/mysql/kohastructure.sql | 33 +++ > 3 files changed, 261 insertions(+) > create mode 100644 Koha/Schema/Result/Configuration.pm > create mode 100644 installer/data/mysql/atomicupdate/bug_26129_configurations_table.perl > >diff --git a/Koha/Schema/Result/Configuration.pm b/Koha/Schema/Result/Configuration.pm >new file mode 100644 >index 0000000000..e4987948c9 >--- /dev/null >+++ b/Koha/Schema/Result/Configuration.pm >@@ -0,0 +1,198 @@ >+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<configurations> >+ >+=cut >+ >+__PACKAGE__->table("configurations"); >+ >+=head1 ACCESSORS >+ >+=head2 id >+ >+ data_type: 'integer' >+ is_auto_increment: 1 >+ is_nullable: 0 >+ >+=head2 library_id >+ >+ data_type: 'varchar' >+ is_foreign_key: 1 >+ is_nullable: 1 >+ size: 10 >+ >+=head2 category_id >+ >+ data_type: 'varchar' >+ is_foreign_key: 1 >+ is_nullable: 1 >+ size: 10 >+ >+=head2 item_type >+ >+ data_type: 'varchar' >+ is_foreign_key: 1 >+ is_nullable: 1 >+ size: 10 >+ >+=head2 name >+ >+ data_type: 'varchar' >+ is_nullable: 0 >+ size: 32 >+ >+=head2 value >+ >+ data_type: 'mediumtext' >+ is_nullable: 1 >+ >+=head2 type >+ >+ data_type: 'enum' >+ default_value: 'text' >+ extra: {list => ["text","boolean","integer"]} >+ is_nullable: 0 >+ >+=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</id> >+ >+=back >+ >+=cut >+ >+__PACKAGE__->set_primary_key("id"); >+ >+=head1 UNIQUE CONSTRAINTS >+ >+=head2 C<library_id> >+ >+=over 4 >+ >+=item * L</library_id> >+ >+=item * L</category_id> >+ >+=item * L</item_type> >+ >+=item * L</name> >+ >+=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<Koha::Schema::Result::Category> >+ >+=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<Koha::Schema::Result::Itemtype> >+ >+=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<Koha::Schema::Result::Branch> >+ >+=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.07046 @ 2020-08-03 17:21:00 >+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:SCRluJvwzSovqN3pVW7omA >+ >+ >+# 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_26129_configurations_table.perl b/installer/data/mysql/atomicupdate/bug_26129_configurations_table.perl >new file mode 100644 >index 0000000000..ae31548d8b >--- /dev/null >+++ b/installer/data/mysql/atomicupdate/bug_26129_configurations_table.perl >@@ -0,0 +1,30 @@ >+$DBversion = 'XXX'; >+if( CheckVersion( $DBversion ) ) { >+ >+ unless( TableExists('configurations') ) { >+ $dbh->do(q{ >+ CREATE TABLE `configurations` ( >+ `id` INT(11) NOT NULL AUTO_INCREMENT, >+ `library_id` VARCHAR(10) NULL DEFAULT NULL, >+ `category_id` VARCHAR(10) NULL DEFAULT NULL, >+ `item_type` VARCHAR(10) NULL DEFAULT NULL, >+ `name` VARCHAR(32) NOT NULL, >+ `value` MEDIUMTEXT NULL DEFAULT NULL, >+ `type` ENUM('text', 'boolean', 'integer') NOT NULL DEFAULT 'text', >+ 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; >+ }); >+ } >+ >+ # Always end with this (adjust the bug info) >+ NewVersion( $DBversion, 26129, "Add a new 'configurations' table"); >+} >diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql >index ae247e67c8..0751169d27 100644 >--- a/installer/data/mysql/kohastructure.sql >+++ b/installer/data/mysql/kohastructure.sql >@@ -2002,6 +2002,38 @@ 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, >+ -- Unique ID of the configuration entry >+ `library_id` VARCHAR(10) NULL DEFAULT NULL, >+ -- Internal identifier for the library the config applies to. NULL means global >+ `category_id` VARCHAR(10) NULL DEFAULT NULL, >+ -- Internal identifier for the category the config applies to. NULL means global >+ `item_type` VARCHAR(10) NULL DEFAULT NULL, >+ -- Internal identifier for the item type the config applies to. NULL means global >+ `name` VARCHAR(32) NOT NULL, >+ -- Configuration entry name >+ `value` MEDIUMTEXT NULL DEFAULT NULL, >+ -- Configuration entry value >+ `type` ENUM('text', 'boolean', 'integer') NOT NULL DEFAULT 'text', >+ -- 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` > -- >@@ -5324,6 +5356,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 */; > >-- >2.25.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 26129
:
107718
|
107719
|
107720
|
118970
|
118971
|
118972
|
118982
|
118983
|
118984
|
128892
|
128893
|
128894
|
128904
|
128905
|
128906
|
130189
|
130190
|
130191