@@ -591,6 +591,36 @@ class MigrationTest < ActiveRecord::TestCase
591591 # For some reason our tests set Rails.@_env which breaks test env switching.
592592 coerce_tests! :test_internal_metadata_stores_environment_when_other_data_exists
593593 coerce_tests! :test_internal_metadata_stores_environment
594+
595+ # Same as original but using binary type instead of blob
596+ coerce_tests! :test_add_column_with_casted_type_if_not_exists_set_to_true
597+ def test_add_column_with_casted_type_if_not_exists_set_to_true_coerced
598+ migration_a = Class . new ( ActiveRecord ::Migration ::Current ) {
599+ def version ; 100 end
600+ def migrate ( x )
601+ add_column "people" , "last_name" , :binary
602+ end
603+ } . new
604+
605+ migration_b = Class . new ( ActiveRecord ::Migration ::Current ) {
606+ def version ; 101 end
607+ def migrate ( x )
608+ add_column "people" , "last_name" , :binary , if_not_exists : true
609+ end
610+ } . new
611+
612+ ActiveRecord ::Migrator . new ( :up , [ migration_a ] , @schema_migration , 100 ) . migrate
613+ assert_column Person , :last_name , "migration_a should have created the last_name column on people"
614+
615+ assert_nothing_raised do
616+ ActiveRecord ::Migrator . new ( :up , [ migration_b ] , @schema_migration , 101 ) . migrate
617+ end
618+ ensure
619+ Person . reset_column_information
620+ if Person . column_names . include? ( "last_name" )
621+ Person . connection . remove_column ( "people" , "last_name" )
622+ end
623+ end
594624end
595625
596626class CoreTest < ActiveRecord ::TestCase
0 commit comments