Syl
Syl

Reputation: 3829

Rails app deployment, rake DB:migrate doesn't create table and want table to already be here to create them

Server ubuntu 64b App using rails 3.1 database mysql

Now rails db:create works fine

Rails db:migrate done manually or through cap deploy:migration give me the following error :

rake aborted! Mysql2::Error: Table 'mywebsite_production.galleries' doesn't exist: SHOW FIELDS FROM galleries /srv/d_mywebsite/www/mywebsite/shared/bundle/ruby/1.9.1/gems/activerecord-3.1.3/lib/active_record/connection_adapters/mysql2_adapter.rb:283:in `query'

What is wrong in this deployment ?

Upvotes: 1

Views: 1728

Answers (3)

Allam Matsubara
Allam Matsubara

Reputation: 529

I just comment out the device and rails_admin routes on my config/routes.rb and everything worked out. Check if any of your routes are requiring the existence ofmywebsite_production.galleries.

Upvotes: 2

Naveed
Naveed

Reputation: 11167

can you all load all table names and check if table you created manually is present it list?

you can list table names using ActiveRecord::Base.connection.tables

Upvotes: 0

JeanMertz
JeanMertz

Reputation: 2270

Two possible problems:

  1. While manually creating the database, you probably didn't name it properly.

  2. Or, because you said that db:create was failing, another problem could be that Rails or your database aren't set up properly and thus can't communicate with each other.

I would advice you to investigate the db:create issue first, this is likely the same thing that causes db:migrate to fail.

By creating the database yourself, all you've done is move the problem up in the stack, and once you manage to manually fix the migration issues, you might run into more problems down the road.

Upvotes: 0

Related Questions