codidact / qpixel

Q&A-based community knowledge-sharing software
https://codidact.com
GNU Affero General Public License v3.0
385 stars 69 forks source link

Wipe everything script fails due to foreign key constraints #1195

Closed trichoplax closed 11 months ago

trichoplax commented 1 year ago

Describe the bug Running the script with rails runner gives an error, and the deletion of the database data fails:

$ rails r scripts/wipe_everything.rb

Mysql2::Error: Cannot delete or update a parent row: a foreign key constraint fails (qpixel_dev.user_abilities, CONSTRAINT fk_rails_de15a6ad96 FOREIGN KEY (ability_id) REFERENCES abilities (id)) (ActiveRecord::InvalidForeignKey)

To Reproduce Steps to reproduce the behavior:

Expected behavior The database should be emptied and reseeded as if starting from a new installation.

A decision needs to be made to either fix this script (which may involve deleting the data per table in a specific order) or to delete this script if it is no longer required.

cellio commented 11 months ago

Does that PR fully address this? I.e. should we close this issue now, or is there something still to do?

TimothyDLewis commented 11 months ago

Fully addresses it; so yes, this can be closed now 🙂 (Sorry, used to issues auto-closing when an associated PR is merged and closed; didn't realize this was a manual process at the moment)

cellio commented 11 months ago

Usually it does auto-close; I don't know why it didn't here. Fixing that now.

TimothyDLewis commented 11 months ago

Oh hmm... Chances are I didn't link it correctly; I'll double-check that next time 😅