我一直在研究一个小但有点复杂的 Rails 应用程序,它有多个 has_and_belongs_to_many 关系。它是开源的,代码在这里。一切正常,但最近我添加了一个新的 HABTM 关系迁移,并且 rspec 测试开始失败。Rake:db:migrate 正在工作(并且问题在本地工作),只是不在测试中。运行 db:test:load --trace 时,出现以下错误:
:fermi og$ rake db:test:load --trace /Users/og/.rvm/rubies/ruby-1.9.3-head/lib/ruby/1.9.1/yaml.rb:56:in
<top (required)>': It seems your ruby installation is missing psych (for YAML output). To eliminate this warning, please install libyaml and reinstall your ruby. ** Invoke db:test:load (first_time) ** Invoke db:test:purge (first_time) ** Invoke environment (first_time) ** Execute environment ** Invoke db:load_config (first_time) ** Execute db:load_config ** Execute db:test:purge ** Execute db:test:load ** Invoke db:test:load_schema (first_time) ** Invoke db:test:purge ** Execute db:test:load_schema ** Invoke db:schema:load (first_time) ** Invoke environment ** Invoke db:load_config ** Execute db:schema:load rake aborted! SQLite3::SQLException: object name reserved for internal use: sqlite_sp_functions: CREATE TABLE "sqlite_sp_functions" ("name" text, "text" text) /Users/og/.rvm/gems/ruby-1.9.3-head/gems/sqlite3-1.3.7/lib/sqlite3/database.rb:91:in
initialize' /Users /og/.rvm/gems/ruby-1.9.3-head/gems/sqlite3-1.3.7/lib/sqlite3/database.rb:91:innew' /Users/og/.rvm/gems/ruby-1.9.3-head/gems/sqlite3-1.3.7/lib/sqlite3/database.rb:91:in
prepare' /Users/og/.rvm/gems/ruby-1.9 .3-head/gems/sqlite3-1.3.7/lib/sqlite3/database.rb:134:inexecute' /Users/og/.rvm/gems/ruby-1.9.3-head/gems/activerecord-3.2.9/lib/active_record/connection_adapters/sqlite_adapter.rb:278:in
block in execute' /Users/og/.rvm/gems/ruby-1.9.3-head/gems/activerecord- 3.2.9/lib/active_record/connection_adapters/abstract_adapter.rb:280:inblock in log' /Users/og/.rvm/gems/ruby-1.9.3-head/gems/activesupport-3.2.9/lib/active_support/notifications/instrumenter.rb:20:in
仪器'/Users/og/.rvm/gems/ruby-1.9.3-head/gems/activerecord-3.2.9/lib/active_record/connection_adapters /abstract_adapter.rb:275log' /Users/og/.rvm/gems/ruby-1.9.3-head/gems/activerecord-3.2.9/lib/active_record/connection_adapters/sqlite_adapter.rb:278:in
:在执行'/Users/og/.rvm/gems/ruby-1.9.3-head/gems/activerecord-3.2.9/lib/active_record/connection_adapters/abstract/schema_statements.rb:170:在create_table' /Users/og/.rvm/gems/ruby-1.9.3-head/gems/activerecord-3.2.9/lib/active_record/migration.rb:466:in
阻止method_missing' /Users/og/.rvm/gems/ruby-1.9.3-head/gems/activerecord-3.2.9/lib/active_record/migration.rb:438:inblock in say_with_time' /Users/og/.rvm/rubies/ruby-1.9.3-head/lib/ruby/1.9.1/benchmark.rb:280:in
measure' /Users/og/.rvm /gems/ruby-1.9.3-head/gems/activerecord-3.2.9/lib/active_record/migration.rb:438:insay_with_time' /Users/og/.rvm/gems/ruby-1.9.3-head/gems/activerecord-3.2.9/lib/active_record/migration.rb:458:in
method_missing' /Users/og/Documents/websites/fermi/db/schema.rb:49 :inblock in <top (required)>' /Users/og/.rvm/gems/ruby-1.9.3-head/gems/activerecord-3.2.9/lib/active_record/schema.rb:50:in
instance_eval' /Users/og/.rvm/gems/ruby-1.9.3-head/gems/activerecord-3.2.9/lib/active_record/schema.rb:50:indefine' /Users/og/Documents/websites/fermi/db/schema.rb:14:in
' /Users/og/.rvm/ gems/ruby-1.9.3-head/gems/activesupport-3.2.9/lib/active_support/dependencies.rb:245:inload' /Users/og/.rvm/gems/ruby-1.9.3-head/gems/activesupport-3.2.9/lib/active_support/dependencies.rb:245:in
block in load' /Users/og/.rvm/gems/ruby-1.9.3-head /gems/activesupport-3.2.9/lib/active_support/dependencies.rb:236:inload_dependency' /Users/og/.rvm/gems/ruby-1.9.3-head/gems/activesupport-3.2.9/lib/active_support/dependencies.rb:245:in
load' /Users/og/.rvm/gems/ruby-1.9.3-head/gems/activerecord-3.2.9/lib/ active_record/railties/数据库。 耙:388:在block (3 levels) in <top (required)>' /Users/og/.rvm/gems/ruby-1.9.3-head@global/gems/rake-10.0.4/lib/rake/task.rb:246:in
调用'/Users/og/.rvm/gems/ruby-1.9.3-head@global/gems/rake-10.0.4/lib/rake/task.rb:246:inblock in execute' /Users/og/.rvm/gems/ruby-1.9.3-head@global/gems/rake-10.0.4/lib/rake/task.rb:241:in
each'/Users/og/.rvm /gems/ruby-1.9.3-head@global/gems/rake-10.0.4/lib/rake/task.rb:241:invoke_with_call_chain'/Users/og/.rvm/rubies/ruby-1.9execute' /Users/og/.rvm/gems/ruby-1.9.3-head@global/gems/rake-10.0.4/lib/rake/task.rb:184:in
中的块。 3-head/lib/ruby/1.9.1/monitor.rb:211:inmon_synchronize' /Users/og/.rvm/gems/ruby-1.9.3-head@global/gems/rake-10.0.4/lib/rake/task.rb:177:in
invoke_with_call_chain' /Users/og/.rvm/gems/ruby-1.9.3-head@global/gems/rake-10.0.4/lib /rake/task.rb:170:ininvoke' /Users/og/.rvm/gems/ruby-1.9.3-head/gems/activerecord-3.2.9/lib/active_record/railties/databases.rake:499:in
块(3 级)在'/Users/og/.rvm/gems/ruby-1.9.3-head@global/gems/rake-10.0.4/lib/rake/task .rb:246:incall' /Users/og/.rvm/gems/ruby-1.9.3-head@global/gems/rake-10.0.4/lib/rake/task.rb:246:in
block in execute' /Users/og/.rvm/gems/ruby-1.9.3-head@global/gems/rake-10.0.4/lib/rake/task.rb:241:ineach' /Users/og/.rvm/gems/ruby-1.9.3-head@global/gems/rake-10.0.4/lib/rake/task.rb:241:in
execute ' /Users/og/.rvm/gems/ruby-1.9.3-head@global/gems/rake-10.0.4/lib/rake/task.rb:184:inblock in invoke_with_call_chain' /Users/og/.rvm/rubies/ruby-1.9.3-head/lib/ruby/1.9.1/monitor.rb:211:in
mon_synchronize' /Users/og/.rvm/gems/ruby-1.9.3-head@global/gems/rake-10.0.4/lib/rake/task.rb:177:ininvoke_with_call_chain' /Users/og/.rvm/gems/ruby-1.9.3-head@global/gems/rake-10.0.4/lib/rake/task.rb:170:in
invoke' /Users/og/.rvm /gems/ruby-1.9.3-head/gems/activerecord-3.2.9/lib/active_record/railties/databases.rake:479:inblock (3 levels) in <top (required)>' /Users/og/.rvm/gems/ruby-1.9.3-head@global/gems/rake-10.0.4/lib/rake/task.rb:246:in
call' /Users/og/.rvm/gems/ruby-1.9.3- head@global/gems/rake-10.0.4/lib/rake/task.rb:246:inblock in execute' /Users/og/.rvm/gems/ruby-1.9.3-head@global/gems/rake-10.0.4/lib/rake/task.rb:241:in
each' /Users/og/.rvm/gems/ruby-1.9.3-head@global/gems/rake-10.0 .4/lib/rake/task.rb:241:execute' /Users/og/.rvm/gems/ruby-1.9.3-head@global/gems/rake-10.0.4/lib/rake/task.rb:184:in
invoke_with_call_chain'/Users/og/.rvm/rubies/ruby-1.9.3-head/lib/ruby/1.9.1/monitor.rb:211中的块:在mon_synchronize' /Users/og/.rvm/gems/ruby-1.9.3-head@global/gems/rake-10.0.4/lib/rake/task.rb:177:in
invoke_with_call_chain'/Users/og/.rvm/gems/ruby-1.9.3-head@global/gems/rake-10.0.4/lib/rake/task.rb:170:ininvoke' /Users/og/.rvm/gems/ruby-1.9.3-head@global/gems/rake-10.0.4/lib/rake/application.rb:143:in
invoke_task'/Users/og/。 rvm/gems/ruby-1.9.3-head@global/gems/rake-10.0.4/lib/rake/application.rb:101:inblock (2 levels) in top_level' /Users/og/.rvm/gems/ruby-1.9.3-head@global/gems/rake-10.0.4/lib/rake/application.rb:101:in
每个'/Users/og/.rvm/gems/ruby-1.9.3-head@global/gems/rake-10.0.4/lib/rake/application.rb:101:inblock in top_level' /Users/og/.rvm/gems/ruby-1.9.3-head@global/gems/rake-10.0.4/lib/rake/application.rb:110:in
run_with_threads'/Users/og/.rvm /gems/ruby-1.9.3-head@global/gems/rake-10.0.4/lib/rake/application.rb:95:intop_level' /Users/og/.rvm/gems/ruby-1.9.3-head@global/gems/rake-10.0.4/lib/rake/application.rb:73:in
block in run' /Users/og/.rvm/gems/ruby-1.9。 3-head@global/gems/rake-10.0.4/lib/rake/application.rb:160:instandard_exception_handling' /Users/og/.rvm/gems/ruby-1.9.3-head@global/gems/rake-10.0.4/lib/rake/application.rb:70:in
run' /Users/og/.rvm/gems/ruby-1.9.3-head@global/gems/rake -10.0.4/bin/rake:33:in<top (required)>' /Users/og/.rvm/gems/ruby-1.9.3-head/bin/rake:23:in
load' /Users/og/.rvm/gems/ruby-1.9.3-head/bin/rake:23:in `' 任务:TOP => db:schema:加载
我的 schema.rb 文件如下:
# encoding: UTF-8
# This file is auto-generated from the current state of the database. Instead
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.
#
# Note that this schema.rb definition is the authoritative source for your
# database schema. If you need to create the application database on another
# system, you should be using db:schema:load, not running all the migrations
# from scratch. The latter is a flawed and unsustainable approach (the more migrations
# you'll amass, the slower it'll run and the greater likelihood for issues).
#
# It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20130519192155) do
create_table "distributions", :force => true do |t|
t.float "mean"
t.float "spread"
t.float "wideness"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.integer "operation_id"
t.string "type"
t.string "name"
end
create_table "distributions_models", :id => false, :force => true do |t|
t.integer "distribution_id"
t.integer "model_id"
end
create_table "distributions_operations", :id => false, :force => true do |t|
t.integer "distribution_id"
t.integer "operation_id"
end
create_table "models", :force => true do |t|
t.string "name"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
create_table "operations", :force => true do |t|
t.string "operator"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
create_table "sqlite_sp_functions", :id => false, :force => true do |t|
t.text "name"
t.text "text"
end
# Could not dump table "sqlite_stat1" because of following StandardError
# Unknown type '' for column 'tbl'
# Could not dump table "sqlite_stat3" because of following StandardError
# Unknown type '' for column 'tbl'
create_table "sqlite_vs_links_names", :id => false, :force => true do |t|
t.text "name"
t.text "alias"
end
create_table "sqlite_vs_properties", :id => false, :force => true do |t|
t.text "parentType"
t.text "parentName"
t.text "propertyName"
t.text "propertyValue"
end
create_table "sqlite_vsp_diagrams", :id => false, :force => true do |t|
t.text "name"
t.text "diadata"
t.text "comment"
t.text "preview"
end
end
任何帮助或信息将不胜感激。我在网上搜索了这些错误很长一段时间,但在网上发现的很少。