Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backport of #8500, recognize migrations, in folders containing numbers and 'rb'. #8504

Merged
merged 1 commit into from
Dec 13, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions activerecord/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
2 changes: 1 addition & 1 deletion activerecord/lib/active_record/migration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -627,7 +627,7 @@ def migrations(paths, *args)
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
Expand Down
6 changes: 6 additions & 0 deletions activerecord/test/cases/migration_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1430,6 +1430,12 @@ def test_finds_migrations_from_two_directories
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)
Expand Down
11 changes: 11 additions & 0 deletions activerecord/test/migrations/10_urban/9_add_expressions.rb
Original file line number Diff line number Diff line change
@@ -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