I have an issue where my the createDb() function (on my instance of the PostgresDatabaseManager) results in the error:
error: must be member of role "<my_db_name>"
(where "<my_db_name>" is the name of the DB I'm creating).
The error doesn't occur in my dev environment (MacOS 10.13.3 running PosgreSQL 9.6.5), only in staging, which is a AWS RDS instance running PostgreSQL 9.6.6.
The problem sounds exactly like this stackoverflow question. The accepted answer, of adding the superuser to the role created for the new DB, also works for me. Eg..
await knexDbManager.knexInstance().raw(`GRANT ${database} TO ${superUser}`);
await knexDbManager.createDb();
Might be worth adding that GRANT statement to the createDb() function.