Silver
Silver

Reputation: 693

Ruby on Rails - Heroku deployment issues

I seem to have reached a bump, searched here and on other foruns but nothing. I'm running rails 3.2.3 and ruby 1.9.3 and want to deploy my app on heroku.

I've created the cedar and although I can git push heroku master I am getting a complete 500 server error. I suspect is it because my DB isn't there. However, I can't seem to get it there. I've run:

heroku run rake db:create -> This gives out some warnings about deprecation and then dkhgclqccm already exists

So it exists already? So lets migrate it:

heroku run rake db:migrate However this outputs:

<deprecation errors>
rake aborted!
An error has occurred, this and all later migrations canceled:

PG::Error: ERROR:  relation "hphotos" does not exist
: ALTER TABLE "hphotos" ADD COLUMN "description" character varying(255)

Tasks: TOP => db:migrate
(See full trace by running task with --trace)

That particular migration is:

class AddDescriptionToHphotos < ActiveRecord::Migration
  def change
    add_column :hphotos, :description, :string
  end
end

It seems good to me, don't know why its giving me this error :/

One Last thing, even if this migrations worked, my DB would be empty and me seeds.rb doesn't have all the necessary data for the database. So I though about pushing the hole DB.

heroku db:push         
 !    Taps Load Error: cannot load such file -- sqlite3
 !    You may need to install or update the taps gem to use db commands.
 !    On most systems this will be:
 !
 !    sudo gem install taps

Why is this showing? I installed the 'heroku' gem and the 'taps' gem and I got this in my gem file:

group :development, :test do
  gem 'mysql2'
end
group :production do
  gem 'pg'
end

Also, when I run heroku run rake db:version, it shows: Current version: 20120508130957 This is actually 5 migrations short on my currrent version, but I can't migrate it as shows the error I spoke of above...

Thanks in advance

Upvotes: 0

Views: 836

Answers (3)

Dushyant
Dushyant

Reputation: 4960

The solution is to add not only taps gem but also sqlite3 gem into the Gemfile, into the :development group. If you are using sqlite3 in your development, then adding taps gem would be enough.

But since you are using mysql2 on your development so to solve that problem you have to add both.

group :development do
  gem 'taps'
  gem 'sqlite3'
end

Upvotes: 0

Abram
Abram

Reputation: 41874

I think you need to check your migrations closely to see if you actually have a file which says:

  def up
    create_table :hphotos do |t|
      [...]
    end

It seems that the table hasn't been created remotely and you are attempting to modify it.

Upvotes: 0

nzifnab
nzifnab

Reputation: 16092

Heroku comes with a database set up (which is why db:create didn't work). have you tried heroku run rake db:schema:load? This should take your schema.rb file and load it up into the DB. This is a much better way of doing it than db:migrate every time you want to setup a new DB

Edit:

For your last question about taps, it looks like it's trying to use sqlite locally but you only have pg in your Gemfile. You probably have in config/database.yml adapter: sqlite. So either you need to use postgres locally and change that adapter to postgres, or go the easier route and use sqlite locally and add that to the :development group.

Note that heroku only uses postgres so I would not suggest developing off of mysql since there are some inconsistencies in some syntax and how you do a couple of things between the two platforms. Then again, if you're using only ANSI-compatible queries or just using rails' methods to activate queries then you should be ok either way.

Upvotes: 1

Related Questions