Sometimes my Heroku DB will completely derp on me and go "NOPE" and not even a Heroku Run rake db:migrate will fix it.
Generally what I then proceed to do is use this sledgehammer for the task.
heroku pg:reset DATABASE_URL --confirm theashvale
You should then be able to re-create and re-migrate the database as desired.
This is really taking a sledgehammer to it though as all your data will be lost but it is nice to be able to start from scratch now and again.
Showing posts with label Heroku. Show all posts
Showing posts with label Heroku. Show all posts
Wednesday, 14 March 2012
Wednesday, 29 February 2012
Developing SQLite3 and Postgres for use with Heroku
So Heroku's FAQ on using SQLite3 alongside Postgres basically consists of "Don't", so in the usual spirit of things, I'm out to make it work. Why you want to do this is up to you, for me it is because the Postgres gem forces the JSON gem to install with Native Extensions instead of just using JSON and all the university machines have ANSICON which breaks JSON via a registry entry. Also even if it did work I don't think they will let me install Postgres on their machines so SQLite3 is a must.
There were many pitfalls on the way to discovering this since I was stubborn but it turns out there is a really pretty and simple way to do this.
We must separate production from development and test as Heroku uses production.
In gemfile
group :production do
gem 'pg'
end
group :development, :test do
gem 'sqlite3'
end
And that is it.
Bask in Rails server for development in SQLite3,
Heroku login, Heroku create --stack cedar, Git push heroku master, Heroku run rake db:migrate, Heroku open.
Then revel in your working heroku production environment.
I even went so far as to play with many things like Bundle install --without production and rake db:migrate RAILS_ENV=development but you should not need to play with such things.
That is all.
There were many pitfalls on the way to discovering this since I was stubborn but it turns out there is a really pretty and simple way to do this.
We must separate production from development and test as Heroku uses production.
In gemfile
group :production do
gem 'pg'
end
group :development, :test do
gem 'sqlite3'
end
And that is it.
Bask in Rails server for development in SQLite3,
Heroku login, Heroku create --stack cedar, Git push heroku master, Heroku run rake db:migrate, Heroku open.
Then revel in your working heroku production environment.
I even went so far as to play with many things like Bundle install --without production and rake db:migrate RAILS_ENV=development but you should not need to play with such things.
That is all.
Subscribe to:
Posts (Atom)