do $$ 
declare
    user_id uuid;
    changeset_id int4;
begin
    select tu.userid
    into user_id
    from vclib.t_users tu 
    join vclib.t_identity ti on tu.identity = ti.identityid
    where ti.identityname = 'Administrator'
    limit 1;
    if user_id is null then
        select userid into user_id
        from vclib.t_users
        limit 1;
    end if;
    call public.sp_generateidforentity('VCLib.CHANGESET', 'PrimaryKey', 1, changeset_id);
    insert into vclib.t_changesets (id, timestamp, userid)
    values (changeset_id, now(), user_id);
    perform fn_copydatatohistory('t_v019_vmp_method', 't_v019_vmp_method_history', changeset_id);
end $$;