{% comment %} Copyright (C) The Arvados Authors. All rights reserved. SPDX-License-Identifier: CC-BY-SA-3.0 {% endcomment %}
  1. Start a shell for the postgres user:
    ~$ sudo -u postgres bash
  2. Generate a new database password:
    $ ruby -e 'puts rand(2**128).to_s(36)'
    yourgeneratedpassword
    
    Record this. You'll need it when you set up the Rails server later.
  3. Create a database user with the password you generated:
    $ createuser --encrypted -R -S --pwprompt {{service_role}}
      Enter password for new role: yourgeneratedpassword
      Enter it again: yourgeneratedpassword
  4. Create a database owned by the new user:
    $ createdb {{service_database}} -T template0 -E UTF8 -O {{service_role}}
  5. {% if use_contrib %}
  6. Enable the pg_trgm extension
    $ psql {{service_database}} -c "CREATE EXTENSION IF NOT EXISTS pg_trgm"
  7. {% endif %}
  8. Exit the postgres user shell:
    $ exit