agileware-jp / redmine_issue_templates

Redmine Issue Template. Pull requests, reporting issues, stars and sponsoring are always welcome!
https://www.redmine.org/plugins/redmine_issue_templates
GNU General Public License v2.0
70 stars 32 forks source link

issue_template_settings needs a UNIQUE index on project_id #34

Open martinvonwittich opened 2 years ago

martinvonwittich commented 2 years ago

Summary

I just noticed on our Redmine installation that the issue_template_settings table doesn't have a UNIQUE index on project_id. This index is necessary to ensure that it isn't possible to put multiple conflicting configurations for a single project into the table.

Description

redmine=# \d issue_template_settings
                                     Tabelle »public.issue_template_settings«
      Spalte       |   Typ   | Sortierfolge | NULL erlaubt? |                     Vorgabewert                     
-------------------+---------+--------------+---------------+-----------------------------------------------------
 id                | integer |              | not null      | nextval('issue_template_settings_id_seq'::regclass)
 project_id        | integer |              |               | 
 help_message      | text    |              |               | 
 enabled           | boolean |              |               | 
 should_replaced   | boolean |              |               | false
 inherit_templates | boolean |              | not null      | false
Indexe:
    "issue_template_settings_pkey" PRIMARY KEY, btree (id)

There is no UNIQUE index on project_id. This means that I could easily put multiple conflicting configurations for a single project into the table:

redmine=# INSERT INTO issue_template_settings (project_id, inherit_templates) VALUES (511, 't');
INSERT 0 1
redmine=# INSERT INTO issue_template_settings (project_id, inherit_templates) VALUES (511, 'f');
INSERT 0 1
redmine=# SELECT * FROM issue_template_settings WHERE project_id = 511;
 id  | project_id | help_message | enabled | should_replaced | inherit_templates 
-----+------------+--------------+---------+-----------------+-------------------
 479 |        511 |              |         | f               | f
 480 |        511 |              |         | f               | t
 481 |        511 |              |         | f               | f
(3 Zeilen)

Environment

github-actions[bot] commented 2 years ago

Thank you for contributing to Redmine Issue Templates plugin!' first issue