File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -17,17 +17,19 @@ protected override void Up(MigrationBuilder migrationBuilder)
1717 nullable : false ,
1818 defaultValue : 170 ) ;
1919
20- // Backfill Height from the most recent Weight entry in the same unit-valid range.
20+ // Backfill Height from the most recent Weight entry only when the stored value is
21+ // unambiguous for the current unit system. The valid ranges overlap from 40-98, so
22+ // those values cannot be safely inferred as metric or imperial during migration.
2123 // Range values align with EditConfigViewModel constants: metric 40-250, imperial 16-98.
2224 migrationBuilder . Sql ( @"
2325 UPDATE Configs
2426 SET Height = CASE
2527 WHEN UnitsType = 1 THEN COALESCE(
26- (SELECT Height FROM Weights WHERE Height BETWEEN 16 AND 98 ORDER BY CreatedAt DESC LIMIT 1),
28+ (SELECT Height FROM Weights WHERE Height BETWEEN 16 AND 39 ORDER BY CreatedAt DESC LIMIT 1),
2729 67
2830 )
2931 ELSE COALESCE(
30- (SELECT Height FROM Weights WHERE Height BETWEEN 40 AND 250 ORDER BY CreatedAt DESC LIMIT 1),
32+ (SELECT Height FROM Weights WHERE Height BETWEEN 99 AND 250 ORDER BY CreatedAt DESC LIMIT 1),
3133 170
3234 )
3335 END
You can’t perform that action at this time.
0 commit comments