diff options
-rw-r--r-- | activerecord/lib/active_record/migration.rb | 2 | ||||
-rw-r--r-- | activerecord/test/cases/migration_test.rb | 13 |
2 files changed, 14 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/migration.rb b/activerecord/lib/active_record/migration.rb index 23e4505f61..d4cda927ad 100644 --- a/activerecord/lib/active_record/migration.rb +++ b/activerecord/lib/active_record/migration.rb @@ -374,7 +374,7 @@ module ActiveRecord end def load_migration - require(filename) + require(File.expand_path(filename)) name.constantize end diff --git a/activerecord/test/cases/migration_test.rb b/activerecord/test/cases/migration_test.rb index 03ee8dcf3c..e213986ede 100644 --- a/activerecord/test/cases/migration_test.rb +++ b/activerecord/test/cases/migration_test.rb @@ -1104,6 +1104,19 @@ if ActiveRecord::Base.connection.supports_migrations? assert_equal migrations[0].name, 'InnocentJointable' end + def test_relative_migrations + $".delete_if do |fname| + fname == (MIGRATIONS_ROOT + "/valid/1_people_have_last_names.rb") + end + Object.send(:remove_const, :PeopleHaveLastNames) + + Dir.chdir(MIGRATIONS_ROOT) do + ActiveRecord::Migrator.up("valid/", 1) + end + + assert defined?(PeopleHaveLastNames) + end + def test_only_loads_pending_migrations # migrate up to 1 ActiveRecord::Migrator.up(MIGRATIONS_ROOT + "/valid", 1) |