A possible database inconsistency?

Moderator: crythias

Locked
MAx695
Znuny newbie
Posts: 1
Joined: 24 Aug 2012, 10:22
Znuny Version: 3.1.6
Company: SISSA

A possible database inconsistency?

Post by MAx695 »

Hi all.
I migrated from otrs 2.3.3 (pretty old, yeah) to 3.1.6 and i've found a little issue about database schema.
I can insert two identical rows in (for example) user_preferences. Here's what i mean:

Code: Select all

insert into user_preferences (user_id, preferences_key,preferences_value) VALUES (1,'ArticleFilterDefault','ArticleSenderTypeFilter<2>');
insert into user_preferences (user_id, preferences_key,preferences_value) VALUES (1,'ArticleFilterDefault','ArticleSenderTypeFilter<1,3>');
are both query successfully inserted in the table. But which one is the right one?? Well, otrs in this case works well because it takes the last value ('ArticleSenderTypeFilter<1,3>') but maybe it's not what i want :) . On the other side, database view, there is one useless row. Also if the perl code is so good to avoid this kind of problem (i mean inserting duplicate rows), add a rule to the database schema is safer.

The solution should be pretty simple: add a constraint to the table like this "unique(user_id, preferences_key);"

What do you think?
Locked