diff --git a/server/app/goauto/migrations/migrate_test.go b/server/app/goauto/migrations/migrate_test.go index e33e489..a9645f4 100644 --- a/server/app/goauto/migrations/migrate_test.go +++ b/server/app/goauto/migrations/migrate_test.go @@ -100,6 +100,25 @@ func TestMySQLCompositeIndexesFitInnoDBLimit(t *testing.T) { } } +func TestSYBSyncRunCountFieldsKeepExistingMySQLColumnNames(t *testing.T) { + parsed, err := schema.Parse(&models.SYBSyncRun{}, &sync.Map{}, schema.NamingStrategy{}) + if err != nil { + t.Fatalf("parse SYB sync run schema: %v", err) + } + for fieldName, wantDBName := range map[string]string{ + "Created": "created_count", + "Updated": "updated_count", + } { + field := parsed.LookUpField(fieldName) + if field == nil { + t.Fatalf("SYBSyncRun.%s field missing", fieldName) + } + if field.DBName != wantDBName { + t.Fatalf("SYBSyncRun.%s DBName = %q, want %q", fieldName, field.DBName, wantDBName) + } + } +} + func TestMySQLCheckColumnHasNoExplicitForeignKeyActions(t *testing.T) { device, ok := reflect.TypeOf(models.CollectionTask{}).FieldByName("Device") if !ok { diff --git a/server/app/goauto/models/schema.go b/server/app/goauto/models/schema.go index 88554ee..32cf2bd 100644 --- a/server/app/goauto/models/schema.go +++ b/server/app/goauto/models/schema.go @@ -437,8 +437,8 @@ type SYBSyncRun struct { DetailCount int `json:"detailCount" gorm:"not null;default:0"` AcceptedCount int `json:"acceptedCount" gorm:"not null;default:0"` ShopSkipped int `json:"shopSkipped" gorm:"not null;default:0"` - Created int `json:"created" gorm:"not null;default:0"` - Updated int `json:"updated" gorm:"not null;default:0"` + Created int `json:"created" gorm:"column:created_count;not null;default:0"` + Updated int `json:"updated" gorm:"column:updated_count;not null;default:0"` ShopFilterHash string `json:"shopFilterHash" gorm:"size:64;not null"` ShopBreakdownJSON string `json:"-" gorm:"type:text;not null"` ErrorMessage string `json:"errorMessage" gorm:"size:1000;not null;default:''"` diff --git a/server/app/goauto/sybimport/sync_run.go b/server/app/goauto/sybimport/sync_run.go index ff94b07..bc8f9d6 100644 --- a/server/app/goauto/sybimport/sync_run.go +++ b/server/app/goauto/sybimport/sync_run.go @@ -64,7 +64,7 @@ func (s *SyncRunService) UpdateProgress(ctx context.Context, id uint64, progress "days_total": progress.DaysTotal, "days_processed": progress.DaysProcessed, "order_count": progress.Report.OrderCount, "detail_count": progress.Report.DetailCount, "accepted_count": progress.Report.AcceptedCount, "shop_skipped": progress.Report.ShopSkipped, - "created": progress.Report.Created, "updated": progress.Report.Updated, + "created_count": progress.Report.Created, "updated_count": progress.Report.Updated, "shop_filter_hash": progress.Report.ShopFilterHash, "shop_breakdown_json": string(breakdown), }).Error } @@ -86,7 +86,7 @@ func (s *SyncRunService) Finish(ctx context.Context, id uint64, status string, r "status": status, "active_slot": nil, "finished_at": now, "error_message": message, "order_count": report.OrderCount, "detail_count": report.DetailCount, "accepted_count": report.AcceptedCount, "shop_skipped": report.ShopSkipped, - "created": report.Created, "updated": report.Updated, + "created_count": report.Created, "updated_count": report.Updated, "shop_breakdown_json": string(breakdown), } if report.ShopFilterHash != "" {