Rake aborted! Could not find table

I am getting a rake aborted error and I suspect that I am missing a
package on my system since the app works for a friend on this
computer.

Here is the terminal output of the error:

anita@anitas-computer:~/sandbox/shovell$ rake db:migrate
(in /home/anita/sandbox/shovell)
rake aborted!
Could not find table ‘stories’

(See full trace by running task with --trace)
anita@anitas-computer:~/sandbox/shovell$

Here is the contents of the migration file:

anita@anitas-computer:~/sandbox/shovell/db/migrate$ cat
20080701040248_create_stories.rb
class CreateStories < ActiveRecord::Migration
def self.up
create_table :stories do |t|
t.text :name
t.text :link

  t.timestamps
end

end

def self.down
drop_table :stories
end
end
anita@anitas-computer:~/sandbox/shovell/db/migrate$

Here is the stack trace:

anita@anitas-computer:~/sandbox/shovell$ rake db:migrate --trace
(in /home/anita/sandbox/shovell)
** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute db:migrate
** Invoke db:schema:dump (first_time)
** Invoke environment
** Execute db:schema:dump
rake aborted!
Could not find table ‘stories’
/usr/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/
connection_adapters/sqlite3_adapter.rb:29:in table_structure' /usr/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/ core_ext/object/misc.rb:28:inreturning’
/usr/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/
connection_adapters/sqlite3_adapter.rb:28:in table_structure' /usr/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/ connection_adapters/sqlite_adapter.rb:189:incolumns’
/usr/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/
schema_dumper.rb:75:in table' /usr/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/ schema_dumper.rb:70:intables’
/usr/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/
schema_dumper.rb:61:in each' /usr/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/ schema_dumper.rb:61:intables’
/usr/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/
schema_dumper.rb:23:in dump' /usr/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/ schema_dumper.rb:17:indump’
/usr/lib/ruby/gems/1.8/gems/rails-2.1.0/lib/tasks/databases.rake:219
/usr/lib/ruby/gems/1.8/gems/rails-2.1.0/lib/tasks/databases.rake:
218:in open' /usr/lib/ruby/gems/1.8/gems/rails-2.1.0/lib/tasks/databases.rake:218 /usr/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:546:incall’
/usr/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:546:in execute' /usr/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:541:ineach’
/usr/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:541:in execute' /usr/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:508:ininvoke_with_call_chain’
/usr/lib/ruby/1.8/thread.rb:135:in synchronize' /usr/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:501:ininvoke_with_call_chain’
/usr/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:494:in invoke' /usr/lib/ruby/gems/1.8/gems/rails-2.1.0/lib/tasks/databases.rake:100 /usr/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:546:incall’
/usr/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:546:in execute' /usr/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:541:ineach’
/usr/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:541:in execute' /usr/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:508:ininvoke_with_call_chain’
/usr/lib/ruby/1.8/thread.rb:135:in synchronize' /usr/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:501:ininvoke_with_call_chain’
/usr/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:494:in invoke' /usr/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1931:ininvoke_task’
/usr/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1909:in top_level' /usr/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1909:ineach’
/usr/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1909:in top_level' /usr/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1948:instandard_exception_handling’
/usr/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1903:in top_level' /usr/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1881:inrun’
/usr/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1948:in
standard_exception_handling' /usr/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1878:inrun’
/usr/lib/ruby/gems/1.8/gems/rake-0.8.1/bin/rake:31
/usr/bin/rake:19:in `load’
/usr/bin/rake:19
anita@anitas-computer:~/sandbox/shovell$

Any thoughts about what file or package is missing to cause this
situation, are gratefully received. Thank you,
Anita.

an you put the database.yml file too?

the migrations seems fine, and as you said it works on someone else’s
computer.

Wolas!:

Thanks for the reply. As requested, database.yml:

anita@anitas-computer:~/sandbox/shovell/config$ cat database.yml

SQLite version 3.x

gem install sqlite3-ruby (not necessary on OS X Leopard)

development:
adapter: sqlite3
database: db/development.sqlite3
timeout: 5000

Warning: The database defined as “test” will be erased and

re-generated from your development database when you run “rake”.

Do not set this db to the same as development or production.

test:
adapter: sqlite3
database: db/test.sqlite3
timeout: 5000

production:
adapter: sqlite3
database: db/production.sqlite3
timeout: 5000
anita@anitas-computer:~/sandbox/shovell/config$

Your migration asked to create new table that is stories but the error
said like it were wanting to modify table stories. please check your
schema.rb or previous migration files. Is there any syntax that want to
modify stories table? and check also your migration version in schema.rb
and in your table.

Reinhart
http://teapoci.blogspot.com

The migration is fine. if the tabls stories was already there it would
have complained about it. bu the error is the opposite:

Could not find table ‘stories’

it defenitely seems like youre modifying the table before you have
created it.

My only suggestion here is make sure you have the development packages
for sqlite3 as well as the client ones.

I ran out of ideas at this point.

j

On Jul 2, 7:55 am, Frederick C. [email protected]

On Jul 1, 6:34 pm, anteaya [email protected] wrote:

(See full trace by running task with --trace)
anita@anitas-computer:~/sandbox/shovell$

Here is the contents of the migration file:

anita@anitas-computer:~/sandbox/shovell/db/migrate$ cat
20080701040248_create_stories.rb

What makes you think that this migration is the problem? Do any other
migrations reference stories?

Fred

you might also want to check config/environment.rb for anything that
might
be preloading or reading from the stories. I tried some cleverness like
this
once and it burped a similar error when migrating up from zero.

RSL

I experience exactly the same problem. It works on my computer (using
MySQL), but fails on another one (using sqlite3).

database.yml:

development:
adapter: sqlite3
database: db/development.sqlite3
timeout: 5000

I have two migration files:
20080701141405_create_commands.rb
20080701142511_add_content_to_database.rb

First one:

def self.up
create_table :commands do |t|
t.string :name
t.text :xml
t.timestamps
end
end

def self.down
drop_table :commands
end

Second one:

def self.up
# here is a loop that fetches external data
Command.create(
:name => name,
:xml => xml_string
)
# end of loop
end

def self.down
Command.delete_all
end

The first one works OK, but the second migration fails with
rake aborted!
Could not find table ‘commands’

If I try to create another “create table” statement, then it complains
with

rake aborted!
SQLite3::SQLException: table “commands” already exists: CREATE TABLE
“commands” (“id” INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, “name”
varchar(255) DEFAULT NULL NULL, “xml” text DEFAULT NULL NULL,
“created_at” datetime DEFAULT NULL NULL, “updated_at” datetime DEFAULT
NULL NULL)

I’m clueless. I don’t set anything in environment.rb by myself.

I had some problems installing rails

Thanks a lot,
Mojca

If that matters, I had some problems installing latest version of gems,
but that got resolved:

gem update --system
Updating RubyGems…
Bulk updating Gem source index for: http://gems.rubyforge.org
Attempting remote update of rubygems-update
ERROR: While executing gem … (Gem::GemNotFoundException)
Could not find rubygems-update (> 0) in any repository

gem env
RubyGems Environment:

  • VERSION: 0.9.2 (0.9.2)
  • INSTALLATION DIRECTORY: /usr/lib/ruby/gems/1.8
  • GEM PATH:
    • /usr/lib/ruby/gems/1.8
  • REMOTE SOURCES:

sudo mv /usr/lib/ruby/gems/1.8/source_cache /tmp

sudo gem update --system
Updating RubyGems…
Bulk updating Gem source index for: http://gems.rubyforge.org
Attempting remote update of rubygems-update
ERROR: While executing gem … (Gem::GemNotFoundException)
Could not find rubygems-update (> 0) in any repository

sudo gem install rubygems-update
Bulk updating Gem source index for: http://gems.rubyforge.org
Successfully installed rubygems-update-1.2.0

sudo gem update --system
Updating RubyGems…
Attempting remote update of rubygems-update
Successfully installed rubygems-update-1.2.0
Updating version of RubyGems to 1.2.0
Installing RubyGems 1.2.0
mkdir -p /usr/lib/ruby/site_ruby/1.8
mkdir -p /usr/bin
install -c -m 0644 rubygems.rb /usr/lib/ruby/site_ruby/1.8/rubygems.rb

[success]

As suggested here is the schema.rb:

anita@anitas-computer:~/sandbox/shovell/db$ cat schema.rb

This file is auto-generated from the current state of the database.

Instead of editing this file,

please use the migrations feature of Active Record to incrementally

modify your database, and

then regenerate this schema definition.

Note that this schema.rb definition is the authoritative source for

your database schema. If you need

to create the application database on another system, you should be

using db:schema:load, not running

all the migrations from scratch. The latter is a flawed and

unsustainable approach (the more migrations

you’ll amass, the slower it’ll run and the greater likelihood for

issues).

It’s strongly recommended to check this file into your version control

system.

ActiveRecord::Schema.define(:version => 20080701040248) do

anita@anitas-computer:~/sandbox/shovell/db$

Now this is the first time that I have looked at schema.rb, is the
define -> do -> nothing format normal? it seems to be missing an end
to at least close the block. If there has been no “end” generated
then perhaps the generator is not working properly. Why would it
start a block and not finish it? Or have I latched onto a red herring
here?

Thanks, still looking,
Anita.

What makes you think that this migration is the problem? Do any other
migrations reference stories?

This is the first migration in the application.

Anita.

On Wed, Jul 2, 2008 at 2:55 AM, Frederick C.

Thank you all for your suggestions and input.

This is the first migration of the application or in other words
migration zero.

I will take a look at the other comments and see what develops.

Thank you,
Anita.

On Wed, Jul 2, 2008 at 1:30 PM, Mojca M.

Here is config/environment.rb:

anita@anitas-computer:~/sandbox/shovell/config$ cat environment.rb

Be sure to restart your server when you modify this file

Uncomment below to force Rails into production mode when

you don’t control web/app server and can’t set it the proper way

ENV[‘RAILS_ENV’] ||= ‘production’

Specifies gem version of Rails to use when vendor/rails is not present

RAILS_GEM_VERSION = ‘2.1.0’ unless defined? RAILS_GEM_VERSION

Bootstrap the Rails environment, frameworks, and default configuration

require File.join(File.dirname(FILE), ‘boot’)

Rails::Initializer.run do |config|

Settings in config/environments/* take precedence over those

specified here.

Application configuration should go into files in

config/initializers

– all .rb files in that directory are automatically loaded.

See Rails::Configuration for more options.

Skip frameworks you’re not going to use. To use Rails without a

database

you must remove the Active Record framework.

config.frameworks -= [ :active_record, :active_resource,

:action_mailer ]

Specify gems that this application depends on.

They can then be installed with “rake gems:install” on new

installations.

config.gem “bj”

config.gem “hpricot”, :version => ‘0.6’, :source =>

http://code.whytheluckystiff.net

config.gem “aws-s3”, :lib => “aws/s3”

Only load the plugins named here, in the order given. By default,

all plugins

in vendor/plugins are loaded in alphabetical order.

:all can be used as a placeholder for all plugins not explicitly

named

config.plugins = [ :exception_notification, :ssl_requirement, :all ]

Add additional load paths for your own custom dirs

config.load_paths += %W( #{RAILS_ROOT}/extras )

Force all environments to use the same logger level

(by default production uses :info, the others :debug)

config.log_level = :debug

Make Time.zone default to the specified zone, and make Active

Record store time values

in the database in UTC, and return them converted to the specified

local zone.

Run “rake -D time” for a list of tasks for finding time zone

names. Uncomment to use default local time.
config.time_zone = ‘UTC’

Your secret key for verifying cookie session data integrity.

If you change this key, all old sessions will become invalid!

Make sure the secret is at least 30 characters and all random,

no regular words or you’ll be exposed to dictionary attacks.

config.action_controller.session = {
:session_key => ‘_shovell_session’,
:secret =>
‘xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx’
#hidden for the purpose of this email
}

Use the database for sessions instead of the cookie-based default,

which shouldn’t be used to store highly confidential information

(create the session table with “rake db:sessions:create”)

config.action_controller.session_store = :active_record_store

Use SQL instead of Active Record’s schema dumper when creating the

test database.

This is necessary if your schema can’t be completely dumped by the

schema dumper,

like if you have constraints or database-specific column types

config.active_record.schema_format = :sql

Activate observers that should always be running

config.active_record.observers = :cacher, :garbage_collector

end
anita@anitas-computer:~/sandbox/shovell/config$

I have the exact same problem on my Debian server.
Has anybody found a solution?

kristian

Kristian wrote:

I have the exact same problem on my Debian server.
Has anybody found a solution?

Take a look at
"no such file to load -- sqlite3" Rails - Rails - Ruby-Forum

It might be the same problem - buggy sqlite3(-ruby) interface. The
suggested solution is to downgrade the gem. I gave up using sqlite3 and
switched to mysql instead.

Mojca

Hi anita,

You just have to migrate the production too… or you can duplicate your
development db and rename to production.sqlite3… unusual but solve the
problem.

Best regards

Eduardo