Last active
August 5, 2018 00:05
-
-
Save ZephiroRB/c9bdf93e4192533d66c7e2683098b823 to your computer and use it in GitHub Desktop.
Rails (PG::Error: ERROR: duplicate key value violates unique constraint "table_pkey" DETAIL: Key (id)=(1) already exists.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#I found the reset_pk_sequence! from this thread. http://www.ruby-forum.com/topic/64428 | |
#rails console | |
ActiveRecord::Base.connection.tables.each do |t| | |
ActiveRecord::Base.connection.reset_pk_sequence!(t) | |
end | |
#or ActiveRecord::Base.connection.tables.each { |t| ActiveRecord::Base.connection.reset_pk_sequence!(t) } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment