手元で簡易なテスト用PostgreSQL環境作る手順を簡単にまとめておきます。
DockerでPostgreSQLサービス起動:
$ docker run --name postgres -d -p 5432:5432 postgres
コンテナーの中に入る:
$ docker exec -it postgres bash
psql
でユーザとデータベースを作る:
# su - postgres
No directory, logging in with HOME=/
$ psql
psql (9.5.4)
Type "help" for help.
postgres=# \du
List of roles
Role name | Attributes | Member of
-----------+------------------------------------------------------------+-----------
postgres | Superuser, Create role, Create DB, Replication, Bypass RLS | {}
postgres=# CREATE ROLE foobar LOGIN CREATEDB PASSWORD 'foobar';
CREATE ROLE
postgres=# \du
List of roles
Role name | Attributes | Member of
-----------+------------------------------------------------------------+-----------
postgres | Superuser, Create role, Create DB, Replication, Bypass RLS | {}
foobar | Create DB | {}
postgres=# CREATE DATABASE foobar OWNER foobar;
CREATE DATABASE