Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

purge-deleted Only Deletes Some Records and Not Others #1524

Open
miqrogroove opened this issue Dec 19, 2023 · 7 comments
Open

purge-deleted Only Deletes Some Records and Not Others #1524

miqrogroove opened this issue Dec 19, 2023 · 7 comments

Comments

@miqrogroove
Copy link
Contributor

I'm getting this same output everytime I run caUtils purge-deleted:

CollectiveAccess 1.7.15 (158/RELEASE) Utilities
(c) 2013-2019 Whirl-i-Gig

Removing deleted representations from database               100.0% 52/52 ETC: < 1 sec. Elapsed: 2 secs 

Done!

Those 52 representations and their associated media files aren't going away.

@kehh
Copy link
Contributor

kehh commented Dec 19, 2023

We've seen this before where there are foreign keys preventing this deletion. Take a look in the database to see if there's anywhere those representations are being used (either a parent representation or maybe one of the ca_{tablename}_x_object_representations). Do a query to find out what the id's of the deleted representations are. (SELECT representation_id FROM ca_object_representations WHERE deleted).

@miqrogroove
Copy link
Contributor Author

@kehh Does that imply my object representations can't be deleted unless the object is also deleted? That would be... highly inconvenient.

Foreign key constraints are a likely issue. I've traced the silent failure as far as

if ($this->numErrors() > 0) {

And I was going to try to pull the codes next.

@miqrogroove
Copy link
Contributor Author

     'opn_error_number' => 250,
     'ops_error_description' => 'Invalid relationship reference for representation_id',
     'ops_error_context' => 'Db->mysqli->execute()',

@miqrogroove
Copy link
Contributor Author

Here's the same query sent straight to the mysql client:

mysql> DELETE FROM ca_object_representations WHERE representation_id = 5773;
ERROR 1451 (23000): Cannot delete or update a parent row: a foreign key constraint fails (`providence`.`ca_download_log`, CONSTRAINT `fk_ca_download_log_representation_id` FOREIGN KEY (`representation_id`) REFERENCES `ca_object_representations` (`representation_id`) ON DELETE RESTR)

@miqrogroove
Copy link
Contributor Author

Good lord. So now I can't delete anything that has ever been downloaded? Is there no code to handle this?

@collectiveaccess
Copy link
Owner

Purge the download log and delete whatever you want. Please keep in mind this is software for archival usage. For most users permanently deleting things is not desirable, especially if those things been interacted with (eg. downloaded).

@miqrogroove
Copy link
Contributor Author

Got it but gee whiz. I'm trying to replace some representations and occasionally things get uploaded in error. Is this not a bug where I have to truncate a table to get the caUtils purge command to work as expected?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants