Just guessing here, but wouldn't it be possible to set B_Parent of the first post in the thread to be moved to the ID of the thread it should be attached to. Also, B_Main should be set to the same ID of all posts in the thread. And if it is moved to another board, B_Board should also be updated of course.
I haven't checked any code so I'm not sure at all if this is how it should be done, but it might work. <disclaimer> Don't try this if you don't know what you do, and ALWAYS make a backup of the database. </disclaimer>