Forum: Ruby on Rails why does "rake db:drop" in prod environment give "Mysql::Error: Table 'equity_production.accounts'

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Greg H. (Guest)
on 2009-02-08 13:23
(Received via mailing list)
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:in
`execute'
/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:in
`columns'
/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:in
`initialize'
/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:in
`active_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:in
`require'
/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:in
`require_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:in
`require_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:in
`each'
/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:in
`each'
/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:in
`process'
/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:in
`run'
/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:in
`require'
/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:in
`new_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:in `call'
/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:in `each'
/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:in
`invoke_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:in
`invoke_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:in `each'
/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:in
`invoke_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:in
`invoke_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:in
`invoke_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:in `each'
/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:in
`standard_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:in `run'
/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:in `run'
/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/
stretch (Guest)
on 2009-02-08 16:03
(Received via mailing list)
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>
Greg H. (Guest)
on 2009-02-08 22:02
(Received via mailing list)
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:in
`execute'
/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:in
`columns'
/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:in
`initialize'
/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:in
`active_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:in
`require'
/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:in
`require_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:in
`require_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:in
`each'
/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:in
`each'
/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:in
`process'
/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:in
`run'
/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:in
`require'
/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:in
`new_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:in `call'
/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:in `each'
/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:in
`invoke_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:in
`invoke_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:in `each'
/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:in
`invoke_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:in
`invoke_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:in
`invoke_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:in `each'
/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:in
`standard_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:in `run'
/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:in `run'
/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 H. (Guest)
on 2009-02-08 22:47
(Received via mailing list)
Update - Had to turn cache classes to false to fix this (in
environments/production.rb) until it's fixed in Rails 2.3
This topic is locked and can not be replied to.