Modify

Opened 8 years ago

Closed 8 years ago

#12777 closed defect (fixed)

Running upgrade db2 failed: relation "codereviews" does not exist

Reported by: ntmlod Owned by: Cinc-th
Priority: normal Component: PeerReviewPlugin
Severity: normal Keywords:
Cc: Trac Release: 1.0

Description

Browsing the existing tickets, there have been several issues with the database related to the case sensitive and the renaming of some tables. Starting from a fresh installation of the plugin, no problem to compile the egg file but the database upgrade failed with the aforementioned message.

After some tests, it seems that the script detects a local database version 1 (from _get_version function in model.py) instead of version 0 and so skip the creation of the initial tables and run the db2 upgrade which can only crash.

Attachments (0)

Change History (7)

comment:1 Changed 8 years ago by ntmlod

I made few actions in order to figure out what's going on:

  • force _get_version to return '0'
    PeerReview: running upgrade  db1
    IntegrityError: duplicate key value violates unique constraint "system_pkey"
    DETAIL:  Key (name)=(CodeReviewVoteThreshold) already exists.
    
  • fix last issue (probably remaining of a previous installation attempt)
    DELETE FROM system WHERE name = 'CodeReviewVoteThreshold';
    DELETE 1
    
  • rerun a database upgrade
    PeerReview: running upgrade  db1
    PeerReview: running upgrade  db2
    ProgrammingError: relation "codereviews" does not exist
    LINE 2: ...iew, Author, Status, DateCreate, Name, Notes FROM CodeReview...
    

However it is there:

\dt
                  Liste des relations
 Schéma |          Nom           | Type  | Propriétaire 
--------+------------------------+-------+--------------
 public | CodeReviews            | table | nemo
 public | ReviewComments         | table | nemo
 public | ReviewFiles            | table | nemo
 public | Reviewers              | table | nemo

comment:2 Changed 8 years ago by ntmlod

I fixed the case sensitive problem with a workaround solution by adding double quotes on each item:

cursor.execute("""INSERT INTO peer_review(review_id,owner,status, created, name, notes)
    SELECT \"IDReview\", \"Author\", \"Status\", \"DateCreate\", \"Name\", \"Notes\" FROM \"CodeReviews\"""")
    cursor.execute("""INSERT INTO peer_reviewer(review_id,reviewer,status, vote)
    SELECT \"IDReview\", \"Reviewer\", \"Status\", \"Vote\" FROM \"Reviewers\"""")
    cursor.execute("""INSERT INTO peer_review_file(file_id,review_id,path,line_start,line_end, revision)
    SELECT \"IDFile\", \"IDReview\", \"Path\", \"LineStart\", \"LineEnd\", \"Version\" FROM \"ReviewFiles\"""")
    cursor.execute("""INSERT INTO peer_review_comment(comment_id,file_id,parent_id,line_num,author,comment,
    attachment_path, created)
    SELECT \"IDComment\", \"IDFile\", \"IDParent\", \"LineNum\", \"Author\", \"Text\", \"AttachmentPath\", \"DateCreate\" FROM \"ReviewComments\"""")
...
    cursor.execute("DROP TABLE \"CodeReviews\"")
    cursor.execute("DROP TABLE \"Reviewers\"")
    cursor.execute("DROP TABLE \"ReviewFiles\"")
    cursor.execute("DROP TABLE \"ReviewComments\"")

Then launch again the upgrade:

PeerReview: running upgrade  db2
checking  peerreviewfile_version
checking  peerreviewcomment_version
checking  peerreviewer_version
  inserting  peerreviewer_version
Custom and change tables for PeerReview need update.
  Dropping peerreview_change
  Dropping peerreview_custom
  Dropping peerreviewer_change
  Dropping peerreviewer_custom
  Dropping peerreviewfile_change
  Dropping peerreviewfile_custom
  Dropping peerreviewcomment_change
  Dropping peerreviewcomment_custom
Recreating change and custom tables.
The upgrade failed. Please fix the issue and try again.

InternalError: current transaction is aborted, commands ignored until end of transaction block
Last edited 8 years ago by ntmlod (previous) (diff)

comment:3 Changed 8 years ago by Ryan J Ollos

Cc: Cinc-th added

comment:4 Changed 8 years ago by Cinc-th

Cc: Cinc-th removed
Owner: changed from Olemis Lang to Cinc-th
Status: newassigned

Upgrading is a mess because of backwards compatibility requirements and other reasons. I'll review the upgrade process next week.

I suppose you are not using SQLite and trying to perform a first time install.

Last edited 8 years ago by Cinc-th (previous) (diff)

comment:5 Changed 8 years ago by Cinc-th

[15557]:

PeerReviewPlugin: new upgrade mechanism

  • Create database tables directly for first time installs instead of performing each upgrade step. This fails for backends other than SQLite.
  • don't try to upgrade ancient versions of the plugin. If you use such a version create a support ticket.

This should fix the current problem.

comment:6 Changed 8 years ago by ntmlod

I cleaned my previous installation (tables & keys), updated the plugin to the last revision and installed it.

No issue on the database upgrade and I can start using this new feature, thanks Cinc-th.

comment:7 Changed 8 years ago by Cinc-th

Resolution: fixed
Status: assignedclosed

Glad to hear installation succeeded.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Cinc-th.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment


E-mail address and name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.