PostgreSQL backup tool with Point-In-Time-Recovery and restore verification
TypeScript backupbackupsdatabasedatabase-backupdevopsdockergolangkubernetesmariadbmongodbmysqlpgpostgrespostgresqls3self-hostedsystem-administrationtoolsweb-ui
REFACTOR (formatters): Apply formatters auto fixes
Rostislav Duginbcd7d8e1aa7a
diff --git a/agent/cmd/main.go b/agent/cmd/main.goindex 0855d5cb..b83c6224 100644--- a/agent/cmd/main.go+++ b/agent/cmd/main.go@@ -116,11 +116,12 @@ func printUsage() {fmt.Fprintln(os.Stderr, " version Print agent version")}-func runUpdateCheck(host string, isSkipUpdate bool, isDev bool, log interface {+func runUpdateCheck(host string, isSkipUpdate, isDev bool, log interface {Info(string, ...any)Warn(string, ...any)Error(string, ...any)-}) {+},+) {if isSkipUpdate {return}diff --git a/agent/internal/config/config.go b/agent/internal/config/config.goindex 3e37d773..1530b689 100644--- a/agent/internal/config/config.go+++ b/agent/internal/config/config.go@@ -51,7 +51,7 @@ func (c *Config) SaveToJSON() error {return err}- return os.WriteFile(configFileName, data, 0644)+ return os.WriteFile(configFileName, data, 0o644)}func (c *Config) loadFromJSON() {diff --git a/agent/internal/config/config_test.go b/agent/internal/config/config_test.goindex cb5f14bd..4bfbc909 100644--- a/agent/internal/config/config_test.go+++ b/agent/internal/config/config_test.go@@ -146,7 +146,7 @@ func writeConfigJSON(t *testing.T, dir string, cfg Config) {data, err := json.MarshalIndent(cfg, "", " ")require.NoError(t, err)- require.NoError(t, os.WriteFile(dir+"/"+configFileName, data, 0644))+ require.NoError(t, os.WriteFile(dir+"/"+configFileName, data, 0o644))}func readConfigJSON(t *testing.T) Config {diff --git a/agent/internal/features/upgrade/upgrader.go b/agent/internal/features/upgrade/upgrader.goindex 425dbcbd..6dd28c4b 100644--- a/agent/internal/features/upgrade/upgrader.go+++ b/agent/internal/features/upgrade/upgrader.go@@ -56,7 +56,7 @@ func CheckAndUpdate(databasusHost, currentVersion string, isDev bool, log Loggerreturn fmt.Errorf("failed to download update: %w", err)}- if err := os.Chmod(tempPath, 0755); err != nil {+ if err := os.Chmod(tempPath, 0o755); err != nil {return fmt.Errorf("failed to set permissions on update: %w", err)}diff --git a/backend/cmd/main.go b/backend/cmd/main.goindex 1cfc7268..611eaad6 100644--- a/backend/cmd/main.go+++ b/backend/cmd/main.go@@ -12,6 +12,12 @@ import ("syscall""time"+ "github.com/gin-contrib/cors"+ "github.com/gin-contrib/gzip"+ "github.com/gin-gonic/gin"+ swaggerFiles "github.com/swaggo/files"+ ginSwagger "github.com/swaggo/gin-swagger"+"databasus-backend/internal/config""databasus-backend/internal/features/audit_logs""databasus-backend/internal/features/backups/backups/backuping"@@ -41,12 +47,6 @@ import (files_utils "databasus-backend/internal/util/files""databasus-backend/internal/util/logger"_ "databasus-backend/swagger" // swagger docs-- "github.com/gin-contrib/cors"- "github.com/gin-contrib/gzip"- "github.com/gin-gonic/gin"- swaggerFiles "github.com/swaggo/files"- ginSwagger "github.com/swaggo/gin-swagger")// @title Databasus Backend API@@ -83,7 +83,6 @@ func main() {config.GetEnv().TempFolder,config.GetEnv().DataFolder,})-if err != nil {log.Error("Failed to ensure directories", "error", err)os.Exit(1)@@ -150,7 +149,7 @@ func handlePasswordReset(log *slog.Logger) {resetPassword(*email, *newPassword, log)}-func resetPassword(email string, newPassword string, log *slog.Logger) {+func resetPassword(email, newPassword string, log *slog.Logger) {log.Info("Resetting password...")userService := users_services.GetUserService()diff --git a/backend/internal/config/config.go b/backend/internal/config/config.goindex e2f7ff0b..3ca4a066 100644--- a/backend/internal/config/config.go+++ b/backend/internal/config/config.go@@ -1,9 +1,6 @@package configimport (- env_utils "databasus-backend/internal/util/env"- "databasus-backend/internal/util/logger"- "databasus-backend/internal/util/tools""os""path/filepath""strings"@@ -11,6 +8,10 @@ import ("github.com/ilyakaznacheev/cleanenv""github.com/joho/godotenv"++ env_utils "databasus-backend/internal/util/env"+ "databasus-backend/internal/util/logger"+ "databasus-backend/internal/util/tools")var log = logger.GetLogger()diff --git a/backend/internal/features/audit_logs/background_service_test.go b/backend/internal/features/audit_logs/background_service_test.goindex 8ed1af3f..9087010f 100644--- a/backend/internal/features/audit_logs/background_service_test.go+++ b/backend/internal/features/audit_logs/background_service_test.go@@ -1,17 +1,17 @@package audit_logsimport (- "databasus-backend/internal/storage""fmt""testing""time"- user_enums "databasus-backend/internal/features/users/enums"- users_testing "databasus-backend/internal/features/users/testing"-"github.com/google/uuid""github.com/stretchr/testify/assert""gorm.io/gorm"++ user_enums "databasus-backend/internal/features/users/enums"+ users_testing "databasus-backend/internal/features/users/testing"+ "databasus-backend/internal/storage")func Test_CleanOldAuditLogs_DeletesLogsOlderThanOneYear(t *testing.T) {diff --git a/backend/internal/features/audit_logs/controller.go b/backend/internal/features/audit_logs/controller.goindex e0a641fb..f4961a99 100644--- a/backend/internal/features/audit_logs/controller.go+++ b/backend/internal/features/audit_logs/controller.go@@ -4,10 +4,10 @@ import ("errors""net/http"- user_models "databasus-backend/internal/features/users/models"-"github.com/gin-gonic/gin""github.com/google/uuid"++ user_models "databasus-backend/internal/features/users/models")type AuditLogController struct {diff --git a/backend/internal/features/audit_logs/controller_test.go b/backend/internal/features/audit_logs/controller_test.goindex d1fc228c..89a0a103 100644--- a/backend/internal/features/audit_logs/controller_test.go+++ b/backend/internal/features/audit_logs/controller_test.go@@ -6,15 +6,15 @@ import ("testing""time"+ "github.com/gin-gonic/gin"+ "github.com/google/uuid"+ "github.com/stretchr/testify/assert"+user_enums "databasus-backend/internal/features/users/enums"users_middleware "databasus-backend/internal/features/users/middleware"users_services "databasus-backend/internal/features/users/services"users_testing "databasus-backend/internal/features/users/testing"test_utils "databasus-backend/internal/util/testing"-- "github.com/gin-gonic/gin"- "github.com/google/uuid"- "github.com/stretchr/testify/assert")func Test_GetGlobalAuditLogs_WithDifferentUserRoles_EnforcesPermissionsCorrectly(t *testing.T) {diff --git a/backend/internal/features/audit_logs/di.go b/backend/internal/features/audit_logs/di.goindex 135945d5..9264780a 100644--- a/backend/internal/features/audit_logs/di.go+++ b/backend/internal/features/audit_logs/di.go@@ -8,14 +8,18 @@ import ("databasus-backend/internal/util/logger")-var auditLogRepository = &AuditLogRepository{}-var auditLogService = &AuditLogService{- auditLogRepository,- logger.GetLogger(),-}+var (+ auditLogRepository = &AuditLogRepository{}+ auditLogService = &AuditLogService{+ auditLogRepository,+ logger.GetLogger(),+ }+)+var auditLogController = &AuditLogController{auditLogService,}+var auditLogBackgroundService = &AuditLogBackgroundService{auditLogService: auditLogService,logger: logger.GetLogger(),diff --git a/backend/internal/features/audit_logs/repository.go b/backend/internal/features/audit_logs/repository.goindex 9823519a..d6264c8e 100644--- a/backend/internal/features/audit_logs/repository.go+++ b/backend/internal/features/audit_logs/repository.go@@ -1,10 +1,11 @@package audit_logsimport (- "databasus-backend/internal/storage""time""github.com/google/uuid"++ "databasus-backend/internal/storage")type AuditLogRepository struct{}@@ -21,7 +22,7 @@ func (r *AuditLogRepository) GetGlobal(limit, offset int,beforeDate *time.Time,) ([]*AuditLogDTO, error) {- var auditLogs = make([]*AuditLogDTO, 0)+ auditLogs := make([]*AuditLogDTO, 0)sql := `SELECT@@ -57,7 +58,7 @@ func (r *AuditLogRepository) GetByUser(limit, offset int,beforeDate *time.Time,) ([]*AuditLogDTO, error) {- var auditLogs = make([]*AuditLogDTO, 0)+ auditLogs := make([]*AuditLogDTO, 0)sql := `SELECT@@ -94,7 +95,7 @@ func (r *AuditLogRepository) GetByWorkspace(limit, offset int,beforeDate *time.Time,) ([]*AuditLogDTO, error) {- var auditLogs = make([]*AuditLogDTO, 0)+ auditLogs := make([]*AuditLogDTO, 0)sql := `SELECTdiff --git a/backend/internal/features/audit_logs/service.go b/backend/internal/features/audit_logs/service.goindex 39e6bc7d..87df9f95 100644--- a/backend/internal/features/audit_logs/service.go+++ b/backend/internal/features/audit_logs/service.go@@ -4,10 +4,10 @@ import ("log/slog""time"+ "github.com/google/uuid"+user_enums "databasus-backend/internal/features/users/enums"user_models "databasus-backend/internal/features/users/models"-- "github.com/google/uuid")type AuditLogService struct {diff --git a/backend/internal/features/audit_logs/service_test.go b/backend/internal/features/audit_logs/service_test.goindex c2874d75..764f48c8 100644--- a/backend/internal/features/audit_logs/service_test.go+++ b/backend/internal/features/audit_logs/service_test.go@@ -4,11 +4,11 @@ import ("testing""time"- user_enums "databasus-backend/internal/features/users/enums"- users_testing "databasus-backend/internal/features/users/testing"-"github.com/google/uuid""github.com/stretchr/testify/assert"++ user_enums "databasus-backend/internal/features/users/enums"+ users_testing "databasus-backend/internal/features/users/testing")func Test_AuditLogs_WorkspaceSpecificLogs(t *testing.T) {diff --git a/backend/internal/features/backups/backups/backuping/backuper_test.go b/backend/internal/features/backups/backups/backuping/backuper_test.goindex 45b9ed6f..eb1c470f 100644--- a/backend/internal/features/backups/backups/backuping/backuper_test.go+++ b/backend/internal/features/backups/backups/backuping/backuper_test.go@@ -5,6 +5,9 @@ import ("testing""time"+ "github.com/stretchr/testify/assert"+ "github.com/stretchr/testify/mock"+backups_core "databasus-backend/internal/features/backups/backups/core"backups_config "databasus-backend/internal/features/backups/config""databasus-backend/internal/features/databases"@@ -14,9 +17,6 @@ import (users_testing "databasus-backend/internal/features/users/testing"workspaces_testing "databasus-backend/internal/features/workspaces/testing"cache_utils "databasus-backend/internal/util/cache"-- "github.com/stretchr/testify/assert"- "github.com/stretchr/testify/mock")func Test_BackupExecuted_NotificationSent(t *testing.T) {diff --git a/backend/internal/features/backups/backups/backuping/cleaner_gfs_test.go b/backend/internal/features/backups/backups/backuping/cleaner_gfs_test.goindex 551db5c5..995a72ae 100644--- a/backend/internal/features/backups/backups/backuping/cleaner_gfs_test.go+++ b/backend/internal/features/backups/backups/backuping/cleaner_gfs_test.go@@ -5,6 +5,9 @@ import ("testing""time"+ "github.com/google/uuid"+ "github.com/stretchr/testify/assert"+backups_core "databasus-backend/internal/features/backups/backups/core"backups_config "databasus-backend/internal/features/backups/config""databasus-backend/internal/features/databases"@@ -13,9 +16,6 @@ import (users_enums "databasus-backend/internal/features/users/enums"users_testing "databasus-backend/internal/features/users/testing"workspaces_testing "databasus-backend/internal/features/workspaces/testing"-- "github.com/google/uuid"- "github.com/stretchr/testify/assert")func Test_BuildGFSKeepSet(t *testing.T) {diff --git a/backend/internal/features/backups/backups/backuping/cleaner_test.go b/backend/internal/features/backups/backups/backuping/cleaner_test.goindex bb8bc0e6..c8995dd8 100644--- a/backend/internal/features/backups/backups/backuping/cleaner_test.go+++ b/backend/internal/features/backups/backups/backuping/cleaner_test.go@@ -4,6 +4,9 @@ import ("testing""time"+ "github.com/google/uuid"+ "github.com/stretchr/testify/assert"+backups_core "databasus-backend/internal/features/backups/backups/core"backups_config "databasus-backend/internal/features/backups/config""databasus-backend/internal/features/databases"@@ -15,9 +18,6 @@ import (workspaces_testing "databasus-backend/internal/features/workspaces/testing""databasus-backend/internal/storage""databasus-backend/internal/util/period"-- "github.com/google/uuid"- "github.com/stretchr/testify/assert")func Test_CleanOldBackups_DeletesBackupsOlderThanRetentionTimePeriod(t *testing.T) {diff --git a/backend/internal/features/backups/backups/backuping/mocks.go b/backend/internal/features/backups/backups/backuping/mocks.goindex 83065e11..e453ce31 100644--- a/backend/internal/features/backups/backups/backuping/mocks.go+++ b/backend/internal/features/backups/backups/backuping/mocks.go@@ -6,15 +6,15 @@ import ("sync/atomic""time"+ "github.com/google/uuid"+ "github.com/stretchr/testify/mock"+common "databasus-backend/internal/features/backups/backups/common"backups_core "databasus-backend/internal/features/backups/backups/core"backups_config "databasus-backend/internal/features/backups/config""databasus-backend/internal/features/databases""databasus-backend/internal/features/notifiers""databasus-backend/internal/features/storages"-- "github.com/google/uuid"- "github.com/stretchr/testify/mock")type MockNotificationSender struct {diff --git a/backend/internal/features/backups/backups/backuping/registry.go b/backend/internal/features/backups/backups/backuping/registry.goindex 69afe38c..415d41d4 100644--- a/backend/internal/features/backups/backups/backuping/registry.go+++ b/backend/internal/features/backups/backups/backuping/registry.go@@ -10,10 +10,10 @@ import ("sync/atomic""time"- cache_utils "databasus-backend/internal/util/cache"-"github.com/google/uuid""github.com/valkey-io/valkey-go"++ cache_utils "databasus-backend/internal/util/cache")const (@@ -415,7 +415,7 @@ func (r *BackupNodesRegistry) UnsubscribeNodeForBackupsAssignments() error {return nil}-func (r *BackupNodesRegistry) PublishBackupCompletion(nodeID uuid.UUID, backupID uuid.UUID) error {+func (r *BackupNodesRegistry) PublishBackupCompletion(nodeID, backupID uuid.UUID) error {ctx := context.Background()message := BackupCompletionMessage{@@ -437,7 +437,7 @@ func (r *BackupNodesRegistry) PublishBackupCompletion(nodeID uuid.UUID, backupID}func (r *BackupNodesRegistry) SubscribeForBackupsCompletions(- handler func(nodeID uuid.UUID, backupID uuid.UUID),+ handler func(nodeID, backupID uuid.UUID),) error {ctx := context.Background()diff --git a/backend/internal/features/backups/backups/backuping/registry_test.go b/backend/internal/features/backups/backups/backuping/registry_test.goindex cefd9959..3c614fd1 100644--- a/backend/internal/features/backups/backups/backuping/registry_test.go+++ b/backend/internal/features/backups/backups/backuping/registry_test.go@@ -9,11 +9,11 @@ import ("testing""time"- cache_utils "databasus-backend/internal/util/cache"- "databasus-backend/internal/util/logger"-"github.com/google/uuid""github.com/stretchr/testify/assert"++ cache_utils "databasus-backend/internal/util/cache"+ "databasus-backend/internal/util/logger")func Test_HearthbeatNodeInRegistry_RegistersNodeWithTTL(t *testing.T) {@@ -903,7 +903,7 @@ func Test_SubscribeForBackupsCompletions_ReceivesCompletedBackups(t *testing.T)receivedBackupID := make(chan uuid.UUID, 1)receivedNodeID := make(chan uuid.UUID, 1)- handler := func(nodeID uuid.UUID, backupID uuid.UUID) {+ handler := func(nodeID, backupID uuid.UUID) {receivedNodeID <- nodeIDreceivedBackupID <- backupID}@@ -940,7 +940,7 @@ func Test_SubscribeForBackupsCompletions_ParsesJsonCorrectly(t *testing.T) {defer registry.UnsubscribeForBackupsCompletions()receivedBackups := make(chan uuid.UUID, 2)- handler := func(nodeID uuid.UUID, backupID uuid.UUID) {+ handler := func(nodeID, backupID uuid.UUID) {receivedBackups <- backupID}@@ -969,7 +969,7 @@ func Test_SubscribeForBackupsCompletions_HandlesInvalidJson(t *testing.T) {defer registry.UnsubscribeForBackupsCompletions()receivedBackupID := make(chan uuid.UUID, 1)- handler := func(nodeID uuid.UUID, backupID uuid.UUID) {+ handler := func(nodeID, backupID uuid.UUID) {receivedBackupID <- backupID}@@ -997,7 +997,7 @@ func Test_UnsubscribeForBackupsCompletions_StopsReceivingMessages(t *testing.T)backupID2 := uuid.New()receivedBackupID := make(chan uuid.UUID, 2)- handler := func(nodeID uuid.UUID, backupID uuid.UUID) {+ handler := func(nodeID, backupID uuid.UUID) {receivedBackupID <- backupID}@@ -1032,7 +1032,7 @@ func Test_SubscribeForBackupsCompletions_WhenAlreadySubscribed_ReturnsError(t *tregistry := createTestRegistry()defer registry.UnsubscribeForBackupsCompletions()- handler := func(nodeID uuid.UUID, backupID uuid.UUID) {}+ handler := func(nodeID, backupID uuid.UUID) {}err := registry.SubscribeForBackupsCompletions(handler)assert.NoError(t, err)@@ -1064,9 +1064,9 @@ func Test_MultipleSubscribers_EachReceivesCompletionMessages(t *testing.T) {receivedBackups2 := make(chan uuid.UUID, 3)receivedBackups3 := make(chan uuid.UUID, 3)- handler1 := func(nodeID uuid.UUID, backupID uuid.UUID) { receivedBackups1 <- backupID }- handler2 := func(nodeID uuid.UUID, backupID uuid.UUID) { receivedBackups2 <- backupID }- handler3 := func(nodeID uuid.UUID, backupID uuid.UUID) { receivedBackups3 <- backupID }+ handler1 := func(nodeID, backupID uuid.UUID) { receivedBackups1 <- backupID }+ handler2 := func(nodeID, backupID uuid.UUID) { receivedBackups2 <- backupID }+ handler3 := func(nodeID, backupID uuid.UUID) { receivedBackups3 <- backupID }err := registry1.SubscribeForBackupsCompletions(handler1)assert.NoError(t, err)diff --git a/backend/internal/features/backups/backups/backuping/scheduler.go b/backend/internal/features/backups/backups/backuping/scheduler.goindex 9113609c..4e032c9c 100644--- a/backend/internal/features/backups/backups/backuping/scheduler.go+++ b/backend/internal/features/backups/backups/backuping/scheduler.go@@ -441,7 +441,7 @@ func (s *BackupsScheduler) calculateLeastBusyNode() (*uuid.UUID, error) {return &bestNode.ID, nil}-func (s *BackupsScheduler) onBackupCompleted(nodeID uuid.UUID, backupID uuid.UUID) {+func (s *BackupsScheduler) onBackupCompleted(nodeID, backupID uuid.UUID) {// Verify this task is actually a backup (registry contains multiple task types)_, err := s.backupRepository.FindByID(backupID)if err != nil {diff --git a/backend/internal/features/backups/backups/backuping/scheduler_test.go b/backend/internal/features/backups/backups/backuping/scheduler_test.goindex e3a36dd8..75bc16d5 100644--- a/backend/internal/features/backups/backups/backuping/scheduler_test.go+++ b/backend/internal/features/backups/backups/backuping/scheduler_test.go@@ -1,6 +1,12 @@package backupingimport (+ "testing"+ "time"++ "github.com/google/uuid"+ "github.com/stretchr/testify/assert"+backups_core "databasus-backend/internal/features/backups/backups/core"backups_config "databasus-backend/internal/features/backups/config""databasus-backend/internal/features/databases"@@ -12,11 +18,6 @@ import (workspaces_testing "databasus-backend/internal/features/workspaces/testing"cache_utils "databasus-backend/internal/util/cache""databasus-backend/internal/util/period"- "testing"- "time"-- "github.com/google/uuid"- "github.com/stretchr/testify/assert")func Test_RunPendingBackups_WhenLastBackupWasYesterday_CreatesNewBackup(t *testing.T) {diff --git a/backend/internal/features/backups/backups/backuping/testing.go b/backend/internal/features/backups/backups/backuping/testing.goindex e98be605..edd816ca 100644--- a/backend/internal/features/backups/backups/backuping/testing.go+++ b/backend/internal/features/backups/backups/backuping/testing.go@@ -8,6 +8,9 @@ import ("testing""time"+ "github.com/gin-gonic/gin"+ "github.com/google/uuid"+backups_core "databasus-backend/internal/features/backups/backups/core""databasus-backend/internal/features/backups/backups/usecases"backups_config "databasus-backend/internal/features/backups/config"@@ -19,9 +22,6 @@ import (workspaces_testing "databasus-backend/internal/features/workspaces/testing""databasus-backend/internal/util/encryption""databasus-backend/internal/util/logger"-- "github.com/gin-gonic/gin"- "github.com/google/uuid")func CreateTestRouter() *gin.Engine {diff --git a/backend/internal/features/backups/backups/common/dto.go b/backend/internal/features/backups/backups/common/dto.goindex b453622b..a0782cad 100644--- a/backend/internal/features/backups/backups/common/dto.go+++ b/backend/internal/features/backups/backups/common/dto.go@@ -1,10 +1,11 @@package commonimport (- backups_config "databasus-backend/internal/features/backups/config""errors""github.com/google/uuid"++ backups_config "databasus-backend/internal/features/backups/config")type BackupMetadata struct {diff --git a/backend/internal/features/backups/backups/controllers/controller.go b/backend/internal/features/backups/backups/controllers/controller.goindex 8530816e..2e7d9d20 100644--- a/backend/internal/features/backups/backups/controllers/controller.go+++ b/backend/internal/features/backups/backups/controllers/controller.go@@ -2,13 +2,6 @@ package backups_controllersimport ("context"- backups_core "databasus-backend/internal/features/backups/backups/core"- backups_download "databasus-backend/internal/features/backups/backups/download"- backups_dto "databasus-backend/internal/features/backups/backups/dto"- backups_services "databasus-backend/internal/features/backups/backups/services"- "databasus-backend/internal/features/databases"- users_middleware "databasus-backend/internal/features/users/middleware"- files_utils "databasus-backend/internal/util/files""fmt""io""net/http"@@ -16,6 +9,14 @@ import ("github.com/gin-gonic/gin""github.com/google/uuid"++ backups_core "databasus-backend/internal/features/backups/backups/core"+ backups_download "databasus-backend/internal/features/backups/backups/download"+ backups_dto "databasus-backend/internal/features/backups/backups/dto"+ backups_services "databasus-backend/internal/features/backups/backups/services"+ "databasus-backend/internal/features/databases"+ users_middleware "databasus-backend/internal/features/users/middleware"+ files_utils "databasus-backend/internal/util/files")type BackupController struct {diff --git a/backend/internal/features/backups/backups/controllers/postgres_wal_controller.go b/backend/internal/features/backups/backups/controllers/postgres_wal_controller.goindex 4de5c532..d14706d9 100644--- a/backend/internal/features/backups/backups/controllers/postgres_wal_controller.go+++ b/backend/internal/features/backups/backups/controllers/postgres_wal_controller.go@@ -5,13 +5,13 @@ import ("net/http""strconv"+ "github.com/gin-gonic/gin"+ "github.com/google/uuid"+backups_core "databasus-backend/internal/features/backups/backups/core"backups_dto "databasus-backend/internal/features/backups/backups/dto"backups_services "databasus-backend/internal/features/backups/backups/services""databasus-backend/internal/features/databases"-- "github.com/gin-gonic/gin"- "github.com/google/uuid")// PostgreWalBackupController handles WAL backup endpoints used by the databasus-cli agent.diff --git a/backend/internal/features/backups/backups/controllers/postgres_wal_controller_test.go b/backend/internal/features/backups/backups/controllers/postgres_wal_controller_test.goindex da77d401..15764c93 100644--- a/backend/internal/features/backups/backups/controllers/postgres_wal_controller_test.go+++ b/backend/internal/features/backups/backups/controllers/postgres_wal_controller_test.go@@ -10,6 +10,11 @@ import ("testing""time"+ "github.com/gin-gonic/gin"+ "github.com/google/uuid"+ "github.com/stretchr/testify/assert"+ "github.com/stretchr/testify/require"+backups_core "databasus-backend/internal/features/backups/backups/core"backups_dto "databasus-backend/internal/features/backups/backups/dto"backups_config "databasus-backend/internal/features/backups/config"@@ -23,11 +28,6 @@ import (workspaces_controllers "databasus-backend/internal/features/workspaces/controllers"workspaces_testing "databasus-backend/internal/features/workspaces/testing"test_utils "databasus-backend/internal/util/testing"-- "github.com/gin-gonic/gin"- "github.com/google/uuid"- "github.com/stretchr/testify/assert"- "github.com/stretchr/testify/require")func Test_WalUpload_InProgressStatusSetBeforeStream(t *testing.T) {diff --git a/backend/internal/features/backups/backups/controllers/testing.go b/backend/internal/features/backups/backups/controllers/testing.goindex 71fa33db..25d2c854 100644--- a/backend/internal/features/backups/backups/controllers/testing.go+++ b/backend/internal/features/backups/backups/controllers/testing.go@@ -4,14 +4,14 @@ import ("testing""time"+ "github.com/gin-gonic/gin"+ "github.com/google/uuid"+backups_core "databasus-backend/internal/features/backups/backups/core"backups_config "databasus-backend/internal/features/backups/config""databasus-backend/internal/features/databases"workspaces_controllers "databasus-backend/internal/features/workspaces/controllers"workspaces_testing "databasus-backend/internal/features/workspaces/testing"-- "github.com/gin-gonic/gin"- "github.com/google/uuid")func CreateTestRouter() *gin.Engine {diff --git a/backend/internal/features/backups/backups/core/model.go b/backend/internal/features/backups/backups/core/model.goindex cd8e2141..9a4123aa 100644--- a/backend/internal/features/backups/backups/core/model.go+++ b/backend/internal/features/backups/backups/core/model.go@@ -4,10 +4,10 @@ import ("fmt""time"+ "github.com/google/uuid"+backups_config "databasus-backend/internal/features/backups/config"files_utils "databasus-backend/internal/util/files"-- "github.com/google/uuid")type PgWalBackupType stringdiff --git a/backend/internal/features/backups/backups/core/repository.go b/backend/internal/features/backups/backups/core/repository.goindex a1c82476..da506d2e 100644--- a/backend/internal/features/backups/backups/core/repository.go+++ b/backend/internal/features/backups/backups/core/repository.go@@ -1,13 +1,13 @@package backups_coreimport (- "databasus-backend/internal/storage""errors"-"time""github.com/google/uuid""gorm.io/gorm"++ "databasus-backend/internal/storage")type BackupRepository struct{}diff --git a/backend/internal/features/backups/backups/download/di.go b/backend/internal/features/backups/backups/download/di.goindex 5181ef10..80c72b6e 100644--- a/backend/internal/features/backups/backups/download/di.go+++ b/backend/internal/features/backups/backups/download/di.go@@ -13,9 +13,11 @@ var downloadTokenRepository = &DownloadTokenRepository{}var downloadTracker = NewDownloadTracker(cache_utils.GetValkeyClient())-var bandwidthManager *BandwidthManager-var downloadTokenService *DownloadTokenService-var downloadTokenBackgroundService *DownloadTokenBackgroundService+var (+ bandwidthManager *BandwidthManager+ downloadTokenService *DownloadTokenService+ downloadTokenBackgroundService *DownloadTokenBackgroundService+)func init() {env := config.GetEnv()diff --git a/backend/internal/features/backups/backups/download/repository.go b/backend/internal/features/backups/backups/download/repository.goindex 359846f4..c1e5707d 100644--- a/backend/internal/features/backups/backups/download/repository.go+++ b/backend/internal/features/backups/backups/download/repository.go@@ -2,12 +2,13 @@ package backups_downloadimport ("crypto/rand"- "databasus-backend/internal/storage""encoding/base64""time""github.com/google/uuid""gorm.io/gorm"++ "databasus-backend/internal/storage")type DownloadTokenRepository struct{}@@ -28,7 +29,6 @@ func (r *DownloadTokenRepository) FindByToken(token string) (*DownloadToken, errerr := storage.GetDb().Where("token = ?", token).First(&downloadToken).Error-if err != nil {if err == gorm.ErrRecordNotFound {return nil, nildiff --git a/backend/internal/features/backups/backups/download/tracking.go b/backend/internal/features/backups/backups/download/tracking.goindex 64fc6eb4..a14ca31c 100644--- a/backend/internal/features/backups/backups/download/tracking.go+++ b/backend/internal/features/backups/backups/download/tracking.go@@ -1,12 +1,13 @@package backups_downloadimport (- cache_utils "databasus-backend/internal/util/cache""errors""time""github.com/google/uuid""github.com/valkey-io/valkey-go"++ cache_utils "databasus-backend/internal/util/cache")const (@@ -16,9 +17,7 @@ const (downloadHeartbeatDelay = 3 * time.Second)-var (- ErrDownloadAlreadyInProgress = errors.New("download already in progress for this user")-)+var ErrDownloadAlreadyInProgress = errors.New("download already in progress for this user")type DownloadTracker struct {cache *cache_utils.CacheUtil[string]diff --git a/backend/internal/features/backups/backups/dto/dto.go b/backend/internal/features/backups/backups/dto/dto.goindex f6813d39..805c646c 100644--- a/backend/internal/features/backups/backups/dto/dto.go+++ b/backend/internal/features/backups/backups/dto/dto.go@@ -1,12 +1,13 @@package backups_dtoimport (- backups_core "databasus-backend/internal/features/backups/backups/core"- "databasus-backend/internal/features/backups/backups/encryption""io""time""github.com/google/uuid"++ backups_core "databasus-backend/internal/features/backups/backups/core"+ "databasus-backend/internal/features/backups/backups/encryption")type GetBackupsRequest struct {diff --git a/backend/internal/features/backups/backups/services/di.go b/backend/internal/features/backups/backups/services/di.goindex 2613f393..a0b5cfca 100644--- a/backend/internal/features/backups/backups/services/di.go+++ b/backend/internal/features/backups/backups/services/di.go@@ -1,6 +1,9 @@package backups_servicesimport (+ "sync"+ "sync/atomic"+audit_logs "databasus-backend/internal/features/audit_logs""databasus-backend/internal/features/backups/backups/backuping"backups_core "databasus-backend/internal/features/backups/backups/core"@@ -15,8 +18,6 @@ import (workspaces_services "databasus-backend/internal/features/workspaces/services""databasus-backend/internal/util/encryption""databasus-backend/internal/util/logger"- "sync"- "sync/atomic")var taskCancelManager = task_cancellation.GetTaskCancelManager()diff --git a/backend/internal/features/backups/backups/services/postgres_wal_service.go b/backend/internal/features/backups/backups/services/postgres_wal_service.goindex b9062547..7e3bba17 100644--- a/backend/internal/features/backups/backups/services/postgres_wal_service.go+++ b/backend/internal/features/backups/backups/services/postgres_wal_service.go@@ -7,6 +7,8 @@ import ("log/slog""time"+ "github.com/google/uuid"+backups_core "databasus-backend/internal/features/backups/backups/core"backups_dto "databasus-backend/internal/features/backups/backups/dto"backup_encryption "databasus-backend/internal/features/backups/backups/encryption"@@ -16,8 +18,6 @@ import (encryption_secrets "databasus-backend/internal/features/encryption/secrets"util_encryption "databasus-backend/internal/util/encryption"util_wal "databasus-backend/internal/util/wal"-- "github.com/google/uuid")// PostgreWalBackupService handles WAL segment and basebackup uploads from the databasus-cli agent.@@ -609,5 +609,5 @@ func (cr *countingReader) Read(p []byte) (n int, err error) {n, err = cr.r.Read(p)cr.n += int64(n)- return+ return n, err}diff --git a/backend/internal/features/backups/backups/services/service.go b/backend/internal/features/backups/backups/services/service.goindex 1cd738e9..026999ff 100644--- a/backend/internal/features/backups/backups/services/service.go+++ b/backend/internal/features/backups/backups/services/service.go@@ -7,6 +7,8 @@ import ("io""log/slog"+ "github.com/google/uuid"+audit_logs "databasus-backend/internal/features/audit_logs""databasus-backend/internal/features/backups/backups/backuping"backups_core "databasus-backend/internal/features/backups/backups/core"@@ -23,8 +25,6 @@ import (workspaces_services "databasus-backend/internal/features/workspaces/services"util_encryption "databasus-backend/internal/util/encryption"files_utils "databasus-backend/internal/util/files"-- "github.com/google/uuid")type BackupService struct {diff --git a/backend/internal/features/backups/backups/usecases/mariadb/create_backup_uc.go b/backend/internal/features/backups/backups/usecases/mariadb/create_backup_uc.goindex 09ba1781..d36ddd11 100644--- a/backend/internal/features/backups/backups/usecases/mariadb/create_backup_uc.go+++ b/backend/internal/features/backups/backups/usecases/mariadb/create_backup_uc.go@@ -279,10 +279,10 @@ func (uc *CreateMariadbBackupUsecase) createTempMyCnfFile(password string,) (string, error) {tempFolder := config.GetEnv().TempFolder- if err := os.MkdirAll(tempFolder, 0700); err != nil {+ if err := os.MkdirAll(tempFolder, 0o700); err != nil {return "", fmt.Errorf("failed to ensure temp folder exists: %w", err)}- if err := os.Chmod(tempFolder, 0700); err != nil {+ if err := os.Chmod(tempFolder, 0o700); err != nil {return "", fmt.Errorf("failed to set temp folder permissions: %w", err)}@@ -291,7 +291,7 @@ func (uc *CreateMariadbBackupUsecase) createTempMyCnfFile(return "", fmt.Errorf("failed to create temp directory: %w", err)}- if err := os.Chmod(tempDir, 0700); err != nil {+ if err := os.Chmod(tempDir, 0o700); err != nil {_ = os.RemoveAll(tempDir)return "", fmt.Errorf("failed to set temp directory permissions: %w", err)}@@ -311,7 +311,7 @@ port=%dcontent += "ssl=false\n"}- err = os.WriteFile(myCnfFile, []byte(content), 0600)+ err = os.WriteFile(myCnfFile, []byte(content), 0o600)if err != nil {_ = os.RemoveAll(tempDir)return "", fmt.Errorf("failed to write .my.cnf: %w", err)diff --git a/backend/internal/features/backups/backups/usecases/mysql/create_backup_uc.go b/backend/internal/features/backups/backups/usecases/mysql/create_backup_uc.goindex f7295038..083fac9f 100644--- a/backend/internal/features/backups/backups/usecases/mysql/create_backup_uc.go+++ b/backend/internal/features/backups/backups/usecases/mysql/create_backup_uc.go@@ -298,10 +298,10 @@ func (uc *CreateMysqlBackupUsecase) createTempMyCnfFile(password string,) (string, error) {tempFolder := config.GetEnv().TempFolder- if err := os.MkdirAll(tempFolder, 0700); err != nil {+ if err := os.MkdirAll(tempFolder, 0o700); err != nil {return "", fmt.Errorf("failed to ensure temp folder exists: %w", err)}- if err := os.Chmod(tempFolder, 0700); err != nil {+ if err := os.Chmod(tempFolder, 0o700); err != nil {return "", fmt.Errorf("failed to set temp folder permissions: %w", err)}@@ -310,7 +310,7 @@ func (uc *CreateMysqlBackupUsecase) createTempMyCnfFile(return "", fmt.Errorf("failed to create temp directory: %w", err)}- if err := os.Chmod(tempDir, 0700); err != nil {+ if err := os.Chmod(tempDir, 0o700); err != nil {_ = os.RemoveAll(tempDir)return "", fmt.Errorf("failed to set temp directory permissions: %w", err)}@@ -328,7 +328,7 @@ port=%dcontent += "ssl-mode=REQUIRED\n"}- err = os.WriteFile(myCnfFile, []byte(content), 0600)+ err = os.WriteFile(myCnfFile, []byte(content), 0o600)if err != nil {_ = os.RemoveAll(tempDir)return "", fmt.Errorf("failed to write .my.cnf: %w", err)diff --git a/backend/internal/features/backups/backups/usecases/postgresql/create_backup_uc.go b/backend/internal/features/backups/backups/usecases/postgresql/create_backup_uc.goindex b6564781..df0400e0 100644--- a/backend/internal/features/backups/backups/usecases/postgresql/create_backup_uc.go+++ b/backend/internal/features/backups/backups/usecases/postgresql/create_backup_uc.go@@ -13,6 +13,8 @@ import ("strings""time"+ "github.com/google/uuid"+"databasus-backend/internal/config"common "databasus-backend/internal/features/backups/backups/common"backups_core "databasus-backend/internal/features/backups/backups/core"@@ -24,8 +26,6 @@ import ("databasus-backend/internal/features/storages""databasus-backend/internal/util/encryption""databasus-backend/internal/util/tools"-- "github.com/google/uuid")const (@@ -748,10 +748,10 @@ func (uc *CreatePostgresqlBackupUsecase) createTempPgpassFile()tempFolder := config.GetEnv().TempFolder- if err := os.MkdirAll(tempFolder, 0700); err != nil {+ if err := os.MkdirAll(tempFolder, 0o700); err != nil {return "", fmt.Errorf("failed to ensure temp folder exists: %w", err)}- if err := os.Chmod(tempFolder, 0700); err != nil {+ if err := os.Chmod(tempFolder, 0o700); err != nil {return "", fmt.Errorf("failed to set temp folder permissions: %w", err)}@@ -760,13 +760,13 @@ func (uc *CreatePostgresqlBackupUsecase) createTempPgpassFile(return "", fmt.Errorf("failed to create temporary directory: %w", err)}- if err := os.Chmod(tempDir, 0700); err != nil {+ if err := os.Chmod(tempDir, 0o700); err != nil {_ = os.RemoveAll(tempDir)return "", fmt.Errorf("failed to set temporary directory permissions: %w", err)}pgpassFile := filepath.Join(tempDir, ".pgpass")- err = os.WriteFile(pgpassFile, []byte(pgpassContent), 0600)+ err = os.WriteFile(pgpassFile, []byte(pgpassContent), 0o600)if err != nil {_ = os.RemoveAll(tempDir)return "", fmt.Errorf("failed to write temporary .pgpass file: %w", err)diff --git a/backend/internal/features/backups/config/controller.go b/backend/internal/features/backups/config/controller.goindex 8c82be28..943f1fd0 100644--- a/backend/internal/features/backups/config/controller.go+++ b/backend/internal/features/backups/config/controller.go@@ -4,10 +4,10 @@ import ("errors""net/http"- users_middleware "databasus-backend/internal/features/users/middleware"-"github.com/gin-gonic/gin""github.com/google/uuid"++ users_middleware "databasus-backend/internal/features/users/middleware")type BackupConfigController struct {diff --git a/backend/internal/features/backups/config/di.go b/backend/internal/features/backups/config/di.goindex 822a76f0..5ffc266b 100644--- a/backend/internal/features/backups/config/di.go+++ b/backend/internal/features/backups/config/di.go@@ -12,16 +12,19 @@ import ("databasus-backend/internal/util/logger")-var backupConfigRepository = &BackupConfigRepository{}-var backupConfigService = &BackupConfigService{- backupConfigRepository,- databases.GetDatabaseService(),- storages.GetStorageService(),- notifiers.GetNotifierService(),- workspaces_services.GetWorkspaceService(),- plans.GetDatabasePlanService(),- nil,-}+var (+ backupConfigRepository = &BackupConfigRepository{}+ backupConfigService = &BackupConfigService{+ backupConfigRepository,+ databases.GetDatabaseService(),+ storages.GetStorageService(),+ notifiers.GetNotifierService(),+ workspaces_services.GetWorkspaceService(),+ plans.GetDatabasePlanService(),+ nil,+ }+)+var backupConfigController = &BackupConfigController{backupConfigService,}diff --git a/backend/internal/features/backups/config/model.go b/backend/internal/features/backups/config/model.goindex d0f04308..ade396b3 100644--- a/backend/internal/features/backups/config/model.go+++ b/backend/internal/features/backups/config/model.go@@ -1,16 +1,17 @@package backups_configimport (- "databasus-backend/internal/config"- "databasus-backend/internal/features/intervals"- plans "databasus-backend/internal/features/plan"- "databasus-backend/internal/features/storages"- "databasus-backend/internal/util/period""errors""strings""github.com/google/uuid""gorm.io/gorm"++ "databasus-backend/internal/config"+ "databasus-backend/internal/features/intervals"+ plans "databasus-backend/internal/features/plan"+ "databasus-backend/internal/features/storages"+ "databasus-backend/internal/util/period")type BackupConfig struct {diff --git a/backend/internal/features/backups/config/model_test.go b/backend/internal/features/backups/config/model_test.goindex 90c6cff1..6d18fbaa 100644--- a/backend/internal/features/backups/config/model_test.go+++ b/backend/internal/features/backups/config/model_test.go@@ -3,12 +3,12 @@ package backups_configimport ("testing"+ "github.com/google/uuid"+ "github.com/stretchr/testify/assert"+"databasus-backend/internal/features/intervals"plans "databasus-backend/internal/features/plan""databasus-backend/internal/util/period"-- "github.com/google/uuid"- "github.com/stretchr/testify/assert")func Test_Validate_WhenRetentionTimePeriodIsWeekAndPlanAllowsMonth_ValidationPasses(t *testing.T) {diff --git a/backend/internal/features/backups/config/repository.go b/backend/internal/features/backups/config/repository.goindex 2de68b40..7c31d578 100644--- a/backend/internal/features/backups/config/repository.go+++ b/backend/internal/features/backups/config/repository.go@@ -1,11 +1,12 @@package backups_configimport (- "databasus-backend/internal/storage""errors""github.com/google/uuid""gorm.io/gorm"++ "databasus-backend/internal/storage")type BackupConfigRepository struct{}@@ -47,7 +48,6 @@ func (r *BackupConfigRepository) Save(return nil})-if err != nil {return nil, err}diff --git a/backend/internal/features/backups/config/service.go b/backend/internal/features/backups/config/service.goindex 090c10c0..61a0493e 100644--- a/backend/internal/features/backups/config/service.go+++ b/backend/internal/features/backups/config/service.go@@ -3,6 +3,8 @@ package backups_configimport ("errors"+ "github.com/google/uuid"+"databasus-backend/internal/features/databases""databasus-backend/internal/features/intervals""databasus-backend/internal/features/notifiers"@@ -10,8 +12,6 @@ import ("databasus-backend/internal/features/storages"users_models "databasus-backend/internal/features/users/models"workspaces_services "databasus-backend/internal/features/workspaces/services"-- "github.com/google/uuid")type BackupConfigService struct {diff --git a/backend/internal/features/backups/config/testing.go b/backend/internal/features/backups/config/testing.goindex 208b2ee1..0e02bb89 100644--- a/backend/internal/features/backups/config/testing.go+++ b/backend/internal/features/backups/config/testing.go@@ -1,11 +1,11 @@package backups_configimport (+ "github.com/google/uuid"+"databasus-backend/internal/features/intervals""databasus-backend/internal/features/storages""databasus-backend/internal/util/period"-- "github.com/google/uuid")func EnableBackupsForTestDatabase(diff --git a/backend/internal/features/databases/controller.go b/backend/internal/features/databases/controller.goindex ec11bf8f..16bc9f28 100644--- a/backend/internal/features/databases/controller.go+++ b/backend/internal/features/databases/controller.go@@ -1,13 +1,14 @@package databasesimport (- users_middleware "databasus-backend/internal/features/users/middleware"- users_services "databasus-backend/internal/features/users/services"- workspaces_services "databasus-backend/internal/features/workspaces/services""net/http""github.com/gin-gonic/gin""github.com/google/uuid"++ users_middleware "databasus-backend/internal/features/users/middleware"+ users_services "databasus-backend/internal/features/users/services"+ workspaces_services "databasus-backend/internal/features/workspaces/services")type DatabaseController struct {diff --git a/backend/internal/features/databases/controller_test.go b/backend/internal/features/databases/controller_test.goindex 214cba38..496881ed 100644--- a/backend/internal/features/databases/controller_test.go+++ b/backend/internal/features/databases/controller_test.go@@ -862,7 +862,7 @@ func Test_DatabaseSensitiveDataLifecycle_AllTypes(t *testing.T) {name stringdatabaseType DatabaseTypecreateDatabase func(workspaceID uuid.UUID) *Database- updateDatabase func(workspaceID uuid.UUID, databaseID uuid.UUID) *Database+ updateDatabase func(workspaceID, databaseID uuid.UUID) *DatabaseverifySensitiveData func(t *testing.T, database *Database)verifyHiddenData func(t *testing.T, database *Database)}{@@ -878,7 +878,7 @@ func Test_DatabaseSensitiveDataLifecycle_AllTypes(t *testing.T) {Postgresql: pgConfig,}},- updateDatabase: func(workspaceID uuid.UUID, databaseID uuid.UUID) *Database {+ updateDatabase: func(workspaceID, databaseID uuid.UUID) *Database {pgConfig := getTestPostgresConfig()pgConfig.Password = ""return &Database{@@ -914,7 +914,7 @@ func Test_DatabaseSensitiveDataLifecycle_AllTypes(t *testing.T) {Mariadb: mariaConfig,}},- updateDatabase: func(workspaceID uuid.UUID, databaseID uuid.UUID) *Database {+ updateDatabase: func(workspaceID, databaseID uuid.UUID) *Database {mariaConfig := getTestMariadbConfig()mariaConfig.Password = ""return &Database{@@ -950,7 +950,7 @@ func Test_DatabaseSensitiveDataLifecycle_AllTypes(t *testing.T) {Mongodb: mongoConfig,}},- updateDatabase: func(workspaceID uuid.UUID, databaseID uuid.UUID) *Database {+ updateDatabase: func(workspaceID, databaseID uuid.UUID) *Database {mongoConfig := getTestMongodbConfig()mongoConfig.Password = ""return &Database{diff --git a/backend/internal/features/databases/databases/mariadb/model.go b/backend/internal/features/databases/databases/mariadb/model.goindex 9a97af1c..54baa4ef 100644--- a/backend/internal/features/databases/databases/mariadb/model.go+++ b/backend/internal/features/databases/databases/mariadb/model.go@@ -12,11 +12,11 @@ import ("strings""time"- "databasus-backend/internal/util/encryption"- "databasus-backend/internal/util/tools"-"github.com/go-sql-driver/mysql""github.com/google/uuid"++ "databasus-backend/internal/util/encryption"+ "databasus-backend/internal/util/tools")type MariadbDatabase struct {@@ -399,7 +399,7 @@ func HasPrivilege(privileges, priv string) bool {return false}-func (m *MariadbDatabase) buildDSN(password string, database string) string {+func (m *MariadbDatabase) buildDSN(password, database string) string {tlsConfig := "false"if m.IsHttps {diff --git a/backend/internal/features/databases/databases/mongodb/model.go b/backend/internal/features/databases/databases/mongodb/model.goindex 9d2f06ed..c167ec20 100644--- a/backend/internal/features/databases/databases/mongodb/model.go+++ b/backend/internal/features/databases/databases/mongodb/model.go@@ -10,13 +10,13 @@ import ("strings""time"- "databasus-backend/internal/util/encryption"- "databasus-backend/internal/util/tools"-"github.com/google/uuid""go.mongodb.org/mongo-driver/bson""go.mongodb.org/mongo-driver/mongo""go.mongodb.org/mongo-driver/mongo/options"++ "databasus-backend/internal/util/encryption"+ "databasus-backend/internal/util/tools")type MongodbDatabase struct {@@ -434,7 +434,6 @@ func (m *MongodbDatabase) CreateReadOnlyUser(},}},}).Err()-if err != nil {if attempt < maxRetries-1 {continuediff --git a/backend/internal/features/databases/databases/mysql/model.go b/backend/internal/features/databases/databases/mysql/model.goindex f653443f..92aabb7e 100644--- a/backend/internal/features/databases/databases/mysql/model.go+++ b/backend/internal/features/databases/databases/mysql/model.go@@ -12,11 +12,11 @@ import ("strings""time"- "databasus-backend/internal/util/encryption"- "databasus-backend/internal/util/tools"-"github.com/go-sql-driver/mysql""github.com/google/uuid"++ "databasus-backend/internal/util/encryption"+ "databasus-backend/internal/util/tools")type MysqlDatabase struct {@@ -403,7 +403,7 @@ func HasPrivilege(privileges, priv string) bool {return false}-func (m *MysqlDatabase) buildDSN(password string, database string) string {+func (m *MysqlDatabase) buildDSN(password, database string) string {tlsConfig := "false"allowCleartext := ""diff --git a/backend/internal/features/databases/databases/postgresql/model.go b/backend/internal/features/databases/databases/postgresql/model.goindex 7d8a0ba6..01414e25 100644--- a/backend/internal/features/databases/databases/postgresql/model.go+++ b/backend/internal/features/databases/databases/postgresql/model.go@@ -2,9 +2,6 @@ package postgresqlimport ("context"- "databasus-backend/internal/config"- "databasus-backend/internal/util/encryption"- "databasus-backend/internal/util/tools""errors""fmt""log/slog"@@ -16,6 +13,10 @@ import ("github.com/jackc/pgx/v5""github.com/jackc/pgx/v5/pgconn""gorm.io/gorm"++ "databasus-backend/internal/config"+ "databasus-backend/internal/util/encryption"+ "databasus-backend/internal/util/tools")type PostgresBackupType string@@ -1112,7 +1113,7 @@ func checkBackupPermissions(}// buildConnectionStringForDB builds connection string for specific database-func buildConnectionStringForDB(p *PostgresqlDatabase, dbName string, password string) string {+func buildConnectionStringForDB(p *PostgresqlDatabase, dbName, password string) string {sslMode := "disable"if p.IsHttps {sslMode = "require"diff --git a/backend/internal/features/databases/interfaces.go b/backend/internal/features/databases/interfaces.goindex 3c514f80..48518108 100644--- a/backend/internal/features/databases/interfaces.go+++ b/backend/internal/features/databases/interfaces.go@@ -1,10 +1,11 @@package databasesimport (- "databasus-backend/internal/util/encryption""log/slog""github.com/google/uuid"++ "databasus-backend/internal/util/encryption")type DatabaseValidator interface {diff --git a/backend/internal/features/databases/model.go b/backend/internal/features/databases/model.goindex 7306b591..0107dd70 100644--- a/backend/internal/features/databases/model.go+++ b/backend/internal/features/databases/model.go@@ -2,17 +2,18 @@ package databasesimport ("context"+ "errors"+ "log/slog"+ "time"++ "github.com/google/uuid"+"databasus-backend/internal/features/databases/databases/mariadb""databasus-backend/internal/features/databases/databases/mongodb""databasus-backend/internal/features/databases/databases/mysql""databasus-backend/internal/features/databases/databases/postgresql""databasus-backend/internal/features/notifiers""databasus-backend/internal/util/encryption"- "errors"- "log/slog"- "time"-- "github.com/google/uuid")type Database struct {diff --git a/backend/internal/features/databases/repository.go b/backend/internal/features/databases/repository.goindex 1277c055..92cd2979 100644--- a/backend/internal/features/databases/repository.go+++ b/backend/internal/features/databases/repository.go@@ -1,15 +1,16 @@package databasesimport (+ "errors"++ "github.com/google/uuid"+ "gorm.io/gorm"+"databasus-backend/internal/features/databases/databases/mariadb""databasus-backend/internal/features/databases/databases/mongodb""databasus-backend/internal/features/databases/databases/mysql""databasus-backend/internal/features/databases/databases/postgresql""databasus-backend/internal/storage"- "errors"-- "github.com/google/uuid"- "gorm.io/gorm")type DatabaseRepository struct{}@@ -120,7 +121,6 @@ func (r *DatabaseRepository) Save(database *Database) (*Database, error) {return nil})-if err != nil {return nil, err}diff --git a/backend/internal/features/databases/service.go b/backend/internal/features/databases/service.goindex 6ad99aa5..a21ed605 100644--- a/backend/internal/features/databases/service.go+++ b/backend/internal/features/databases/service.go@@ -9,6 +9,8 @@ import ("strings""time"+ "github.com/google/uuid"+"databasus-backend/internal/config"audit_logs "databasus-backend/internal/features/audit_logs""databasus-backend/internal/features/databases/databases/mariadb"@@ -19,8 +21,6 @@ import (users_models "databasus-backend/internal/features/users/models"workspaces_services "databasus-backend/internal/features/workspaces/services""databasus-backend/internal/util/encryption"-- "github.com/google/uuid")type DatabaseService struct {diff --git a/backend/internal/features/databases/testing.go b/backend/internal/features/databases/testing.goindex 3a0699c2..0b6c3056 100644--- a/backend/internal/features/databases/testing.go+++ b/backend/internal/features/databases/testing.go@@ -4,6 +4,8 @@ import ("fmt""strconv"+ "github.com/google/uuid"+"databasus-backend/internal/config""databasus-backend/internal/features/databases/databases/mariadb""databasus-backend/internal/features/databases/databases/mongodb"@@ -12,8 +14,6 @@ import ("databasus-backend/internal/features/storages""databasus-backend/internal/storage""databasus-backend/internal/util/tools"-- "github.com/google/uuid")func GetTestPostgresConfig() *postgresql.PostgresqlDatabase {diff --git a/backend/internal/features/disk/service.go b/backend/internal/features/disk/service.goindex 2b712eb8..a8b573d3 100644--- a/backend/internal/features/disk/service.go+++ b/backend/internal/features/disk/service.go@@ -1,12 +1,13 @@package diskimport (- "databasus-backend/internal/config""fmt""path/filepath""runtime""github.com/shirou/gopsutil/v4/disk"++ "databasus-backend/internal/config")type DiskService struct{}diff --git a/backend/internal/features/email/di.go b/backend/internal/features/email/di.goindex 89841fac..7e593dda 100644--- a/backend/internal/features/email/di.go+++ b/backend/internal/features/email/di.go@@ -5,8 +5,10 @@ import ("databasus-backend/internal/util/logger")-var env = config.GetEnv()-var log = logger.GetLogger()+var (+ env = config.GetEnv()+ log = logger.GetLogger()+)var emailSMTPSender = &EmailSMTPSender{log,diff --git a/backend/internal/features/encryption/secrets/service.go b/backend/internal/features/encryption/secrets/service.goindex 8bfb86d6..c6edf357 100644--- a/backend/internal/features/encryption/secrets/service.go+++ b/backend/internal/features/encryption/secrets/service.go@@ -5,12 +5,12 @@ import ("fmt""os"+ "github.com/google/uuid"+ "gorm.io/gorm"+"databasus-backend/internal/config"user_models "databasus-backend/internal/features/users/models""databasus-backend/internal/storage"-- "github.com/google/uuid"- "gorm.io/gorm")type SecretKeyService struct {@@ -33,7 +33,7 @@ func (s *SecretKeyService) MigrateKeyFromDbToFileIfExist() error {}secretKeyPath := config.GetEnv().SecretKeyPath- if err := os.WriteFile(secretKeyPath, []byte(secretKey.Secret), 0600); err != nil {+ if err := os.WriteFile(secretKeyPath, []byte(secretKey.Secret), 0o600); err != nil {return fmt.Errorf("failed to write secret key to file: %w", err)}@@ -54,7 +54,7 @@ func (s *SecretKeyService) GetSecretKey() (string, error) {if err != nil {if os.IsNotExist(err) {newKey := s.generateNewSecretKey()- if err := os.WriteFile(secretKeyPath, []byte(newKey), 0600); err != nil {+ if err := os.WriteFile(secretKeyPath, []byte(newKey), 0o600); err != nil {return "", fmt.Errorf("failed to write new secret key: %w", err)}s.cachedKey = &newKeydiff --git a/backend/internal/features/healthcheck/attempt/check_database_health_uc.go b/backend/internal/features/healthcheck/attempt/check_database_health_uc.goindex d06a4b26..2d31347f 100644--- a/backend/internal/features/healthcheck/attempt/check_database_health_uc.go+++ b/backend/internal/features/healthcheck/attempt/check_database_health_uc.go@@ -1,9 +1,6 @@package healthcheck_attemptimport (- "databasus-backend/internal/features/databases"- healthcheck_config "databasus-backend/internal/features/healthcheck/config"- "databasus-backend/internal/util/logger""errors""fmt""log/slog"@@ -11,6 +8,10 @@ import ("github.com/google/uuid""gorm.io/gorm"++ "databasus-backend/internal/features/databases"+ healthcheck_config "databasus-backend/internal/features/healthcheck/config"+ "databasus-backend/internal/util/logger")type CheckDatabaseHealthUseCase struct {@@ -251,5 +252,4 @@ func (uc *CheckDatabaseHealthUseCase) sendDbStatusNotification(messageBody,)}-}diff --git a/backend/internal/features/healthcheck/attempt/check_database_health_uc_test.go b/backend/internal/features/healthcheck/attempt/check_database_health_uc_test.goindex fa0afa7f..7c7564d9 100644--- a/backend/internal/features/healthcheck/attempt/check_database_health_uc_test.go+++ b/backend/internal/features/healthcheck/attempt/check_database_health_uc_test.go@@ -6,6 +6,9 @@ import ("testing""time"+ "github.com/stretchr/testify/assert"+ "github.com/stretchr/testify/mock"+"databasus-backend/internal/features/databases"healthcheck_config "databasus-backend/internal/features/healthcheck/config""databasus-backend/internal/features/notifiers"@@ -13,9 +16,6 @@ import (users_enums "databasus-backend/internal/features/users/enums"users_testing "databasus-backend/internal/features/users/testing"workspaces_testing "databasus-backend/internal/features/workspaces/testing"-- "github.com/stretchr/testify/assert"- "github.com/stretchr/testify/mock")func Test_CheckDatabaseHealthUseCase(t *testing.T) {diff --git a/backend/internal/features/healthcheck/attempt/controller.go b/backend/internal/features/healthcheck/attempt/controller.goindex 3613b4aa..742a5a9c 100644--- a/backend/internal/features/healthcheck/attempt/controller.go+++ b/backend/internal/features/healthcheck/attempt/controller.go@@ -1,12 +1,13 @@package healthcheck_attemptimport (- users_middleware "databasus-backend/internal/features/users/middleware""net/http""time""github.com/gin-gonic/gin""github.com/google/uuid"++ users_middleware "databasus-backend/internal/features/users/middleware")type HealthcheckAttemptController struct {diff --git a/backend/internal/features/healthcheck/attempt/di.go b/backend/internal/features/healthcheck/attempt/di.goindex aedfde15..f1d8d151 100644--- a/backend/internal/features/healthcheck/attempt/di.go+++ b/backend/internal/features/healthcheck/attempt/di.go@@ -11,12 +11,14 @@ import ("databasus-backend/internal/util/logger")-var healthcheckAttemptRepository = &HealthcheckAttemptRepository{}-var healthcheckAttemptService = &HealthcheckAttemptService{- healthcheckAttemptRepository,- databases.GetDatabaseService(),- workspaces_services.GetWorkspaceService(),-}+var (+ healthcheckAttemptRepository = &HealthcheckAttemptRepository{}+ healthcheckAttemptService = &HealthcheckAttemptService{+ healthcheckAttemptRepository,+ databases.GetDatabaseService(),+ workspaces_services.GetWorkspaceService(),+ }+)var checkDatabaseHealthUseCase = &CheckDatabaseHealthUseCase{healthcheckAttemptRepository,@@ -31,6 +33,7 @@ var healthcheckAttemptBackgroundService = &HealthcheckAttemptBackgroundService{runOnce: sync.Once{},hasRun: atomic.Bool{},}+var healthcheckAttemptController = &HealthcheckAttemptController{healthcheckAttemptService,}diff --git a/backend/internal/features/healthcheck/attempt/interfaces.go b/backend/internal/features/healthcheck/attempt/interfaces.goindex 4963e2ec..3d2cad68 100644--- a/backend/internal/features/healthcheck/attempt/interfaces.go+++ b/backend/internal/features/healthcheck/attempt/interfaces.go@@ -1,10 +1,10 @@package healthcheck_attemptimport (+ "github.com/google/uuid"+"databasus-backend/internal/features/databases""databasus-backend/internal/features/notifiers"-- "github.com/google/uuid")type HealthcheckAttemptSender interface {diff --git a/backend/internal/features/healthcheck/attempt/mocks.go b/backend/internal/features/healthcheck/attempt/mocks.goindex 38d3f6ca..68faf415 100644--- a/backend/internal/features/healthcheck/attempt/mocks.go+++ b/backend/internal/features/healthcheck/attempt/mocks.go@@ -1,11 +1,11 @@package healthcheck_attemptimport (- "databasus-backend/internal/features/databases"- "databasus-backend/internal/features/notifiers"-"github.com/google/uuid""github.com/stretchr/testify/mock"++ "databasus-backend/internal/features/databases"+ "databasus-backend/internal/features/notifiers")type MockHealthcheckAttemptSender struct {diff --git a/backend/internal/features/healthcheck/attempt/model.go b/backend/internal/features/healthcheck/attempt/model.goindex 42e49ca9..0516b17f 100644--- a/backend/internal/features/healthcheck/attempt/model.go+++ b/backend/internal/features/healthcheck/attempt/model.go@@ -1,10 +1,11 @@package healthcheck_attemptimport (- "databasus-backend/internal/features/databases""time""github.com/google/uuid"++ "databasus-backend/internal/features/databases")type HealthcheckAttempt struct {diff --git a/backend/internal/features/healthcheck/attempt/repository.go b/backend/internal/features/healthcheck/attempt/repository.goindex 301b989d..9485d572 100644--- a/backend/internal/features/healthcheck/attempt/repository.go+++ b/backend/internal/features/healthcheck/attempt/repository.go@@ -1,10 +1,11 @@package healthcheck_attemptimport (- "databasus-backend/internal/storage""time""github.com/google/uuid"++ "databasus-backend/internal/storage")type HealthcheckAttemptRepository struct{}diff --git a/backend/internal/features/healthcheck/attempt/service.go b/backend/internal/features/healthcheck/attempt/service.goindex 07cc381f..18ad4d36 100644--- a/backend/internal/features/healthcheck/attempt/service.go+++ b/backend/internal/features/healthcheck/attempt/service.go@@ -1,13 +1,14 @@package healthcheck_attemptimport (- "databasus-backend/internal/features/databases"- users_models "databasus-backend/internal/features/users/models"- workspaces_services "databasus-backend/internal/features/workspaces/services""errors""time""github.com/google/uuid"++ "databasus-backend/internal/features/databases"+ users_models "databasus-backend/internal/features/users/models"+ workspaces_services "databasus-backend/internal/features/workspaces/services")type HealthcheckAttemptService struct {diff --git a/backend/internal/features/healthcheck/config/controller.go b/backend/internal/features/healthcheck/config/controller.goindex 8a023afa..1456c2b9 100644--- a/backend/internal/features/healthcheck/config/controller.go+++ b/backend/internal/features/healthcheck/config/controller.go@@ -1,11 +1,12 @@package healthcheck_configimport (- users_middleware "databasus-backend/internal/features/users/middleware""net/http""github.com/gin-gonic/gin""github.com/google/uuid"++ users_middleware "databasus-backend/internal/features/users/middleware")type HealthcheckConfigController struct {diff --git a/backend/internal/features/healthcheck/config/di.go b/backend/internal/features/healthcheck/config/di.goindex ce5744b0..bb2a4a62 100644--- a/backend/internal/features/healthcheck/config/di.go+++ b/backend/internal/features/healthcheck/config/di.go@@ -10,14 +10,17 @@ import ("databasus-backend/internal/util/logger")-var healthcheckConfigRepository = &HealthcheckConfigRepository{}-var healthcheckConfigService = &HealthcheckConfigService{- databases.GetDatabaseService(),- healthcheckConfigRepository,- workspaces_services.GetWorkspaceService(),- audit_logs.GetAuditLogService(),- logger.GetLogger(),-}+var (+ healthcheckConfigRepository = &HealthcheckConfigRepository{}+ healthcheckConfigService = &HealthcheckConfigService{+ databases.GetDatabaseService(),+ healthcheckConfigRepository,+ workspaces_services.GetWorkspaceService(),+ audit_logs.GetAuditLogService(),+ logger.GetLogger(),+ }+)+var healthcheckConfigController = &HealthcheckConfigController{healthcheckConfigService,}diff --git a/backend/internal/features/healthcheck/config/repository.go b/backend/internal/features/healthcheck/config/repository.goindex c4117046..cdd46f24 100644--- a/backend/internal/features/healthcheck/config/repository.go+++ b/backend/internal/features/healthcheck/config/repository.go@@ -1,11 +1,12 @@package healthcheck_configimport (- "databasus-backend/internal/storage""errors""github.com/google/uuid""gorm.io/gorm"++ "databasus-backend/internal/storage")type HealthcheckConfigRepository struct{}diff --git a/backend/internal/features/healthcheck/config/service.go b/backend/internal/features/healthcheck/config/service.goindex 7809f2e4..4b57ab3c 100644--- a/backend/internal/features/healthcheck/config/service.go+++ b/backend/internal/features/healthcheck/config/service.go@@ -1,15 +1,16 @@package healthcheck_configimport (- "databasus-backend/internal/features/audit_logs"- "databasus-backend/internal/features/databases"- users_models "databasus-backend/internal/features/users/models"- workspaces_services "databasus-backend/internal/features/workspaces/services""errors""fmt""log/slog""github.com/google/uuid"++ "databasus-backend/internal/features/audit_logs"+ "databasus-backend/internal/features/databases"+ users_models "databasus-backend/internal/features/users/models"+ workspaces_services "databasus-backend/internal/features/workspaces/services")type HealthcheckConfigService struct {diff --git a/backend/internal/features/notifiers/controller.go b/backend/internal/features/notifiers/controller.goindex 27b78dd0..ef62a9b6 100644--- a/backend/internal/features/notifiers/controller.go+++ b/backend/internal/features/notifiers/controller.go@@ -2,13 +2,13 @@ package notifiersimport ("errors"-- users_middleware "databasus-backend/internal/features/users/middleware"- workspaces_services "databasus-backend/internal/features/workspaces/services""net/http""github.com/gin-gonic/gin""github.com/google/uuid"++ users_middleware "databasus-backend/internal/features/users/middleware"+ workspaces_services "databasus-backend/internal/features/workspaces/services")type NotifierController struct {diff --git a/backend/internal/features/notifiers/controller_test.go b/backend/internal/features/notifiers/controller_test.goindex 034d58fa..36c03733 100644--- a/backend/internal/features/notifiers/controller_test.go+++ b/backend/internal/features/notifiers/controller_test.go@@ -5,6 +5,10 @@ import ("net/http""testing"+ "github.com/gin-gonic/gin"+ "github.com/google/uuid"+ "github.com/stretchr/testify/assert"+"databasus-backend/internal/config"audit_logs "databasus-backend/internal/features/audit_logs"discord_notifier "databasus-backend/internal/features/notifiers/models/discord"@@ -20,10 +24,6 @@ import (workspaces_controllers "databasus-backend/internal/features/workspaces/controllers"workspaces_testing "databasus-backend/internal/features/workspaces/testing"test_utils "databasus-backend/internal/util/testing"-- "github.com/gin-gonic/gin"- "github.com/google/uuid"- "github.com/stretchr/testify/assert")func Test_SaveNewNotifier_NotifierReturnedViaGet(t *testing.T) {@@ -455,7 +455,7 @@ func Test_NotifierSensitiveDataLifecycle_AllTypes(t *testing.T) {name stringnotifierType NotifierTypecreateNotifier func(workspaceID uuid.UUID) *Notifier- updateNotifier func(workspaceID uuid.UUID, notifierID uuid.UUID) *Notifier+ updateNotifier func(workspaceID, notifierID uuid.UUID) *NotifierverifySensitiveData func(t *testing.T, notifier *Notifier)verifyHiddenData func(t *testing.T, notifier *Notifier)}{@@ -473,7 +473,7 @@ func Test_NotifierSensitiveDataLifecycle_AllTypes(t *testing.T) {},}},- updateNotifier: func(workspaceID uuid.UUID, notifierID uuid.UUID) *Notifier {+ updateNotifier: func(workspaceID, notifierID uuid.UUID) *Notifier {return &Notifier{ID: notifierID,WorkspaceID: workspaceID,@@ -515,7 +515,7 @@ func Test_NotifierSensitiveDataLifecycle_AllTypes(t *testing.T) {},}},- updateNotifier: func(workspaceID uuid.UUID, notifierID uuid.UUID) *Notifier {+ updateNotifier: func(workspaceID, notifierID uuid.UUID) *Notifier {return &Notifier{ID: notifierID,WorkspaceID: workspaceID,@@ -557,7 +557,7 @@ func Test_NotifierSensitiveDataLifecycle_AllTypes(t *testing.T) {},}},- updateNotifier: func(workspaceID uuid.UUID, notifierID uuid.UUID) *Notifier {+ updateNotifier: func(workspaceID, notifierID uuid.UUID) *Notifier {return &Notifier{ID: notifierID,WorkspaceID: workspaceID,@@ -595,7 +595,7 @@ func Test_NotifierSensitiveDataLifecycle_AllTypes(t *testing.T) {},}},- updateNotifier: func(workspaceID uuid.UUID, notifierID uuid.UUID) *Notifier {+ updateNotifier: func(workspaceID, notifierID uuid.UUID) *Notifier {return &Notifier{ID: notifierID,WorkspaceID: workspaceID,@@ -636,7 +636,7 @@ func Test_NotifierSensitiveDataLifecycle_AllTypes(t *testing.T) {},}},- updateNotifier: func(workspaceID uuid.UUID, notifierID uuid.UUID) *Notifier {+ updateNotifier: func(workspaceID, notifierID uuid.UUID) *Notifier {return &Notifier{ID: notifierID,WorkspaceID: workspaceID,@@ -682,7 +682,7 @@ func Test_NotifierSensitiveDataLifecycle_AllTypes(t *testing.T) {},}},- updateNotifier: func(workspaceID uuid.UUID, notifierID uuid.UUID) *Notifier {+ updateNotifier: func(workspaceID, notifierID uuid.UUID) *Notifier {return &Notifier{ID: notifierID,WorkspaceID: workspaceID,@@ -1265,7 +1265,7 @@ func createTelegramNotifier(workspaceID uuid.UUID) *Notifier {}}-func verifyNotifierData(t *testing.T, expected *Notifier, actual *Notifier) {+func verifyNotifierData(t *testing.T, expected, actual *Notifier) {assert.Equal(t, expected.Name, actual.Name)assert.Equal(t, expected.NotifierType, actual.NotifierType)assert.Equal(t, expected.WorkspaceID, actual.WorkspaceID)diff --git a/backend/internal/features/notifiers/di.go b/backend/internal/features/notifiers/di.goindex 71e63a40..c86f02a6 100644--- a/backend/internal/features/notifiers/di.go+++ b/backend/internal/features/notifiers/di.go@@ -10,15 +10,18 @@ import ("databasus-backend/internal/util/logger")-var notifierRepository = &NotifierRepository{}-var notifierService = &NotifierService{- notifierRepository,- logger.GetLogger(),- workspaces_services.GetWorkspaceService(),- audit_logs.GetAuditLogService(),- encryption.GetFieldEncryptor(),- nil,-}+var (+ notifierRepository = &NotifierRepository{}+ notifierService = &NotifierService{+ notifierRepository,+ logger.GetLogger(),+ workspaces_services.GetWorkspaceService(),+ audit_logs.GetAuditLogService(),+ encryption.GetFieldEncryptor(),+ nil,+ }+)+var notifierController = &NotifierController{notifierService,workspaces_services.GetWorkspaceService(),diff --git a/backend/internal/features/notifiers/interfaces.go b/backend/internal/features/notifiers/interfaces.goindex cd961083..c082afa8 100644--- a/backend/internal/features/notifiers/interfaces.go+++ b/backend/internal/features/notifiers/interfaces.go@@ -1,10 +1,11 @@package notifiersimport (- "databasus-backend/internal/util/encryption""log/slog""github.com/google/uuid"++ "databasus-backend/internal/util/encryption")type NotificationSender interface {diff --git a/backend/internal/features/notifiers/model.go b/backend/internal/features/notifiers/model.goindex b8b50a4d..1aa9d3d6 100644--- a/backend/internal/features/notifiers/model.go+++ b/backend/internal/features/notifiers/model.go@@ -1,6 +1,11 @@package notifiersimport (+ "errors"+ "log/slog"++ "github.com/google/uuid"+discord_notifier "databasus-backend/internal/features/notifiers/models/discord""databasus-backend/internal/features/notifiers/models/email_notifier"slack_notifier "databasus-backend/internal/features/notifiers/models/slack"@@ -8,10 +13,6 @@ import (telegram_notifier "databasus-backend/internal/features/notifiers/models/telegram"webhook_notifier "databasus-backend/internal/features/notifiers/models/webhook""databasus-backend/internal/util/encryption"- "errors"- "log/slog"-- "github.com/google/uuid")type Notifier struct {diff --git a/backend/internal/features/notifiers/models/discord/model.go b/backend/internal/features/notifiers/models/discord/model.goindex 7ee8c686..55f87572 100644--- a/backend/internal/features/notifiers/models/discord/model.go+++ b/backend/internal/features/notifiers/models/discord/model.go@@ -2,7 +2,6 @@ package discord_notifierimport ("bytes"- "databasus-backend/internal/util/encryption""encoding/json""errors""fmt"@@ -11,6 +10,8 @@ import ("net/http""github.com/google/uuid"++ "databasus-backend/internal/util/encryption")type DiscordNotifier struct {diff --git a/backend/internal/features/notifiers/models/email_notifier/model.go b/backend/internal/features/notifiers/models/email_notifier/model.goindex eeb93685..a7f93a31 100644--- a/backend/internal/features/notifiers/models/email_notifier/model.go+++ b/backend/internal/features/notifiers/models/email_notifier/model.go@@ -2,7 +2,6 @@ package email_notifierimport ("crypto/tls"- "databasus-backend/internal/util/encryption""errors""fmt""log/slog"@@ -13,6 +12,8 @@ import ("time""github.com/google/uuid"++ "databasus-backend/internal/util/encryption")const (diff --git a/backend/internal/features/notifiers/models/slack/model.go b/backend/internal/features/notifiers/models/slack/model.goindex 3ff5ab91..3b7d3368 100644--- a/backend/internal/features/notifiers/models/slack/model.go+++ b/backend/internal/features/notifiers/models/slack/model.go@@ -2,7 +2,6 @@ package slack_notifierimport ("bytes"- "databasus-backend/internal/util/encryption""encoding/json""errors""fmt"@@ -14,6 +13,8 @@ import ("time""github.com/google/uuid"++ "databasus-backend/internal/util/encryption")type SlackNotifier struct {diff --git a/backend/internal/features/notifiers/models/teams/model.go b/backend/internal/features/notifiers/models/teams/model.goindex e339f647..34fedf7c 100644--- a/backend/internal/features/notifiers/models/teams/model.go+++ b/backend/internal/features/notifiers/models/teams/model.go@@ -2,7 +2,6 @@ package teams_notifierimport ("bytes"- "databasus-backend/internal/util/encryption""encoding/json""errors""fmt"@@ -11,6 +10,8 @@ import ("net/url""github.com/google/uuid"++ "databasus-backend/internal/util/encryption")type TeamsNotifier struct {diff --git a/backend/internal/features/notifiers/models/telegram/model.go b/backend/internal/features/notifiers/models/telegram/model.goindex de32e681..adf9f291 100644--- a/backend/internal/features/notifiers/models/telegram/model.go+++ b/backend/internal/features/notifiers/models/telegram/model.go@@ -1,7 +1,6 @@package telegram_notifierimport (- "databasus-backend/internal/util/encryption""errors""fmt""io"@@ -12,6 +11,8 @@ import ("strings""github.com/google/uuid"++ "databasus-backend/internal/util/encryption")type TelegramNotifier struct {diff --git a/backend/internal/features/notifiers/models/webhook/model.go b/backend/internal/features/notifiers/models/webhook/model.goindex 2bca1892..6dbbe87e 100644--- a/backend/internal/features/notifiers/models/webhook/model.go+++ b/backend/internal/features/notifiers/models/webhook/model.go@@ -2,7 +2,6 @@ package webhook_notifierimport ("bytes"- "databasus-backend/internal/util/encryption""encoding/json""errors""fmt"@@ -14,6 +13,8 @@ import ("github.com/google/uuid""gorm.io/gorm"++ "databasus-backend/internal/util/encryption")type WebhookHeader struct {@@ -42,7 +43,6 @@ func (t *WebhookNotifier) TableName() string {func (t *WebhookNotifier) BeforeSave(_ *gorm.DB) error {if len(t.Headers) > 0 {data, err := json.Marshal(t.Headers)-if err != nil {return err}diff --git a/backend/internal/features/notifiers/repository.go b/backend/internal/features/notifiers/repository.goindex 0d77bccd..50361b22 100644--- a/backend/internal/features/notifiers/repository.go+++ b/backend/internal/features/notifiers/repository.go@@ -1,10 +1,10 @@package notifiersimport (- "databasus-backend/internal/storage"-"github.com/google/uuid""gorm.io/gorm"++ "databasus-backend/internal/storage")type NotifierRepository struct{}@@ -13,7 +13,6 @@ func (r *NotifierRepository) Save(notifier *Notifier) (*Notifier, error) {db := storage.GetDb()err := db.Transaction(func(tx *gorm.DB) error {-switch notifier.NotifierType {case NotifierTypeTelegram:if notifier.TelegramNotifier != nil {@@ -116,7 +115,6 @@ func (r *NotifierRepository) Save(notifier *Notifier) (*Notifier, error) {return nil})-if err != nil {return nil, err}diff --git a/backend/internal/features/notifiers/service.go b/backend/internal/features/notifiers/service.goindex 1b24d374..027a51ef 100644--- a/backend/internal/features/notifiers/service.go+++ b/backend/internal/features/notifiers/service.go@@ -4,12 +4,12 @@ import ("fmt""log/slog"+ "github.com/google/uuid"+audit_logs "databasus-backend/internal/features/audit_logs"users_models "databasus-backend/internal/features/users/models"workspaces_services "databasus-backend/internal/features/workspaces/services""databasus-backend/internal/util/encryption"-- "github.com/google/uuid")type NotifierService struct {diff --git a/backend/internal/features/notifiers/testing.go b/backend/internal/features/notifiers/testing.goindex f61c54c7..61cfea4b 100644--- a/backend/internal/features/notifiers/testing.go+++ b/backend/internal/features/notifiers/testing.go@@ -1,9 +1,9 @@package notifiersimport (- webhook_notifier "databasus-backend/internal/features/notifiers/models/webhook"-"github.com/google/uuid"++ webhook_notifier "databasus-backend/internal/features/notifiers/models/webhook")func CreateTestNotifier(workspaceID uuid.UUID) *Notifier {diff --git a/backend/internal/features/plan/model.go b/backend/internal/features/plan/model.goindex ac14da9b..235b2a52 100644--- a/backend/internal/features/plan/model.go+++ b/backend/internal/features/plan/model.go@@ -1,9 +1,9 @@package plansimport (- "databasus-backend/internal/util/period"-"github.com/google/uuid"++ "databasus-backend/internal/util/period")type DatabasePlan struct {diff --git a/backend/internal/features/plan/repository.go b/backend/internal/features/plan/repository.goindex e92f31ef..ba156a9d 100644--- a/backend/internal/features/plan/repository.go+++ b/backend/internal/features/plan/repository.go@@ -1,9 +1,9 @@package plansimport (- "databasus-backend/internal/storage"-"github.com/google/uuid"++ "databasus-backend/internal/storage")type DatabasePlanRepository struct{}diff --git a/backend/internal/features/plan/service.go b/backend/internal/features/plan/service.goindex 1a342359..1f7b94b2 100644--- a/backend/internal/features/plan/service.go+++ b/backend/internal/features/plan/service.go@@ -1,11 +1,12 @@package plansimport (- "databasus-backend/internal/config"- "databasus-backend/internal/util/period""log/slog""github.com/google/uuid"++ "databasus-backend/internal/config"+ "databasus-backend/internal/util/period")type DatabasePlanService struct {diff --git a/backend/internal/features/restores/controller.go b/backend/internal/features/restores/controller.goindex e3b26631..c4d8dbeb 100644--- a/backend/internal/features/restores/controller.go+++ b/backend/internal/features/restores/controller.go@@ -1,12 +1,13 @@package restoresimport (- restores_core "databasus-backend/internal/features/restores/core"- users_middleware "databasus-backend/internal/features/users/middleware""net/http""github.com/gin-gonic/gin""github.com/google/uuid"++ restores_core "databasus-backend/internal/features/restores/core"+ users_middleware "databasus-backend/internal/features/users/middleware")type RestoreController struct {diff --git a/backend/internal/features/restores/core/model.go b/backend/internal/features/restores/core/model.goindex d3d5d00e..cb762cba 100644--- a/backend/internal/features/restores/core/model.go+++ b/backend/internal/features/restores/core/model.go@@ -1,14 +1,15 @@package restores_coreimport (+ "time"++ "github.com/google/uuid"+backups_core "databasus-backend/internal/features/backups/backups/core""databasus-backend/internal/features/databases/databases/mariadb""databasus-backend/internal/features/databases/databases/mongodb""databasus-backend/internal/features/databases/databases/mysql""databasus-backend/internal/features/databases/databases/postgresql"- "time"-- "github.com/google/uuid")type Restore struct {diff --git a/backend/internal/features/restores/core/repository.go b/backend/internal/features/restores/core/repository.goindex 7e23bc53..13dde946 100644--- a/backend/internal/features/restores/core/repository.go+++ b/backend/internal/features/restores/core/repository.go@@ -1,9 +1,9 @@package restores_coreimport (- "databasus-backend/internal/storage"-"github.com/google/uuid"++ "databasus-backend/internal/storage")type RestoreRepository struct{}diff --git a/backend/internal/features/restores/di.go b/backend/internal/features/restores/di.goindex b74cc128..d9e05d16 100644--- a/backend/internal/features/restores/di.go+++ b/backend/internal/features/restores/di.go@@ -19,21 +19,24 @@ import ("databasus-backend/internal/util/logger")-var restoreRepository = &restores_core.RestoreRepository{}-var restoreService = &RestoreService{- backups_services.GetBackupService(),- restoreRepository,- storages.GetStorageService(),- backups_config.GetBackupConfigService(),- usecases.GetRestoreBackupUsecase(),- databases.GetDatabaseService(),- logger.GetLogger(),- workspaces_services.GetWorkspaceService(),- audit_logs.GetAuditLogService(),- encryption.GetFieldEncryptor(),- disk.GetDiskService(),- tasks_cancellation.GetTaskCancelManager(),-}+var (+ restoreRepository = &restores_core.RestoreRepository{}+ restoreService = &RestoreService{+ backups_services.GetBackupService(),+ restoreRepository,+ storages.GetStorageService(),+ backups_config.GetBackupConfigService(),+ usecases.GetRestoreBackupUsecase(),+ databases.GetDatabaseService(),+ logger.GetLogger(),+ workspaces_services.GetWorkspaceService(),+ audit_logs.GetAuditLogService(),+ encryption.GetFieldEncryptor(),+ disk.GetDiskService(),+ tasks_cancellation.GetTaskCancelManager(),+ }+)+var restoreController = &RestoreController{restoreService,}diff --git a/backend/internal/features/restores/restoring/dto.go b/backend/internal/features/restores/restoring/dto.goindex eb4a3cba..fb17e701 100644--- a/backend/internal/features/restores/restoring/dto.go+++ b/backend/internal/features/restores/restoring/dto.go@@ -1,13 +1,14 @@package restoringimport (+ "time"++ "github.com/google/uuid"+"databasus-backend/internal/features/databases/databases/mariadb""databasus-backend/internal/features/databases/databases/mongodb""databasus-backend/internal/features/databases/databases/mysql""databasus-backend/internal/features/databases/databases/postgresql"- "time"-- "github.com/google/uuid")type RestoreDatabaseCache struct {diff --git a/backend/internal/features/restores/restoring/registry.go b/backend/internal/features/restores/restoring/registry.goindex 01b72bd8..950dfc06 100644--- a/backend/internal/features/restores/restoring/registry.go+++ b/backend/internal/features/restores/restoring/registry.go@@ -10,10 +10,10 @@ import ("sync/atomic""time"- cache_utils "databasus-backend/internal/util/cache"-"github.com/google/uuid""github.com/valkey-io/valkey-go"++ cache_utils "databasus-backend/internal/util/cache")const (@@ -453,7 +453,7 @@ func (r *RestoreNodesRegistry) PublishRestoreCompletion(}func (r *RestoreNodesRegistry) SubscribeForRestoresCompletions(- handler func(nodeID uuid.UUID, restoreID uuid.UUID),+ handler func(nodeID, restoreID uuid.UUID),) error {ctx := context.Background()diff --git a/backend/internal/features/restores/restoring/registry_test.go b/backend/internal/features/restores/restoring/registry_test.goindex 2b7e87f6..653b4915 100644--- a/backend/internal/features/restores/restoring/registry_test.go+++ b/backend/internal/features/restores/restoring/registry_test.go@@ -9,11 +9,11 @@ import ("testing""time"- cache_utils "databasus-backend/internal/util/cache"- "databasus-backend/internal/util/logger"-"github.com/google/uuid""github.com/stretchr/testify/assert"++ cache_utils "databasus-backend/internal/util/cache"+ "databasus-backend/internal/util/logger")func Test_HearthbeatNodeInRegistry_RegistersNodeWithTTL(t *testing.T) {@@ -905,7 +905,7 @@ func Test_SubscribeForRestoresCompletions_ReceivesCompletedRestores(t *testing.TreceivedRestoreID := make(chan uuid.UUID, 1)receivedNodeID := make(chan uuid.UUID, 1)- handler := func(nodeID uuid.UUID, restoreID uuid.UUID) {+ handler := func(nodeID, restoreID uuid.UUID) {receivedNodeID <- nodeIDreceivedRestoreID <- restoreID}@@ -942,7 +942,7 @@ func Test_SubscribeForRestoresCompletions_ParsesJsonCorrectly(t *testing.T) {defer registry.UnsubscribeForRestoresCompletions()receivedRestores := make(chan uuid.UUID, 2)- handler := func(nodeID uuid.UUID, restoreID uuid.UUID) {+ handler := func(nodeID, restoreID uuid.UUID) {receivedRestores <- restoreID}@@ -971,7 +971,7 @@ func Test_SubscribeForRestoresCompletions_HandlesInvalidJson(t *testing.T) {defer registry.UnsubscribeForRestoresCompletions()receivedRestoreID := make(chan uuid.UUID, 1)- handler := func(nodeID uuid.UUID, restoreID uuid.UUID) {+ handler := func(nodeID, restoreID uuid.UUID) {receivedRestoreID <- restoreID}@@ -999,7 +999,7 @@ func Test_UnsubscribeForRestoresCompletions_StopsReceivingMessages(t *testing.T)restoreID2 := uuid.New()receivedRestoreID := make(chan uuid.UUID, 2)- handler := func(nodeID uuid.UUID, restoreID uuid.UUID) {+ handler := func(nodeID, restoreID uuid.UUID) {receivedRestoreID <- restoreID}@@ -1034,7 +1034,7 @@ func Test_SubscribeForRestoresCompletions_WhenAlreadySubscribed_ReturnsError(t *registry := createTestRegistry()defer registry.UnsubscribeForRestoresCompletions()- handler := func(nodeID uuid.UUID, restoreID uuid.UUID) {}+ handler := func(nodeID, restoreID uuid.UUID) {}err := registry.SubscribeForRestoresCompletions(handler)assert.NoError(t, err)@@ -1066,9 +1066,9 @@ func Test_MultipleSubscribers_EachReceivesCompletionMessages(t *testing.T) {receivedRestores2 := make(chan uuid.UUID, 3)receivedRestores3 := make(chan uuid.UUID, 3)- handler1 := func(nodeID uuid.UUID, restoreID uuid.UUID) { receivedRestores1 <- restoreID }- handler2 := func(nodeID uuid.UUID, restoreID uuid.UUID) { receivedRestores2 <- restoreID }- handler3 := func(nodeID uuid.UUID, restoreID uuid.UUID) { receivedRestores3 <- restoreID }+ handler1 := func(nodeID, restoreID uuid.UUID) { receivedRestores1 <- restoreID }+ handler2 := func(nodeID, restoreID uuid.UUID) { receivedRestores2 <- restoreID }+ handler3 := func(nodeID, restoreID uuid.UUID) { receivedRestores3 <- restoreID }err := registry1.SubscribeForRestoresCompletions(handler1)assert.NoError(t, err)diff --git a/backend/internal/features/restores/restoring/restorer.go b/backend/internal/features/restores/restoring/restorer.goindex 092df7a0..1ad89cc9 100644--- a/backend/internal/features/restores/restoring/restorer.go+++ b/backend/internal/features/restores/restoring/restorer.go@@ -237,7 +237,6 @@ func (n *RestorerNode) MakeRestore(restoreID uuid.UUID) {storage,isExcludeExtensions,)-if err != nil {errMsg := err.Error()diff --git a/backend/internal/features/restores/restoring/scheduler.go b/backend/internal/features/restores/restoring/scheduler.goindex 58faf627..0f36766b 100644--- a/backend/internal/features/restores/restoring/scheduler.go+++ b/backend/internal/features/restores/restoring/scheduler.go@@ -265,7 +265,7 @@ func (s *RestoresScheduler) calculateLeastBusyNode() (*uuid.UUID, error) {return &bestNode.ID, nil}-func (s *RestoresScheduler) onRestoreCompleted(nodeID uuid.UUID, restoreID uuid.UUID) {+func (s *RestoresScheduler) onRestoreCompleted(nodeID, restoreID uuid.UUID) {// Verify this task is actually a restore (registry contains multiple task types)_, err := s.restoreRepository.FindByID(restoreID)if err != nil {diff --git a/backend/internal/features/restores/restoring/scheduler_test.go b/backend/internal/features/restores/restoring/scheduler_test.goindex 66899cf5..67f3f111 100644--- a/backend/internal/features/restores/restoring/scheduler_test.go+++ b/backend/internal/features/restores/restoring/scheduler_test.go@@ -4,6 +4,9 @@ import ("testing""time"+ "github.com/google/uuid"+ "github.com/stretchr/testify/assert"+"databasus-backend/internal/config"backups_controllers "databasus-backend/internal/features/backups/backups/controllers"backups_core "databasus-backend/internal/features/backups/backups/core"@@ -18,9 +21,6 @@ import (workspaces_testing "databasus-backend/internal/features/workspaces/testing"cache_utils "databasus-backend/internal/util/cache""databasus-backend/internal/util/encryption"-- "github.com/google/uuid"- "github.com/stretchr/testify/assert")func Test_CheckDeadNodesAndFailRestores_NodeDies_FailsRestoreAndCleansUpRegistry(t *testing.T) {diff --git a/backend/internal/features/restores/service.go b/backend/internal/features/restores/service.goindex 139eaade..1807a5d7 100644--- a/backend/internal/features/restores/service.go+++ b/backend/internal/features/restores/service.go@@ -1,6 +1,13 @@package restoresimport (+ "errors"+ "fmt"+ "log/slog"+ "time"++ "github.com/google/uuid"+"databasus-backend/internal/config"audit_logs "databasus-backend/internal/features/audit_logs"backups_core "databasus-backend/internal/features/backups/backups/core"@@ -17,12 +24,6 @@ import (workspaces_services "databasus-backend/internal/features/workspaces/services""databasus-backend/internal/util/encryption""databasus-backend/internal/util/tools"- "errors"- "fmt"- "log/slog"- "time"-- "github.com/google/uuid")type RestoreService struct {diff --git a/backend/internal/features/restores/usecases/mariadb/restore_backup_uc.go b/backend/internal/features/restores/usecases/mariadb/restore_backup_uc.goindex d6a03355..9996e934 100644--- a/backend/internal/features/restores/usecases/mariadb/restore_backup_uc.go+++ b/backend/internal/features/restores/usecases/mariadb/restore_backup_uc.go@@ -286,10 +286,10 @@ func (uc *RestoreMariadbBackupUsecase) createTempMyCnfFile(password string,) (string, error) {tempFolder := config.GetEnv().TempFolder- if err := os.MkdirAll(tempFolder, 0700); err != nil {+ if err := os.MkdirAll(tempFolder, 0o700); err != nil {return "", fmt.Errorf("failed to ensure temp folder exists: %w", err)}- if err := os.Chmod(tempFolder, 0700); err != nil {+ if err := os.Chmod(tempFolder, 0o700); err != nil {return "", fmt.Errorf("failed to set temp folder permissions: %w", err)}@@ -298,7 +298,7 @@ func (uc *RestoreMariadbBackupUsecase) createTempMyCnfFile(return "", fmt.Errorf("failed to create temp directory: %w", err)}- if err := os.Chmod(tempDir, 0700); err != nil {+ if err := os.Chmod(tempDir, 0o700); err != nil {_ = os.RemoveAll(tempDir)return "", fmt.Errorf("failed to set temp directory permissions: %w", err)}@@ -318,7 +318,7 @@ port=%dcontent += "ssl=false\n"}- err = os.WriteFile(myCnfFile, []byte(content), 0600)+ err = os.WriteFile(myCnfFile, []byte(content), 0o600)if err != nil {_ = os.RemoveAll(tempDir)return "", fmt.Errorf("failed to write .my.cnf: %w", err)diff --git a/backend/internal/features/restores/usecases/mysql/restore_backup_uc.go b/backend/internal/features/restores/usecases/mysql/restore_backup_uc.goindex 2f11760c..46680ad6 100644--- a/backend/internal/features/restores/usecases/mysql/restore_backup_uc.go+++ b/backend/internal/features/restores/usecases/mysql/restore_backup_uc.go@@ -277,10 +277,10 @@ func (uc *RestoreMysqlBackupUsecase) createTempMyCnfFile(password string,) (string, error) {tempFolder := config.GetEnv().TempFolder- if err := os.MkdirAll(tempFolder, 0700); err != nil {+ if err := os.MkdirAll(tempFolder, 0o700); err != nil {return "", fmt.Errorf("failed to ensure temp folder exists: %w", err)}- if err := os.Chmod(tempFolder, 0700); err != nil {+ if err := os.Chmod(tempFolder, 0o700); err != nil {return "", fmt.Errorf("failed to set temp folder permissions: %w", err)}@@ -289,7 +289,7 @@ func (uc *RestoreMysqlBackupUsecase) createTempMyCnfFile(return "", fmt.Errorf("failed to create temp directory: %w", err)}- if err := os.Chmod(tempDir, 0700); err != nil {+ if err := os.Chmod(tempDir, 0o700); err != nil {_ = os.RemoveAll(tempDir)return "", fmt.Errorf("failed to set temp directory permissions: %w", err)}@@ -307,7 +307,7 @@ port=%dcontent += "ssl-mode=REQUIRED\n"}- err = os.WriteFile(myCnfFile, []byte(content), 0600)+ err = os.WriteFile(myCnfFile, []byte(content), 0o600)if err != nil {_ = os.RemoveAll(tempDir)return "", fmt.Errorf("failed to write .my.cnf: %w", err)diff --git a/backend/internal/features/restores/usecases/postgresql/restore_backup_uc.go b/backend/internal/features/restores/usecases/postgresql/restore_backup_uc.goindex 8b5ef80a..6ce91727 100644--- a/backend/internal/features/restores/usecases/postgresql/restore_backup_uc.go+++ b/backend/internal/features/restores/usecases/postgresql/restore_backup_uc.go@@ -14,6 +14,8 @@ import ("strings""time"+ "github.com/google/uuid"+"databasus-backend/internal/config"backups_core "databasus-backend/internal/features/backups/backups/core""databasus-backend/internal/features/backups/backups/encryption"@@ -25,8 +27,6 @@ import ("databasus-backend/internal/features/storages"util_encryption "databasus-backend/internal/util/encryption""databasus-backend/internal/util/tools"-- "github.com/google/uuid")type RestorePostgresqlBackupUsecase struct {@@ -992,10 +992,10 @@ func (uc *RestorePostgresqlBackupUsecase) createTempPgpassFile()tempFolder := config.GetEnv().TempFolder- if err := os.MkdirAll(tempFolder, 0700); err != nil {+ if err := os.MkdirAll(tempFolder, 0o700); err != nil {return "", fmt.Errorf("failed to ensure temp folder exists: %w", err)}- if err := os.Chmod(tempFolder, 0700); err != nil {+ if err := os.Chmod(tempFolder, 0o700); err != nil {return "", fmt.Errorf("failed to set temp folder permissions: %w", err)}@@ -1004,13 +1004,13 @@ func (uc *RestorePostgresqlBackupUsecase) createTempPgpassFile(return "", fmt.Errorf("failed to create temporary directory: %w", err)}- if err := os.Chmod(tempDir, 0700); err != nil {+ if err := os.Chmod(tempDir, 0o700); err != nil {_ = os.RemoveAll(tempDir)return "", fmt.Errorf("failed to set temporary directory permissions: %w", err)}pgpassFile := filepath.Join(tempDir, ".pgpass")- err = os.WriteFile(pgpassFile, []byte(pgpassContent), 0600)+ err = os.WriteFile(pgpassFile, []byte(pgpassContent), 0o600)if err != nil {_ = os.RemoveAll(tempDir)return "", fmt.Errorf("failed to write temporary .pgpass file: %w", err)diff --git a/backend/internal/features/storages/controller.go b/backend/internal/features/storages/controller.goindex 1ecc54a7..5828ae0e 100644--- a/backend/internal/features/storages/controller.go+++ b/backend/internal/features/storages/controller.go@@ -2,13 +2,13 @@ package storagesimport ("errors"-- users_middleware "databasus-backend/internal/features/users/middleware"- workspaces_services "databasus-backend/internal/features/workspaces/services""net/http""github.com/gin-gonic/gin""github.com/google/uuid"++ users_middleware "databasus-backend/internal/features/users/middleware"+ workspaces_services "databasus-backend/internal/features/workspaces/services")type StorageController struct {diff --git a/backend/internal/features/storages/controller_test.go b/backend/internal/features/storages/controller_test.goindex 1bb892e4..786b91cc 100644--- a/backend/internal/features/storages/controller_test.go+++ b/backend/internal/features/storages/controller_test.go@@ -6,6 +6,10 @@ import ("strings""testing"+ "github.com/gin-gonic/gin"+ "github.com/google/uuid"+ "github.com/stretchr/testify/assert"+"databasus-backend/internal/config"audit_logs "databasus-backend/internal/features/audit_logs"azure_blob_storage "databasus-backend/internal/features/storages/models/azure_blob"@@ -25,10 +29,6 @@ import (workspaces_testing "databasus-backend/internal/features/workspaces/testing""databasus-backend/internal/util/encryption"test_utils "databasus-backend/internal/util/testing"-- "github.com/gin-gonic/gin"- "github.com/google/uuid"- "github.com/stretchr/testify/assert")type mockStorageDatabaseCounter struct{}@@ -1128,7 +1128,7 @@ func Test_StorageSensitiveDataLifecycle_AllTypes(t *testing.T) {name stringstorageType StorageTypecreateStorage func(workspaceID uuid.UUID) *Storage- updateStorage func(workspaceID uuid.UUID, storageID uuid.UUID) *Storage+ updateStorage func(workspaceID, storageID uuid.UUID) *StorageverifySensitiveData func(t *testing.T, storage *Storage)verifyHiddenData func(t *testing.T, storage *Storage)}{@@ -1149,7 +1149,7 @@ func Test_StorageSensitiveDataLifecycle_AllTypes(t *testing.T) {},}},- updateStorage: func(workspaceID uuid.UUID, storageID uuid.UUID) *Storage {+ updateStorage: func(workspaceID, storageID uuid.UUID) *Storage {return &Storage{ID: storageID,WorkspaceID: workspaceID,@@ -1195,7 +1195,7 @@ func Test_StorageSensitiveDataLifecycle_AllTypes(t *testing.T) {LocalStorage: &local_storage.LocalStorage{},}},- updateStorage: func(workspaceID uuid.UUID, storageID uuid.UUID) *Storage {+ updateStorage: func(workspaceID, storageID uuid.UUID) *Storage {return &Storage{ID: storageID,WorkspaceID: workspaceID,@@ -1229,7 +1229,7 @@ func Test_StorageSensitiveDataLifecycle_AllTypes(t *testing.T) {},}},- updateStorage: func(workspaceID uuid.UUID, storageID uuid.UUID) *Storage {+ updateStorage: func(workspaceID, storageID uuid.UUID) *Storage {return &Storage{ID: storageID,WorkspaceID: workspaceID,@@ -1277,7 +1277,7 @@ func Test_StorageSensitiveDataLifecycle_AllTypes(t *testing.T) {},}},- updateStorage: func(workspaceID uuid.UUID, storageID uuid.UUID) *Storage {+ updateStorage: func(workspaceID, storageID uuid.UUID) *Storage {return &Storage{ID: storageID,WorkspaceID: workspaceID,@@ -1327,7 +1327,7 @@ func Test_StorageSensitiveDataLifecycle_AllTypes(t *testing.T) {},}},- updateStorage: func(workspaceID uuid.UUID, storageID uuid.UUID) *Storage {+ updateStorage: func(workspaceID, storageID uuid.UUID) *Storage {return &Storage{ID: storageID,WorkspaceID: workspaceID,@@ -1375,7 +1375,7 @@ func Test_StorageSensitiveDataLifecycle_AllTypes(t *testing.T) {},}},- updateStorage: func(workspaceID uuid.UUID, storageID uuid.UUID) *Storage {+ updateStorage: func(workspaceID, storageID uuid.UUID) *Storage {return &Storage{ID: storageID,WorkspaceID: workspaceID,@@ -1436,7 +1436,7 @@ func Test_StorageSensitiveDataLifecycle_AllTypes(t *testing.T) {},}},- updateStorage: func(workspaceID uuid.UUID, storageID uuid.UUID) *Storage {+ updateStorage: func(workspaceID, storageID uuid.UUID) *Storage {return &Storage{ID: storageID,WorkspaceID: workspaceID,@@ -1484,7 +1484,7 @@ func Test_StorageSensitiveDataLifecycle_AllTypes(t *testing.T) {},}},- updateStorage: func(workspaceID uuid.UUID, storageID uuid.UUID) *Storage {+ updateStorage: func(workspaceID, storageID uuid.UUID) *Storage {return &Storage{ID: storageID,WorkspaceID: workspaceID,@@ -1535,7 +1535,7 @@ func Test_StorageSensitiveDataLifecycle_AllTypes(t *testing.T) {},}},- updateStorage: func(workspaceID uuid.UUID, storageID uuid.UUID) *Storage {+ updateStorage: func(workspaceID, storageID uuid.UUID) *Storage {return &Storage{ID: storageID,WorkspaceID: workspaceID,@@ -2136,7 +2136,7 @@ func createNewStorage(workspaceID uuid.UUID) *Storage {}}-func verifyStorageData(t *testing.T, expected *Storage, actual *Storage) {+func verifyStorageData(t *testing.T, expected, actual *Storage) {assert.Equal(t, expected.Name, actual.Name)assert.Equal(t, expected.Type, actual.Type)assert.Equal(t, expected.WorkspaceID, actual.WorkspaceID)diff --git a/backend/internal/features/storages/di.go b/backend/internal/features/storages/di.goindex 57822b88..e3b6ad95 100644--- a/backend/internal/features/storages/di.go+++ b/backend/internal/features/storages/di.go@@ -10,14 +10,17 @@ import ("databasus-backend/internal/util/logger")-var storageRepository = &StorageRepository{}-var storageService = &StorageService{- storageRepository,- workspaces_services.GetWorkspaceService(),- audit_logs.GetAuditLogService(),- encryption.GetFieldEncryptor(),- nil,-}+var (+ storageRepository = &StorageRepository{}+ storageService = &StorageService{+ storageRepository,+ workspaces_services.GetWorkspaceService(),+ audit_logs.GetAuditLogService(),+ encryption.GetFieldEncryptor(),+ nil,+ }+)+var storageController = &StorageController{storageService,workspaces_services.GetWorkspaceService(),diff --git a/backend/internal/features/storages/interfaces.go b/backend/internal/features/storages/interfaces.goindex 67421f6b..39fb7574 100644--- a/backend/internal/features/storages/interfaces.go+++ b/backend/internal/features/storages/interfaces.go@@ -2,11 +2,12 @@ package storagesimport ("context"- "databasus-backend/internal/util/encryption""io""log/slog""github.com/google/uuid"++ "databasus-backend/internal/util/encryption")type StorageFileSaver interface {diff --git a/backend/internal/features/storages/model.go b/backend/internal/features/storages/model.goindex 3ab6a99c..a762bdaf 100644--- a/backend/internal/features/storages/model.go+++ b/backend/internal/features/storages/model.go@@ -2,6 +2,12 @@ package storagesimport ("context"+ "errors"+ "io"+ "log/slog"++ "github.com/google/uuid"+azure_blob_storage "databasus-backend/internal/features/storages/models/azure_blob"ftp_storage "databasus-backend/internal/features/storages/models/ftp"google_drive_storage "databasus-backend/internal/features/storages/models/google_drive"@@ -11,11 +17,6 @@ import (s3_storage "databasus-backend/internal/features/storages/models/s3"sftp_storage "databasus-backend/internal/features/storages/models/sftp""databasus-backend/internal/util/encryption"- "errors"- "io"- "log/slog"-- "github.com/google/uuid")type Storage struct {diff --git a/backend/internal/features/storages/model_test.go b/backend/internal/features/storages/model_test.goindex ee9bb17f..3958921f 100644--- a/backend/internal/features/storages/model_test.go+++ b/backend/internal/features/storages/model_test.go@@ -3,17 +3,6 @@ package storagesimport ("bytes""context"- "databasus-backend/internal/config"- azure_blob_storage "databasus-backend/internal/features/storages/models/azure_blob"- ftp_storage "databasus-backend/internal/features/storages/models/ftp"- google_drive_storage "databasus-backend/internal/features/storages/models/google_drive"- local_storage "databasus-backend/internal/features/storages/models/local"- nas_storage "databasus-backend/internal/features/storages/models/nas"- rclone_storage "databasus-backend/internal/features/storages/models/rclone"- s3_storage "databasus-backend/internal/features/storages/models/s3"- sftp_storage "databasus-backend/internal/features/storages/models/sftp"- "databasus-backend/internal/util/encryption"- "databasus-backend/internal/util/logger""fmt""io""os"@@ -28,6 +17,18 @@ import ("github.com/minio/minio-go/v7/pkg/credentials""github.com/stretchr/testify/assert""github.com/stretchr/testify/require"++ "databasus-backend/internal/config"+ azure_blob_storage "databasus-backend/internal/features/storages/models/azure_blob"+ ftp_storage "databasus-backend/internal/features/storages/models/ftp"+ google_drive_storage "databasus-backend/internal/features/storages/models/google_drive"+ local_storage "databasus-backend/internal/features/storages/models/local"+ nas_storage "databasus-backend/internal/features/storages/models/nas"+ rclone_storage "databasus-backend/internal/features/storages/models/rclone"+ s3_storage "databasus-backend/internal/features/storages/models/s3"+ sftp_storage "databasus-backend/internal/features/storages/models/sftp"+ "databasus-backend/internal/util/encryption"+ "databasus-backend/internal/util/logger")type S3Container struct {@@ -283,7 +284,7 @@ func setupTestFile() (string, error) {testData := []byte("This is test data for storage testing")// 0644 means: owner can read/write- err := os.WriteFile(testFilePath, testData, 0644)+ err := os.WriteFile(testFilePath, testData, 0o644)if err != nil {return "", fmt.Errorf("failed to create test file: %w", err)}diff --git a/backend/internal/features/storages/models/azure_blob/model.go b/backend/internal/features/storages/models/azure_blob/model.goindex 302779d9..32f5d425 100644--- a/backend/internal/features/storages/models/azure_blob/model.go+++ b/backend/internal/features/storages/models/azure_blob/model.go@@ -3,7 +3,6 @@ package azure_blob_storageimport ("bytes""context"- "databasus-backend/internal/util/encryption""encoding/base64""errors""fmt"@@ -19,6 +18,8 @@ import ("github.com/Azure/azure-sdk-for-go/sdk/storage/azblob""github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/blockblob""github.com/google/uuid"++ "databasus-backend/internal/util/encryption")const (diff --git a/backend/internal/features/storages/models/ftp/model.go b/backend/internal/features/storages/models/ftp/model.goindex f17e1d86..1066a97b 100644--- a/backend/internal/features/storages/models/ftp/model.go+++ b/backend/internal/features/storages/models/ftp/model.go@@ -3,7 +3,6 @@ package ftp_storageimport ("context""crypto/tls"- "databasus-backend/internal/util/encryption""errors""fmt""io"@@ -13,6 +12,8 @@ import ("github.com/google/uuid""github.com/jlaffaye/ftp"++ "databasus-backend/internal/util/encryption")const (diff --git a/backend/internal/features/storages/models/google_drive/model.go b/backend/internal/features/storages/models/google_drive/model.goindex 2194b4a1..74f2424f 100644--- a/backend/internal/features/storages/models/google_drive/model.go+++ b/backend/internal/features/storages/models/google_drive/model.go@@ -2,7 +2,6 @@ package google_drive_storageimport ("context"- "databasus-backend/internal/util/encryption""encoding/json""errors""fmt"@@ -16,10 +15,11 @@ import ("github.com/google/uuid""golang.org/x/oauth2""golang.org/x/oauth2/google"-drive "google.golang.org/api/drive/v3""google.golang.org/api/googleapi""google.golang.org/api/option"++ "databasus-backend/internal/util/encryption")const (@@ -633,7 +633,6 @@ func (s *GoogleDriveStorage) deleteByName(return nil})-if err != nil {return fmt.Errorf("failed to delete %q: %w", name, err)}diff --git a/backend/internal/features/storages/models/local/model.go b/backend/internal/features/storages/models/local/model.goindex a08da638..79a4f951 100644--- a/backend/internal/features/storages/models/local/model.go+++ b/backend/internal/features/storages/models/local/model.go@@ -2,9 +2,6 @@ package local_storageimport ("context"- "databasus-backend/internal/config"- "databasus-backend/internal/util/encryption"- files_utils "databasus-backend/internal/util/files""fmt""io""log/slog"@@ -12,6 +9,10 @@ import ("path/filepath""github.com/google/uuid"++ "databasus-backend/internal/config"+ "databasus-backend/internal/util/encryption"+ files_utils "databasus-backend/internal/util/files")const (diff --git a/backend/internal/features/storages/models/nas/model.go b/backend/internal/features/storages/models/nas/model.goindex c09e8cfd..2ccec4c7 100644--- a/backend/internal/features/storages/models/nas/model.go+++ b/backend/internal/features/storages/models/nas/model.go@@ -3,7 +3,6 @@ package nas_storageimport ("context""crypto/tls"- "databasus-backend/internal/util/encryption""errors""fmt""io"@@ -15,6 +14,8 @@ import ("github.com/google/uuid""github.com/hirochachacha/go-smb2"++ "databasus-backend/internal/util/encryption")const (@@ -399,7 +400,7 @@ func (n *NASStorage) ensureDirectory(fs *smb2.Share, path string) error {_, err := fs.Stat(currentPath)if err != nil {// Directory doesn't exist, try to create it- err = fs.Mkdir(currentPath, 0755)+ err = fs.Mkdir(currentPath, 0o755)if err != nil {return fmt.Errorf("failed to create directory '%s': %w", currentPath, err)}diff --git a/backend/internal/features/storages/models/rclone/model.go b/backend/internal/features/storages/models/rclone/model.goindex 8ba7e14c..6b9f9fb6 100644--- a/backend/internal/features/storages/models/rclone/model.go+++ b/backend/internal/features/storages/models/rclone/model.go@@ -3,7 +3,6 @@ package rclone_storageimport ("bufio""context"- "databasus-backend/internal/util/encryption""errors""fmt""io"@@ -13,11 +12,12 @@ import ("time""github.com/google/uuid"+ _ "github.com/rclone/rclone/backend/all""github.com/rclone/rclone/fs""github.com/rclone/rclone/fs/config""github.com/rclone/rclone/fs/operations"- _ "github.com/rclone/rclone/backend/all"+ "databasus-backend/internal/util/encryption")const (diff --git a/backend/internal/features/storages/models/s3/model.go b/backend/internal/features/storages/models/s3/model.goindex 77763bbf..5b1e9d56 100644--- a/backend/internal/features/storages/models/s3/model.go+++ b/backend/internal/features/storages/models/s3/model.go@@ -5,7 +5,6 @@ import ("context""crypto/md5""crypto/tls"- "databasus-backend/internal/util/encryption""encoding/base64""errors""fmt"@@ -19,6 +18,8 @@ import ("github.com/google/uuid""github.com/minio/minio-go/v7""github.com/minio/minio-go/v7/pkg/credentials"++ "databasus-backend/internal/util/encryption")const (@@ -423,7 +424,7 @@ func (s *S3Storage) getCoreClient(encryptor encryption.FieldEncryptor) (*minio.Cfunc (s *S3Storage) getClientParams(encryptor encryption.FieldEncryptor,-) (endpoint string, useSSL bool, accessKey string, secretKey string, bucketLookup minio.BucketLookupType, transport *http.Transport, err error) {+) (endpoint string, useSSL bool, accessKey, secretKey string, bucketLookup minio.BucketLookupType, transport *http.Transport, err error) {endpoint = s.S3EndpointuseSSL = truediff --git a/backend/internal/features/storages/models/sftp/model.go b/backend/internal/features/storages/models/sftp/model.goindex 29de2980..b3f56dba 100644--- a/backend/internal/features/storages/models/sftp/model.go+++ b/backend/internal/features/storages/models/sftp/model.go@@ -2,7 +2,6 @@ package sftp_storageimport ("context"- "databasus-backend/internal/util/encryption""errors""fmt""io"@@ -14,6 +13,8 @@ import ("github.com/google/uuid""github.com/pkg/sftp""golang.org/x/crypto/ssh"++ "databasus-backend/internal/util/encryption")const (diff --git a/backend/internal/features/storages/repository.go b/backend/internal/features/storages/repository.goindex 1aae3dc6..a042cb56 100644--- a/backend/internal/features/storages/repository.go+++ b/backend/internal/features/storages/repository.go@@ -1,10 +1,10 @@package storagesimport (- db "databasus-backend/internal/storage"-"github.com/google/uuid""gorm.io/gorm"++ db "databasus-backend/internal/storage")type StorageRepository struct{}@@ -123,7 +123,6 @@ func (r *StorageRepository) Save(storage *Storage) (*Storage, error) {return nil})-if err != nil {return nil, err}diff --git a/backend/internal/features/storages/service.go b/backend/internal/features/storages/service.goindex d918dedd..46fb3ab6 100644--- a/backend/internal/features/storages/service.go+++ b/backend/internal/features/storages/service.go@@ -3,14 +3,14 @@ package storagesimport ("fmt"+ "github.com/google/uuid"+"databasus-backend/internal/config"audit_logs "databasus-backend/internal/features/audit_logs"users_enums "databasus-backend/internal/features/users/enums"users_models "databasus-backend/internal/features/users/models"workspaces_services "databasus-backend/internal/features/workspaces/services""databasus-backend/internal/util/encryption"-- "github.com/google/uuid")type StorageService struct {diff --git a/backend/internal/features/storages/testing.go b/backend/internal/features/storages/testing.goindex b51ba700..768e2875 100644--- a/backend/internal/features/storages/testing.go+++ b/backend/internal/features/storages/testing.go@@ -1,9 +1,9 @@package storagesimport (- local_storage "databasus-backend/internal/features/storages/models/local"-"github.com/google/uuid"++ local_storage "databasus-backend/internal/features/storages/models/local")func CreateTestStorage(workspaceID uuid.UUID) *Storage {diff --git a/backend/internal/features/system/healthcheck/di.go b/backend/internal/features/system/healthcheck/di.goindex e5e85c0a..234b625e 100644--- a/backend/internal/features/system/healthcheck/di.go+++ b/backend/internal/features/system/healthcheck/di.go@@ -10,6 +10,7 @@ var healthcheckService = &HealthcheckService{backuping.GetBackupsScheduler(),backuping.GetBackuperNode(),}+var healthcheckController = &HealthcheckController{healthcheckService,}diff --git a/backend/internal/features/system/healthcheck/service.go b/backend/internal/features/system/healthcheck/service.goindex a308ff07..fd41de58 100644--- a/backend/internal/features/system/healthcheck/service.go+++ b/backend/internal/features/system/healthcheck/service.go@@ -2,13 +2,14 @@ package system_healthcheckimport ("context"+ "errors"+ "time"+"databasus-backend/internal/config""databasus-backend/internal/features/backups/backups/backuping""databasus-backend/internal/features/disk""databasus-backend/internal/storage"cache_utils "databasus-backend/internal/util/cache"- "errors"- "time")type HealthcheckService struct {@@ -43,7 +44,6 @@ func (s *HealthcheckService) performHealthCheck() error {db := storage.GetDb()err = db.Raw("SELECT 1").Error-if err != nil {return errors.New("cannot connect to the database")}@@ -61,7 +61,6 @@ func (s *HealthcheckService) performHealthCheck() error {if config.GetEnv().IsProcessingNode {if !s.backuperNode.IsBackuperRunning() {return errors.New("backuper node is not running for more than 5 minutes")-}}diff --git a/backend/internal/features/tasks/cancellation/cancel_manager.go b/backend/internal/features/tasks/cancellation/cancel_manager.goindex 5a98eac9..992ac22a 100644--- a/backend/internal/features/tasks/cancellation/cancel_manager.go+++ b/backend/internal/features/tasks/cancellation/cancel_manager.go@@ -2,11 +2,12 @@ package task_cancellationimport ("context"- cache_utils "databasus-backend/internal/util/cache""log/slog""sync""github.com/google/uuid"++ cache_utils "databasus-backend/internal/util/cache")const taskCancelChannel = "task:cancel"diff --git a/backend/internal/features/tasks/cancellation/di.go b/backend/internal/features/tasks/cancellation/di.goindex 17635215..e3026531 100644--- a/backend/internal/features/tasks/cancellation/di.go+++ b/backend/internal/features/tasks/cancellation/di.go@@ -5,10 +5,10 @@ import ("sync""sync/atomic"+ "github.com/google/uuid"+cache_utils "databasus-backend/internal/util/cache""databasus-backend/internal/util/logger"-- "github.com/google/uuid")var taskCancelManager = &TaskCancelManager{diff --git a/backend/internal/features/tests/mariadb_backup_restore_test.go b/backend/internal/features/tests/mariadb_backup_restore_test.goindex 43f2cf7c..4b05b934 100644--- a/backend/internal/features/tests/mariadb_backup_restore_test.go+++ b/backend/internal/features/tests/mariadb_backup_restore_test.go@@ -587,7 +587,7 @@ func waitForMariadbRestoreCompletion(}}-func verifyMariadbDataIntegrity(t *testing.T, originalDB *sqlx.DB, restoredDB *sqlx.DB) {+func verifyMariadbDataIntegrity(t *testing.T, originalDB, restoredDB *sqlx.DB) {var originalData []MariadbTestDataItemvar restoredData []MariadbTestDataItemdiff --git a/backend/internal/features/tests/mysql_backup_restore_test.go b/backend/internal/features/tests/mysql_backup_restore_test.goindex 71d09b59..b14e3267 100644--- a/backend/internal/features/tests/mysql_backup_restore_test.go+++ b/backend/internal/features/tests/mysql_backup_restore_test.go@@ -542,7 +542,7 @@ func waitForMysqlRestoreCompletion(}}-func verifyMysqlDataIntegrity(t *testing.T, originalDB *sqlx.DB, restoredDB *sqlx.DB) {+func verifyMysqlDataIntegrity(t *testing.T, originalDB, restoredDB *sqlx.DB) {var originalData []MysqlTestDataItemvar restoredData []MysqlTestDataItemdiff --git a/backend/internal/features/tests/postgresql_backup_restore_test.go b/backend/internal/features/tests/postgresql_backup_restore_test.goindex 5e78a3dd..3dbc7bed 100644--- a/backend/internal/features/tests/postgresql_backup_restore_test.go+++ b/backend/internal/features/tests/postgresql_backup_restore_test.go@@ -376,7 +376,7 @@ func Test_BackupAndRestorePostgresql_WithReadOnlyUser_RestoreIsSuccessful(t *tes}}-func testBackupRestoreForVersion(t *testing.T, pgVersion string, port string, cpuCount int) {+func testBackupRestoreForVersion(t *testing.T, pgVersion, port string, cpuCount int) {container, err := connectToPostgresContainer(pgVersion, port)assert.NoError(t, err)defer func() {@@ -478,7 +478,7 @@ func testBackupRestoreForVersion(t *testing.T, pgVersion string, port string, cpworkspaces_testing.RemoveTestWorkspace(workspace, router)}-func testSchemaSelectionAllSchemasForVersion(t *testing.T, pgVersion string, port string) {+func testSchemaSelectionAllSchemasForVersion(t *testing.T, pgVersion, port string) {container, err := connectToPostgresContainer(pgVersion, port)if err != nil {t.Fatalf("Failed to connect to PostgreSQL container: %v", err)@@ -607,7 +607,7 @@ func testSchemaSelectionAllSchemasForVersion(t *testing.T, pgVersion string, porworkspaces_testing.RemoveTestWorkspace(workspace, router)}-func testBackupRestoreWithExcludeExtensionsForVersion(t *testing.T, pgVersion string, port string) {+func testBackupRestoreWithExcludeExtensionsForVersion(t *testing.T, pgVersion, port string) {container, err := connectToPostgresContainer(pgVersion, port)if err != nil {t.Fatalf("Failed to connect to PostgreSQL container: %v", err)@@ -885,7 +885,7 @@ func testBackupRestoreWithoutExcludeExtensionsForVersion(workspaces_testing.RemoveTestWorkspace(workspace, router)}-func testBackupRestoreWithReadOnlyUserForVersion(t *testing.T, pgVersion string, port string) {+func testBackupRestoreWithReadOnlyUserForVersion(t *testing.T, pgVersion, port string) {container, err := connectToPostgresContainer(pgVersion, port)assert.NoError(t, err)defer func() {@@ -1128,7 +1128,7 @@ func testSchemaSelectionOnlySpecifiedSchemasForVersion(workspaces_testing.RemoveTestWorkspace(workspace, router)}-func testBackupRestoreWithEncryptionForVersion(t *testing.T, pgVersion string, port string) {+func testBackupRestoreWithEncryptionForVersion(t *testing.T, pgVersion, port string) {container, err := connectToPostgresContainer(pgVersion, port)assert.NoError(t, err)defer func() {@@ -1673,7 +1673,7 @@ func createSupabaseRestoreViaAPI()}-func verifyDataIntegrity(t *testing.T, originalDB *sqlx.DB, restoredDB *sqlx.DB, tableName string) {+func verifyDataIntegrity(t *testing.T, originalDB, restoredDB *sqlx.DB, tableName string) {var originalData []TestDataItemvar restoredData []TestDataItem@@ -1755,7 +1755,7 @@ func updateDatabaseCredentialsViaAPI(return &updatedDatabase}-func connectToPostgresContainer(version string, port string) (*PostgresContainer, error) {+func connectToPostgresContainer(version, port string) (*PostgresContainer, error) {dbName := "testdb"password := "testpassword"username := "testuser"diff --git a/backend/internal/features/users/controllers/e2e_test.go b/backend/internal/features/users/controllers/e2e_test.goindex 06dd892c..7981dff1 100644--- a/backend/internal/features/users/controllers/e2e_test.go+++ b/backend/internal/features/users/controllers/e2e_test.go@@ -4,16 +4,16 @@ import ("net/http""testing"+ "github.com/gin-gonic/gin"+ "github.com/google/uuid"+ "github.com/stretchr/testify/assert"+users_dto "databasus-backend/internal/features/users/dto"users_enums "databasus-backend/internal/features/users/enums"users_middleware "databasus-backend/internal/features/users/middleware"users_services "databasus-backend/internal/features/users/services"users_testing "databasus-backend/internal/features/users/testing"test_utils "databasus-backend/internal/util/testing"-- "github.com/gin-gonic/gin"- "github.com/google/uuid"- "github.com/stretchr/testify/assert")func Test_AdminLifecycleE2E_CompletesSuccessfully(t *testing.T) {diff --git a/backend/internal/features/users/controllers/management_controller.go b/backend/internal/features/users/controllers/management_controller.goindex f4c3f989..66b4aa29 100644--- a/backend/internal/features/users/controllers/management_controller.go+++ b/backend/internal/features/users/controllers/management_controller.go@@ -4,13 +4,13 @@ import ("fmt""net/http"+ "github.com/gin-gonic/gin"+ "github.com/google/uuid"+user_dto "databasus-backend/internal/features/users/dto"user_enums "databasus-backend/internal/features/users/enums"user_middleware "databasus-backend/internal/features/users/middleware"users_services "databasus-backend/internal/features/users/services"-- "github.com/gin-gonic/gin"- "github.com/google/uuid")type ManagementController struct {diff --git a/backend/internal/features/users/controllers/management_controller_test.go b/backend/internal/features/users/controllers/management_controller_test.goindex a68ef318..3681e309 100644--- a/backend/internal/features/users/controllers/management_controller_test.go+++ b/backend/internal/features/users/controllers/management_controller_test.go@@ -5,6 +5,10 @@ import ("testing""time"+ "github.com/gin-gonic/gin"+ "github.com/google/uuid"+ "github.com/stretchr/testify/assert"+"databasus-backend/internal/features/audit_logs"users_dto "databasus-backend/internal/features/users/dto"users_enums "databasus-backend/internal/features/users/enums"@@ -15,10 +19,6 @@ import (workspaces_dto "databasus-backend/internal/features/workspaces/dto"workspaces_testing "databasus-backend/internal/features/workspaces/testing"test_utils "databasus-backend/internal/util/testing"-- "github.com/gin-gonic/gin"- "github.com/google/uuid"- "github.com/stretchr/testify/assert")func Test_GetUsersList_WhenUserIsAdmin_ReturnsUsers(t *testing.T) {diff --git a/backend/internal/features/users/controllers/password_reset_test.go b/backend/internal/features/users/controllers/password_reset_test.goindex 65a3f54e..c56cd2d5 100644--- a/backend/internal/features/users/controllers/password_reset_test.go+++ b/backend/internal/features/users/controllers/password_reset_test.go@@ -5,6 +5,10 @@ import ("testing""time"+ "github.com/google/uuid"+ "github.com/stretchr/testify/assert"+ "golang.org/x/crypto/bcrypt"+users_dto "databasus-backend/internal/features/users/dto"users_enums "databasus-backend/internal/features/users/enums"users_models "databasus-backend/internal/features/users/models"@@ -12,10 +16,6 @@ import (users_testing "databasus-backend/internal/features/users/testing""databasus-backend/internal/storage"test_utils "databasus-backend/internal/util/testing"-- "github.com/google/uuid"- "github.com/stretchr/testify/assert"- "golang.org/x/crypto/bcrypt")func Test_SendResetPasswordCode_WithValidEmail_CodeSent(t *testing.T) {diff --git a/backend/internal/features/users/controllers/settings_controller.go b/backend/internal/features/users/controllers/settings_controller.goindex a9fbaefb..7bf46085 100644--- a/backend/internal/features/users/controllers/settings_controller.go+++ b/backend/internal/features/users/controllers/settings_controller.go@@ -3,12 +3,12 @@ package users_controllersimport ("net/http"+ "github.com/gin-gonic/gin"+user_enums "databasus-backend/internal/features/users/enums"user_middleware "databasus-backend/internal/features/users/middleware"user_models "databasus-backend/internal/features/users/models"users_services "databasus-backend/internal/features/users/services"-- "github.com/gin-gonic/gin")type SettingsController struct {diff --git a/backend/internal/features/users/controllers/settings_controller_test.go b/backend/internal/features/users/controllers/settings_controller_test.goindex 5a45ad35..0db8ccd5 100644--- a/backend/internal/features/users/controllers/settings_controller_test.go+++ b/backend/internal/features/users/controllers/settings_controller_test.go@@ -4,12 +4,12 @@ import ("net/http""testing"+ "github.com/stretchr/testify/assert"+users_enums "databasus-backend/internal/features/users/enums"users_models "databasus-backend/internal/features/users/models"users_testing "databasus-backend/internal/features/users/testing"test_utils "databasus-backend/internal/util/testing"-- "github.com/stretchr/testify/assert")func Test_GetUserSettings_WhenUserIsAdmin_ReturnsSettings(t *testing.T) {diff --git a/backend/internal/features/users/controllers/user_controller.go b/backend/internal/features/users/controllers/user_controller.goindex 08455834..cd80ca48 100644--- a/backend/internal/features/users/controllers/user_controller.go+++ b/backend/internal/features/users/controllers/user_controller.go@@ -5,6 +5,8 @@ import ("net/http""time"+ "github.com/gin-gonic/gin"+"databasus-backend/internal/config"user_dto "databasus-backend/internal/features/users/dto"users_errors "databasus-backend/internal/features/users/errors"@@ -12,8 +14,6 @@ import (users_services "databasus-backend/internal/features/users/services"cache_utils "databasus-backend/internal/util/cache"cloudflare_turnstile "databasus-backend/internal/util/cloudflare_turnstile"-- "github.com/gin-gonic/gin")type UserController struct {diff --git a/backend/internal/features/users/controllers/user_controller_test.go b/backend/internal/features/users/controllers/user_controller_test.goindex 6c8be5c7..cdad166a 100644--- a/backend/internal/features/users/controllers/user_controller_test.go+++ b/backend/internal/features/users/controllers/user_controller_test.go@@ -7,15 +7,15 @@ import ("net/http/httptest""testing"+ "github.com/google/uuid"+ "github.com/stretchr/testify/assert"+ "golang.org/x/oauth2"+users_dto "databasus-backend/internal/features/users/dto"users_enums "databasus-backend/internal/features/users/enums"users_services "databasus-backend/internal/features/users/services"users_testing "databasus-backend/internal/features/users/testing"test_utils "databasus-backend/internal/util/testing"-- "github.com/google/uuid"- "github.com/stretchr/testify/assert"- "golang.org/x/oauth2")func Test_SignUpUser_WithValidData_UserCreated(t *testing.T) {diff --git a/backend/internal/features/users/dto/dto.go b/backend/internal/features/users/dto/dto.goindex 5e224f98..dc092be4 100644--- a/backend/internal/features/users/dto/dto.go+++ b/backend/internal/features/users/dto/dto.go@@ -3,9 +3,9 @@ package users_dtoimport ("time"- users_enums "databasus-backend/internal/features/users/enums"-"github.com/google/uuid"++ users_enums "databasus-backend/internal/features/users/enums")type SignUpRequestDTO struct {diff --git a/backend/internal/features/users/errors/errors.go b/backend/internal/features/users/errors/errors.goindex d25ea8a1..e4045892 100644--- a/backend/internal/features/users/errors/errors.go+++ b/backend/internal/features/users/errors/errors.go@@ -2,6 +2,4 @@ package users_errorsimport "errors"-var (- ErrInsufficientPermissionsToInviteUsers = errors.New("insufficient permissions to invite users")-)+var ErrInsufficientPermissionsToInviteUsers = errors.New("insufficient permissions to invite users")diff --git a/backend/internal/features/users/interfaces/interfaces.go b/backend/internal/features/users/interfaces/interfaces.goindex 07c9acd8..4b606377 100644--- a/backend/internal/features/users/interfaces/interfaces.go+++ b/backend/internal/features/users/interfaces/interfaces.go@@ -5,7 +5,7 @@ import ()type AuditLogWriter interface {- WriteAuditLog(message string, userID *uuid.UUID, workspaceID *uuid.UUID)+ WriteAuditLog(message string, userID, workspaceID *uuid.UUID)}type EmailSender interface {diff --git a/backend/internal/features/users/middleware/middleware.go b/backend/internal/features/users/middleware/middleware.goindex 3bb710af..43e41ced 100644--- a/backend/internal/features/users/middleware/middleware.go+++ b/backend/internal/features/users/middleware/middleware.go@@ -1,12 +1,13 @@package users_middlewareimport (- users_enums "databasus-backend/internal/features/users/enums"- users_models "databasus-backend/internal/features/users/models"- users_services "databasus-backend/internal/features/users/services""net/http""github.com/gin-gonic/gin"++ users_enums "databasus-backend/internal/features/users/enums"+ users_models "databasus-backend/internal/features/users/models"+ users_services "databasus-backend/internal/features/users/services")// AuthMiddleware validates JWT token and adds user to contextdiff --git a/backend/internal/features/users/models/user.go b/backend/internal/features/users/models/user.goindex e4f218c5..592b293b 100644--- a/backend/internal/features/users/models/user.go+++ b/backend/internal/features/users/models/user.go@@ -1,10 +1,11 @@package users_modelsimport (- users_enums "databasus-backend/internal/features/users/enums""time""github.com/google/uuid"++ users_enums "databasus-backend/internal/features/users/enums")type User struct {diff --git a/backend/internal/features/users/repositories/di.go b/backend/internal/features/users/repositories/di.goindex b4b4e6a1..af676239 100644--- a/backend/internal/features/users/repositories/di.go+++ b/backend/internal/features/users/repositories/di.go@@ -1,8 +1,10 @@package users_repositories-var userRepository = &UserRepository{}-var usersSettingsRepository = &UsersSettingsRepository{}-var passwordResetRepository = &PasswordResetRepository{}+var (+ userRepository = &UserRepository{}+ usersSettingsRepository = &UsersSettingsRepository{}+ passwordResetRepository = &PasswordResetRepository{}+)func GetUserRepository() *UserRepository {return userRepositorydiff --git a/backend/internal/features/users/repositories/password_reset_repository.go b/backend/internal/features/users/repositories/password_reset_repository.goindex 1c851044..1ccdeb83 100644--- a/backend/internal/features/users/repositories/password_reset_repository.go+++ b/backend/internal/features/users/repositories/password_reset_repository.go@@ -3,10 +3,10 @@ package users_repositoriesimport ("time"+ "github.com/google/uuid"+users_models "databasus-backend/internal/features/users/models""databasus-backend/internal/storage"-- "github.com/google/uuid")type PasswordResetRepository struct{}@@ -27,7 +27,6 @@ func (r *PasswordResetRepository) GetValidCodeByUserID(Where("user_id = ? AND is_used = ? AND expires_at > ?", userID, false, time.Now().UTC()).Order("created_at DESC").First(&code).Error-if err != nil {return nil, err}diff --git a/backend/internal/features/users/repositories/user_repository.go b/backend/internal/features/users/repositories/user_repository.goindex 23181580..10830ca1 100644--- a/backend/internal/features/users/repositories/user_repository.go+++ b/backend/internal/features/users/repositories/user_repository.go@@ -1,14 +1,15 @@package users_repositoriesimport (- users_enums "databasus-backend/internal/features/users/enums"- users_models "databasus-backend/internal/features/users/models"- "databasus-backend/internal/storage""fmt""time""github.com/google/uuid""gorm.io/gorm"++ users_enums "databasus-backend/internal/features/users/enums"+ users_models "databasus-backend/internal/features/users/models"+ "databasus-backend/internal/storage")type UserRepository struct{}@@ -156,7 +157,7 @@ func (r *UserRepository) RenameUserEmailForTests(oldEmail, newEmail string) erroreturn nil}-func (r *UserRepository) UpdateUserInfo(userID uuid.UUID, name *string, email *string) error {+func (r *UserRepository) UpdateUserInfo(userID uuid.UUID, name, email *string) error {updates := make(map[string]any)if name != nil {diff --git a/backend/internal/features/users/repositories/users_settings_repository.go b/backend/internal/features/users/repositories/users_settings_repository.goindex 82e5f93d..e15fc10e 100644--- a/backend/internal/features/users/repositories/users_settings_repository.go+++ b/backend/internal/features/users/repositories/users_settings_repository.go@@ -1,11 +1,11 @@package users_repositoriesimport (- user_models "databasus-backend/internal/features/users/models"- "databasus-backend/internal/storage"-"github.com/google/uuid""gorm.io/gorm"++ user_models "databasus-backend/internal/features/users/models"+ "databasus-backend/internal/storage")type UsersSettingsRepository struct{}diff --git a/backend/internal/features/users/services/di.go b/backend/internal/features/users/services/di.goindex 43aa2b82..893f8e4d 100644--- a/backend/internal/features/users/services/di.go+++ b/backend/internal/features/users/services/di.go@@ -14,10 +14,12 @@ var userService = &UserService{email.GetEmailSMTPSender(),users_repositories.GetPasswordResetRepository(),}+var settingsService = &SettingsService{users_repositories.GetUsersSettingsRepository(),nil,}+var managementService = &UserManagementService{users_repositories.GetUserRepository(),nil,diff --git a/backend/internal/features/users/services/management_service.go b/backend/internal/features/users/services/management_service.goindex 3a039e21..b2dc09da 100644--- a/backend/internal/features/users/services/management_service.go+++ b/backend/internal/features/users/services/management_service.go@@ -5,12 +5,12 @@ import ("fmt""time"+ "github.com/google/uuid"+user_enums "databasus-backend/internal/features/users/enums"user_interfaces "databasus-backend/internal/features/users/interfaces"user_models "databasus-backend/internal/features/users/models"user_repositories "databasus-backend/internal/features/users/repositories"-- "github.com/google/uuid")type UserManagementService struct {diff --git a/backend/internal/features/users/services/oauth_testing.go b/backend/internal/features/users/services/oauth_testing.goindex 97f10e8b..e5eef165 100644--- a/backend/internal/features/users/services/oauth_testing.go+++ b/backend/internal/features/users/services/oauth_testing.go@@ -1,9 +1,9 @@package users_servicesimport (- users_dto "databasus-backend/internal/features/users/dto"-"golang.org/x/oauth2"++ users_dto "databasus-backend/internal/features/users/dto")func (s *UserService) HandleGitHubOAuthWithMockEndpoint(diff --git a/backend/internal/features/users/services/user_services.go b/backend/internal/features/users/services/user_services.goindex 2fbd12c3..f2837453 100644--- a/backend/internal/features/users/services/user_services.go+++ b/backend/internal/features/users/services/user_services.go@@ -194,7 +194,6 @@ func (s *UserService) GetUserFromToken(token string) (*users_models.User, error)}return []byte(secretKey), nil})-if err != nil {return nil, fmt.Errorf("invalid token: %w", err)}@@ -275,7 +274,6 @@ func (s *UserService) CreateInitialAdmin() error {func (s *UserService) IsRootAdminHasPassword() (bool, error) {admin, err := s.userRepository.GetUserByEmail("admin")-if err != nil {return false, fmt.Errorf("failed to get admin user: %w", err)}@@ -321,7 +319,7 @@ func (s *UserService) SetRootAdminPassword(password string) error {return nil}-func (s *UserService) ChangeUserPasswordByEmail(email string, newPassword string) error {+func (s *UserService) ChangeUserPasswordByEmail(email, newPassword string) error {user, err := s.userRepository.GetUserByEmail(email)if err != nil {return fmt.Errorf("failed to get user: %w", err)diff --git a/backend/internal/features/users/testing/user_utils.go b/backend/internal/features/users/testing/user_utils.goindex 50a6c4dd..6f4add2e 100644--- a/backend/internal/features/users/testing/user_utils.go+++ b/backend/internal/features/users/testing/user_utils.go@@ -5,13 +5,13 @@ import ("strings""time"+ "github.com/google/uuid"+users_dto "databasus-backend/internal/features/users/dto"users_enums "databasus-backend/internal/features/users/enums"users_models "databasus-backend/internal/features/users/models"users_repositories "databasus-backend/internal/features/users/repositories"users_services "databasus-backend/internal/features/users/services"-- "github.com/google/uuid")func CreateTestUser(role users_enums.UserRole) *users_dto.SignInResponseDTO {diff --git a/backend/internal/features/workspaces/controllers/e2e_test.go b/backend/internal/features/workspaces/controllers/e2e_test.goindex 44b6454c..d897c240 100644--- a/backend/internal/features/workspaces/controllers/e2e_test.go+++ b/backend/internal/features/workspaces/controllers/e2e_test.go@@ -4,15 +4,15 @@ import ("net/http""testing"+ "github.com/google/uuid"+ "github.com/stretchr/testify/assert"+users_enums "databasus-backend/internal/features/users/enums"users_testing "databasus-backend/internal/features/users/testing"workspaces_dto "databasus-backend/internal/features/workspaces/dto"workspaces_models "databasus-backend/internal/features/workspaces/models"workspaces_testing "databasus-backend/internal/features/workspaces/testing"test_utils "databasus-backend/internal/util/testing"-- "github.com/google/uuid"- "github.com/stretchr/testify/assert")func Test_WorkspaceLifecycleE2E_CompletesSuccessfully(t *testing.T) {diff --git a/backend/internal/features/workspaces/controllers/membership_controller.go b/backend/internal/features/workspaces/controllers/membership_controller.goindex 8297270c..8315d0a6 100644--- a/backend/internal/features/workspaces/controllers/membership_controller.go+++ b/backend/internal/features/workspaces/controllers/membership_controller.go@@ -4,13 +4,13 @@ import ("errors""net/http"+ "github.com/gin-gonic/gin"+ "github.com/google/uuid"+users_middleware "databasus-backend/internal/features/users/middleware"workspaces_dto "databasus-backend/internal/features/workspaces/dto"workspaces_errors "databasus-backend/internal/features/workspaces/errors"workspaces_services "databasus-backend/internal/features/workspaces/services"-- "github.com/gin-gonic/gin"- "github.com/google/uuid")type MembershipController struct {diff --git a/backend/internal/features/workspaces/controllers/membership_controller_test.go b/backend/internal/features/workspaces/controllers/membership_controller_test.goindex cb73439b..f2fcaffb 100644--- a/backend/internal/features/workspaces/controllers/membership_controller_test.go+++ b/backend/internal/features/workspaces/controllers/membership_controller_test.go@@ -6,14 +6,14 @@ import ("strings""testing"+ "github.com/google/uuid"+ "github.com/stretchr/testify/assert"+users_enums "databasus-backend/internal/features/users/enums"users_testing "databasus-backend/internal/features/users/testing"workspaces_dto "databasus-backend/internal/features/workspaces/dto"workspaces_testing "databasus-backend/internal/features/workspaces/testing"test_utils "databasus-backend/internal/util/testing"-- "github.com/google/uuid"- "github.com/stretchr/testify/assert")// ListMembers Testsdiff --git a/backend/internal/features/workspaces/controllers/workspace_controller.go b/backend/internal/features/workspaces/controllers/workspace_controller.goindex faac0d5c..cf757539 100644--- a/backend/internal/features/workspaces/controllers/workspace_controller.go+++ b/backend/internal/features/workspaces/controllers/workspace_controller.go@@ -4,15 +4,15 @@ import ("errors""net/http"+ "github.com/gin-gonic/gin"+ "github.com/google/uuid"+audit_logs "databasus-backend/internal/features/audit_logs"users_middleware "databasus-backend/internal/features/users/middleware"workspaces_dto "databasus-backend/internal/features/workspaces/dto"workspaces_errors "databasus-backend/internal/features/workspaces/errors"workspaces_models "databasus-backend/internal/features/workspaces/models"workspaces_services "databasus-backend/internal/features/workspaces/services"-- "github.com/gin-gonic/gin"- "github.com/google/uuid")type WorkspaceController struct {diff --git a/backend/internal/features/workspaces/controllers/workspace_controller_test.go b/backend/internal/features/workspaces/controllers/workspace_controller_test.goindex 826de085..671fab42 100644--- a/backend/internal/features/workspaces/controllers/workspace_controller_test.go+++ b/backend/internal/features/workspaces/controllers/workspace_controller_test.go@@ -5,6 +5,9 @@ import ("net/http""testing"+ "github.com/google/uuid"+ "github.com/stretchr/testify/assert"+audit_logs "databasus-backend/internal/features/audit_logs"users_dto "databasus-backend/internal/features/users/dto"users_enums "databasus-backend/internal/features/users/enums"@@ -15,9 +18,6 @@ import (workspaces_models "databasus-backend/internal/features/workspaces/models"workspaces_testing "databasus-backend/internal/features/workspaces/testing"test_utils "databasus-backend/internal/util/testing"-- "github.com/google/uuid"- "github.com/stretchr/testify/assert")func Test_CreateWorkspace_PermissionsEnforced(t *testing.T) {diff --git a/backend/internal/features/workspaces/dto/dto.go b/backend/internal/features/workspaces/dto/dto.goindex bcff4e1c..75790071 100644--- a/backend/internal/features/workspaces/dto/dto.go+++ b/backend/internal/features/workspaces/dto/dto.go@@ -3,9 +3,9 @@ package workspaces_dtoimport ("time"- users_enums "databasus-backend/internal/features/users/enums"-"github.com/google/uuid"++ users_enums "databasus-backend/internal/features/users/enums")type AddMemberStatus stringdiff --git a/backend/internal/features/workspaces/models/workspace_membership.go b/backend/internal/features/workspaces/models/workspace_membership.goindex ea067d12..d47ca3d6 100644--- a/backend/internal/features/workspaces/models/workspace_membership.go+++ b/backend/internal/features/workspaces/models/workspace_membership.go@@ -3,9 +3,9 @@ package workspaces_modelsimport ("time"- users_enums "databasus-backend/internal/features/users/enums"-"github.com/google/uuid"++ users_enums "databasus-backend/internal/features/users/enums")type WorkspaceMembership struct {diff --git a/backend/internal/features/workspaces/repositories/membership_repository.go b/backend/internal/features/workspaces/repositories/membership_repository.goindex 128efac9..3b008729 100644--- a/backend/internal/features/workspaces/repositories/membership_repository.go+++ b/backend/internal/features/workspaces/repositories/membership_repository.go@@ -4,13 +4,13 @@ import ("errors""time"+ "github.com/google/uuid"+ "gorm.io/gorm"+users_enums "databasus-backend/internal/features/users/enums"workspaces_dto "databasus-backend/internal/features/workspaces/dto"workspaces_models "databasus-backend/internal/features/workspaces/models""databasus-backend/internal/storage"-- "github.com/google/uuid"- "gorm.io/gorm")type MembershipRepository struct{}@@ -82,7 +82,6 @@ func (r *MembershipRepository) GetUserWorkspaceRole(err := storage.GetDb().Where("workspace_id = ? AND user_id = ?", workspaceID, userID).First(&membership).Error-if err != nil {if errors.Is(err, gorm.ErrRecordNotFound) {return nil, nil@@ -102,7 +101,6 @@ func (r *MembershipRepository) GetWorkspaceOwner(err := storage.GetDb().Where("workspace_id = ? AND role = ?", workspaceID, users_enums.WorkspaceRoleOwner).First(&membership).Error-if err != nil {return nil, err}diff --git a/backend/internal/features/workspaces/repositories/workspace_repository.go b/backend/internal/features/workspaces/repositories/workspace_repository.goindex c8385aa8..71bdca2e 100644--- a/backend/internal/features/workspaces/repositories/workspace_repository.go+++ b/backend/internal/features/workspaces/repositories/workspace_repository.go@@ -3,10 +3,10 @@ package workspaces_repositoriesimport ("time"+ "github.com/google/uuid"+workspaces_models "databasus-backend/internal/features/workspaces/models""databasus-backend/internal/storage"-- "github.com/google/uuid")type WorkspaceRepository struct{}diff --git a/backend/internal/features/workspaces/services/di.go b/backend/internal/features/workspaces/services/di.goindex e03867ca..fc480016 100644--- a/backend/internal/features/workspaces/services/di.go+++ b/backend/internal/features/workspaces/services/di.go@@ -9,8 +9,10 @@ import ("databasus-backend/internal/util/logger")-var workspaceRepository = &workspaces_repositories.WorkspaceRepository{}-var membershipRepository = &workspaces_repositories.MembershipRepository{}+var (+ workspaceRepository = &workspaces_repositories.WorkspaceRepository{}+ membershipRepository = &workspaces_repositories.MembershipRepository{}+)var workspaceService = &WorkspaceService{workspaceRepository,diff --git a/backend/internal/features/workspaces/services/membership_service.go b/backend/internal/features/workspaces/services/membership_service.goindex b47fbf21..b39d83d4 100644--- a/backend/internal/features/workspaces/services/membership_service.go+++ b/backend/internal/features/workspaces/services/membership_service.go@@ -4,6 +4,8 @@ import ("fmt""log/slog"+ "github.com/google/uuid"+"databasus-backend/internal/config"audit_logs "databasus-backend/internal/features/audit_logs"users_dto "databasus-backend/internal/features/users/dto"@@ -15,8 +17,6 @@ import (workspaces_interfaces "databasus-backend/internal/features/workspaces/interfaces"workspaces_models "databasus-backend/internal/features/workspaces/models"workspaces_repositories "databasus-backend/internal/features/workspaces/repositories"-- "github.com/google/uuid")type MembershipService struct {diff --git a/backend/internal/features/workspaces/services/workspace_service.go b/backend/internal/features/workspaces/services/workspace_service.goindex 2e7c16dd..937a77e4 100644--- a/backend/internal/features/workspaces/services/workspace_service.go+++ b/backend/internal/features/workspaces/services/workspace_service.go@@ -4,6 +4,8 @@ import ("fmt""time"+ "github.com/google/uuid"+audit_logs "databasus-backend/internal/features/audit_logs"users_enums "databasus-backend/internal/features/users/enums"users_models "databasus-backend/internal/features/users/models"@@ -13,8 +15,6 @@ import (workspaces_interfaces "databasus-backend/internal/features/workspaces/interfaces"workspaces_models "databasus-backend/internal/features/workspaces/models"workspaces_repositories "databasus-backend/internal/features/workspaces/repositories"-- "github.com/google/uuid")type WorkspaceService struct {@@ -37,7 +37,6 @@ func (s *WorkspaceService) CreateWorkspace(creator *users_models.User,) (*workspaces_dto.WorkspaceResponseDTO, error) {settings, err := s.settingsService.GetSettings()-if err != nil {return nil, fmt.Errorf("failed to get settings: %w", err)}@@ -116,7 +115,6 @@ func (s *WorkspaceService) UpdateWorkspace(user *users_models.User,) (*workspaces_models.Workspace, error) {canManage, err := s.CanUserManageWorkspace(workspaceID, user)-if err != nil {return nil, err}diff --git a/backend/internal/features/workspaces/testing/testing.go b/backend/internal/features/workspaces/testing/testing.goindex b4fb60eb..cafaebd5 100644--- a/backend/internal/features/workspaces/testing/testing.go+++ b/backend/internal/features/workspaces/testing/testing.go@@ -7,6 +7,9 @@ import ("net/http""net/http/httptest"+ "github.com/gin-gonic/gin"+ "github.com/google/uuid"+"databasus-backend/internal/features/audit_logs"users_dto "databasus-backend/internal/features/users/dto"users_enums "databasus-backend/internal/features/users/enums"@@ -16,9 +19,6 @@ import (workspaces_dto "databasus-backend/internal/features/workspaces/dto"workspaces_models "databasus-backend/internal/features/workspaces/models"workspaces_repositories "databasus-backend/internal/features/workspaces/repositories"-- "github.com/gin-gonic/gin"- "github.com/google/uuid")func CreateTestRouter(controllers ...ControllerInterface) *gin.Engine {diff --git a/backend/internal/storage/storage.go b/backend/internal/storage/storage.goindex f04688d0..c549ce84 100644--- a/backend/internal/storage/storage.go+++ b/backend/internal/storage/storage.go@@ -1,14 +1,15 @@package storageimport (- "databasus-backend/internal/config"- "databasus-backend/internal/util/logger""os""sync""gorm.io/driver/postgres""gorm.io/gorm"gormLogger "gorm.io/gorm/logger"++ "databasus-backend/internal/config"+ "databasus-backend/internal/util/logger")var log = logger.GetLogger()diff --git a/backend/internal/util/cache/cache.go b/backend/internal/util/cache/cache.goindex 6ea67602..0ab5aa85 100644--- a/backend/internal/util/cache/cache.go+++ b/backend/internal/util/cache/cache.go@@ -3,10 +3,11 @@ package cache_utilsimport ("context""crypto/tls"- "databasus-backend/internal/config""sync""github.com/valkey-io/valkey-go"++ "databasus-backend/internal/config")var (diff --git a/backend/internal/util/cache/pubsub.go b/backend/internal/util/cache/pubsub.goindex 965c463c..8b7f949c 100644--- a/backend/internal/util/cache/pubsub.go+++ b/backend/internal/util/cache/pubsub.go@@ -6,9 +6,9 @@ import ("log/slog""sync"- "databasus-backend/internal/util/logger"-"github.com/valkey-io/valkey-go"++ "databasus-backend/internal/util/logger")type PubSubManager struct {@@ -46,7 +46,7 @@ func (m *PubSubManager) Subscribe(return nil}-func (m *PubSubManager) Publish(ctx context.Context, channel string, message string) error {+func (m *PubSubManager) Publish(ctx context.Context, channel, message string) error {cmd := m.client.B().Publish().Channel(channel).Message(message).Build()result := m.client.Do(ctx, cmd)diff --git a/backend/internal/util/encryption/secret_key_field_encryptor.go b/backend/internal/util/encryption/secret_key_field_encryptor.goindex cee5f472..d01dcd38 100644--- a/backend/internal/util/encryption/secret_key_field_encryptor.go+++ b/backend/internal/util/encryption/secret_key_field_encryptor.go@@ -5,13 +5,14 @@ import ("crypto/cipher""crypto/hmac""crypto/sha256"- "databasus-backend/internal/features/encryption/secrets""encoding/base64""errors""fmt""strings""github.com/google/uuid"++ "databasus-backend/internal/features/encryption/secrets")const encryptedPrefix = "enc:"diff --git a/backend/internal/util/files/creator.go b/backend/internal/util/files/creator.goindex 77b65fa1..092dd5e3 100644--- a/backend/internal/util/files/creator.go+++ b/backend/internal/util/files/creator.go@@ -6,7 +6,7 @@ import ()func EnsureDirectories(directories []string) error {- const directoryPermissions = 0755+ const directoryPermissions = 0o755for _, directory := range directories {if _, err := os.Stat(directory); os.IsNotExist(err) {