Gitea upgrade from Gogs to 1.16.8: unmigrated pull_repo table

After following instructions to upgrade a Gogs instance to Gitea 1.16.8, the list of pull requests shown for a given project is broken with runtime error: invalid memory address or nil pointer dereference in the logs.

The Gitea admin figured out the source of the problem to be a dangling pull request with an issue not referencing any entry in the pull_requests table. A run of gitea doctor --all --fix would have removed the dangling entry and fixed the problem, but the pull request in question would have been lost.

Instead they analyzed the content of the database and figured out that the pull_repo table held the missing information. This table existed in Gogs until September 2015 when it was replaced by the pull_request table but not properly migrated. The Gitea admin partially reconstructed an entry in the pull_request table by copy/pasting from the pull_repo table which fixed the list of pull requests even though it still lacks information that could be salvaged.

It looks like a fine candidate for a new entry to gitea doctor as it would allow other Gogs instance to retrieve pull requests instead of assuming they are broken. To implement this one would need a backup of a Gitea instance with such a pull_repo table from which test cases could be extracted and made into fixtures to verify the implementation produces the expected results.

It is likely that other admins facing the same problem after a migration from Gogs did not spend as much time to figure it out and just lost dangling pull requests by running gitea doctor --all --fix. Recovering the pull requests for those instances may also be possible, if provided with a dump that also has a pull_repo table.

Not a very difficult improvement to the doctor, if there is interest.