Drop qt_users dependency for configs and track app version

This commit is contained in:
Mikhail Chusavitin
2026-02-05 15:07:23 +03:00
parent 77c00de97a
commit 548a256d04
14 changed files with 103 additions and 31 deletions

View File

@@ -66,7 +66,7 @@ func main() {
// Get all configurations from MariaDB
var configs []models.Configuration
if err := mariaDB.Preload("User").Find(&configs).Error; err != nil {
if err := mariaDB.Find(&configs).Error; err != nil {
log.Fatalf("Failed to fetch configurations: %v", err)
}
@@ -74,13 +74,10 @@ func main() {
localCount := local.CountConfigurations()
log.Printf("Found %d configurations in local SQLite", localCount)
if *dryRun {
if *dryRun {
log.Println("\n[DRY RUN] Would migrate the following configurations:")
for _, c := range configs {
userName := c.OwnerUsername
if userName == "" && c.User != nil {
userName = c.User.Username
}
if userName == "" {
userName = "unknown"
}
@@ -131,14 +128,10 @@ func main() {
UpdatedAt: now,
SyncedAt: &now,
SyncStatus: "synced",
OriginalUserID: c.UserID,
OriginalUserID: derefUint(c.UserID),
OriginalUsername: c.OwnerUsername,
}
if localConfig.OriginalUsername == "" && c.User != nil {
localConfig.OriginalUsername = c.User.Username
}
if err := local.SaveConfiguration(localConfig); err != nil {
log.Printf(" ERROR: %s - %v", c.Name, err)
errors++
@@ -173,3 +166,10 @@ func main() {
fmt.Println("\nDone! You can now run the server with: go run ./cmd/server")
}
func derefUint(v *uint) uint {
if v == nil {
return 0
}
return *v
}