Hello, I have a question regarding PostgreSQL user management in my application setup.
I’m working with a NestJS application that uses TypeORM and connects to a PostgreSQL database. I have two database users:
root – with full privileges
app_user – limited to SELECT, INSERT, UPDATE, and DELETE
My goal is to keep the application running at all times with app_user for security reasons. However, when I need to modify the database schema (e.g., during a migration), I currently deploy the app once using the root user to run the migration, then redeploy it with app_user.
Is there a way to avoid redeploying and instead configure the application or migration process to:
use root only for running migrations, and
use app_user for the actual application runtime?
In other words, can I run the app once, but use separate users for migrations and for normal operations?