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

@@ -7,6 +7,7 @@ import (
"strings"
"time"
"git.mchus.pro/mchus/quoteforge/internal/appmeta"
"git.mchus.pro/mchus/quoteforge/internal/localdb"
"git.mchus.pro/mchus/quoteforge/internal/models"
"git.mchus.pro/mchus/quoteforge/internal/services/sync"
@@ -820,6 +821,7 @@ func (s *LocalConfigurationService) appendVersionTx(
Data: snapshot,
ChangeNote: &changeNote,
CreatedBy: createdByPtr,
AppVersion: appmeta.Version(),
}
if err := tx.Create(version).Error; err != nil {
@@ -915,6 +917,7 @@ func (s *LocalConfigurationService) rollbackToVersion(configurationUUID string,
Data: target.Data,
ChangeNote: &changeNote,
CreatedBy: stringPtrOrNil(userID),
AppVersion: appmeta.Version(),
}
if err := tx.Create(version).Error; err != nil {

View File

@@ -7,6 +7,7 @@ import (
"log/slog"
"time"
"git.mchus.pro/mchus/quoteforge/internal/appmeta"
"git.mchus.pro/mchus/quoteforge/internal/db"
"git.mchus.pro/mchus/quoteforge/internal/localdb"
"git.mchus.pro/mchus/quoteforge/internal/models"
@@ -605,15 +606,10 @@ func (s *Service) ensureConfigurationOwner(mariaDB *gorm.DB, cfg *models.Configu
return fmt.Errorf("owner username is empty")
}
userID, err := models.EnsureDBUser(mariaDB, ownerUsername)
if err != nil {
return err
}
if userID == 0 {
return fmt.Errorf("resolved user ID is 0 for owner %q", ownerUsername)
}
cfg.UserID = userID
// user_id is legacy and no longer used for ownership in local-first mode.
// Keep it NULL on writes; ownership is represented by owner_username.
cfg.UserID = nil
cfg.AppVersion = appmeta.Version()
return nil
}