提交 f3839b2b 编写于 作者: J José Valim

ActiveRecord should raise an error on invalid migration types.

上级 ae8070e2
......@@ -319,16 +319,19 @@ def initialize(base)
def method_missing(symbol, *args)
if symbol.to_s == 'xml'
xml_column_fallback(args)
else
super
end
end
def xml_column_fallback(*args)
case @base.adapter_name.downcase
when 'sqlite', 'mysql'
options = args.extract_options!
column(args[0], :text, options)
end
when 'sqlite', 'mysql'
options = args.extract_options!
column(args[0], :text, options)
end
end
# Appends a primary key definition to the table definition.
# Can be called multiple times, but this is probably not a good idea.
def primary_key(name)
......
......@@ -27,6 +27,16 @@ def test_schema_define
assert_nothing_raised { @connection.select_all "SELECT * FROM schema_migrations" }
assert_equal 7, ActiveRecord::Migrator::current_version
end
def test_schema_raises_an_error_for_invalid_column_ntype
assert_raise NoMethodError do
ActiveRecord::Schema.define(:version => 8) do
create_table :vegetables do |t|
t.unknown :color
end
end
end
end
end
end
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册