Setup postgresql for web development

postgresql , databases , prisma , shell , linux

Login into postgresql server using admin/root privileges #

Inside postgresql root shell #

So far this is enough for most cases like working with Ruby on Rails(Active record), Django(Django ORM), Flask(SQLAlchemy), Laravel(Eloquent), And Spring(Hibernate) etc.

But things are a bit different in when it comes to prisma (ORM mostly popular in js ecosystem) it requires us to make a new shadow database before every migrations.

You can read more about it here

Basically we need our database user to have permission to create new database in postgresql server. To do this run:

ALTER ROLE username_here CREATEDB;

To check if user has permission to create new databases run this:

\du

it should output a table something similar to this:

 Role name         |                         Attributes                         | Member of
-------------------+------------------------------------------------------------+-----------
 postgres          | Superuser, Create role, Create DB, Replication, Bypass RLS | {}
 username_here     | Create DB                                                  | {}

Here are some common postgresql commands:

Thanks for reading & Keep coding!!! #