do $$
begin
  if not exists (
    select 1
    from pg_enum
    where enumlabel = 'PLATFORM'
      and enumtypid = 'wallet_owner_type_enum'::regtype
  ) then
    alter type wallet_owner_type_enum add value 'PLATFORM';
  end if;
end
$$;

alter table loan_repayments
  add column if not exists fee_paid_amount numeric(10, 2) not null default '0';

insert into wallets (owner_type, owner_id, currency)
values ('PLATFORM', 1, 'CAD')
on conflict (owner_type, owner_id) do nothing;

