reuse postgres connection code in migration script