opened 01:17PM - 03 Aug 22 UTC
kind/bug
### Description
I upgraded from 1.15.x to 1.16.8 and have been using gitea with… no problems for about a month. Recently, a user noticed that they were unable to create issues for some repositories (specifically repositories with existing issues.) Referencing issue [#16814](https://github.com/go-gitea/gitea/issues/16814) I attempted to recreate the issue_index table but gitea doctor fails with the following:
```
$ /opt/gitea/bin/gitea --config /etc/gitea/gitea.conf doctor recreate-table issue_index
2022/08/03 09:04:56 ...e/cli@v1.22.9/app.go:405:RunAsSubcommand() [I] PING DATABASE mysql
2022/08/03 09:04:56 main.go:118:main() [F] Failed to run app with [/opt/gitea/bin/gitea --config /etc/gitea/gitea.conf doctor recreate-table issue_index]: migrate: Database has not been initialized
```
When attempting to 'doctor --fix --all' I get a similar error:
```
$ /opt/gitea/bin/gitea --config /etc/gitea/gitea.conf doctor --all --fix
[1] Check paths and basic configuration
- [I] Configuration File Path: "/etc/gitea/gitea.conf"
- [I] Repository Root Path: "/git/gitea"
- [I] Data Root Path: "/opt/gitea/bin/data"
- [I] Custom File Root Path: "/opt/gitea/bin/custom"
- [I] Work directory: "/opt/gitea/bin"
- [I] Log Root Path: "/var/log/gitea"
OK
[2] Check if there is garbage storage files
OK
[3] Check Database Version
- [W] Got Error: migrate: Database has not been initialized during ensure up to date
- [W] Attempting to migrate to the latest DB version to fix this.
OK
[4] Check consistency of database
- [C] Model version on the database does not match the current Gitea version. Model consistency will not be checked until the database is upgraded
ERROR
[5] Check if user with wrong type exist
OK
[6] Check if OpenSSH authorized_keys file is up-to-date
OK
[7] Check if SCRIPT_TYPE is available
- [I] ScriptType bash is on the current PATH at /usr/bin/bash
OK
[8] Check if hook files are up-to-date and executable
OK
[9] Recalculate Stars number for all user
- [I] Updated User Stars numbers.
OK
[10] Check old archives
- [I] 0 / 0 old archives in repository deleted
OK
[11] Check that all git repositories have receive.advertisePushOptions set to true
- [I] Enabled push options for 63 repositories.
OK
[12] Check for incorrectly dumped repo_units (See #16961)
- [I] Fixed 0 broken repo_units
OK
[13] Recalculate merge bases
- [I] 0 PR mergebases updated of 16 PRs total in 63 repos
OK
[14] Check git-daemon-export-ok files
- [I] Updated git-daemon-export-ok files for 0 of 63 repositories.
OK
[15] Check if users has an valid email address
- [I] All users have a valid e-mail.
OK
```
And when I attempt to run 'doctor migrate' I get the following:
```
$ /opt/gitea/bin/gitea --config /etc/gitea/gitea.conf doctor migrate
[1] Check paths and basic configuration
- [I] Configuration File Path: "/etc/gitea/gitea.conf"
- [I] Repository Root Path: "/git/gitea"
- [I] Data Root Path: "/opt/gitea/bin/data"
- [I] Custom File Root Path: "/opt/gitea/bin/custom"
- [I] Work directory: "/opt/gitea/bin"
- [I] Log Root Path: "/var/log/gitea"
OK
[2] Check Database Version
- [C] Error: migrate: Database has not been initialized during ensure up to date
ERROR
[3] Check if user with wrong type exist
OK
[4] Check if OpenSSH authorized_keys file is up-to-date
OK
```
I have upgraded to 1.17.0 in case there was a bug but the problem still remains. How can I resolve this issue so that I can recreate issue_index?
### Gitea Version
1.17.0
### Can you reproduce the bug on the Gitea demo site?
No
### Log Gist
_No response_
### Screenshots
_No response_
### Git Version
2.31.1
### Operating System
RHEL8
### How are you running Gitea?
Gitea is running non-containerized via systemd, proxied behind Apache, with a mariadb database (10.8.3) on a RHEL 8 system.
### Database
MySQL