From e024665c9d73509578d5c672c964a34cb303762f Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Tue, 21 Feb 2017 12:21:12 +0000 Subject: [PATCH] Bug 15707 - Add UNIQUE constraint to library groups table --- Koha/Schema/Result/LibraryGroup.pm | 18 ++++++++++++++++-- installer/data/mysql/atomicupdate/library_groups.sql | 3 ++- installer/data/mysql/kohastructure.sql | 3 ++- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/Koha/Schema/Result/LibraryGroup.pm b/Koha/Schema/Result/LibraryGroup.pm index 5811d7c..5ffb973 100644 --- a/Koha/Schema/Result/LibraryGroup.pm +++ b/Koha/Schema/Result/LibraryGroup.pm @@ -104,6 +104,20 @@ __PACKAGE__->add_columns( __PACKAGE__->set_primary_key("id"); +=head1 UNIQUE CONSTRAINTS + +=head2 C + +=over 4 + +=item * L + +=back + +=cut + +__PACKAGE__->add_unique_constraint("title", ["title"]); + =head1 RELATIONS =head2 branchcode @@ -162,8 +176,8 @@ __PACKAGE__->belongs_to( ); -# Created by DBIx::Class::Schema::Loader v0.07042 @ 2016-11-02 13:23:16 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:aQJgATq8JW4hCBFZfYus7w +# Created by DBIx::Class::Schema::Loader v0.07042 @ 2017-03-01 13:07:33 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:K63IXlbjifZWzBnbvFIz0A # You can replace this text with custom code or comments, and it will be preserved on regeneration diff --git a/installer/data/mysql/atomicupdate/library_groups.sql b/installer/data/mysql/atomicupdate/library_groups.sql index ba30eec..f05e44f 100644 --- a/installer/data/mysql/atomicupdate/library_groups.sql +++ b/installer/data/mysql/atomicupdate/library_groups.sql @@ -8,5 +8,6 @@ CREATE TABLE library_groups ( updated_on TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, -- Date and time of last PRIMARY KEY id ( id ), FOREIGN KEY (parent_id) REFERENCES library_groups(id) ON UPDATE CASCADE ON DELETE CASCADE, - FOREIGN KEY (branchcode) REFERENCES branches(branchcode) ON UPDATE CASCADE ON DELETE CASCADE + FOREIGN KEY (branchcode) REFERENCES branches(branchcode) ON UPDATE CASCADE ON DELETE CASCADE, + UNIQUE( title ) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index 2b25eff..57bf2d5 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -3970,7 +3970,8 @@ CREATE TABLE library_groups ( updated_on DATETIME NULL DEFAULT NULL, -- Date and time of last PRIMARY KEY id ( id ), FOREIGN KEY (parent_id) REFERENCES library_groups(id) ON UPDATE CASCADE ON DELETE CASCADE, - FOREIGN KEY (branchcode) REFERENCES branches(branchcode) ON UPDATE CASCADE ON DELETE CASCADE + FOREIGN KEY (branchcode) REFERENCES branches(branchcode) ON UPDATE CASCADE ON DELETE CASCADE, + UNIQUE( title ) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; -- 2.1.4