Let me clarify:
Topics and all its replies are imported following the topic ids from smaller to greater on the vbulletin database. That also means that we are importing in chronological order.
However, that would lead to think that if you ever find a reference to another topic, it would always be for another one that already existed.
But there are cases in which this is not true, just a couple of example:
- split topic with a comment that lead to the split. The split would be with an id that is higher but exists in a topic with a lesser id.
- edit for future readers in which old topics’ post have reference to more recent ones
So, yeah, while the topics_custom_field is generated and filled up while the import progresses, as explained in the very first topic, it’s not reliable to do it “on the fly” because you can’t be sure to find always the right correspondence between ids.
Another pass after the full import has completed is needed.
About TopicCustomField.each do |tcf|, I’m not sure what the tcf part would do. Ruby is not a language I’ve learnt. Our script is written in C# as the majority of the people that offered to work with it, use it for work already.