Mysql2::Error: Duplicate entry '2147483647' for key

From Kolmisoft Wiki
Revision as of 14:38, 1 January 2014 by Mindaugas (talk | contribs) (Created page with '= Log = Mysql2::Error: Duplicate entry '2147483647' for key --- !ruby/exception:Mysql2::Error message: Duplicate entry '2147483647' for key 'PRIMARY' error_number: 1062 sq…')
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

Log

Mysql2::Error: Duplicate entry '2147483647' for key
--- !ruby/exception:Mysql2::Error
message: Duplicate entry '2147483647' for key 'PRIMARY'
error_number: 1062
sql_state: '23000' 


Cause

Usually means id for some table is exhausted (somehow, probably by manually editing and messing with DB).

2147483647 is maximum value for SIGNED INT


Fix

Change field type to UNSIGNED BIGINT, where limit is: 18446744073709551615 (good luck reaching this one).


Example

Let's say we have problem with [dids] table, fix:

ALTER TABLE `dids` CHANGE `id` `id` BIGINT( 11 ) UNSIGNED NOT NULL AUTO_INCREMENT;