Connecting to Postgres instance on github action for migratioin

Am trying to perform migration on github action but i cant directly connect to the postgres instance on fly because of the IP. So i need to connect to it through poxy flyctl proxy 5432 -a <postgres-app-name> . The step of connecting to postgres on github action works fine but the issue is that when connection the posgres is established, the terminal remains open this makes the steps on github action to run for ever.
Is there any way to run the connection in the background so i can run other commands.
or other way of connecting to postgres with keeping the terminal open ?