Yayo
Yayo

Reputation: 13

Cannot use db Migrate, rake aborted error

I am working a new project in Codeanywhere (I am new on Ruby), but when I try to use "rake db : migrate" I have this error:

rake aborted!                                                                                                                                                                                                                                        
Don't know how to build task ':' (see --tasks)                                                                                                                                                                                                       
/home/cabox/.rvm/gems/ruby-2.1.2/gems/rake-12.0.0/exe/rake:27:in `<top (required)>'                                                     
(See full trace by running task with --trace)

Before this I use bundle update and after and nothing, and when I put "rake-T", db Migartion is on the tasks, when I try with --trace, pass the same.

I try before with rake db:migrate and the same happened `rake aborted!

SyntaxError:     
/home/cabox/workspace/blog/db/migrate/20170103233409_create_posts.rb:5: syntax error, unexpected ':'                                                                                                                                    
/home/cabox/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.6/lib/active_support/dependencies.rb:247:in `require'                                                                                                                                        
/home/cabox/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.6/lib/active_support/dependencies.rb:247:in `block in require'                                                                                                                               
/home/cabox/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.6/lib/active_support/dependencies.rb:232:in `load_dependency'                                                                                                                                
/home/cabox/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.6/lib/active_support/dependencies.rb:247:in `require'                                                                                                                                        
/home/cabox/.rvm/gems/ruby-2.1.2/gems/activerecord-4.1.6/lib/active_record/migration.rb:761:in `load_migration'                                                                                                                                      
/home/cabox/.rvm/gems/ruby-2.1.2/gems/activerecord- 4.1.6/lib/active_record/migration.rb:757:in `migration'                                                                                                                                           
/home/cabox/.rvm/gems/ruby-2.1.2/gems/activerecord-4.1.6/lib/active_record/migration.rb:752:in `disable_ddl_transaction'                                                                                                                             
/home/cabox/.rvm/gems/ruby-2.1.2/gems/activerecord-4.1.6/lib/active_record/migration.rb:1044:in `use_transaction?'                                                                                                                                   
/home/cabox/.rvm/gems/ruby-2.1.2/gems/activerecord-4.1.6/lib/active_record/migration.rb:1036:in `ddl_transaction'                                                                                                                                    
/home/cabox/.rvm/gems/ruby-2.1.2/gems/activerecord-4.1.6/lib/active_record/migration.rb:990:in `execute_migration_in_transaction'                                                                                                                    
/home/cabox/.rvm/gems/ruby-2.1.2/gems/activerecord-4.1.6/lib/active_record/migration.rb:952:in `block in migrate'                                                                                                                                    
/home/cabox/.rvm/gems/ruby-2.1.2/gems/activerecord-4.1.6/lib/active_record/migration.rb:948:in `each'                                                                                                                                                
/home/cabox/.rvm/gems/ruby-2.1.2/gems/activerecord-4.1.6/lib/active_record/migration.rb:948:in `migrate'                                                                                                                                             
/home/cabox/.rvm/gems/ruby-2.1.2/gems/activerecord-4.1.6/lib/active_record/migration.rb:807:in `up'                                                                                                                                                  
/home/cabox/.rvm/gems/ruby-2.1.2/gems/activerecord-4.1.6/lib/active_record/migration.rb:785:in `migrate'                                                                                                                                             
/home/cabox/.rvm/gems/ruby-2.1.2/gems/activerecord-4.1.6/lib/active_record/railties/databases.rake:34:in `block (2 levels) in <top (required)>'                                                                                                      
/home/cabox/.rvm/gems/ruby-2.1.2/gems/rake-12.0.0/exe/rake:27:in `<top (required)>'                                                                                                                                                                  
Tasks: TOP => db:migrate                                                                                                                                                                                                                             
(See full trace by running task with --trace)` >    

Does anyone know how to solve this problem?

In the migration file I have:

class CreatePosts < ActiveRecord::Migration
  def change
    create_table :posts do |t|
      t.string :title
      t.strind : 
      t.text :body 
      t.timestamps
    end
  end
end

Upvotes: 0

Views: 917

Answers (3)

Rockwell Rice
Rockwell Rice

Reputation: 3002

I am pretty sure what is happening is you are inserting a space in there when you type it out. It needs to be

rake db:migrate

not

rake db : migrate

That error message is pretty common when there is a spelling error or some other kind of typing error when running the command.

Your migration has a typo as well, should be this

class CreatePosts < ActiveRecord::Migration
  def change
    create_table :posts do |t|
      t.string :title
      t.text :body 
      t.timestamps
    end
  end
end

Upvotes: 5

sureshvignesh
sureshvignesh

Reputation: 170

Rake is a software task management tool, similar to Make, etc. in other systems

The generic syntax is

rake namesapce:task

In your case it is

rake db:migrate

Upvotes: 1

RamPrasad Reddy
RamPrasad Reddy

Reputation: 125

Try doing rake db:reset if you want to rebuild your db again. It does 4 things for you

rake db:drop
rake db:create
rake db:migrate
rake db:seed 

Upvotes: -1

Related Questions