gitea doctor recreate-table fails due to 'uninitialized database' #9335

Closed
opened 2025-11-02 08:35:49 -06:00 by GiteaMirror · 2 comments
Owner

Originally created by @tazerdev on GitHub (Aug 3, 2022).

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 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

Originally created by @tazerdev on GitHub (Aug 3, 2022). ### 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
GiteaMirror added the issue/needs-feedback label 2025-11-02 08:35:49 -06:00
Author
Owner

@wxiaoguang commented on GitHub (Sep 23, 2022):

It's highly likely you were using a wrong gitea config and connected to a wrong database which doesn't contain valid Gitea version table.

@wxiaoguang commented on GitHub (Sep 23, 2022): It's highly likely you were using a wrong gitea config and connected to a wrong database which doesn't contain valid Gitea `version` table.
Author
Owner

@wxiaoguang commented on GitHub (Sep 28, 2022):

Since it doesn't seem to be a Gitea problem, I will close this issue. Feel free to re-open if you find a bug (and show the /etc/gitea/gitea.conf to see whether it's correct)

@wxiaoguang commented on GitHub (Sep 28, 2022): Since it doesn't seem to be a Gitea problem, I will close this issue. Feel free to re-open if you find a bug (and show the /etc/gitea/gitea.conf to see whether it's correct)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#9335