refactor pgsql integretion & fix template error on ubuntu