SitePoint Sponsor

User Tag List

Results 1 to 13 of 13
  1. #1
    SitePoint Enthusiast
    Join Date
    Sep 2009
    Posts
    42
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    simply rails 2-rake db:migrate not working

    I am back into the simply rails 2 book after reading half of learn to program and I am not getting the read out supposed on page 132 after puting in
    rake db:migrate in the the shovell folder... it just produces the same line in paretheses that I started with, but the 001_create_stories.rb file on page 126looks good. Anybody know why the read out is wrong?

  2. #2
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,189
    Mentioned
    191 Post(s)
    Tagged
    2 Thread(s)
    Without knowing what the "same line" is, I'll guess.
    Maybe you missed the
    :force => true
    on page 129?

  3. #3
    SitePoint Enthusiast
    Join Date
    Sep 2009
    Posts
    42
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    what I mean is the same line as the prompt line, and like I said I checked the force true line in that file to make sure it read right and it looked correct

  4. #4
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,189
    Mentioned
    191 Post(s)
    Tagged
    2 Thread(s)
    So at the prompt
    ../shovell> rake db:migrate
    shows
    (in /path/to/shovell)
    and then hangs (or does nothing else)? No error messages?

    Does it go back to the prompt
    ../shovell>

  5. #5
    SitePoint Enthusiast
    Join Date
    Sep 2009
    Posts
    42
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yes it comes right back to same original prompt

  6. #6
    SitePoint Evangelist
    Join Date
    Feb 2006
    Location
    Worcs. UK
    Posts
    404
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Have you checked that the migration hasn't already been run? Once a migration has been run, if you run the migration again, you get minimal output. It might be worth rolling back to the previous migration and then running the migration again.

  7. #7
    SitePoint Enthusiast
    Join Date
    Sep 2009
    Posts
    42
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I don't think I know how to check if a migration has been run, how do I do it?

  8. #8
    SitePoint Enthusiast
    Join Date
    Sep 2009
    Posts
    42
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I never got an answer to why db:migrate didn't work, can somebody review my question and see if they know, I don't know to check if the migration has been done or not

    Brad

  9. #9
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,189
    Mentioned
    191 Post(s)
    Tagged
    2 Thread(s)
    In the application's log folder should be a "development.log" file. If you look at that you should find migration info and lots more.

  10. #10
    SitePoint Enthusiast
    Join Date
    May 2008
    Posts
    39
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Probably be easier to check the db/schema.rb file. It shows what your database currently looks like, have look and see if the migration you've written has already been applied.

  11. #11
    SitePoint Enthusiast
    Join Date
    Sep 2009
    Posts
    42
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    below is the file, but I am not really sure what I am looking at, I am guessing it is correct
    create_table "stories", :force => true do |t|
    t.string "name"
    t.string "link"
    t.datetime "created_at"
    t.datetime "updated_at"
    end

    end

  12. #12
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,189
    Mentioned
    191 Post(s)
    Tagged
    2 Thread(s)
    Except for the version which would be different, yours looks like mine
    Code Ruby:
    ActiveRecord::Schema.define(:version => 20080830130129) do
     
      create_table "stories", :force => true do |t|
        t.string   "name"
        t.string   "link"
        t.datetime "created_at"
        t.datetime "updated_at"
      end
     
    end

  13. #13
    SitePoint Enthusiast
    Join Date
    May 2008
    Posts
    39
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yeah, so it looks like the migration has already been run.

    You write the migration, you run 'rake db:migrate', the migrations are applied to the database. 'rake db:migrate' then won't do anything until you create a new migration.

    A migration is like a set of instructions of what should be done to a database, so each one is only run once. If you were working in a team, the migrations can be kept with the project and then team members can easily run them against their own databases.

    schema.rb then keeps track of what your database looks like (and also lists the number of the latest migration in the :version hash).


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
  •