Using SELECT `%s` FROM `%s` WHERE 0 = 1 to assert the existence of a column is simple but noisy: it shows errors in the migrations that are confusing for Forgejo admins because they are not actual errors.
Use introspection instead, which is more complicated but leads to the same result.
Add a test that ensures it works as expected, for all database types. Although the migration is run for all database types, it does not account for various scenarios and is never tested in the case a column does not exist.
Refs: https://codeberg.org/forgejo/forgejo/issues/6583
Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/6591
Reviewed-by: Otto <otto@codeberg.org>
Co-authored-by: Earl Warren <contact@earl-warren.org>
Co-committed-by: Earl Warren <contact@earl-warren.org>
Some database fields were added in the database to facilitate
migration from Gitea and do not serve any purpose. Drop them since
v1.22 is the last version of the database to allow a transparent
migration to Forgejo.