-- +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;
