mardi 20 septembre 2016

'rake db:migrate' is not working correctly. Not creating tables in my simple_cms in my model

Here is what I did: 1. rails generate migration DoNothingYet invoke active_record 20160919195736_do_nothing_yet.rb

  1. rails generate model User invoke active_record create db/migrate/20160919201440_create_users.rb create app/models/user.rb invoke test_unit create test/models/user_test.rb create test/fixtures/users.yml

Here's the two files I created and edited:

  1. class DoNothingYet < ActiveRecord::Migration

    def up end

    def down end

    end

  2. class CreateUsers < ActiveRecord::Migration

     def up
       `create_table :users do |t|` 
        `t.column "first_name", :string, :limit => 25`
        `t.string "last_name", :limit => 50`
         t.string "email", :default => "", :null => false 
         t.string "password", :limit => 40 
            #t.dateime "created_at"
            #t.datetime "updated_at"
            t.timestamps
    
    
    end
    
    

    end

    def down drop_table :users end

    end

When I run: rake db:migrate

It does not return anything. When I run rake db:migrate --trace I get back:

 Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
** Invoke db:load_config (first_time)
** Execute db:load_config
** Execute db:migrate
** Invoke db:_dump (first_time)
** Execute db:_dump
** Invoke db:schema:dump (first_time)

** Invoke environment ** Invoke db:load_config ** Execute db:schema:dump

When I log in mysql to my simple_cms_development database via my Username- simple_cms.

I try SHOW TABLES;

No tables appeared.

When I run rake db:schema:load --trace this is what I get:

JohnMicttesMBP5:simple_cms john-michaelnalettenalette$ rake db:schema:load --trace

** Invoke db:schema:load (first_time)
** Invoke db:load_config (first_time)
** Execute db:load_config
** Execute db:schema:load
-- create_table("users", {:force=>:cascade})
   -> 0.1929s
 -- initialize_schema_migrations_table()
   -> 0.1518s
-- create_table("users", {:force=>:cascade})
rake aborted!
 Mysql2::Error: Access denied for user 'simple_cms'@'localhost' to     database 'test'
/Users/john-michaelnalettenalette/simple_cms/vendor/bundle/gems/mysql2-  0.3.21/lib/mysql2/client.rb:70:in `connect'
/Users/john-michaelnalettenalette/simple_cms/vendor/bundle/gems/mysql2-0.3.21/lib/mysql2/client.rb:70:in `initialize'
/Library/Ruby/Gems/2.0.0/gems/activerecord-  4.2.2/lib/active_record/connection_adapters/mysql2_adapter.rb:18:in `new'
/Library/Ruby/Gems/2.0.0/gems/activerecord-4.2.2/lib/active_record/connection_adapters/mysql2_adapter.rb:18:in   `mysql2_connection'
/Library/Ruby/Gems/2.0.0/gems/activerecord-        4.2.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:438     :in `new_connection'
/Library/Ruby/Gems/2.0.0/gems/activerecord-     4.2.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:448     :in `checkout_new_connection'
/Library/Ruby/Gems/2.0.0/gems/activerecord-     4.2.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:422     :in `acquire_connection'
/Library/Ruby/Gems/2.0.0/gems/activerecord-     4.2.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:349     :in `block in checkout'
 /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/m     onitor.rb:211:in `mon_synchronize'
 /Library/Ruby/Gems/2.0.0/gems/activerecord-    4.2.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:348    :in `checkout'
/Library/Ruby/Gems/2.0.0/gems/activerecord-  4.2.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:263    :in `block in connection'
  /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/m     onitor.rb:211:in `mon_synchronize'
 /Library/Ruby/Gems/2.0.0/gems/activerecord-   4.2.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:262    :in `connection'
/Library/Ruby/Gems/2.0.0/gems/activerecord-  4.2.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:567    :in `retrieve_connection'
/Library/Ruby/Gems/2.0.0/gems/activerecord-  4.2.2/lib/active_record/connection_handling.rb:113:in `retrieve_connection'
/Library/Ruby/Gems/2.0.0/gems/activerecord-  4.2.2/lib/active_record/connection_handling.rb:87:in `connection'
/Library/Ruby/Gems/2.0.0/gems/activerecord-     4.2.2/lib/active_record/migration.rb:646:in `connection'
/Library/Ruby/Gems/2.0.0/gems/activerecord-c      4.2.2/lib/active_record/migration.rb:661:in `block in method_missing'
/Library/Ruby/Gems/2.0.0/gems/activerecord-     4.2.2/lib/active_record/migration.rb:632:in `block in say_with_time'
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/b     enchmark.rb:281:in `measure'
/Library/Ruby/Gems/2.0.0/gems/activerecord-    4.2.2/lib/active_record/migration.rb:632:in `say_with_time'
/Library/Ruby/Gems/2.0.0/gems/activerecord-     4.2.2/lib/active_record/migration.rb:652:in `method_missing'
/Users/john-michaelnalettenalette/simple_cms/db/schema.rb:16:in `block       in <top (required)>'
/Library/Ruby/Gems/2.0.0/gems/activerecord-     4.2.2/lib/active_record/schema.rb:41:in `instance_eval'
/Library/Ruby/Gems/2.0.0/gems/activerecord-    4.2.2/lib/active_record/schema.rb:41:in `define'
/Library/Ruby/Gems/2.0.0/gems/activerecord-    4.2.2/lib/active_record/schema.rb:61:in `define'
/Users/john-michaelnalettenalette/simple_cms/db/schema.rb:14:in `<top    (required)>'
/Library/Ruby/Gems/2.0.0/gems/activesupport-    4.2.2/lib/active_support/dependencies.rb:268:in `load'
/Library/Ruby/Gems/2.0.0/gems/activesupport-    4.2.2/lib/active_support/dependencies.rb:268:in `block in load'
/Library/Ruby/Gems/2.0.0/gems/activesupport-    4.2.2/lib/active_support/dependencies.rb:240:in `load_dependency'
/Library/Ruby/Gems/2.0.0/gems/activesupport-    4.2.2/lib/active_support/dependencies.rb:268:in `load'
/Library/Ruby/Gems/2.0.0/gems/activerecord-    4.2.2/lib/active_record/tasks/database_tasks.rb:218:in `load_schema_for'
/Library/Ruby/Gems/2.0.0/gems/activerecord-     4.2.2/lib/active_record/tasks/database_tasks.rb:235:in `block in    load_schema_current'
/Library/Ruby/Gems/2.0.0/gems/activerecord-    4.2.2/lib/active_record/tasks/database_tasks.rb:275:in `block in   each_current_configuration'
/Library/Ruby/Gems/2.0.0/gems/activerecord-    4.2.2/lib/active_record/tasks/database_tasks.rb:274:in `each'
/Library/Ruby/Gems/2.0.0/gems/activerecord-    4.2.2/lib/active_record/tasks/database_tasks.rb:274:in     `each_current_configuration'
/Library/Ruby/Gems/2.0.0/gems/activerecord-    4.2.2/lib/active_record/tasks/database_tasks.rb:234:in     `load_schema_current'
/Library/Ruby/Gems/2.0.0/gems/activerecord-    4.2.2/lib/active_record/railties/databases.rake:244:in `block (3 levels) in     <top (required)>'
/Library/Ruby/Gems/2.0.0/gems/rake-11.2.2/lib/rake/task.rb:248:in     `call'
/Library/Ruby/Gems/2.0.0/gems/rake-11.2.2/lib/rake/task.rb:248:in     `block in execute'
/Library/Ruby/Gems/2.0.0/gems/rake-11.2.2/lib/rake/task.rb:243:in     `each'
/Library/Ruby/Gems/2.0.0/gems/rake-11.2.2/lib/rake/task.rb:243:in     `execute'
 /Library/Ruby/Gems/2.0.0/gems/rake-11.2.2/lib/rake/task.rb:187:in     `block in invoke_with_call_chain'
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/m     onitor.rb:211:in `mon_synchronize'
/Library/Ruby/Gems/2.0.0/gems/rake-11.2.2/lib/rake/task.rb:180:in     `invoke_with_call_chain'
/Library/Ruby/Gems/2.0.0/gems/rake-11.2.2/lib/rake/task.rb:173:in     `invoke'
/Library/Ruby/Gems/2.0.0/gems/rake-    11.2.2/lib/rake/application.rb:152:in `invoke_task'
/Library/Ruby/Gems/2.0.0/gems/rake-    11.2.2/lib/rake/application.rb:108:in `block (2 levels) in top_level'
/Library/Ruby/Gems/2.0.0/gems/rake-11.2.2/lib/rake/application.rb:108:in `each'
/Library/Ruby/Gems/2.0.0/gems/rake-11.2.2/lib/rake/application.rb:108:in `block in top_level'
/Library/Ruby/Gems/2.0.0/gems/rake-11.2.2/lib/rake/application.rb:117:in `run_with_threads'
/Library/Ruby/Gems/2.0.0/gems/rake-11.2.2/lib/rake/application.rb:102:in `top_level'
/Library/Ruby/Gems/2.0.0/gems/rake-11.2.2/lib/rake/application.rb:80:in `block in run'
/Library/Ruby/Gems/2.0.0/gems/rake-11.2.2/lib/rake/application.rb:178:in `standard_exception_handling'
/Library/Ruby/Gems/2.0.0/gems/rake-11.2.2/lib/rake/application.rb:77:in `run'
/usr/bin/rake:37:in `<main>'
Tasks: TOP => db:schema:load

Any suggestions would be appreciated?

Aucun commentaire:

Enregistrer un commentaire