# DB Ownership / Wiping out Production

**URL:** https://meta.discourse.org/t/db-ownership-wiping-out-production/113534
**Category:** Self-hosting
**Created:** [April 5, 2019, 11:32am UTC](https://meta.discourse.org/t/db-ownership-wiping-out-production/113534 "2019-04-05T11:32:18Z")
**Posts on this page:** 1
**Showing post:** 12

<div class="post-metadata">

### Author: ![pgr](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pgr/32/156783_2.png) [@pgr](https://meta.discourse.org/u/pgr)
#### Post date: [May 21, 2019, 11:39am UTC](https://meta.discourse.org/t/db-ownership-wiping-out-production/113534/12 "2019-05-21T11:39:02Z")

</div>

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).

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

```

And then:

```sql
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.

---

_[View the full topic](https://meta.discourse.org/t/db-ownership-wiping-out-production/113534)._
