diff options
author | Yves Senn <yves.senn@gmail.com> | 2012-12-12 21:51:38 +0100 |
---|---|---|
committer | Yves Senn <yves.senn@garaio.com> | 2012-12-13 09:08:32 +0100 |
commit | 349d4606004d20cb0ace1980bcb6d0af13f6b504 (patch) | |
tree | 9a3b26f3f5e2be349cafd96e7a343435824f7e35 | |
parent | d4333eded218346eb8b8313f7c69851782f594ef (diff) | |
download | rails-349d4606004d20cb0ace1980bcb6d0af13f6b504.tar.gz rails-349d4606004d20cb0ace1980bcb6d0af13f6b504.tar.bz2 rails-349d4606004d20cb0ace1980bcb6d0af13f6b504.zip |
recognize migrations, in folders containing numbers and 'rb'.
Closes #8492
-rw-r--r-- | activerecord/CHANGELOG.md | 5 | ||||
-rw-r--r-- | activerecord/lib/active_record/migration.rb | 2 | ||||
-rw-r--r-- | activerecord/test/cases/migrator_test.rb | 6 | ||||
-rw-r--r-- | activerecord/test/migrations/10_urban/9_add_expressions.rb | 11 |
4 files changed, 23 insertions, 1 deletions
diff --git a/activerecord/CHANGELOG.md b/activerecord/CHANGELOG.md index 3955a2466e..de386cd358 100644 --- a/activerecord/CHANGELOG.md +++ b/activerecord/CHANGELOG.md @@ -1,5 +1,10 @@ ## Rails 4.0.0 (unreleased) ## +* Recognize migrations placed in directories containing numbers and 'rb'. + Fix #8492 + + *Yves Senn* + * Add `ActiveRecord::Base.cache_timestamp_format` class attribute to control the format of the timestamp value in the cache key. This allows users to improve the precision of the cache key. diff --git a/activerecord/lib/active_record/migration.rb b/activerecord/lib/active_record/migration.rb index 22347fcaef..ef2107ad24 100644 --- a/activerecord/lib/active_record/migration.rb +++ b/activerecord/lib/active_record/migration.rb @@ -665,7 +665,7 @@ module ActiveRecord files = Dir[*paths.map { |p| "#{p}/**/[0-9]*_*.rb" }] migrations = files.map do |file| - version, name, scope = file.scan(/([0-9]+)_([_a-z0-9]*)\.?([_a-z0-9]*)?.rb/).first + version, name, scope = file.scan(/([0-9]+)_([_a-z0-9]*)\.?([_a-z0-9]*)?\.rb\z/).first raise IllegalMigrationNameError.new(file) unless version version = version.to_i diff --git a/activerecord/test/cases/migrator_test.rb b/activerecord/test/cases/migrator_test.rb index 1e16addcf3..199d0c584b 100644 --- a/activerecord/test/cases/migrator_test.rb +++ b/activerecord/test/cases/migrator_test.rb @@ -84,6 +84,12 @@ module ActiveRecord end end + def test_finds_migrations_in_numbered_directory + migrations = ActiveRecord::Migrator.migrations [MIGRATIONS_ROOT + '/10_urban'] + assert_equal 9, migrations[0].version + assert_equal 'AddExpressions', migrations[0].name + end + def test_deprecated_constructor assert_deprecated do ActiveRecord::Migrator.new(:up, MIGRATIONS_ROOT + "/valid") diff --git a/activerecord/test/migrations/10_urban/9_add_expressions.rb b/activerecord/test/migrations/10_urban/9_add_expressions.rb new file mode 100644 index 0000000000..79a342e574 --- /dev/null +++ b/activerecord/test/migrations/10_urban/9_add_expressions.rb @@ -0,0 +1,11 @@ +class AddExpressions < ActiveRecord::Migration + def self.up + create_table("expressions") do |t| + t.column :expression, :string + end + end + + def self.down + drop_table "expressions" + end +end |