Devise primary key error on postgresql, heroku, Rails 4 [duplicate]

孤街浪徒 提交于 2019-12-22 05:58:08

问题


It is really odd, I'm trying to create a new user by command line and I'm getting this error:

User.create :email => "pheewq+1@gmail.com", :password => '123456789', :password_confirmation => '123456789'

PG::UniqueViolation: ERROR:  duplicate key value violates unique constraint "users_pkey"
DETAIL:  Key (id)=(37) already exists.

回答1:


Try This

$ heroku run rails console
irb(main)> ActiveRecord::Base.connection.tables.each { |t|     ActiveRecord::Base.connection.reset_pk_sequence!(t) }

Source: https://stackoverflow.com/a/15108735/3034747



来源:https://stackoverflow.com/questions/24957863/devise-primary-key-error-on-postgresql-heroku-rails-4

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!