inpho / inphosite

The InPhO API
https://inphoproject.org
15 stars 5 forks source link

can't delete thinker - internal server error #160

Open colinallen opened 7 years ago

colinallen commented 7 years ago

Internal server error response with curl -X DELETE -u user:password https://inpho.cogs.indiana.edu/thinker/5679

colinallen commented 7 years ago

passes unit test for entity deletion, but that tests only 'idea' deletion, which I was also able to do via curl

colinallen commented 7 years ago

For thinker 3002 (duplication of FIchte), the error is Error - <class 'sqlalchemy.exc.IntegrityError'>: (IntegrityError) (1451, 'Cannot delete or update a parent row: a foreign key constraint fails (seponto.thinker_has_influenced, CONSTRAINT fk_thinker_has_influenced_thinker1 FOREIGN KEY (thinker1_id) REFERENCES thinker (ID) ON DELETE NO ACTION ON UPDATE NO ACTION)') 'DELETE FROM thinker WHERE thinker.ID = %s' (3002,)

So it appears that entity can be deleted because it's mentioned elsewhere.

colinallen commented 7 years ago

Related but different reason for 5679:

Error - <class 'sqlalchemy.exc.IntegrityError'>: (IntegrityError) (1451, 'Cannot delete or update a parent row: a foreign key constraint fails (seponto.date, CONSTRAINT fk_date_entity1 FOREIGN KEY (entity_id) REFERENCES entity (ID) ON DELETE NO ACTION ON UPDATE NO ACTION)') 'DELETE FROM entity WHERE entity.ID = %s' (5679,)

colinallen commented 6 years ago

Also getting error for some ideas -- e.g. https://www.inphoproject.org/idea/5696 (fallacies) which is a duplicate of https://www.inphoproject.org/idea/1980 -- both give internal server error on attempt to delete.

JaimieMurdock commented 6 years ago

I am curious as to whether a SQL Alchemy update would just fix this... inphosite depends on v0.6.9 released on May 6, 2012. SQL Alchemy is now on v1.2.0.

Without unit tests, I'm hesitant to simply upgrade. This could be good motivation for testing the project and getting Travis-CI integration, like we have with vsm/topic-explorer.

JaimieMurdock commented 6 years ago

I have modified some of the foreign key constraints

SHOW CREATE TABLE `thinker_has_influenced`;

ALTER TABLE `thinker_has_influenced`
DROP FOREIGN KEY `fk_thinker_has_influenced_thinker1`;

ALTER TABLE `thinker_has_influenced` 
ADD CONSTRAINT fk_thinker_has_influenced_thinker1 
FOREIGN KEY (thinker1_id) REFERENCES thinker(ID) 
ON DELETE CASCADE;

ALTER TABLE `thinker_has_influenced`
DROP FOREIGN KEY `fk_thinker_has_influenced_thinker2`;

ALTER TABLE `thinker_has_influenced` 
ADD CONSTRAINT fk_thinker_has_influenced_thinker2 
FOREIGN KEY (thinker2_id) REFERENCES thinker(ID) 
ON DELETE CASCADE;

I've got to do this for more tables.

JaimieMurdock commented 6 years ago

SHOW CREATE TABLE `date`;

ALTER TABLE `date`
DROP FOREIGN KEY `fk_date_entity1`;

ALTER TABLE `date`
ADD CONSTRAINT `fk_date_entity1` 
FOREIGN KEY (`entity_id`) REFERENCES `entity` (`ID`) 
ON DELETE CASCADE;
JaimieMurdock commented 6 years ago
SHOW CREATE TABLE `thinker_teacher_of`;

ALTER TABLE `thinker_teacher_of`
DROP FOREIGN KEY `fk_thinker_teacher_of_thinker1`,
DROP FOREIGN KEY `fk_thinker_teacher_of_thinker2`;

ALTER TABLE `thinker_teacher_of`
ADD CONSTRAINT `fk_thinker_teacher_of_thinker1` FOREIGN KEY (`thinker1_id`) REFERENCES `thinker` (`ID`) ON DELETE CASCADE,
ADD CONSTRAINT `fk_thinker_teacher_of_thinker2` FOREIGN KEY (`thinker2_id`) REFERENCES `thinker` (`ID`) ON DELETE CASCADE;
JaimieMurdock commented 6 years ago

Successfully deleted:

Now attempting to figure out the idea tables to delete 1980 - same issues I suspect.

JaimieMurdock commented 6 years ago

Different issue:

UnmappedColumnError: Can't execute sync rule for source column 'idea.ID'; mapper 'Mapper|IdeaGraphEdge|idea_graph_edges' does not map this column.  Try using an explicit `foreign_keys` collection which does not include destination column 'idea_graph_edges.ante_id' (or use a viewonly=True relation).
colinallen commented 6 years ago

I have successfully deleted all the thinker instances that I had previously marked for deletion, so just ideas now. (Noting in passing that remaining problem no longer matches issue title.)

colinallen commented 6 years ago

I'm marking up entities that I can't delete with the words "marked for deletion" in the label, so can be retrieved as https://www.inphoproject.org/entity?redirect=true&q=deletion