alter table public.document_tables
    add column if not exists grid_key uuid;

update public.document_tables
set grid_key = gen_random_uuid()
where grid_key is null;

alter table public.document_tables
    alter column grid_key set not null;

alter table public.document_tables
    alter column grid_key set default gen_random_uuid();

create unique index if not exists document_tables_grid_key_idx
    on public.document_tables (grid_key);
