drop index if exists iszl.ix_t_policy_spolnpol;

alter table iszl.t_policy drop column if exists spolnpol;

alter table iszl.t_policy
add column spolnpol varchar(122) generated always as (
    case 
        when series is null and number is null or series = '' and number = '' then ''
        when series is null or series = '' then trim(number)
        when number is null or number = '' then trim(series)
        else trim(series || chr(160) || number)
    end
) stored;

create index ix_t_policy_spolnpol on iszl.t_policy (spolnpol);
