0
allo。當我嘗試我得到這個錯誤「的Heroku運行耙分貝:遷移」:ActiveRecord :: StatementInvalid:PG :: UndefinedTable:錯誤:關係「options」不存在
rake aborted!
ActiveRecord::StatementInvalid: PG::UndefinedTable: ERROR: relation "options" does not exist
LINE 5: WHERE a.attrelid = '"options"'::regclass
^
: SELECT a.attname, format_type(a.atttypid, a.atttypmod),
pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod
FROM pg_attribute a LEFT JOIN pg_attrdef d
ON a.attrelid = d.adrelid AND a.attnum = d.adnum
WHERE a.attrelid = '"options"'::regclass
AND a.attnum > 0 AND NOT a.attisdropped
ORDER BY a.attnum
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.0.0/lib/active_record/connection_adapters/postgresql_adapter.rb:768:in `async_exec'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.0.0/lib/active_record/connection_adapters/postgresql_adapter.rb:768:in `exec_no_cache'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.0.0/lib/active_record/connection_adapters/postgresql/database_statements.rb:138:in `block in exec_query'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.0.0/lib/active_record/connection_adapters/abstract_adapter.rb:425:in `block in log'
/app/vendor/bundle/ruby/2.2.0/gems/activesupport-4.0.0/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.0.0/lib/active_record/connection_adapters/abstract_adapter.rb:420:in `log'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.0.0/lib/active_record/connection_adapters/postgresql/database_statements.rb:137:in `exec_query'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.0.0/lib/active_record/connection_adapters/postgresql_adapter.rb:915:in `column_definitions'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.0.0/lib/active_record/connection_adapters/postgresql/schema_statements.rb:174:in `columns'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.0.0/lib/active_record/connection_adapters/schema_cache.rb:114:in `block in prepare_default_proc'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.0.0/lib/active_record/connection_adapters/schema_cache.rb:56:in `yield'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.0.0/lib/active_record/connection_adapters/schema_cache.rb:56:in `columns'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.0.0/lib/active_record/model_schema.rb:208:in `columns'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.0.0/lib/active_record/model_schema.rb:217:in `columns_hash'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.0.0/lib/active_record/dynamic_matchers.rb:60:in `block in valid?'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.0.0/lib/active_record/dynamic_matchers.rb:60:in `each'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.0.0/lib/active_record/dynamic_matchers.rb:60:in `all?'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.0.0/lib/active_record/dynamic_matchers.rb:60:in `valid?'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.0.0/lib/active_record/dynamic_matchers.rb:18:in `method_missing'
/app/app/models/option.rb:4:in `get_config_value'
/app/app/models/achat.rb:17:in `<class:Achat>'
/app/app/models/achat.rb:1:in `<top (required)>'
/app/vendor/bundle/ruby/2.2.0/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:228:in `require'
/app/vendor/bundle/ruby/2.2.0/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:228:in `block in require'
/app/vendor/bundle/ruby/2.2.0/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:213:in `load_dependency'
/app/vendor/bundle/ruby/2.2.0/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:228:in `require'
/app/vendor/bundle/ruby/2.2.0/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:329:in `require_or_load'
/app/vendor/bundle/ruby/2.2.0/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:288:in `depend_on'
/app/vendor/bundle/ruby/2.2.0/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:206:in `require_dependency'
/app/vendor/bundle/ruby/2.2.0/gems/railties-4.0.0/lib/rails/engine.rb:465:in `block (2 levels) in eager_load!'
/app/vendor/bundle/ruby/2.2.0/gems/railties-4.0.0/lib/rails/engine.rb:464:in `each'
/app/vendor/bundle/ruby/2.2.0/gems/railties-4.0.0/lib/rails/engine.rb:464:in `block in eager_load!'
/app/vendor/bundle/ruby/2.2.0/gems/railties-4.0.0/lib/rails/engine.rb:462:in `each'
/app/vendor/bundle/ruby/2.2.0/gems/railties-4.0.0/lib/rails/engine.rb:462:in `eager_load!'
/app/vendor/bundle/ruby/2.2.0/gems/railties-4.0.0/lib/rails/engine.rb:347:in `eager_load!'
/app/vendor/bundle/ruby/2.2.0/gems/railties-4.0.0/lib/rails/application/finisher.rb:56:in `each'
/app/vendor/bundle/ruby/2.2.0/gems/railties-4.0.0/lib/rails/application/finisher.rb:56:in `block in <module:Finisher>'
/app/vendor/bundle/ruby/2.2.0/gems/railties-4.0.0/lib/rails/initializable.rb:30:in `instance_exec'
/app/vendor/bundle/ruby/2.2.0/gems/railties-4.0.0/lib/rails/initializable.rb:30:in `run'
/app/vendor/bundle/ruby/2.2.0/gems/railties-4.0.0/lib/rails/initializable.rb:55:in `block in run_initializers'
/app/vendor/bundle/ruby/2.2.0/gems/railties-4.0.0/lib/rails/initializable.rb:54:in `run_initializers'
/app/vendor/bundle/ruby/2.2.0/gems/railties-4.0.0/lib/rails/application.rb:215:in `initialize!'
/app/vendor/bundle/ruby/2.2.0/gems/railties-4.0.0/lib/rails/railtie/configurable.rb:30:in `method_missing'
/app/config/environment.rb:5:in `<top (required)>'
/app/vendor/bundle/ruby/2.2.0/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:228:in `require'
/app/vendor/bundle/ruby/2.2.0/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:228:in `block in require'
/app/vendor/bundle/ruby/2.2.0/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:213:in `load_dependency'
/app/vendor/bundle/ruby/2.2.0/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:228:in `require'
/app/vendor/bundle/ruby/2.2.0/gems/railties-4.0.0/lib/rails/application.rb:189:in `require_environment!'
/app/vendor/bundle/ruby/2.2.0/gems/railties-4.0.0/lib/rails/application.rb:249:in `block in run_tasks_blocks'
/app/vendor/bundle/ruby/2.2.0/gems/rake-11.3.0/exe/rake:27:in `<top (required)>'
PG::UndefinedTable: ERROR: relation "options" does not exist
LINE 5: WHERE a.attrelid = '"options"'::regclass
^
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.0.0/lib/active_record/connection_adapters/postgresql_adapter.rb:768:in `async_exec'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.0.0/lib/active_record/connection_adapters/postgresql_adapter.rb:768:in `exec_no_cache'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.0.0/lib/active_record/connection_adapters/postgresql/database_statements.rb:138:in `block in exec_query'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.0.0/lib/active_record/connection_adapters/abstract_adapter.rb:425:in `block in log'
/app/vendor/bundle/ruby/2.2.0/gems/activesupport-4.0.0/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.0.0/lib/active_record/connection_adapters/abstract_adapter.rb:420:in `log'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.0.0/lib/active_record/connection_adapters/postgresql/database_statements.rb:137:in `exec_query'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.0.0/lib/active_record/connection_adapters/postgresql_adapter.rb:915:in `column_definitions'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.0.0/lib/active_record/connection_adapters/postgresql/schema_statements.rb:174:in `columns'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.0.0/lib/active_record/connection_adapters/schema_cache.rb:114:in `block in prepare_default_proc'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.0.0/lib/active_record/connection_adapters/schema_cache.rb:56:in `yield'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.0.0/lib/active_record/connection_adapters/schema_cache.rb:56:in `columns'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.0.0/lib/active_record/model_schema.rb:208:in `columns'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.0.0/lib/active_record/model_schema.rb:217:in `columns_hash'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.0.0/lib/active_record/dynamic_matchers.rb:60:in `block in valid?'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.0.0/lib/active_record/dynamic_matchers.rb:60:in `each'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.0.0/lib/active_record/dynamic_matchers.rb:60:in `all?'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.0.0/lib/active_record/dynamic_matchers.rb:60:in `valid?'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.0.0/lib/active_record/dynamic_matchers.rb:18:in `method_missing'
/app/app/models/option.rb:4:in `get_config_value'
/app/app/models/achat.rb:17:in `<class:Achat>'
/app/app/models/achat.rb:1:in `<top (required)>'
/app/vendor/bundle/ruby/2.2.0/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:228:in `require'
/app/vendor/bundle/ruby/2.2.0/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:228:in `block in require'
/app/vendor/bundle/ruby/2.2.0/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:213:in `load_dependency'
/app/vendor/bundle/ruby/2.2.0/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:228:in `require'
/app/vendor/bundle/ruby/2.2.0/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:329:in `require_or_load'
/app/vendor/bundle/ruby/2.2.0/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:288:in `depend_on'
/app/vendor/bundle/ruby/2.2.0/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:206:in `require_dependency'
/app/vendor/bundle/ruby/2.2.0/gems/railties-4.0.0/lib/rails/engine.rb:465:in `block (2 levels) in eager_load!'
/app/vendor/bundle/ruby/2.2.0/gems/railties-4.0.0/lib/rails/engine.rb:464:in `each'
/app/vendor/bundle/ruby/2.2.0/gems/railties-4.0.0/lib/rails/engine.rb:464:in `block in eager_load!'
/app/vendor/bundle/ruby/2.2.0/gems/railties-4.0.0/lib/rails/engine.rb:462:in `each'
/app/vendor/bundle/ruby/2.2.0/gems/railties-4.0.0/lib/rails/engine.rb:462:in `eager_load!'
/app/vendor/bundle/ruby/2.2.0/gems/railties-4.0.0/lib/rails/engine.rb:347:in `eager_load!'
/app/vendor/bundle/ruby/2.2.0/gems/railties-4.0.0/lib/rails/application/finisher.rb:56:in `each'
/app/vendor/bundle/ruby/2.2.0/gems/railties-4.0.0/lib/rails/application/finisher.rb:56:in `block in <module:Finisher>'
/app/vendor/bundle/ruby/2.2.0/gems/railties-4.0.0/lib/rails/initializable.rb:30:in `instance_exec'
/app/vendor/bundle/ruby/2.2.0/gems/railties-4.0.0/lib/rails/initializable.rb:30:in `run'
/app/vendor/bundle/ruby/2.2.0/gems/railties-4.0.0/lib/rails/initializable.rb:55:in `block in run_initializers'
/app/vendor/bundle/ruby/2.2.0/gems/railties-4.0.0/lib/rails/initializable.rb:54:in `run_initializers'
/app/vendor/bundle/ruby/2.2.0/gems/railties-4.0.0/lib/rails/application.rb:215:in `initialize!'
/app/vendor/bundle/ruby/2.2.0/gems/railties-4.0.0/lib/rails/railtie/configurable.rb:30:in `method_missing'
/app/config/environment.rb:5:in `<top (required)>'
/app/vendor/bundle/ruby/2.2.0/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:228:in `require'
/app/vendor/bundle/ruby/2.2.0/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:228:in `block in require'
/app/vendor/bundle/ruby/2.2.0/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:213:in `load_dependency'
/app/vendor/bundle/ruby/2.2.0/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:228:in `require'
/app/vendor/bundle/ruby/2.2.0/gems/railties-4.0.0/lib/rails/application.rb:189:in `require_environment!'
/app/vendor/bundle/ruby/2.2.0/gems/railties-4.0.0/lib/rails/application.rb:249:in `block in run_tasks_blocks'
/app/vendor/bundle/ruby/2.2.0/gems/rake-11.3.0/exe/rake:27:in `<top (required)>'
Tasks: TOP => db:migrate => environment
(See full trace by running task with --trace)
'
但是當我運行「耙分貝:遷移」我的電腦上運行良好。任何人都可以幫助我。我與導軌4.0.0,2.2.3紅寶石,Postgres的SGBD工作,我在linuxmint 17
我的移民:
class CreateOptions < ActiveRecord::Migration
def change
create_table :options do |t|
t.string :config_key
t.string :config_value
t.timestamps
end
end
end
我的模型:
class Option < ActiveRecord::Base
class << self
def get_config_value(key)
c = find_by_config_key(key)
c.nil? ? nil : c.config_value
end
def set_config_values(values_hash)
values_hash.each_pair { |key, value| set_value(key.to_s.camelize, value) }
end
def set_value(key, value)
config = find_by_config_key(key)
config.nil? ?
Option.create(:config_key => key, :config_value => value) :
config.update_attribute(:config_value, value)
end
def get_multiple_configs_as_hash(keys)
conf_hash = {}
keys.each { |k| conf_hash[k.underscore.to_sym] = get_config_value(k) }
conf_hash
end
end
end
你有一個名爲「選項」的數據庫表?你可以連接到你的PG實例,以驗證?如果是這樣,你的Rails應用中是否有名爲「options」的模型? –
您可以添加引發錯誤的遷移代碼嗎? –
您有'class Option