I'm with the same problem of this post. But I'm using Rails and don't know how to do this workaround in activerecord.
I'm inserting some data using seeds.rb:
device_platforms = DevicePlatform.create([{id: 1, name: 'Android'}, {id: 2, name: 'IOS'}, {id: 3, name: 'Windows Phone'}])
When I insert another DevicePlatform, I get this exception:
Failure/Error: @device_platform = FactoryGirl.create(:device_platform)
ActiveRecord::RecordNotUnique:
PG::UniqueViolation: ERRO: duplicar valor da chave viola a restrição de unicidade "device_platforms_pkey"
DETAIL: Chave (id)=(2) já existe.
: INSERT INTO "device_platforms" ("created_at", "name", "updated_at") VALUES ($1, $2, $3) RETURNING "id"
The message is in portuguese, it says that a row with that ID already exists.
Thanks.
ids in your seeds. If you must includeids in your seeds then you'll have toconnection.executethe SQL in the other question after adding your seeds.ids being anything in particular is a bad practice. You can do it if you need to but you will need to run some SQL to patch up the sequences that are used to supplyidvalues.