Closed Bug 1251610 Opened 8 years ago Closed 4 years ago

Delete apps from addons table

Categories

(Cloud Services :: Operations: AMO, task)

task
Not set
normal

Tracking

(Not tracked)

RESOLVED WONTFIX

People

(Reporter: jorgev, Assigned: wezhou)

Details

(Whiteboard: cleanup)

I was investigating the use of version.deleted for Andrew, and ended up with 1300 versions that used it. After looking into them a little more, I realized they were old app data from the Marketplace days, and version.deleted wasn't used for add-ons at all. We should get rid of all the app data so it's easier to identify code and DB entities that are no longer in use.

We should delete all entries in the addons table that have addontype_id = 11, and other data associated with them (versions, files, etc.).
Component: Administration → Operations: AMO
Product: addons.mozilla.org → Cloud Services
QA Contact: jthomas
Let's do this after our production push.

If someone from the dev team can provide queries that would be helpful.
Assignee: nobody → wezhou
Whiteboard: cleanup
"delete all entries in the addons table that have addontype_id = 11" is straightforward, but how should we delete "other data associated with them (versions, files, etc.)"?

Is there a command that safely deletes entries with addontype_id = 11 and their associated data?
Flags: needinfo?(jthomas)
The table schema for versions, files, etc should have a constraint to cascade on delete. It should just work but we should test on dev and stage first. If we are really paranoid we can try running it on a prod snapshot instance first.
Flags: needinfo?(jthomas)
Tested on -dev. It looks like at least one of the foreign key constraints doesn't have the "cascade on delete" option, which prevents the rows from being deleted.

MySQL [addons_dev_allizom_org]> delete from addons where addontype_id = 11;
ERROR 1451 (23000): Cannot delete or update a parent row: a foreign key constraint fails (`addons_dev_allizom_org`.`users_install`, CONSTRAINT `addon_id_refs_id` FOREIGN KEY (`addon_id`) REFERENCES `addons` (`id`))

Because the "cascade on delete" option is not easily set on existing constraints, we will need to get dev opinion on how to do this safely and effectively. I'll try to talk to them about this.
Most of our tables do *not* have on delete cascade, because the cascade is handled by django, not MySQL. Some do because they were created manually but we should always assume it's not the case.

That being said, the `users_install` table should have been dropped in https://github.com/mozilla/addons-server/commit/6119cdedad97c38ce48dc34389fcb67140f0a1a9 so maybe it's safe to try again ?

No action in a long time, closing as WONTFIX. Please reopen if this is still needed.

Status: NEW → RESOLVED
Closed: 4 years ago
Resolution: --- → WONTFIX
You need to log in before you can comment on or make changes to this bug.