2962: Migrating from MySQL to PostgreSQL fails to properly initialize sequences

leed****@gmai***** (Google Code) (Is this you? Claim this profile.)
Aug. 23, 2013
What version are you running?

1.7.6

What's the URL of the page containing the problem?

/r/new/

What steps will reproduce the problem?
1. Install ReviewBoard with MySQL database backend
2. Use rb-site manage ${OLD_SITE} dumpdb to dump the database
3. Install ReviewBoard with PostgreSQL database backend
4. TRUNCATE django_content_type CASCADE
5. TRUNCATE django_content_type CASCADE
6. rb-site manage ${NEW_SITE} loaddb dumpdb.json
7. Try to add a comment, create a review, etc.

What is the expected output? What do you see instead?

If should add the comment or create the review. Instead there's a 500 error. The following errors are in the log.

2013-04-24 18:32:51,325 - ERROR - Exception thrown for user dlee at http://rbtest.digium.internal/r/new/
duplicate key value violates unique constraint "diffviewer_diffsethistory_pkey"
DETAIL:  Key (id)=(7) already exists.


What operating system are you using? What browser?

Server is Ubuntu 12.04, x86_64. Browser is Chrome on OS X.

Please provide any additional information below.

https://groups.google.com/d/msg/reviewboard/Ehv0JwthROg/OSMHZzucdKAJ

The following script seems to fix up the sequences.

psql -t ${DB} -c "SELECT E'select setval(\'' || c.relname || E'\',  (select max(id)+1 from ' || replace(c.relname, '_id_seq', '') || '), false);' FROM pg_class c WHERE c.relkind = 'S';" | psql ${DB}
david
#1 david
This really isn't a common case (I think you've been the only one so far), and I'm not sure what we would do with that script. I'm going to close this for now, and hope that it's really not a general problem.
  • +SetupIssue