ActiveRecord::StatementInvalid error

When I try to run my webserver in the production environment I just
get an application error message. This is all I can find in the log:
ActiveRecord::StatementInvalid
/usr/lib/ruby/gems/1.8/gems/activerecord-1.15.1/lib/active_record/
connection_adapters/sqlite_adapter.rb:274:in `table_structure'
/usr/lib/ruby/gems/1.8/gems/activesupport-1.4.0/lib/active_support/
core_ext/object/misc.rb:23:in `returning'
/usr/lib/ruby/gems/1.8/gems/activerecord-1.15.1/lib/active_record/
connection_adapters/sqlite_adapter.rb:273:in `table_structure'
/usr/lib/ruby/gems/1.8/gems/activerecord-1.15.1/lib/active_record/
connection_adapters/sqlite_adapter.rb:210:in `columns'
/usr/lib/ruby/gems/1.8/gems/activerecord-1.15.1/lib/active_record/
base.rb:760:in `columns'
/usr/lib/ruby/gems/1.8/gems/activerecord-1.15.1/lib/active_record/
base.rb:768:in `columns_hash'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.13.1/lib/action_controller/
session/active_record_store.rb:105:in `setup_sessid_compatibility!
'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.13.1/lib/action_controller/
session/active_record_store.rb:79:in `find_by_session_id'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.13.1/lib/action_controller/
session/active_record_store.rb:283:in `initialize'
/usr/lib/ruby/gems/1.8/gems/activerecord-1.15.1/lib/active_record/
base.rb:864:in `silence'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.13.1/lib/action_controller/
session/active_record_store.rb:283:in `initialize'
/usr/lib/ruby/1.8/cgi/session.rb:273:in `initialize'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.13.1/lib/action_controller/
cgi_process.rb:122:in `session'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.13.1/lib/action_controller/
cgi_process.rb:154:in `stale_session_check!'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.13.1/lib/action_controller/
cgi_process.rb:109:in `session'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.13.1/lib/action_controller/
base.rb:1052:in `assign_shortcuts_without_flash'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.13.1/lib/action_controller/
flash.rb:140:in `assign_shortcuts'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.13.1/lib/action_controller/
base.rb:424:in `process_without_filters'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.13.1/lib/action_controller/
filters.rb:624:in `process_without_session_management_support'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.13.1/lib/action_controller/
session_management.rb:114:in `process'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.13.1/lib/action_controller/
base.rb:330:in `process'
/usr/lib/ruby/gems/1.8/gems/rails-1.2.1/lib/dispatcher.rb:41:in
`dispatch'
/usr/lib/ruby/gems/1.8/gems/rails-1.2.1/lib/fcgi_handler.rb:168:in
`process_request'
/usr/lib/ruby/gems/1.8/gems/rails-1.2.1/lib/fcgi_handler.rb:143:in
`process_each_request!'
/usr/lib/ruby/gems/1.8/gems/rails-1.2.1/lib/fcgi_handler.rb:109:in
`with_signal_handler'
/usr/lib/ruby/gems/1.8/gems/rails-1.2.1/lib/fcgi_handler.rb:142:in
`process_each_request!'
/usr/lib/ruby/1.8/fcgi.rb:600:in `each_cgi'
/usr/lib/ruby/1.8/fcgi.rb:597:in `each_cgi'
/usr/lib/ruby/gems/1.8/gems/rails-1.2.1/lib/fcgi_handler.rb:141:in
`process_each_request!'
/usr/lib/ruby/gems/1.8/gems/rails-1.2.1/lib/fcgi_handler.rb:55:in
`process!'
/usr/lib/ruby/gems/1.8/gems/rails-1.2.1/lib/fcgi_handler.rb:25:in
`process!'
/usr/local/code/ruby/coverage-prod/public/dispatch.fcgi:24
ActiveRecord::StatementInvalid
/usr/lib/ruby/gems/1.8/gems/activerecord-1.15.1/lib/active_record/
connection_adapters/sqlite_adapter.rb:274:in `table_structure'
/usr/lib/ruby/gems/1.8/gems/activesupport-1.4.0/lib/active_support/
core_ext/object/misc.rb:23:in `returning'
/usr/lib/ruby/gems/1.8/gems/activerecord-1.15.1/lib/active_record/
connection_adapters/sqlite_adapter.rb:273:in `table_structure'
/usr/lib/ruby/gems/1.8/gems/activerecord-1.15.1/lib/active_record/
connection_adapters/sqlite_adapter.rb:210:in `columns'
/usr/lib/ruby/gems/1.8/gems/activerecord-1.15.1/lib/active_record/
base.rb:760:in `columns'
/usr/lib/ruby/gems/1.8/gems/activerecord-1.15.1/lib/active_record/
base.rb:768:in `columns_hash'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.13.1/lib/action_controller/
session/active_record_store.rb:105:in `setup_sessid_compatibility!
'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.13.1/lib/action_controller/
session/active_record_store.rb:79:in `find_by_session_id'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.13.1/lib/action_controller/
session/active_record_store.rb:283:in `initialize'
/usr/lib/ruby/gems/1.8/gems/activerecord-1.15.1/lib/active_record/
base.rb:864:in `silence'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.13.1/lib/action_controller/
session/active_record_store.rb:283:in `initialize'
/usr/lib/ruby/1.8/cgi/session.rb:273:in `initialize'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.13.1/lib/action_controller/
cgi_process.rb:122:in `session'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.13.1/lib/action_controller/
cgi_process.rb:154:in `stale_session_check!'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.13.1/lib/action_controller/
cgi_process.rb:109:in `session'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.13.1/lib/action_controller/
base.rb:1052:in `assign_shortcuts_without_flash'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.13.1/lib/action_controller/
flash.rb:140:in `assign_shortcuts'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.13.1/lib/action_controller/
base.rb:424:in `process_without_filters'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.13.1/lib/action_controller/
filters.rb:624:in `process_without_session_management_support'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.13.1/lib/action_controller/
session_management.rb:114:in `process'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.13.1/lib/action_controller/
base.rb:330:in `process'
/usr/lib/ruby/gems/1.8/gems/rails-1.2.1/lib/dispatcher.rb:41:in
`dispatch'
/usr/lib/ruby/gems/1.8/gems/rails-1.2.1/lib/fcgi_handler.rb:168:in
`process_request'
/usr/lib/ruby/gems/1.8/gems/rails-1.2.1/lib/fcgi_handler.rb:143:in
`process_each_request!'
/usr/lib/ruby/gems/1.8/gems/rails-1.2.1/lib/fcgi_handler.rb:109:in
`with_signal_handler'
/usr/lib/ruby/gems/1.8/gems/rails-1.2.1/lib/fcgi_handler.rb:142:in
`process_each_request!'
/usr/lib/ruby/1.8/fcgi.rb:600:in `each_cgi'
/usr/lib/ruby/1.8/fcgi.rb:597:in `each_cgi'
/usr/lib/ruby/gems/1.8/gems/rails-1.2.1/lib/fcgi_handler.rb:141:in
`process_each_request!'
/usr/lib/ruby/gems/1.8/gems/rails-1.2.1/lib/fcgi_handler.rb:55:in
`process!'
/usr/lib/ruby/gems/1.8/gems/rails-1.2.1/lib/fcgi_handler.rb:25:in
`process!'
/usr/local/code/ruby/coverage-prod/public/dispatch.fcgi:24

How can I debug this? Is there some way to figure out what the invalid
statement is?

go into config/environment.rb and uncomment the line

  # config.log_level = :debug

then restart

don't forget to comment it and restart again after you've fixed the problem.