Переехал в macports и возникли проблемы с database.yml - PullRequest
1 голос
/ 15 марта 2011

Я перешел в macports и пытался запустить rake db: migrate, но получил

$ rake db:migrate(in /Users/me/work/myproject)
rake aborted!
Mysql::Error: Table 'myproject_development.users' doesn't exist: SHOW FIELDS FROM `users`

Я думаю, что это может быть мой database.yml?Что мне нужно изменить, так как сейчас я использую macports и mysql5.До этого я только использовал CocoaMySql для создания моей базы данных myproject_development.

development:
  adapter: mysql
  encoding: utf8
  reconnect: false
  database: myproject_development
  pool: 5
  username: root
  password:
  socket: /tmp/mysql.sock

# 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: mysql
  encoding: utf8
  reconnect: false
  database: myproject_test
  pool: 5
  username: root
  password:
  socket: /tmp/mysql.sock

production:
  adapter: mysql
  encoding: utf8
  reconnect: false
  database: myproject_production
  pool: 5
  username: root
  password: 
  socket: /tmp/mysql.sock

//////// Результаты rake DB: migrate --trace //////////////

                rake db:migrate --trace
            (in /Users/me/work/myproject)
            ** Invoke db:migrate (first_time)
            ** Invoke environment (first_time)
            ** Execute environment
            rake aborted!
            Mysql::Error: Table 'myproject_development.users' doesn't exist: SHOW FIELDS FROM `users`
            /Users/me/.gem/ruby/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapters/abstract_adapter.rb:219:in `log'
            /Users/me/.gem/ruby/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapters/mysql_adapter.rb:323:in `execute'
            /Users/me/.gem/ruby/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapters/mysql_adapter.rb:469:in `columns'
            /Users/me/.gem/ruby/1.8/gems/activerecord-2.3.5/lib/active_record/base.rb:1271:in `columns'
            /Users/me/.gem/ruby/1.8/gems/activerecord-2.3.5/lib/active_record/base.rb:1284:in `column_names'
            /opt/local/lib/ruby/gems/1.8/gems/searchlogic-2.5.4/lib/searchlogic/named_scopes/ordering.rb:33:in `ordering_condition_details'
            /opt/local/lib/ruby/gems/1.8/gems/searchlogic-2.5.4/lib/searchlogic/named_scopes/ordering.rb:25:in `create_condition'
            /opt/local/lib/ruby/gems/1.8/gems/searchlogic-2.5.4/lib/searchlogic/named_scopes/or_conditions.rb:28:in `create_condition'
            /opt/local/lib/ruby/gems/1.8/gems/searchlogic-2.5.4/lib/searchlogic/named_scopes/column_conditions.rb:63:in `respond_to?'
            /Users/me/.gem/ruby/1.8/gems/activerecord-2.3.5/lib/active_record/base.rb:1481:in `respond_to?'
            /Users/me/.gem/ruby/1.8/gems/activerecord-2.3.5/lib/active_record/observer.rb:183:in `flatten'
            /Users/me/.gem/ruby/1.8/gems/activerecord-2.3.5/lib/active_record/observer.rb:183:in `observed_classes'
            /Users/me/.gem/ruby/1.8/gems/activerecord-2.3.5/lib/active_record/observer.rb:166:in `initialize'
            /opt/local/lib/ruby/1.8/singleton.rb:94:in `new'
            /opt/local/lib/ruby/1.8/singleton.rb:94:in `instance'
            /Users/me/.gem/ruby/1.8/gems/activerecord-2.3.5/lib/active_record/observer.rb:38:in `instantiate_observers'
            /Users/me/.gem/ruby/1.8/gems/activerecord-2.3.5/lib/active_record/observer.rb:36:in `each'
            /Users/me/.gem/ruby/1.8/gems/activerecord-2.3.5/lib/active_record/observer.rb:36:in `instantiate_observers'
            /Users/me/.gem/ruby/1.8/gems/actionpack-2.3.5/lib/action_controller/dispatcher.rb:15:in `define_dispatcher_callbacks'
            /Users/me/.gem/ruby/1.8/gems/activesupport-2.3.5/lib/active_support/callbacks.rb:182:in `call'
            /Users/me/.gem/ruby/1.8/gems/activesupport-2.3.5/lib/active_support/callbacks.rb:182:in `evaluate_method'
            /Users/me/.gem/ruby/1.8/gems/activesupport-2.3.5/lib/active_support/callbacks.rb:166:in `call'
            /Users/me/.gem/ruby/1.8/gems/activesupport-2.3.5/lib/active_support/callbacks.rb:90:in `run'
            /Users/me/.gem/ruby/1.8/gems/activesupport-2.3.5/lib/active_support/callbacks.rb:90:in `each'
            /Users/me/.gem/ruby/1.8/gems/activesupport-2.3.5/lib/active_support/callbacks.rb:90:in `send'
            /Users/me/.gem/ruby/1.8/gems/activesupport-2.3.5/lib/active_support/callbacks.rb:90:in `run'
            /Users/me/.gem/ruby/1.8/gems/activesupport-2.3.5/lib/active_support/callbacks.rb:276:in `run_callbacks'
            /Users/me/.gem/ruby/1.8/gems/actionpack-2.3.5/lib/action_controller/dispatcher.rb:51:in `send'
            /Users/me/.gem/ruby/1.8/gems/actionpack-2.3.5/lib/action_controller/dispatcher.rb:51:in `run_prepare_callbacks'
            /Users/me/.gem/ruby/1.8/gems/rails-2.3.5/lib/initializer.rb:631:in `prepare_dispatcher'
            /Users/me/.gem/ruby/1.8/gems/rails-2.3.5/lib/initializer.rb:185:in `process'
            /Users/me/.gem/ruby/1.8/gems/rails-2.3.5/lib/initializer.rb:113:in `send'
            /Users/me/.gem/ruby/1.8/gems/rails-2.3.5/lib/initializer.rb:113:in `run'
            /Users/me/work/myproject/config/environment.rb:14
            /opt/local/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
            /opt/local/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb:31:in `require'
            /Users/me/.gem/ruby/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:156:in `require'
            /Users/me/.gem/ruby/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:521:in `new_constants_in'
            /Users/me/.gem/ruby/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:156:in `require'
            /Users/me/.gem/ruby/1.8/gems/rails-2.3.5/lib/tasks/misc.rake:4
            /opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in `call'
            /opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in `execute'
            /opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in `each'
            /opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in `execute'
            /opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:597:in `invoke_with_call_chain'
            /opt/local/lib/ruby/1.8/monitor.rb:242:in `synchronize'
            /opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:590:in `invoke_with_call_chain'
            /opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:607:in `invoke_prerequisites'
            /opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:604:in `each'
            /opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:604:in `invoke_prerequisites'
            /opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:596:in `invoke_with_call_chain'
            /opt/local/lib/ruby/1.8/monitor.rb:242:in `synchronize'
            /opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:590:in `invoke_with_call_chain'
            /opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:583:in `invoke'
            /opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2051:in `invoke_task'
            /opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `top_level'
            /opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `each'
            /opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `top_level'
            /opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling'
            /opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2023:in `top_level'
            /opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2001:in `run'
            /opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling'
            /opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:1998:in `run'
            /opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/bin/rake:31
            /opt/local/bin/rake:19:in `load'
            /opt/local/bin/rake:19

Ответы [ 2 ]

0 голосов
/ 15 марта 2011

Ваше приложение не может найти таблицу mysql.

В основном это означает несколько вещей:

  1. Вы подключаетесь к правильной базе данных?
  2. Ваша база данных обновлена?
  3. У вас есть правильные учетные данные для доступа к БД?
  4. У вас есть правильный драгоценный камень?
  5. Поскольку это mysql, вы подключаетесь к правильному сокету?

проверьте все это, и вы, вероятно, узнаете, что не так с вашим БД. Некоторые дополнительные указатели:

  1. Вы уверены, что ваши миграции правильные и в порядке? (Вы не выбираете из таблицы, которая еще не создана, не так ли?)
0 голосов
/ 15 марта 2011

Вы сделали rake db:create:all?

...