Reputation: 13735
When I try to run:
heroku run rake db:drop db:create db:migrate
I get the error:
Running rake db:drop attached to terminal... up, run.5
Couldn't drop adsfsadfas : #<ActiveRecord::StatementInvalid: PGError: ERROR: must be owner of database adsfsadfas
: DROP DATABASE IF EXISTS "adsfsadfas">
I am on the Heroku Cedar stack. Am I allowed to drop databases on Heroku?
Thanks!
John
Upvotes: 34
Views: 22901
Reputation: 10392
The rake db:reset task is not supported. Heroku apps do not have permission to drop and create databases. Use the
heroku pg:reset
command instead.
Upvotes: 52
Reputation: 8735
Directly destructive commands (drop and create) are not permitted on heroku. But if you're ok with loosing all the data, you can reset the database with pg:reset
.
heroku pg:reset DATABASE_URL
Every other change should be done with db:migrate
. This assures consistency of the database state.
If your migrations don't run through the full stack anymore you can use db:schema:load
. This loads the schema directly from schema.rb. But be aware that this can also be destructive if create_table
uses the parameters force: true
or force: :cascade
.
heroku run rake db:schema:load
Upvotes: 13