This script uses SET FOREIGN_KEY_CHECKS=0
which can cause a plethora of issues.
One of those issues are the user ID foreign keys containing invalid data.
For future reference, those broken foreign keys can be set to null
with the following commands:
Use at your own risks. Don't run commands on production server without test.
UPDATE posts p
LEFT JOIN users u ON u.id = p.user_id
SET user_id = null
WHERE u.id IS NULL
UPDATE posts p
LEFT JOIN users u ON u.id = p.edited_user_id
SET edited_user_id = null
WHERE u.id IS NULL
UPDATE posts p
LEFT JOIN users u ON u.id = p.hidden_user_id
SET hidden_user_id = null
WHERE u.id IS NULL
UPDATE discussions d
LEFT JOIN users u ON u.id = d.user_id
SET user_id = null
WHERE u.id IS NULL