Skip to content

Instantly share code, notes, and snippets.

@squarism
Last active July 31, 2023 18:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save squarism/5722cc43751ede5f5df41830f7d0e11d to your computer and use it in GitHub Desktop.
Save squarism/5722cc43751ede5f5df41830f7d0e11d to your computer and use it in GitHub Desktop.
Postgres 15.x development databases setup with Prisma
# Things have changed in postgres 15.x+
$ createdb -O <your shell uid> foo_dev
$ createuser foo
$ psql
psql> grant all privileges on database foo_dev to foo;
psql> alter user foo with encrypted password 'random-password';
# enter the database that you just created
psql> create schema foo authorization foo;
# check your work so far
foo_dev=> \dn
List of schemas
Name | Owner
--------+---------
foo | foo
....
# foo should be listed. Another check you can do is `show search_path`;
foo_dev=> show search_path;
search_path
-----------------
"$user", public
# if you have a test database (you should), you will need to repeat these steps for `foo_test`
# (except for creating the foo user, you already did that).
psql> exit
$ createdb -O <your shell uid> foo_test
$ psql
psql> grant all privileges on database foo_test to foo;
# for prisma 5, you need createdb
psql> alter user foo createdb;
# revoke with `alter user foo with nocreatedb;`
psql> exit
$ psql foo_test foo
psql> create schema foo authorization foo;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment