Correcting latest ordering after migrating data

(Martin Walsh) #1

After migrating data from wordpress I have an issue the the default ordering of ‘latest’ doesn’t make a lot of sense. Posts from 2012 show up as active 7 hours ago. When importing the created_at and updated_at are set to the original posting date.

I have noticed that any posts with images, discourse will download the images (which is nice) which then flags it as being edited right NOW which I presume is why these posts are now in latest. The others I’m not so sure about…
Staging Server:

I’ve not delved greatly into the db schema other than a quick look at some of the models.

Is there a simple SQL update I can run here,? I’m happy for latest to reflect activity for all imported data.

Going forward all new posts will populate latest correctly however it just looks wrong right now.


(Martin Walsh) #2

OK I think the main one is bumped_at in topics. I ended up running through a few other columns first to see what worked, not perfect perhaps but good enough for what I need.

UPDATE topics set updated_at=last_posted_at;
UPDATE posts set updated_at=created_at;
UPDATE posts set last_version_at=created_at;

UPDATE topics set bumped_at=created_at;

Something else I just noticed, there is a background process which appears to go through all your posts and pull down media (images) so if you do a migration you may want to give it a few hours to mature and then perform the above.

(Kane York) #3

Maybe the downloading images job should always specify that the topic shouldn’t be bumped?

Right now it only does that if bypass_bump is passed in the job scheduling arguments.

(Jeff Atwood) #4

What do you think @zogstrip? I tend to agree.

(Régis Hanol) #5

I agree too :crocodile:

(Tuan Anh Tran) #6

Can you post more on how do you migrate from wordpress to discourse? I’m interested in this as well since the wp instance of mine is over 20,000 posts and i haven’t found a solution on migrating to discourse yet.

(Martin Walsh) #7

Sorry @tuananh only just logged in here, are you still looking for a solution?

I think I still have a script lying around somewhere on a snapshot.