store: scope kind assignments, laps, and samples via activity ownership
None of these three tables gained their own user_id column -- they're always accessed through a specific activity, so ownership is checked via a join/subquery against activities.user_id instead.
This commit is contained in:
@@ -21,10 +21,10 @@ func TestResetAllSyncedData_DeletesActivitiesCascadesAndRewindsWatermark(t *test
|
||||
if err != nil {
|
||||
t.Fatalf("CreateWorkoutKind: %v", err)
|
||||
}
|
||||
if err := db.ReplaceLaps(ctx, activityID, []Lap{{LapIndex: 1}}); err != nil {
|
||||
if err := db.ReplaceLaps(ctx, userID, activityID, []Lap{{LapIndex: 1}}); err != nil {
|
||||
t.Fatalf("ReplaceLaps: %v", err)
|
||||
}
|
||||
if _, err := db.InsertKindAssignment(ctx, KindAssignment{
|
||||
if _, err := db.InsertKindAssignment(ctx, userID, KindAssignment{
|
||||
ActivityID: activityID, WorkoutKindID: &kindID, AssignmentSource: AssignmentSourceRuleEngine,
|
||||
Status: AssignmentStatusAssigned, CandidateKindsJSON: "[]",
|
||||
}); err != nil {
|
||||
@@ -45,14 +45,14 @@ func TestResetAllSyncedData_DeletesActivitiesCascadesAndRewindsWatermark(t *test
|
||||
if len(activities) != 0 {
|
||||
t.Errorf("expected 0 activities after reset, got %d", len(activities))
|
||||
}
|
||||
laps, err := db.LapsForActivity(ctx, activityID)
|
||||
laps, err := db.LapsForActivity(ctx, userID, activityID)
|
||||
if err != nil {
|
||||
t.Fatalf("LapsForActivity: %v", err)
|
||||
}
|
||||
if len(laps) != 0 {
|
||||
t.Errorf("expected laps to cascade-delete, got %d", len(laps))
|
||||
}
|
||||
if _, ok, err := db.CurrentAssignment(ctx, activityID); err != nil || ok {
|
||||
if _, ok, err := db.CurrentAssignment(ctx, userID, activityID); err != nil || ok {
|
||||
t.Errorf("expected kind assignment to cascade-delete, ok=%v err=%v", ok, err)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user