こんにちは、
データベースをバックアップして実行するのに深刻な問題があります。今週初めにテーブルを削除し (再構築したい)、あらゆる種類の問題を抱えています。
私は次のことをしました:
rake db:drop:all
rake db:create:all
rake db:migrate
次のエラーが表示されます (完全なスタック トレースが一番下に表示されます)。
PG::Error: ERROR: relation "users" does not exist
LINE 4: WHERE a.attrelid = '"users"'::regclass
^
: SELECT a.attname, format_type(a.atttypid, a.atttypmod), d.adsrc, a.attnotnull
FROM pg_attribute a LEFT JOIN pg_attrdef d
ON a.attrelid = d.adrelid AND a.attnum = d.adnum
WHERE a.attrelid = '"users"'::regclass
AND a.attnum > 0 AND NOT a.attisdropped
ORDER BY a.attnum
ここで問題になるのは Authlogic です。このエラー (実際のエラー) が表示された唯一の理由は、authlogic エラーを隠したためです。
You must establish a database connection before using acts_as_authentic
この投稿で提案されているように:スタック オーバーフロー スレッド
ユーザーの移行:
class CreateUsers < ActiveRecord::Migration
def change
create_table :users do |t|
t.string :name, :null => false
t.string :email, :null => false
t.string :plan, :default => "basic"
t.boolean :verified, :default => false
t.boolean :admin, :default => false
t.integer :selected_portfolio_id
t.datetime :last_email_at
t.hstore :data
t.string :crypted_password, :null => false
t.string :password_salt, :null => false
t.string :persistence_token, :null => false
t.string :perishable_token, :null => false
# magic fields (all optional, see Authlogic::Session::MagicColumns)
t.integer :login_count, :null => false, :default => 0
t.integer :failed_login_count, :null => false, :default => 0
t.datetime :last_request_at
t.datetime :current_login_at
t.datetime :last_login_at
t.string :current_login_ip
t.string :last_login_ip
# optional, see Authlogic::Session::Params
#t.string :single_access_token, :null => false
t.timestamps
end
add_index :users, ["email"], :name => "index_users_on_email", :unique => true
add_index :users, ["persistence_token"], :name => "index_users_on_persistence_token", :unique => true
end
end
authlogic がデータベースの移行時に負荷をかけようとするのはなぜですか? これが問題だと思います....完全なスタックトレース:
/Users/brandon/.rvm/gems/ruby-1.9.3-p194@myapp/gems/activerecord-3.2. 6/lib/active_record/connection_adapters/postgresql_adapter.rb:1151:in `async_exec'
/Users/brandon/.rvm/gems/ruby-1.9.3-p194@myapp/gems/activerecord-3.2. 6/lib/active_record/connection_adapters/postgresql_adapter.rb:1151:in `exec_no_cache'
/Users/brandon/.rvm/gems/ruby-1.9.3-p194@myapp/gems/activerecord-3.2. 6/lib/active_record/connection_adapters/postgresql_adapter.rb:664:in `block in exec_query'
/Users/brandon/.rvm/gems/ruby-1.9.3-p194@myapp/gems/activerecord-3.2. 6/lib/active_record/connection_adapters/abstract_adapter.rb:280:in `block in log'
/Users/brandon/.rvm/gems/ruby-1.9.3-p194@myapp/gems/activesupport-3.2.6/lib/active_support/notifications/instrumenter. rb:20:in `instrument'
/Users/brandon/.rvm/gems/ruby-1.9.3-p194@myapp/gems/activerecord-3.2. 6/lib/active_record/connection_adapters/abstract_adapter.rb:275:in `log'
/Users/brandon/.rvm/gems/ruby-1.9.3-p194@myapp/gems/activerecord-3.2. 6/lib/active_record/connection_adapters/postgresql_adapter.rb:663:in `exec_query'
/Users/brandon/.rvm/gems/ruby-1.9.3-p194@myapp/gems/activerecord-3.2. 6/lib/active_record/connection_adapters/postgresql_adapter.rb:1276:in `column_definitions'
/Users/brandon/.rvm/gems/ruby-1.9.3-p194@myapp/gems/activerecord-3.2. 6/lib/active_record/connection_adapters/postgresql_adapter.rb:859:in `columns'
/Users/brandon/.rvm/gems/ruby-1.9.3-p194@myapp/gems/activerecord-3.2. 6/lib/active_record/connection_adapters/schema_cache.rb:12:in `block in initialize'
/Users/brandon/.rvm/gems/ruby-1.9.3-p194@myapp/gems/activerecord-3.2.6/lib/active_record/model_schema.rb:228:in `yield'
/Users/brandon/.rvm/gems/ruby-1.9.3-p194@myapp/gems/activerecord-3.2.6/lib/active_record/model_schema.rb:228:in `default'
/Users/brandon/.rvm/gems/ruby-1.9.3-p194@myapp/gems/activerecord-3.2.6/lib/active_record/model_schema.rb:228:in `columns'
/Users/brandon/.rvm/gems/ruby-1.9.3-p194@myapp/gems/activerecord-3.2.6/lib/active_record/model_schema.rb:248:in `column_names'
/Users/brandon/Documents/authlogic/lib/authlogic/acts_as_authentic/base.rb:67:in `db_setup?'
/Users/brandon/Documents/authlogic/lib/authlogic/acts_as_authentic/base.rb:31:in `acts_as_authentic'
/Users/brandon/Dropbox/code/myapp/app/models/user_related/user.rb:14:in `<class:User>'
/Users/brandon/Dropbox/code/myapp/app/models/user_related/user.rb:1:in `<top (required)>'
/Users/brandon/.rvm/gems/ruby-1.9.3-p194@myapp/gems/activesupport-3.2.6/lib/active_support/dependencies.rb:469:in `load'
/Users/brandon/.rvm/gems/ruby-1.9.3-p194@myapp/gems/activesupport-3.2.6/lib/active_support/dependencies.rb:469:in `block in load_file'
/Users/brandon/.rvm/gems/ruby-1.9.3-p194@myapp/gems/activesupport-3.2.6/lib/active_support/dependencies.rb:639:in `new_constants_in'
/Users/brandon/.rvm/gems/ruby-1.9.3-p194@myapp/gems/activesupport-3.2.6/lib/active_support/dependencies.rb:468:in `load_file'
/Users/brandon/.rvm/gems/ruby-1.9.3-p194@myapp/gems/activesupport-3.2.6/lib/active_support/dependencies.rb:353:in `require_or_load'
/Users/brandon/.rvm/gems/ruby-1.9.3-p194@myapp/gems/activesupport-3.2.6/lib/active_support/dependencies.rb:502:in `load_missing_constant'
/Users/brandon/.rvm/gems/ruby-1.9.3-p194@myapp/gems/activesupport-3.2.6/lib/active_support/dependencies.rb:192:in `block in const_missing'
/Users/brandon/.rvm/gems/ruby-1.9.3-p194@myapp/gems/activesupport-3.2.6/lib/active_support/dependencies.rb:190:in `each'
/Users/brandon/.rvm/gems/ruby-1.9.3-p194@myapp/gems/activesupport-3.2.6/lib/active_support/dependencies.rb:190:in `const_missing'
/Users/brandon/.rvm/gems/ruby-1.9.3-p194@myapp/gems/activesupport-3.2.6/lib/active_support/inflector/methods.rb:229:in `block in constantize'
/Users/brandon/.rvm/gems/ruby-1.9.3-p194@myapp/gems/activesupport-3.2.6/lib/active_support/inflector/methods.rb:228:in `each'
/Users/brandon/.rvm/gems/ruby-1.9.3-p194@myapp/gems/activesupport-3.2.6/lib/active_support/inflector/methods.rb:228:in `constantize'
/Users/brandon/.rvm/gems/ruby-1.9.3-p194@myapp/gems/activesupport-3.2.6/lib/active_support/core_ext/string/inflections. rb:54:in `constantize'
/Users/brandon/.rvm/gems/ruby-1.9.3-p194@myapp/gems/activemodel-3.2.6/lib/active_model/observing.rb:189:in `block in observe'
/Users/brandon/.rvm/gems/ruby-1.9.3-p194@myapp/gems/activemodel-3.2.6/lib/active_model/observing.rb:189:in `collect!'
/Users/brandon/.rvm/gems/ruby-1.9.3-p194@myapp/gems/activemodel-3.2.6/lib/active_model/observing.rb:189:in `observe'
/Users/brandon/Dropbox/code/myapp/app/models/user_related/user_observer.rb:2:in `<class:UserObserver>'
/Users/brandon/Dropbox/code/myapp/app/models/user_related/user_observer.rb:1:in `<top (required)>'
/Users/brandon/.rvm/gems/ruby-1.9.3-p194@myapp/gems/activesupport-3.2.6/lib/active_support/dependencies.rb:469:in `load'
/Users/brandon/.rvm/gems/ruby-1.9.3-p194@myapp/gems/activesupport-3.2.6/lib/active_support/dependencies.rb:469:in `block in load_file'
/Users/brandon/.rvm/gems/ruby-1.9.3-p194@myapp/gems/activesupport-3.2.6/lib/active_support/dependencies.rb:639:in `new_constants_in'
/Users/brandon/.rvm/gems/ruby-1.9.3-p194@myapp/gems/activesupport-3.2.6/lib/active_support/dependencies.rb:468:in `load_file'
/Users/brandon/.rvm/gems/ruby-1.9.3-p194@myapp/gems/activesupport-3.2.6/lib/active_support/dependencies.rb:353:in `require_or_load'
/Users/brandon/.rvm/gems/ruby-1.9.3-p194@myapp/gems/activesupport-3.2.6/lib/active_support/dependencies.rb:502:in `load_missing_constant'
/Users/brandon/.rvm/gems/ruby-1.9.3-p194@myapp/gems/activesupport-3.2.6/lib/active_support/dependencies.rb:192:in `block in const_missing'
/Users/brandon/.rvm/gems/ruby-1.9.3-p194@myapp/gems/activesupport-3.2.6/lib/active_support/dependencies.rb:190:in `each'
/Users/brandon/.rvm/gems/ruby-1.9.3-p194@myapp/gems/activesupport-3.2.6/lib/active_support/dependencies.rb:190:in `const_missing'
/Users/brandon/.rvm/gems/ruby-1.9.3-p194@myapp/gems/activesupport-3.2.6/lib/active_support/inflector/methods.rb:229:in `block in constantize'
/Users/brandon/.rvm/gems/ruby-1.9.3-p194@myapp/gems/activesupport-3.2.6/lib/active_support/inflector/methods.rb:228:in `each'
/Users/brandon/.rvm/gems/ruby-1.9.3-p194@myapp/gems/activesupport-3.2.6/lib/active_support/inflector/methods.rb:228:in `constantize'
/Users/brandon/.rvm/gems/ruby-1.9.3-p194@myapp/gems/activesupport-3.2.6/lib/active_support/core_ext/string/inflections. rb:54:in `constantize'
/Users/brandon/.rvm/gems/ruby-1.9.3-p194@myapp/gems/activemodel-3.2.6/lib/active_model/observing.rb:86:in `instantiate_observer'
/Users/brandon/.rvm/gems/ruby-1.9.3-p194@myapp/gems/activemodel-3.2.6/lib/active_model/observing.rb:59:in `block in instantiate_observers'
/Users/brandon/.rvm/gems/ruby-1.9.3-p194@myapp/gems/activemodel-3.2.6/lib/active_model/observing.rb:59:in `each'
/Users/brandon/.rvm/gems/ruby-1.9.3-p194@myapp/gems/activemodel-3.2.6/lib/active_model/observing.rb:59:in `instantiate_observers'
/Users/brandon/.rvm/gems/ruby-1.9.3-p194@myapp/gems/activerecord-3.2.6/lib/active_record/railtie.rb:117:in `block (2 levels) in <class:Railtie>'
/Users/brandon/.rvm/gems/ruby-1.9.3-p194@myapp/gems/activesupport-3.2.6/lib/active_support/lazy_load_hooks.rb:36:in `instance_eval'
/Users/brandon/.rvm/gems/ruby-1.9.3-p194@myapp/gems/activesupport-3.2.6/lib/active_support/lazy_load_hooks.rb:36:in `execute_hook'
/Users/brandon/.rvm/gems/ruby-1.9.3-p194@myapp/gems/activesupport-3.2.6/lib/active_support/lazy_load_hooks.rb:26:in `block in on_load'
/Users/brandon/.rvm/gems/ruby-1.9.3-p194@myapp/gems/activesupport-3.2.6/lib/active_support/lazy_load_hooks.rb:25:in `each'
/Users/brandon/.rvm/gems/ruby-1.9.3-p194@myapp/gems/activesupport-3.2.6/lib/active_support/lazy_load_hooks.rb:25:in `on_load'
/Users/brandon/.rvm/gems/ruby-1.9.3-p194@myapp/gems/activerecord-3.2.6/lib/active_record/railtie.rb:116:in `block in < class:Railtie>'
/Users/brandon/.rvm/gems/ruby-1.9.3-p194@myapp/gems/activesupport-3.2.6/lib/active_support/lazy_load_hooks.rb:34:in `call'
/Users/brandon/.rvm/gems/ruby-1.9.3-p194@myapp/gems/activesupport-3.2.6/lib/active_support/lazy_load_hooks.rb:34:in `execute_hook'
/Users/brandon/.rvm/gems/ruby-1.9.3-p194@myapp/gems/activesupport-3.2.6/lib/active_support/lazy_load_hooks.rb:43:in `block in run_load_hooks'
/Users/brandon/.rvm/gems/ruby-1.9.3-p194@myapp/gems/activesupport-3.2.6/lib/active_support/lazy_load_hooks.rb:42:in `each'
/Users/brandon/.rvm/gems/ruby-1.9.3-p194@myapp/gems/activesupport-3.2.6/lib/active_support/lazy_load_hooks.rb:42:in `run_load_hooks'
/Users/brandon/.rvm/gems/ruby-1.9.3-p194@myapp/gems/railties-3.2.6/lib/rails/application/finisher.rb:59:in `block in < module:Finisher>'
/Users/brandon/.rvm/gems/ruby-1.9.3-p194@myapp/gems/railties-3.2.6/lib/rails/initializable.rb:30:in `instance_exec'
/Users/brandon/.rvm/gems/ruby-1.9.3-p194@myapp/gems/railties-3.2.6/lib/rails/initializable.rb:30:in `run'
/Users/brandon/.rvm/gems/ruby-1.9.3-p194@myapp/gems/railties-3.2.6/lib/rails/initializable.rb:55:in `block in run_initializers'
/Users/brandon/.rvm/gems/ruby-1.9.3-p194@myapp/gems/railties-3.2.6/lib/rails/initializable.rb:54:in `each'
/Users/brandon/.rvm/gems/ruby-1.9.3-p194@myapp/gems/railties-3.2.6/lib/rails/initializable.rb:54:in `run_initializers'
/Users/brandon/.rvm/gems/ruby-1.9.3-p194@myapp/gems/railties-3.2.6/lib/rails/application.rb:136:in `initialize!'
/Users/brandon/.rvm/gems/ruby-1.9.3-p194@myapp/gems/railties-3.2.6/lib/rails/railtie/configurable.rb:30:in `method_missing'
/Users/brandon/Dropbox/code/myapp/config/environment.rb:5:in `<top (required)>'
/Users/brandon/.rvm/gems/ruby-1.9.3-p194@myapp/gems/activesupport-3.2.6/lib/active_support/dependencies.rb:251:in `require'
/Users/brandon/.rvm/gems/ruby-1.9.3-p194@myapp/gems/activesupport-3.2.6/lib/active_support/dependencies.rb:251:in `block in require'
/Users/brandon/.rvm/gems/ruby-1.9.3-p194@myapp/gems/activesupport-3.2.6/lib/active_support/dependencies.rb:236:in `load_dependency'
/Users/brandon/.rvm/gems/ruby-1.9.3-p194@myapp/gems/activesupport-3.2.6/lib/active_support/dependencies.rb:251:in `require'
/Users/brandon/.rvm/gems/ruby-1.9.3-p194@myapp/gems/railties-3.2.6/lib/rails/application.rb:103:in `require_environment!'
/Users/brandon/.rvm/gems/ruby-1.9.3-p194@myapp/gems/railties-3.2.6/lib/rails/application.rb:292:in `block (2 levels) in initialize_tasks'
/Users/brandon/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `call'
/Users/brandon/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `block in execute'
/Users/brandon/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `each'
/Users/brandon/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `execute'
/Users/brandon/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/task.rb:158:in `block in invoke_with_call_chain'
/Users/brandon/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
/Users/brandon/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/task.rb:151:in `invoke_with_call_chain'
/Users/brandon/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/task.rb:176:in `block in invoke_prerequisites'
/Users/brandon/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/task.rb:174:in `each'
/Users/brandon/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/task.rb:174:in `invoke_prerequisites'
/Users/brandon/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/task.rb:157:in `block in invoke_with_call_chain'
/Users/brandon/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
/Users/brandon/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/task.rb:151:in `invoke_with_call_chain'
/Users/brandon/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/task.rb:144:in `invoke'
/Users/brandon/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/application.rb:116:in `invoke_task'
/Users/brandon/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `block (2 levels) in top_level'
/Users/brandon/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `each'
/Users/brandon/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `block in top_level'
/Users/brandon/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/Users/brandon/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/application.rb:88:in `top_level'
/Users/brandon/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/application.rb:66:in `block in run'
/Users/brandon/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/Users/brandon/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/application.rb:63:in `run'
/Users/brandon/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/bin/rake:33:in `<top (required)>'
/Users/brandon/.rvm/gems/ruby-1.9.3-p194@global/bin/rake:19:in `load'
/Users/brandon/.rvm/gems/ruby-1.9.3-p194@global/bin/rake:19:in `<main>'
Tasks: TOP => db:migrate => environment
更新 1
「本物として機能する」をコメントアウトし、データベースを移行してから再適用することで、この問題を解決できました。絆創膏ですが、正しくないようです。どうすればこれを適切に修正できますか?