Skip to content

Instantly share code, notes, and snippets.

@danieljohnmorris
Last active January 3, 2016 20:29
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danieljohnmorris/8515138 to your computer and use it in GitHub Desktop.
Save danieljohnmorris/8515138 to your computer and use it in GitHub Desktop.
postgres - duplicate key violates unique constraint postgresql (i get this error when downloading production rails db to localhost through heroku)
# in psql prompt
# connect to db
\c databasename
# update counter
SELECT setval('tablename_columnname_seq', (SELECT MAX(columnname) FROM tablename)+1);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment