Create a PostgreSQL database
Fill in the variables above and set the user’s password in the script:
CREATE USER ${{ USERNAME }} WITH PASSWORD 'put_your_password';CREATE DATABASE ${{ DBNAME }} OWNER ${{ USERNAME }};GRANT ALL PRIVILEGES ON DATABASE ${{ DBNAME }} TO ${{ USERNAME }};\c ${{ DBNAME }}GRANT ALL ON SCHEMA public TO ${{ USERNAME }};Run as superuser (e.g. postgres):
psql -h ${{ HOSTNAME }} -p 5432 -U postgres -f init.sqlOr inline. Use a separate -c per statement: psql sends each -c string to the server as
one request, so two statements in a single -c run inside one implicit transaction — and
CREATE DATABASE cannot run inside a transaction block.
psql -h ${{ HOSTNAME }} -p 5432 -U postgres \ -c "CREATE USER ${{ USERNAME }} WITH PASSWORD 'put_your_password';" \ -c "CREATE DATABASE ${{ DBNAME }} OWNER ${{ USERNAME }};"