kuda.ai

Thoughts on programming and music theory.

dark mode

Postgres: Migration Zero

Created on April 13, 2026

postgres

when you start your new app, the first two things you will likely want to do: create a role with login and a DB.

This TIL is inspired by Corey Schafer, a YouTuber, from his video: Python Alembic Migrations.

# create a new "user" (i.e., a role with login):
sudo -u postgres psql -c "create role david with password 'pa55word';"

# create a new DB with david as owner:
sudo -u postgres createdb nonpublic -O david

Why a new user? You don’t want to use the superadmin postgres, but use a dedicated user for your app.

Why a new DB? Hmm, good one, you could definately use the default DB, but then why not isolate? :)