• Support
  • Post link doesn't work after migration

Hi,

I've used this script to migrate my forum:
https://discuss.flarum.org/d/1117-phpbb-migrate-script-updated-for-beta-5
I required some modification as it was very old phpbb2 version.

Right now - all new discussion opened or updated after migration allow me to find link to exact post
It works on long topic list (it always pointing to last post in discussion), when I'm scrolling down or click on post date - I can get link to exact post like this (for post 22)
https://discuss.flarum.org/d/123-my-topic/22

But for old topics - whatever I try - It always showing without number on the end (on browser address or when I click on post date and all links going directly to first post - it always generate link without number like this: https://discuss.flarum.org/d/123-my-topic

How to get it fixed? What's missing on DB?

I've got it. This column is empty for migrated topics: last_post_number
There is any easy way to get it refreshed for all discussions?

There isn't anything automatic, but you could write a script that finds the number of the post with the highest number in that discussion, and save that as the discussion's last_post_number. If you need to do this in PHP vs directly through the database, you can use the setLastPost method of the Discussion model.

I can see that some other columns contain value of 1, example:

  • last_post_id
  • post_number_index - What's that?
  • first_post_id

I will need to update it as well or I can leave it like it is? What's required to get it works properly?

    Wadera you can see from the foreign key constraints that those reference the id of the posts table. They are automatically filled by Flarum in order to show first and last post in discussion lists while reducing database requests. If you imported data, you should update the values accordingly so that Flarum can show those informations in the discussion list.

    While last_post_number reflects the number of the last visible post for the purpose of link generation and read status, post_number_index contains the last generated post number. That way even if the last post of a discussion is deleted, its number won't be re-used. Immediately following the import the two columns should most likely contain the same value, unless the source forum supports soft-deleted "hidden" posts as well.

    5 months later

    I've spent some time trying to reuse some migration scripts to get it fixed, but without luck so far 🙁

    As far as I understand using setLastPost method of the Discussion model can be used on all discussion which should fix the issue, but my codding skill is to weak to build this maintenance tool script from scratch.

    I'm ready to pay some dev for help me get it sorted (with some cost estimation first of course... I would say €50 as starting price as it's just for small community forum available for free - nothing related to business. If you estimate higher price - please clarify why - maybe it's much more work than I think 😉 )

    Also when this "tool" will be ready - it should be released to community for free use.

    I think that this kind of "maintenance tool" can be useful in future when something being broken on DB...
    As example - that's another person with similar issue:
    https://discuss.flarum.org/d/21891-recount-table-column-number-after-migration-from-other-software

    In ideal world - it should be available on administration panel as a simple button to click for "Fix my database, recount discussion, tags and posts counts".

    But simple php / CLI script is also fine for me 😉