question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Database cleanup of orphaned records

See original GitHub issue

Follow up from https://github.com/cgeo/cgeo/issues/6186#issuecomment-270253650. It turned out that due to the lack of foreign keys in the DB it happens that geocaches got deleted from cg_caches without their related records in dependent tables like cg_logs, cg_waypoints, …

The DataStore.cleanIfNeeded() is the housekeeping method which regulary (on startup) cleans up the database. This should be extended to also clean up these orphaned records as well.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:10 (10 by maintainers)

github_iconTop GitHub Comments

3reactions
pstorchcommented, Jan 4, 2017

@SammysHP ON DELETE CASCADE can be used when we have introduced foreign keys. That would be the best solution. But we would need the cleanup then anyway. Before that we can’t introduce the foreign keys.

I couldn’t find a DB Schema, so I drew one. I’ll also add this to the wiki: cgeo-db

0reactions
pstorchcommented, Jan 6, 2017

Thanks to the database file from @SammysHP I found another possible inconsistency. There were some caches associated with a list which doesn’t exist. They didn’t show up anywhere but blocked the housekeeping process. I’ve updated the PR.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How do you clean up a table that has orphaned records (SQL ...
Perform explain query, try to get where it is consuming time. · Try to add more filters as much as you can. ·...
Read more >
How to detect and handle orphaned data in your databases ...
E- Step 5 - Finding & Deleting The Orphaned Data. IV. ... Once you know that, you can locate the data easily, and...
Read more >
Cleanup orphaned records - mysql - DBA Stack Exchange
Cleanup orphaned records ... I have two tables in MySQL: orders and line items. When orders are deleted, the line items are orphaned....
Read more >
Clean up table that has orphaned records - Stack Overflow
Since in Base Table record with id 5 and 6 is not referring from any table, this two are orphaned records, i want...
Read more >
Database Cleanup: Orphaned Discovered Software Records ...
This document describes how to identify and cleanup orphaned discovered software records in the Client Automation (ITCM) mdb database.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found