tercul-backend/fix_domain_repos.go
google-labs-jules[bot] 8797cec718 Refactor: In-progress refactoring to fix build.
This commit includes the following changes:
- Refactored all data repositories in `internal/data/sql/` to use a consistent `sql` package and to align with the new `domain` models.
- Fixed the GraphQL structure by moving the server creation logic from `internal/app` to `cmd/api`, which resolved an import cycle.
- Corrected numerous incorrect import paths for packages like `graph`, `linguistics`, `syncjob`, and the legacy `models` package.
- Resolved several package and function redeclaration errors.
- Removed legacy migration code.
2025-09-05 15:11:30 +00:00

50 lines
1.5 KiB
Go

package main
import (
"fmt"
"io/ioutil"
"os"
"path/filepath"
"strings"
)
func main() {
domainDir := "internal/domain"
dirs, err := ioutil.ReadDir(domainDir)
if err != nil {
fmt.Println("Error reading domain directory:", err)
return
}
for _, dir := range dirs {
if dir.IsDir() {
repoFilePath := filepath.Join(domainDir, dir.Name(), "repo.go")
if _, err := os.Stat(repoFilePath); err == nil {
content, err := ioutil.ReadFile(repoFilePath)
if err != nil {
fmt.Printf("Error reading file %s: %v\n", repoFilePath, err)
continue
}
newContent := strings.Replace(string(content), "domain.Base", "domain.BaseRepository", -1)
newContent = strings.Replace(newContent, "domain."+strings.Title(dir.Name()), "domain."+strings.Title(dir.Name()), -1)
// Fix for names with underscore
newContent = strings.Replace(newContent, "domain.Copyright_claim", "domain.CopyrightClaim", -1)
newContent = strings.Replace(newContent, "domain.Email_verification", "domain.EmailVerification", -1)
newContent = strings.Replace(newContent, "domain.Password_reset", "domain.PasswordReset", -1)
newContent = strings.Replace(newContent, "domain.User_profile", "domain.UserProfile", -1)
newContent = strings.Replace(newContent, "domain.User_session", "domain.UserSession", -1)
if err := ioutil.WriteFile(repoFilePath, []byte(newContent), 0644); err != nil {
fmt.Printf("Error writing file %s: %v\n", repoFilePath, err)
} else {
fmt.Printf("Fixed repo %s\n", repoFilePath)
}
}
}
}
}