SQLException on db:test:load with Rails

I've been working on a small but somewhat complex Rails application with multiple has_and_belongs_to_many relationships. It's open source, and the code is here. Everything was working fine, but recently I added a new HABTM relationship migration, and an rspec test started to fail. Rake:db:migrate was working (and the issue was working locally), just not in testing. Upon running db:test:load --trace , I get the following error:

: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 <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 <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:in new' /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:in execute' /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:in block in log' /Users/og/.rvm/gems/ruby-1.9.3-head/gems/activesupport-3.2.9/lib/active_support/notifications/instrumenter.rb:20:in instrument' /Users/og/.rvm/gems/ruby-1.9.3-head/gems/activerecord-3.2.9/lib/active_ record/connection_adapters/abstract_adapter.rb:275:in log' /Users/og/.rvm/gems/ruby-1.9.3-head/gems/activerecord-3.2.9/lib/active_record/connection_adapters/sqlite_adapter.rb:278:in execute' /Users/og/.rvm/gems/ruby-1.9.3-head/gems/activerecord-3.2.9/lib/active_record/connection_adapters/abstract/schema_statements.rb:170:in create_table' /Users/og/.rvm/gems/ruby-1.9.3-head/gems/activerecord-3.2.9/lib/active_record/migration.rb:466:in block in method_missing' /Users/og/.rvm/gems/ruby-1.9.3-head/gems/activerecord-3.2.9/lib/active_record/migration.rb:438:in block 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:in say_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:in block in <top (required)>' /Users/og/.rvm/gems/ruby-1.9.3-head/gems/activerecord-3.2.9/lib/active_record/schema.rb:50:in block 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:in define' /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:in load' /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:in load_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/databases.rake:388:in 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 call' /Users/og/.rvm/gems/ruby-1.9.3-head@global/gems/rake-10.0.4/lib/r ake/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:in each' /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:in block 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: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:in invoke' /Users/og/.rvm/gems/ruby-1.9.3-head/gems/activerecord-3.2.9/lib/active_record/railties/databases.rake:499:in block (3 levels) in ' /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:in block 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:in execute' /Users/og/.rvm/gems/ruby-1.9.3-head@global/gems/rake-10.0.4/lib/rake/task.rb:184:in block 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: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:in invoke' /Users/og/.rvm/gems/ruby-1.9.3-head/gems/activerecord-3.2.9/lib/active_record/railties/databases.rake:479:in 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 call' /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:in each' /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:in block 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: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:in invoke' /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:in block (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 each' /Users/og/.rvm/gems/ruby-1.9.3-head@global/gems/rake-10.0.4/lib/rake/application.rb:101:in block 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_thr eads' /Users/og/.rvm/gems/ruby-1.9.3-head@global/gems/rake-10.0.4/lib/rake/application.rb:95:in top_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:in standard_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 `' Tasks: TOP => db:schema:load

My schema.rb file is the following:

# 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

Any help or information would be much appreciated. I've search these errors online for quite a while, but have found very little online.


What worked for me was to delete schema.rb, which is the schema definition file.

(The first paragraph of comments within this file recommends deleting it and generating a new one, rather than editing it.)

Then just run rake db:migrate , which performs all the migrations and re-creates the schema.rb file.


I got the similar error either and I have no idea. But when I delete those code, in this case,

try delete these line:

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

then rake test:prepare might work.


Add the following config line to config/application.rb or in config/environments/development.rb :

ActiveRecord::SchemaDumper.ignore_tables = /^sqlite_*/

This will ignore all tables starting with "sqlite_" in your database during the schema dump.

链接地址: http://www.djcxy.com/p/49942.html

上一篇: 从rails 3.2升级到rails 4.2之前的测试套件

下一篇: 数据库上的SQLException:test:使用Rails加载