1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

ActiveRecord should raise an error on invalid migration types.

This commit is contained in:
José Valim 2010-02-28 11:53:48 +01:00
parent ae8070e21b
commit f3839b2b99
2 changed files with 17 additions and 4 deletions

View file

@ -319,16 +319,19 @@ module ActiveRecord
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)

View file

@ -27,6 +27,16 @@ if ActiveRecord::Base.connection.supports_migrations?
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