Changing Postgres commands to separate