clearing rails app database on heroku production site

Viewed 17227

So I'm new to ROR and Heroku and need a little help. I've created an app and have deployed it; however, I'd like to clear out the database associated with it. Meaning I'd like to clear any users (and their attached data) that have been created thus far.

I've basically created several phony accounts to test out whether the database on the production site works, but now i'd like to clear this out, and start with a fresh database.

Is this possible without deleting the database entirely?

Any help would be sincerely appreciated. Thank you very much for your time!

13 Answers

Databases can be reset from the web dashboard as well:

Find your database and click on the link: enter image description here

On the database page click on "Settings" enter image description here

Then click on, "Reset Database" and follow the instructions to confirm. enter image description here

You'll of course need to use rake to migrate to get your tables back.

To reset the database

It will ask you to confirm after you run this:

heroku pg:reset DATABASE_URL

To reset all in one line

I don't use this method just in case I make a mistake (I prefer the above method asking me to confirm). Replace myherokuapp with the name of your app:

heroku pg:reset DATABASE_URL --confirm myherokuapp

To reset and reseed

Like the previous, be careful as this will completely delete your current database and re seed it from seeds.rb. Replace myherokuapp with the name of your app in the following:

heroku pg:reset DATABASE_URL --confirm myherokuapp
heroku run rake db:migrate db:seed

Use this command in the project directory. Adding DISABLE_DATABASE_ENVIRONMENT_CHECK=1 allows the production environment to operate like a development environment.

heroku run db:reset DISABLE_DATABASE_ENVIRONMENT_CHECK=1
Related