SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Member
    Join Date
    Feb 2009
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Simply Rails 2 [rake db:migrate] "rake aborted!"

    Hi,
    I am a new user to RoR and very a very green programmer to boot. I am using the Simply Rails 2 book by Patrick Lenz and I have run into a problem using rake.
    I am running ruby 1.8.6 in Ubuntu 8.04 as well as the recommended Mongrel web server and the SQLite3 DB version 3.4.2. I am having trouble running the rake and I am confused as to how to go about solving the problem. I have read various other posts and have still been unable to fix my problem. Has anyone navigated through a similar problem successfully and/or does anyone have any advice as to how to go about correcting this issue? Much Thanks.

    After trying to run-> rake db:migrate
    "I receive this following error"

    chris@chris-laptop:~/shovell$ rake db:migrate
    (in /home/chris/shovell)
    == CreateStories: migrating ==================================================
    -- create_tablestories)
    rake aborted!
    An error has occurred, all later migrations canceled:

    SQLite3::SQLException: table "stories" already exists: CREATE TABLE "stories" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255), "link" varchar(255), "created_at" datetime, "updated_at" datetime)

    (See full trace by running task with --trace)
    "Then I run the trace and here is what I receive"

    >> chris@chris-laptop:~/shovell$ rake db:migrate --trace
    (in /home/chris/shovell)
    ** Invoke db:migrate (first_time)
    ** Invoke environment (first_time)
    ** Execute environment
    ** Execute db:migrate
    == CreateStories: migrating ==================================================
    -- create_tablestories)
    rake aborted!
    An error has occurred, all later migrations canceled:

    SQLite3::SQLException: table "stories" already exists: CREATE TABLE "stories" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255), "link" varchar(255), "created_at" datetime, "updated_at" datetime)
    /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/sqlite_adapter.rb:132:in `execute'
    /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/connection_adapters/sqlite_adapter.rb:372:in `catch_schema_changes'
    /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/connection_adapters/sqlite_adapter.rb:132:in `execute'
    /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/connection_adapters/abstract/schema_statements.rb:114:in `create_table'
    /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/migration.rb:346:in `send'
    /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/migration.rb:346:in `method_missing'
    /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/migration.rb:326:in `say_with_time'
    /usr/local/lib/ruby/1.8/benchmark.rb:293:in `measure'
    /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/migration.rb:326:in `say_with_time'
    /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/migration.rb:342:in `method_missing'
    ./db/migrate//001_create_stories.rb:3:in `up_without_benchmarks'
    /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/migration.rb:280:in `send'
    /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/migration.rb:280:in `migrate'
    /usr/local/lib/ruby/1.8/benchmark.rb:293:in `measure'
    /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/migration.rb:280:in `migrate'
    (__DELEGATION__):2:in `__send__'
    (__DELEGATION__):2:in `migrate'
    /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/migration.rb:480:in `migrate'
    /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/migration.rb:556:in `call'
    /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/migration.rb:556:in `ddl_transaction'
    /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/migration.rb:479:in `migrate'
    /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/migration.rb:466:in `each'
    /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/migration.rb:466:in `migrate'
    /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/migration.rb:394:in `up'
    /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/migration.rb:377:in `migrate'
    /usr/local/lib/ruby/gems/1.8/gems/rails-2.2.2/lib/tasks/databases.rake:111
    /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:238: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

    "I am confused at this point and any help would be sincerely appreciated" Thx!

  2. #2
    Follow Me On Twitter: @djg gold trophysilver trophybronze trophy Dan Grossman's Avatar
    Join Date
    Aug 2000
    Location
    Philadephia, PA
    Posts
    20,580
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    The first line of the error seems to be telling you the problem...

    SQLite3::SQLException: table "stories" already exists
    There's already a table there, so it can't make it for you.

    * If the database is already where you want it, why run the command again?
    * If it isn't, perhaps an incomplete copy, drop the tables so they can be created again?

  3. #3
    SitePoint Member
    Join Date
    Feb 2009
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Many Thanks Dan. I was actually in the wrong DB I think. I kept trying to drop the tables from the SQLite3 when the tables were in SQLite3 db/development. Once I got into the correct DB I was able to drop the table "per your advice" and the rake worked like a charm. Thanks a bunch!!!
    -CJ

  4. #4
    SitePoint Member
    Join Date
    Jul 2009
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I have just generated the Vote model from ch7(p186) and when i type in $ rake db:migrate it thinks im migrating to the stories table.

    Have I missed something?

  5. #5
    SitePoint Guru
    Join Date
    Jan 2001
    Location
    Alkmaar, Netherlands
    Posts
    710
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It tries to migrate every pending migration if they have not been migrated yet(It checks schema_migrations table)

    PS: Maybe you can copy paste your vote creation migration...


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •