feat: replace age integer with date_of_birth across backend and client
Store date_of_birth (DATE) instead of a static age integer so that age is always computed dynamically from the stored date of birth. - Migration 011: adds date_of_birth, backfills from age, drops age - AgeFromDOB helper computes current age from YYYY-MM-DD string - User model, repository SQL, and service validation updated - Flutter: User.age becomes a computed getter; profile edit screen uses a date picker bounded to [today-120y, today-10y] Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
13
backend/migrations/011_replace_age_with_date_of_birth.sql
Normal file
13
backend/migrations/011_replace_age_with_date_of_birth.sql
Normal file
@@ -0,0 +1,13 @@
|
||||
-- +goose Up
|
||||
ALTER TABLE users ADD COLUMN date_of_birth DATE;
|
||||
UPDATE users
|
||||
SET date_of_birth = (CURRENT_DATE - (age * INTERVAL '1 year'))::DATE
|
||||
WHERE age IS NOT NULL;
|
||||
ALTER TABLE users DROP COLUMN age;
|
||||
|
||||
-- +goose Down
|
||||
ALTER TABLE users ADD COLUMN age SMALLINT;
|
||||
UPDATE users
|
||||
SET age = EXTRACT(YEAR FROM AGE(CURRENT_DATE, date_of_birth))::SMALLINT
|
||||
WHERE date_of_birth IS NOT NULL;
|
||||
ALTER TABLE users DROP COLUMN date_of_birth;
|
||||
Reference in New Issue
Block a user