InDefero

Sign in or create your account | Project List | Help

Issue 183: Project can not be deleted because of foreign key integrity constraints

Reported by Sindre Myren, Apr 6, 2009

Error message:
Exception making POST request to 
/code/index.php/admin/projects/28/delete/
ERROR: update or delete on table "indefero_idf_tags" 
violates foreign key constraint 
"indefero_idf_issues_status_fkey" on table 
"indefero_idf_issues" DETAIL: Key (id)=(474) is still 
referenced from table "indefero_idf_issues". - DELETE FROM 
indefero_idf_tags WHERE id = 474

My guesses is that the problem here is that idf_tags are deleted 
before idf_issues. Could this issue "simply" be resolved 
by somehow swapping the deletion order?

Comment 1 by Sindre Myren, Apr 6, 2009

I was able to delete the project in question, after manually 
changing the "status" key in all of the issues attached to 
the project to something else.

I suggest this as a dirty hack you *might* use to solve this problem 
temperately if a proper solution can not be found swiftly.

Comment 2 by Loïc d'Anterroches, Apr 6, 2009

Which version of InDefero are you using? I fixed a related bug 
sometimes ago.

Comment 3 by Sindre Myren, Apr 6, 2009

git, latest version

Comment 4 by Loïc d'Anterroches, Apr 7, 2009

Labels: Priority:High, -Priority:Medium
Status: Accepted
Summary: Project can not be deleted because of foreign key integrity constraints
Owner: loic

Comment 5 by Loïc d'Anterroches, Apr 7, 2009

I am annoyed, I tried without success to reproduce the error. Do you 
have an old backup of the database that could be used to do some 
tests?

Comment 6 by Sindre Myren, Apr 7, 2009

Hi - sorry - I do not.
But I was able to reproduce the error.

Steps to reproduce:
1)
press Administer -> Creat Project
Chose short_name=test3, repository=svn

2) (migth be unnecessary)
press Project list > test3 > Administer > Issue_tracking
Add a line:
"Fixed2              = Developer made requested changes, QA2 
should verify"
and click save.

3) 
press Issues > Add Issue
Chose status=Fixed2

4) (migth be unnecessary)
press Issues> Issue 1> add comment
save

5)
press Administer > test3 > delete project

Resulting error:
Exception making POST request to 
/code/index.php/admin/projects/65/delete/
ERROR: update or delete on table "indefero_idf_tags" 
violates foreign key constraint 
"indefero_idf_issues_status_fkey" on table 
"indefero_idf_issues" DETAIL: Key (id)=(1132) is still 
referenced from table "indefero_idf_issues". - DELETE FROM 
indefero_idf_tags WHERE id = 1132
PHP 	/home/www/pluf/src/Pluf/DB/PostgreSQL.php, line 163
URI 	POST /code/index.php/admin/projects/65/delete/

Thanks for everything so far.

Comment 7 by Sindre Myren, Apr 7, 2009

Full error as html file (session id sensured)

Comment 8 by Loïc d'Anterroches, Apr 7, 2009

Great! On Thursday morning I start my Easter holidays, so I am not 
sure I can fix that before, if not, this will be done on Tuesday the 
14th.

Comment 9 by Loïc d'Anterroches, Apr 16, 2009

Ok, I was able to reproduce the problem, I am working on it now.

Comment 10 by Loïc d'Anterroches, Apr 16, 2009

Fixed in commit 1656c99, thanks a lot! I would have not been able to 
fix it so quickly without your steps to reproduce the error. Really, 
thanks a lot!
Status: Fixed

Created: 11 months 10 days ago by Sindre Myren

Updated: 11 months 11 hours ago

Status: Fixed

Owner: Loïc d'Anterroches

Followed by: 1 person

Labels:
Type:Defect
Priority:High