Check this error when user logs in:
anamariamv opened this issue · 1 comments
anamariamv commented
ERROR: duplicate key value violates unique constraint "users_pkey"
Detail: Key (id)=(2) already exists.
diesalbla commented
This kind of error is rooted at Postgresql handling of serial types. It arises when a row is created using a value for the serial
column larger than the latest used value.
This error can be reproduced in the localhost db as follows:
- Start an
sbt
session with thelocalhost.conf
file, and executeflywayClean
andflywayMigrate
to reset the database. - Start a
psql
session with theninecards_user
user into theninecards
DB. - In
psql
, execute the following commands:
insert into users(id,email,sessiontoken,apikey) values (2,'a','a','a') ;
insert into users(email,sessiontoken,apikey) values ('b','b','b') ;
insert into users(email,sessiontoken,apikey) values ('b','b','b') ;
Once the error appears, the next insertion proceeds normally. This error should not normally occur, since the only insertions to this tables are through the signup operation. Nevertheless, some solutions are proposed here.