aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorYves Senn <yves.senn@gmail.com>2012-12-12 21:51:38 +0100
committerYves Senn <yves.senn@garaio.com>2012-12-13 11:40:02 +0100
commitd68e299167c8da07dc63a55197313b5c3396c3a4 (patch)
treee157f4439543540dae9bac669c4f74c2de8f7185 /activerecord
parent6fbee4fc539cc29c68c0d515fa5e0af208f3f681 (diff)
downloadrails-d68e299167c8da07dc63a55197313b5c3396c3a4.tar.gz
rails-d68e299167c8da07dc63a55197313b5c3396c3a4.tar.bz2
rails-d68e299167c8da07dc63a55197313b5c3396c3a4.zip
recognize migrations, in folders containing numbers and 'rb'.
Backport of #8500 Closes #8492 Conflicts: activerecord/test/cases/migrator_test.rb
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/CHANGELOG.md6
-rw-r--r--activerecord/lib/active_record/migration.rb2
-rw-r--r--activerecord/test/cases/migration_test.rb6
-rw-r--r--activerecord/test/migrations/10_urban/9_add_expressions.rb11
4 files changed, 24 insertions, 1 deletions
diff --git a/activerecord/CHANGELOG.md b/activerecord/CHANGELOG.md
index 9e65cc0145..0b22939884 100644
--- a/activerecord/CHANGELOG.md
+++ b/activerecord/CHANGELOG.md
@@ -1,5 +1,11 @@
## Rails 3.2.10 (unreleased)
+* Recognize migrations placed in directories containing numbers and 'rb'.
+ Fix #8492
+ Backport of #8500
+
+ *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 6420f81347..e8ec93470d 100644
--- a/activerecord/lib/active_record/migration.rb
+++ b/activerecord/lib/active_record/migration.rb
@@ -627,7 +627,7 @@ module ActiveRecord
seen = Hash.new false
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/migration_test.rb b/activerecord/test/cases/migration_test.rb
index f0c55b1535..ff633f7f0f 100644
--- a/activerecord/test/cases/migration_test.rb
+++ b/activerecord/test/cases/migration_test.rb
@@ -1430,6 +1430,12 @@ if ActiveRecord::Base.connection.supports_migrations?
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_dump_schema_information_outputs_lexically_ordered_versions
migration_path = MIGRATIONS_ROOT + '/valid_with_timestamps'
ActiveRecord::Migrator.run(:up, migration_path, 20100301010101)
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