fix generate_unique_key issue for pg