Refactor database connection (#37496)

Clean up legacy copied&pasted code, introduce the unique "database
connection" function. Move migration testing helper function
PrepareTestEnv to a separate package.

By the way, remove "shadow connection secrets" tricks: showing
connection string on UI is useless

---------

Co-authored-by: Nicolas <bircni@icloud.com>
This commit is contained in:
wxiaoguangandNicolas authored and GitHub committed 2026-05-01 15:38:38 +00:00
1 parent 02b1b8a549
commit deb31d3f30
67 files changed
+611 -865

No files matched your search

+6 -2
View File
@@ -3,10 +3,14 @@
package db
import "xorm.io/xorm/schemas"
import (
"code.gitea.io/gitea/modules/setting"
"xorm.io/xorm/schemas"
)
// DumpDatabase dumps all data from database according the special database SQL syntax to file system.
func DumpDatabase(filePath, dbType string) error {
func DumpDatabase(filePath string, dbType setting.DatabaseType) error {
var tbs []*schemas.Table
for _, t := range registeredModels {
t, err := xormEngine.TableInfo(t)