I migrated my db from Sqlite to Postgres. Now when I try to create a new record
Account.create! code:"0001", name:"foo"
I got this error
ActiveRecord::RecordNotUnique: PG::Error: ERROR: duplicate key value violates unique constraint "accounts_pkey"
DETAIL: Key (id)=(4) already exists.
It seems like the autoincrement is not working. Do I need some extra configuration???
You can change the
sequence valueof your PG table manually using pgAdminIII.Go to your Database -> Sequences, click on your table correspondent to your model and change it’s
Current value.