Search code examples
postgresqlflyway

What Postgres privileges should I give to Flyway?


I created a new database in Postgres and a new user dedicated specifically for schema migrations by Flyway.

createdb mydb
createuser mydb_deploy

What reasonable permissions should I give to this user, just sufficient for Flyway to connect to database and do schema migrations?

I'm new to Postgres and Flyway.


Solution

  • The Flyway user needs very high privileges because that will be the owner of all created objects.

    You could simply deal out superuser privileges, but that should be avoided whenever possible.

    When starting with an empty database, GRANT ALL ON DATABASE to the Flyway user so that it can create schemas in the database and then objects in the schemas.

    Then the Flyway user will own all objects in the database, and everything should work fine.