Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reset DB #141

Closed
fgblomqvist opened this issue Apr 19, 2018 · 12 comments
Closed

Reset DB #141

fgblomqvist opened this issue Apr 19, 2018 · 12 comments

Comments

@fgblomqvist
Copy link

Heroku has the command pg:reset that just resets a db. This is useful when e.g. cloning a DB from production to staging regularly (and automatically).

dokku postgres:reset staging-db
dokku postgres:export db | dokku postgres:import staging-db
@pynixwang
Copy link

maybe
dokku postgres:exec 'drop schema public cascade; create schema public;'

exec also can execute other command.

@fgblomqvist
Copy link
Author

Right, the actual command required to do it right now is not very complicated. In the end, pg:reset could certainly just execute a command similar to that. I still think having the pg:reset command would just simplify things.

@pynixwang
Copy link

@fgblomqvist but exec command is more useful, can reset db, can run a db init script, or other awesome thing.

@fgblomqvist
Copy link
Author

@pynixwang

Of course, but why do we even have this whole addon then? PSQL is much more useful, you can achieve every single thing with it.

You're missing my point completely.

@josegonzalez
Copy link
Member

@fgblomqvist Would you be willing to come up with a PR for this functionality?

@fgblomqvist
Copy link
Author

fgblomqvist commented Sep 29, 2018

I haven't been using Dokku for a few months and currently don't have any environment set up for testing something like this. If this still hasn't been created next time I set one up I can definitely give it a try, but yeah, not now.

(I do remember taking a look at it back in May but I think I concluded that I needed to get a bit more familiar with the code base before I could do anything)

@pynixwang
Copy link

@fgblomqvist yes PSQL is more useful, but you must enter an interactive environment. and you can not run some command quietly.

@fgblomqvist
Copy link
Author

fgblomqvist commented Sep 30, 2018

@pynixwang Wrong. psql -c "select * from my_table". The output can be redirected however you like it, or if you want to not see it at all you can just redirect it accordingly.

@pynixwang
Copy link

@fgblomqvist dokku postgresql has no psql command. maybe heroku has it.

@josegonzalez
Copy link
Member

josegonzalez commented Oct 1, 2018

Thats actually not true. We use it here.

For the purposes of this issue, I am on-board with the feature. If someone wants to implement it, great. Otherwise, I'd appreciate keeping the chatter to a minimum, I get a ton of GH notifications and its hard to keep up sometimes :(

@cristianszwarc
Copy link

manual alternative

    dokku postgres:create some_amazing_db
    docker exec "dokku.postgres.some_amazing_db" su - postgres -c "dropdb some_amazing_db"
    docker exec "dokku.postgres.some_amazing_db" su - postgres -c "createdb -E utf8  some_amazing_db"

@josegonzalez
Copy link
Member

Closing as there is an in-progress PR for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants