diff options
author | Andrew White <pixeltrix@users.noreply.github.com> | 2015-11-02 15:12:12 +0000 |
---|---|---|
committer | Andrew White <pixeltrix@users.noreply.github.com> | 2015-11-02 15:12:12 +0000 |
commit | 38ddfefe54558659554909464d41f9072d21d6ee (patch) | |
tree | 926637cc1a2686e5abb86ec3288aaca0818f9289 /activerecord/lib/active_record/migration.rb | |
parent | 22e17695672f266c85e36ed36d847fc3f65d5dea (diff) | |
parent | a7beeb7faac405de0f78c39dbfb7240a584d0d10 (diff) | |
download | rails-38ddfefe54558659554909464d41f9072d21d6ee.tar.gz rails-38ddfefe54558659554909464d41f9072d21d6ee.tar.bz2 rails-38ddfefe54558659554909464d41f9072d21d6ee.zip |
Merge pull request #21841 from yui-knk/fix_migration_status
Make `db:migrate:status` to render `1_some.rb` format migrate files.
Diffstat (limited to 'activerecord/lib/active_record/migration.rb')
-rw-r--r-- | activerecord/lib/active_record/migration.rb | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/migration.rb b/activerecord/lib/active_record/migration.rb index 63ec8f6745..1e870d4c44 100644 --- a/activerecord/lib/active_record/migration.rb +++ b/activerecord/lib/active_record/migration.rb @@ -477,6 +477,7 @@ module ActiveRecord class Migration autoload :CommandRecorder, 'active_record/migration/command_recorder' + MigrationFilenameRegexp = /\A([0-9]+)_([_a-z0-9]*)\.?([_a-z0-9]*)?\.rb\z/ # :nodoc: # This class is used to verify that all migrations have been run before # loading a web page if config.active_record.migration_error is set to :page_load @@ -995,14 +996,21 @@ module ActiveRecord Array(@migrations_paths) end + def match_to_migration_filename?(filename) # :nodoc: + File.basename(filename) =~ Migration::MigrationFilenameRegexp + end + + def parse_migration_filename(filename) # :nodoc: + File.basename(filename).scan(Migration::MigrationFilenameRegexp).first + end + def migrations(paths) paths = Array(paths) 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\z/).first - + version, name, scope = parse_migration_filename(file) raise IllegalMigrationNameError.new(file) unless version version = version.to_i name = name.camelize |