cannot do rake db:migrate
Opened this issue · 0 comments
I created a test table, but when I run rake db:migrate
, I got below errors!
class CreateTests < ActiveRecord::Migration
def change
create_table :tests do |t|
t.string :name
t.string :label
t.timestamps null: false
end
end
end
rake aborted!
StandardError: An error has occurred, all later migrations canceled:
undefined method type_cast_from_database' for "NVARCHAR":String/home/vagrant/.gem/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/attribute.rb:94:in
type_cast'
/home/vagrant/.gem/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/attribute.rb:42:in original_value' /home/vagrant/.gem/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/attribute.rb:37:in
value'
/home/vagrant/.gem/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/attribute.rb:54:in changed_in_place_from?' /home/vagrant/.gem/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/attribute_methods/dirty.rb:74:in
attribute_changed_in_place?'
/home/vagrant/.gem/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/attribute_methods/dirty.rb:149:in block in changed_in_place' /home/vagrant/.gem/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/attribute_methods/dirty.rb:148:in
select'
/home/vagrant/.gem/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/attribute_methods/dirty.rb:148:in changed_in_place' /home/vagrant/.gem/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/attribute_methods/dirty.rb:141:in
attributes_changed_in_place'
/home/vagrant/.gem/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/attribute_methods/dirty.rb:62:in changed_attributes' /home/vagrant/.gem/ruby/2.2.0/gems/activemodel-4.2.0/lib/active_model/dirty.rb:173:in
attribute_changed?'
/home/vagrant/.gem/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/attribute_methods/dirty.rb:115:in old_attribute_value' /home/vagrant/.gem/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/attribute_methods/dirty.rb:90:in
write_attribute'
/home/vagrant/.gem/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/attribute_methods.rb:50:in __temp__6756273796f6e6' /home/vagrant/.gem/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/attribute_assignment.rb:54:in
public_send'
/home/vagrant/.gem/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/attribute_assignment.rb:54:in _assign_attribute' /home/vagrant/.gem/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/attribute_assignment.rb:41:in
block in assign_attributes'
/home/vagrant/.gem/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/attribute_assignment.rb:35:in each' /home/vagrant/.gem/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/attribute_assignment.rb:35:in
assign_attributes'
/home/vagrant/.gem/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/core.rb:557:in init_attributes' /home/vagrant/.gem/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/core.rb:280:in
initialize'
/home/vagrant/.gem/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/inheritance.rb:61:in new' /home/vagrant/.gem/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/inheritance.rb:61:in
new'
/home/vagrant/.gem/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/persistence.rb:50:in create!' /home/vagrant/.gem/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/migration.rb:1026:in
record_version_state_after_migrating'
/home/vagrant/.gem/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/migration.rb:996:in block in execute_migration_in_transaction' /home/vagrant/.gem/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/migration.rb:1043:in
ddl_transaction'
/home/vagrant/.gem/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/migration.rb:994:in execute_migration_in_transaction' /home/vagrant/.gem/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/migration.rb:956:in
block in migrate'
/home/vagrant/.gem/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/migration.rb:952:in each' /home/vagrant/.gem/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/migration.rb:952:in
migrate'
/home/vagrant/.gem/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/migration.rb:820:in up' /home/vagrant/.gem/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/migration.rb:798:in
migrate'
/home/vagrant/.gem/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/tasks/database_tasks.rb:137:in migrate' /home/vagrant/.gem/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/railties/databases.rake:44:in
block (2 levels) in <top (required)>'
**NoMethodError: undefined method type_cast_from_database' for "NVARCHAR":String** /home/vagrant/.gem/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/attribute.rb:94:in
type_cast'
/home/vagrant/.gem/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/attribute.rb:42:inoriginal_value' /home/vagrant/.gem/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/attribute.rb:37:in
value'
/home/vagrant/.gem/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/attribute.rb:54:inchanged_in_place_from?' /home/vagrant/.gem/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/attribute_methods/dirty.rb:74:in
attribute_changed_in_place?'
/home/vagrant/.gem/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/attribute_methods/dirty.rb:149:inblock in changed_in_place' /home/vagrant/.gem/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/attribute_methods/dirty.rb:148:in
select'
/home/vagrant/.gem/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/attribute_methods/dirty.rb:148:inchanged_in_place' /home/vagrant/.gem/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/attribute_methods/dirty.rb:141:in
attributes_changed_in_place'
/home/vagrant/.gem/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/attribute_methods/dirty.rb:62:inchanged_attributes' /home/vagrant/.gem/ruby/2.2.0/gems/activemodel-4.2.0/lib/active_model/dirty.rb:173:in
attribute_changed?'
/home/vagrant/.gem/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/attribute_methods/dirty.rb:115:inold_attribute_value' /home/vagrant/.gem/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/attribute_methods/dirty.rb:90:in
write_attribute'
/home/vagrant/.gem/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/attribute_methods.rb:50:in__temp__6756273796f6e6' /home/vagrant/.gem/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/attribute_assignment.rb:54:in
public_send'
/home/vagrant/.gem/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/attribute_assignment.rb:54:in_assign_attribute' /home/vagrant/.gem/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/attribute_assignment.rb:41:in
block in assign_attributes'
/home/vagrant/.gem/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/attribute_assignment.rb:35:ineach' /home/vagrant/.gem/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/attribute_assignment.rb:35:in
assign_attributes'
/home/vagrant/.gem/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/core.rb:557:ininit_attributes' /home/vagrant/.gem/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/core.rb:280:in
initialize'
/home/vagrant/.gem/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/inheritance.rb:61:innew' /home/vagrant/.gem/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/inheritance.rb:61:in
new'
/home/vagrant/.gem/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/persistence.rb:50:increate!' /home/vagrant/.gem/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/migration.rb:1026:in
record_version_state_after_migrating'
/home/vagrant/.gem/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/migration.rb:996:inblock in execute_migration_in_transaction' /home/vagrant/.gem/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/migration.rb:1043:in
ddl_transaction'
/home/vagrant/.gem/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/migration.rb:994:inexecute_migration_in_transaction' /home/vagrant/.gem/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/migration.rb:956:in
block in migrate'
/home/vagrant/.gem/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/migration.rb:952:ineach' /home/vagrant/.gem/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/migration.rb:952:in
migrate'
/home/vagrant/.gem/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/migration.rb:820:inup' /home/vagrant/.gem/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/migration.rb:798:in
migrate'
/home/vagrant/.gem/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/tasks/database_tasks.rb:137:inmigrate' /home/vagrant/.gem/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/railties/databases.rake:44:in
block (2 levels) in <top (required)>'
Tasks: TOP => db:migrate