create table interval_increment
(
    interval_increment interval
);

insert into interval_increment
    (interval_increment)
select
    now() - max(max_date) as interval_increment
from
    (
        select date_trunc('day', max(first_notification_of_loss)) as max_date from claim       union
        select date_trunc('day', max(created_at))                 as max_date from claim       union
        select date_trunc('day', max(updated_at))                 as max_date from claim       union
        select date_trunc('day', max(created_at))                 as max_date from claim_head  union
        select date_trunc('day', max(updated_at))                 as max_date from claim_head  union
        select date_trunc('day', max(created_at))                 as max_date from claimant    union
        select date_trunc('day', max(updated_at))                 as max_date from claimant    union
        select date_trunc('day', max(created_at))                 as max_date from damage      union
        select date_trunc('day', max(updated_at))                 as max_date from damage      union
        select date_trunc('day', max(from_date_time))             as max_date from driver      union
        select date_trunc('day', max(to_date_time))               as max_date from driver      union
        select date_trunc('day', max(created_at))                 as max_date from driver      union
        select date_trunc('day', max(updated_at))                 as max_date from driver      union
        select date_trunc('day', max(created_at))                 as max_date from incident    union
        select date_trunc('day', max(updated_at))                 as max_date from incident    union
        select date_trunc('day', max(from_date_time))             as max_date from passenger   union
        select date_trunc('day', max(to_date_time))               as max_date from passenger   union
        select date_trunc('day', max(created_at))                 as max_date from passenger   union
        select date_trunc('day', max(updated_at))                 as max_date from passenger   union
        select date_trunc('day', max(created_at))                 as max_date from person      union
        select date_trunc('day', max(updated_at))                 as max_date from person      union
        select date_trunc('day', max(created_at))                 as max_date from policy      union
        select date_trunc('day', max(updated_at))                 as max_date from policy      union
        select date_trunc('day', max(created_at))                 as max_date from transaction union
        select date_trunc('day', max(updated_at))                 as max_date from transaction union
        select date_trunc('day', max(created_at))                 as max_date from vehicle     union
        select date_trunc('day', max(updated_at))                 as max_date from vehicle     union
        select date_trunc('day', max(created_at))                 as max_date from witness     union
        select date_trunc('day', max(updated_at))                 as max_date from witness     union
        select max(cast(year_first_licensed || '-12-31' as date)) as max_date from vehicle
    ) x;

update claim       set first_notification_of_loss = first_notification_of_loss + b.interval_increment from interval_increment b;
update claim       set created_at                 = created_at                 + b.interval_increment from interval_increment b;
update claim       set updated_at                 = updated_at                 + b.interval_increment from interval_increment b;
update claim_head  set created_at                 = created_at                 + b.interval_increment from interval_increment b;
update claim_head  set updated_at                 = updated_at                 + b.interval_increment from interval_increment b;
update claimant    set created_at                 = created_at                 + b.interval_increment from interval_increment b;
update claimant    set updated_at                 = updated_at                 + b.interval_increment from interval_increment b;
update damage      set created_at                 = created_at                 + b.interval_increment from interval_increment b;
update damage      set updated_at                 = updated_at                 + b.interval_increment from interval_increment b;
update driver      set from_date_time             = from_date_time             + b.interval_increment from interval_increment b;
update driver      set to_date_time               = to_date_time               + b.interval_increment from interval_increment b;
update driver      set created_at                 = created_at                 + b.interval_increment from interval_increment b;
update driver      set updated_at                 = updated_at                 + b.interval_increment from interval_increment b;
update incident    set created_at                 = created_at                 + b.interval_increment from interval_increment b;
update incident    set updated_at                 = updated_at                 + b.interval_increment from interval_increment b;
update passenger   set from_date_time             = from_date_time             + b.interval_increment from interval_increment b;
update passenger   set to_date_time               = to_date_time               + b.interval_increment from interval_increment b;
update passenger   set created_at                 = created_at                 + b.interval_increment from interval_increment b;
update passenger   set updated_at                 = updated_at                 + b.interval_increment from interval_increment b;
update person      set created_at                 = created_at                 + b.interval_increment from interval_increment b;
update person      set updated_at                 = updated_at                 + b.interval_increment from interval_increment b;
update policy      set created_at                 = created_at                 + b.interval_increment from interval_increment b;
update policy      set updated_at                 = updated_at                 + b.interval_increment from interval_increment b;
update transaction set created_at                 = created_at                 + b.interval_increment from interval_increment b;
update transaction set updated_at                 = updated_at                 + b.interval_increment from interval_increment b;
update vehicle     set created_at                 = created_at                 + b.interval_increment from interval_increment b;
update vehicle     set updated_at                 = updated_at                 + b.interval_increment from interval_increment b;
update witness     set created_at                 = created_at                 + b.interval_increment from interval_increment b;
update witness     set updated_at                 = updated_at                 + b.interval_increment from interval_increment b;
update vehicle a
    set year_first_licensed = extract('year' from (cast(a.year_first_licensed || '-01-01' as date) + b.interval_increment))
from
    interval_increment b;

drop table interval_increment;