ALTER TABLE chat ADD remind_days_ahead BIGINT NOT NULL DEFAULT 0;

UPDATE chat SET remind_days_ahead = (SELECT days_ahead FROM reminder WHERE chat_id = chat.id ORDER BY days_ahead ASC LIMIT 1);

DROP TABLE reminder;