DB Ownership / Wiping out Production

Just to leave some feedback here, since I had to re-do this today.

What eventually worked for me is to

  • delete the full /docker-app/standalone directory
  • no need to stop the container, the next command includes that in its script
  • run ./launcher rebuild app
  • the rebuild took about 10 minutes and included an update to the code by pulling it from GitHub.

I had some trouble on my next step, so I’ll also document it here in case it’s useful for someone. I needed to create a privileged database user that I could use from my DB Tool of choice (which is DB Weaver on Windows).

/launcher enter app
su postgres -c "psql discourse"

And then:

CREATE USER myadmin WITH PASSWORD 'xxxxxxxxx';
ALTER USER myadmin WITH SUPERUSER CREATEROLE CREATEDB;
GRANT ALL PRIVILEGES ON DATABASE discourse to myadmin;

Use \q to exit that shell.

I also created a Discourse admin with:
su discourse -c 'RAILS_ENV=production RAILS_DB=discourse bundle exec rake admin:create'

I hope this helps someone.

3 Likes