本文介绍了带有Rails的db:test:load上的SQLException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在开发一个具有多个has_and_belongs_to_many关系的小型但有些复杂的Rails应用程序。它是开源的,代码是。一切工作正常,但是最近我添加了新的HABTM关系迁移,并且rspec测试开始失败。 Rake:db:migrate在工作(问题在本地工作),只是不在测试中。运行db:test:load --trace时,出现以下错误:

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:

我的schema.rb文件如下:

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.

推荐答案

对我有用的是删除schema.rb,这是架构定义文件。

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.)

然后只需运行 rake db:migrate ,即可执行所有迁移并重新创建schema.rb文件。

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

这篇关于带有Rails的db:test:load上的SQLException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-17 12:00
查看更多