Why does "rake db:drop" in prod environment give "Mysql::Error: Table 'equity_production.accounts'


#1

Hi,

Any ideas why (just trying to migrate a Rails app to the prod server)
that
“rake db:drop” & “rake db:migrate” etc aren’t working due to the below
mentioned mysql error? Obviously this error shouldn’t be coming up as
it’s
not possible to have had the tables in place prior to the “rake
db:migrate”
not working. Works fine in development.

Any ideas?

[root@home current]# rake db:drop RAILS_ENV=production --trace
(in /u/apps/equity/releases/20090208104618)
** Invoke db:drop (first_time)
** Invoke environment (first_time)
** Execute environment
rake aborted!
Mysql::Error: Table ‘equity_production.accounts’ doesn’t exist: SHOW
FIELDS
FROM accounts
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/connection_adapters/abstract_adapter.rb:188:in
log' /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/connection_adapters/mysql_adapter.rb:309:inexecute’
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/connection_adapters/mysql_adapter.rb:440:in
columns' /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/base.rb:1220:incolumns’
/u/apps/equity/releases/20090208104618/vendor/plugins/active_scaffold/lib/active_scaffold/config/core.rb:100:in
initialize_without_calendar_date_select' /u/apps/equity/releases/20090208104618/vendor/plugins/active_scaffold/lib/bridges/calendar_date_select/lib/as_cds_bridge.rb:5:ininitialize’
/u/apps/equity/releases/20090208104618/vendor/plugins/active_scaffold/lib/active_scaffold.rb:56:in
new' /u/apps/equity/releases/20090208104618/vendor/plugins/active_scaffold/lib/active_scaffold.rb:56:inactive_scaffold’
/u/apps/equity/releases/20090208104618/app/controllers/account_controller.rb:2
/usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in
gem_original_require' /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:inrequire’
/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:155:in
require' /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:262:inrequire_or_load’
/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:221:in
depend_on' /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:133:inrequire_dependency’
/usr/local/lib/ruby/gems/1.8/gems/rails-2.2.2/lib/initializer.rb:368:in
load_application_classes' /usr/local/lib/ruby/gems/1.8/gems/rails-2.2.2/lib/initializer.rb:367:ineach’
/usr/local/lib/ruby/gems/1.8/gems/rails-2.2.2/lib/initializer.rb:367:in
load_application_classes' /usr/local/lib/ruby/gems/1.8/gems/rails-2.2.2/lib/initializer.rb:365:ineach’
/usr/local/lib/ruby/gems/1.8/gems/rails-2.2.2/lib/initializer.rb:365:in
load_application_classes' /usr/local/lib/ruby/gems/1.8/gems/rails-2.2.2/lib/initializer.rb:185:inprocess’
/usr/local/lib/ruby/gems/1.8/gems/rails-2.2.2/lib/initializer.rb:112:in
send' /usr/local/lib/ruby/gems/1.8/gems/rails-2.2.2/lib/initializer.rb:112:inrun’
/u/apps/equity/releases/20090208104618/config/environment.rb:13
/usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in
gem_original_require' /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:inrequire’
/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:153:in
require' /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:521:innew_constants_in’
/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:153:in
require' /usr/local/lib/ruby/gems/1.8/gems/rails-2.2.2/lib/tasks/misc.rake:3 /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:617:incall’
/usr/local/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:617:in
execute' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:612:ineach’
/usr/local/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:612:in
execute' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:578:ininvoke_with_call_chain’
/usr/local/lib/ruby/1.8/monitor.rb:242:in synchronize' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:571:ininvoke_with_call_chain’
/usr/local/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:588:in
invoke_prerequisites' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:585:ineach’
/usr/local/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:585:in
invoke_prerequisites' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:577:ininvoke_with_call_chain’
/usr/local/lib/ruby/1.8/monitor.rb:242:in synchronize' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:571:ininvoke_with_call_chain’
/usr/local/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:564:in invoke' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:2019:ininvoke_task’
/usr/local/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:1997:in
top_level' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:1997:ineach’
/usr/local/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:1997:in
top_level' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:2036:instandard_exception_handling’
/usr/local/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:1991:in
top_level' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:1970:inrun’
/usr/local/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:2036:in
standard_exception_handling' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:1967:inrun’
/usr/local/lib/ruby/gems/1.8/gems/rake-0.8.3/bin/rake:31
/usr/local/bin/rake:19:in `load’
/usr/local/bin/rake:19
[root@home current]#


Greg
http://blog.gregnet.org/


#2

Hey Greg,

From an SQL command window, can you see the accounts table when you
enter the command: ‘show tables in equity_production’? If not, is the
db in the list when you call ‘show databases’?

basic, I know, but that’s what i’d check out first, not knowing the
context

Al

On Feb 8, 3:22 am, Greg H. removed_email_address@domain.invalid


#3

2009/2/9 stretch removed_email_address@domain.invalid

Al

database exists but no tables, so in fact it wasn’t a good rake example
to
show. Here’s a better one that assumes no tables. When I run “rake
db:migrate RAILS_ENV=production” I get the same issue.

Question is why is rake expecting to see database tables for this
command?
i.e. it the rake command that creates the tables. It seems to be
failing
at the “** Execute environment” stage?

[root@home current]# rake db:migrate RAILS_ENV=production --trace
(in /u/apps/equity/releases/20090208104618)
** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
rake aborted!
Mysql::Error: Table ‘equity_production.accounts’ doesn’t exist: SHOW
FIELDS
FROM accounts
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/connection_adapters/abstract_adapter.rb:188:in
log' /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/connection_adapters/mysql_adapter.rb:309:inexecute’
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/connection_adapters/mysql_adapter.rb:440:in
columns' /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/base.rb:1220:incolumns’
/u/apps/equity/releases/20090208104618/vendor/plugins/active_scaffold/lib/active_scaffold/config/core.rb:100:in
initialize_without_calendar_date_select' /u/apps/equity/releases/20090208104618/vendor/plugins/active_scaffold/lib/bridges/calendar_date_select/lib/as_cds_bridge.rb:5:ininitialize’
/u/apps/equity/releases/20090208104618/vendor/plugins/active_scaffold/lib/active_scaffold.rb:56:in
new' /u/apps/equity/releases/20090208104618/vendor/plugins/active_scaffold/lib/active_scaffold.rb:56:inactive_scaffold’
/u/apps/equity/releases/20090208104618/app/controllers/account_controller.rb:2
/usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in
gem_original_require' /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:inrequire’
/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:155:in
require' /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:262:inrequire_or_load’
/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:221:in
depend_on' /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:133:inrequire_dependency’
/usr/local/lib/ruby/gems/1.8/gems/rails-2.2.2/lib/initializer.rb:368:in
load_application_classes' /usr/local/lib/ruby/gems/1.8/gems/rails-2.2.2/lib/initializer.rb:367:ineach’
/usr/local/lib/ruby/gems/1.8/gems/rails-2.2.2/lib/initializer.rb:367:in
load_application_classes' /usr/local/lib/ruby/gems/1.8/gems/rails-2.2.2/lib/initializer.rb:365:ineach’
/usr/local/lib/ruby/gems/1.8/gems/rails-2.2.2/lib/initializer.rb:365:in
load_application_classes' /usr/local/lib/ruby/gems/1.8/gems/rails-2.2.2/lib/initializer.rb:185:inprocess’
/usr/local/lib/ruby/gems/1.8/gems/rails-2.2.2/lib/initializer.rb:112:in
send' /usr/local/lib/ruby/gems/1.8/gems/rails-2.2.2/lib/initializer.rb:112:inrun’
/u/apps/equity/releases/20090208104618/config/environment.rb:13
/usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in
gem_original_require' /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:inrequire’
/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:153:in
require' /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:521:innew_constants_in’
/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:153:in
require' /usr/local/lib/ruby/gems/1.8/gems/rails-2.2.2/lib/tasks/misc.rake:3 /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:617:incall’
/usr/local/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:617:in
execute' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:612:ineach’
/usr/local/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:612:in
execute' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:578:ininvoke_with_call_chain’
/usr/local/lib/ruby/1.8/monitor.rb:242:in synchronize' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:571:ininvoke_with_call_chain’
/usr/local/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:588:in
invoke_prerequisites' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:585:ineach’
/usr/local/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:585:in
invoke_prerequisites' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:577:ininvoke_with_call_chain’
/usr/local/lib/ruby/1.8/monitor.rb:242:in synchronize' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:571:ininvoke_with_call_chain’
/usr/local/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:564:in invoke' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:2019:ininvoke_task’
/usr/local/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:1997:in
top_level' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:1997:ineach’
/usr/local/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:1997:in
top_level' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:2036:instandard_exception_handling’
/usr/local/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:1991:in
top_level' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:1970:inrun’
/usr/local/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:2036:in
standard_exception_handling' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:1967:inrun’
/usr/local/lib/ruby/gems/1.8/gems/rake-0.8.3/bin/rake:31
/usr/local/bin/rake:19:in `load’
/usr/local/bin/rake:19
[root@home current]#


#4

Update - Had to turn cache classes to false to fix this (in
environments/production.rb) until it’s fixed in Rails 2.3