perf: refactor

This commit is contained in:
ryan
2026-06-20 09:48:33 +08:00
parent cac6e88bc0
commit 200525a1ab
6 changed files with 149 additions and 179 deletions
+14
View File
@@ -42,6 +42,20 @@ func gooseDialect() string {
return dialectPostgres
}
func tableExistsSQL(dialect string) string {
if dialect == dialectSqlite {
return "SELECT COUNT(*) FROM sqlite_master WHERE type='table' AND name=?"
}
return "SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = 'public' AND table_name = $1"
}
func tablesWithPrefixSQL(dialect string) string {
if dialect == dialectSqlite {
return "SELECT name FROM sqlite_master WHERE type='table' AND name LIKE ?"
}
return "SELECT table_name FROM information_schema.tables WHERE table_schema='public' AND table_name LIKE $1"
}
func migrationDir() string {
if !config.Config.Database.Enabled {
return "goose/sqlite"