After a few months working on a open-source project sometimes I still find myself having trouble with some things. And that is okay! This time was with PostgreSQL.
As some of you know I work on a project called Serenata de Amor Operation. One of the tools we developed is called Jarbas. It is a web application with a Django backend using PostgreSQL for database. So the last time I configured and ran Jarbas was last year on a Linux computer it also was the first time I contributed for the project. Not much mystery there, but now I’m on a MacOS machine and things are a bit different.
So I started by installing PostgreSQL with brew (which I highly recommend). Homebrew makes the installation process pretty straightforward. The command line for it is:
|
You may think that’s it. Easy peasy. Then just go to Jarbas cloned repository and the first thing to do would be creating a .env file and then running the traditional Django command python manage.py migrate. And that’s where I got the first error:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
That’s when you ask yourself: Wait, what? What kind of error is that?

After a few minutes searching I came across this wonderful Stackoverflow thread. I’ll break it down for you: After you install PostgreSQL probably (like me), you’ll have to start the service and initialize a database for you to use. I won’t copy here the steps described on the thread but there you’ll see it gives you two choices at a given moment:
- Either load the launch agent;
- Start the agent.
I chose to start it since it was my first time doing this it was logical that this was a safe choice to go on.
After starting it, I needed to check whether it worked or not. You never now util you test it right? And to do so, we try to connect into PostgreSQL by doing this:
|
That only gave me a running Postgres client I still needed a database.
Jarbas app expect a database called jarbas. So that’s the name we give when creating the new database by doing:
|
As you might expect, that wasn’t enough once more. Tried again to run the migrate command and this happened: django.db.utils.OperationalError: FATAL: role "Jarbas" does not exist.
Don’t you just love dev life?!
Let’s create a Role then:
|
|
And once again got an error: django.db.utils.OperationalError: FATAL: role "jarbas" is not permitted to log in. Now we need to give the role permissions, why that didn’t cross my mind before?
|
|
Again with the migrate command and voilà:

And then you get to the point where you might think: How the hell am I supposed to know if everything is working properly? Well, Jarbas has test suites so you might try to run tests and they will fail:
|
|
|
|
|
|
You’ll need to make another modification on jarbas role to give it permissions to create a database:
|
|
After that, tests beautifully pass:
