Bug 31843

Summary: Stock rotations do not allow rotas with the same name
Product: Koha Reporter: Pedro Amorim <pjamorim91>
Component: ToolsAssignee: Bugs List <koha-bugs>
Status: NEW --- QA Contact: Testopia <testopia>
Severity: enhancement    
Priority: P5 - low CC: martin.renvoize
Version: MainKeywords: Academy
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:

Description Pedro Amorim 2022-10-17 10:49:07 UTC
Steps to reproduce:
* Enable StockRotation system preference
* Tools > Stock rotation > New rota
* Enter name "rota", save.
* Create new rota, enter name "rota" again.
* Nasty plack error

This error also occurs when updating a rota's name to an already existing rota's name.

plack-intranet-error.log:
[WARN] DBIx::Class::Storage::DBI::_dbh_execute(): DBI Exception: DBD::mysql::st execute failed: Duplicate entry 'rota' for key 'stockrotationrotas_title' at /kohadevbox/koha/Koha/Object.pm line 170


> describe stockrotationrotas;
+-------------+--------------+------+-----+---------+----------------+
| Field       | Type         | Null | Key | Default | Extra          |
+-------------+--------------+------+-----+---------+----------------+
| rota_id     | int(11)      | NO   | PRI | NULL    | auto_increment |
| title       | varchar(100) | NO   | UNI | NULL    |                |
| description | text         | NO   |     | NULL    |                |
| cyclical    | tinyint(1)   | NO   |     | 0       |                |
| active      | tinyint(1)   | NO   |     | 0       |                |
+-------------+--------------+------+-----+---------+----------------+

Seems that the title is set as unique in the database and is causing this.