{"action":"created","comment":{"url":"https://api.github.com/repos/rails/rails/pulls/comments/41350251","id":41350251,"diff_hunk":"@@ -951,15 +952,24 @@ def migrations_paths\n         Array(@migrations_paths)\n       end\n \n+      def match_to_migration_filename?(filename) # :nodoc:\n+        filename =~ Migration::MigrationFilenameRegexp\n+      end\n+\n+      def parse_migration_filename(filename) # :nodoc:\n+        filename.scan(Migration::MigrationFilenameRegexp).first\n+      end\n+\n       def migrations(paths)\n         paths = Array(paths)\n \n         files = Dir[*paths.map { |p| \"#{p}/**/[0-9]*_*.rb\" }]\n \n         migrations = files.map do |file|\n-          version, name, scope = file.scan(/([0-9]+)_([_a-z0-9]*)\\.?([_a-z0-9]*)?\\.rb\\z/).first\n+          basename = File.basename(file)\n+          raise IllegalMigrationNameError.new(file) unless match_to_migration_filename?(basename)\n \n-          raise IllegalMigrationNameError.new(file) unless version\n+          version, name, scope = parse_migration_filename(basename)","path":"activerecord/lib/active_record/migration.rb","position":31,"original_position":31,"commit_id":"7ba37cf21e744c0d51bbdf4d38aa02a18b1f7eb9","original_commit_id":"7ba37cf21e744c0d51bbdf4d38aa02a18b1f7eb9","user":{"login":"yui-knk","id":5356517,"avatar_url":"https://avatars.githubusercontent.com/u/5356517?v=3","gravatar_id":"","url":"https://api.github.com/users/yui-knk","html_url":"https://github.com/yui-knk","followers_url":"https://api.github.com/users/yui-knk/followers","following_url":"https://api.github.com/users/yui-knk/following{/other_user}","gists_url":"https://api.github.com/users/yui-knk/gists{/gist_id}","starred_url":"https://api.github.com/users/yui-knk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yui-knk/subscriptions","organizations_url":"https://api.github.com/users/yui-knk/orgs","repos_url":"https://api.github.com/users/yui-knk/repos","events_url":"https://api.github.com/users/yui-knk/events{/privacy}","received_events_url":"https://api.github.com/users/yui-knk/received_events","type":"User","site_admin":false},"body":"> We could also push the `File.basename` conversions down into the two methods\r\n\r\nYes, I will.\r\n\r\n> I think we can still do the old way of checking the version and just have the one regexp comparison.\r\n\r\nSure in old way have just the one comparison, but I think old way was ambiguous. Why `IllegalMigrationNameError` is raised when `version` is not got? In this case I think using `match_to_migration_filename?` makes clear why `IllegalMigrationNameError` is raised.\r\n\r\nHow do you think about this?","created_at":"2015-10-07T04:26:51Z","updated_at":"2015-10-07T04:26:51Z","html_url":"https://github.com/rails/rails/pull/21841#discussion_r41350251","pull_request_url":"https://api.github.com/repos/rails/rails/pulls/21841","_links":{"self":{"href":"https://api.github.com/repos/rails/rails/pulls/comments/41350251"},"html":{"href":"https://github.com/rails/rails/pull/21841#discussion_r41350251"},"pull_request":{"href":"https://api.github.com/repos/rails/rails/pulls/21841"}}},"pull_request":{"url":"https://api.github.com/repos/rails/rails/pulls/21841","id":46623543,"html_url":"https://github.com/rails/rails/pull/21841","diff_url":"https://github.com/rails/rails/pull/21841.diff","patch_url":"https://github.com/rails/rails/pull/21841.patch","issue_url":"https://api.github.com/repos/rails/rails/issues/21841","number":21841,"state":"open","locked":false,"title":"Make `db:migrate:status` to render `1_some.rb` format migrate files.","user":{"login":"yui-knk","id":5356517,"avatar_url":"https://avatars.githubusercontent.com/u/5356517?v=3","gravatar_id":"","url":"https://api.github.com/users/yui-knk","html_url":"https://github.com/yui-knk","followers_url":"https://api.github.com/users/yui-knk/followers","following_url":"https://api.github.com/users/yui-knk/following{/other_user}","gists_url":"https://api.github.com/users/yui-knk/gists{/gist_id}","starred_url":"https://api.github.com/users/yui-knk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yui-knk/subscriptions","organizations_url":"https://api.github.com/users/yui-knk/orgs","repos_url":"https://api.github.com/users/yui-knk/repos","events_url":"https://api.github.com/users/yui-knk/events{/privacy}","received_events_url":"https://api.github.com/users/yui-knk/received_events","type":"User","site_admin":false},"body":"`1_valid_people_have_last_names.rb` and\r\n`20150823202140_create_users.rb` are valid migration file name.\r\nBut `1_valid_people_have_last_names.rb` is rendered as\r\n`********** NO FILE **********` when `rake db:migrate:status`.\r\n\r\nFix to this bug, this commit includes\r\n\r\n* define some API private methdos and a Constant\r\n  `match_to_migration_filename?`, `parse_migration_filename`, and\r\n  `MigrationFilenameRegexp`\r\n* use these methods in `db:migrate:status` task\r\n\r\nExample:\r\n\r\nThese files are in `db/migrate`\r\n\r\n* 1_valid_people_have_last_names.rb\r\n* 20150819202140_irreversible_migration.rb\r\n* 20150823202140_add_admin_flag_to_users.rb\r\n* 20150823202141_migration_tests.rb\r\n* 2_we_need_reminders.rb\r\n* 3_innocent_jointable.rb\r\n\r\nwe can migrate all of them.\r\n\r\nBefore\r\n\r\n```shell\r\n$ bundle exec rake db:migrate:status\r\n\r\n...\r\n\r\n Status   Migration ID    Migration Name\r\n--------------------------------------------------\r\n   up     001             ********** NO FILE **********\r\n   up     002             ********** NO FILE **********\r\n   up     003             ********** NO FILE **********\r\n   up     20150819202140  Irreversible migration\r\n   up     20150823202140  Add admin flag to users\r\n   up     20150823202141  Migration tests\r\n```\r\n\r\nAfter\r\n\r\n```shell\r\n$ bundle exec rake db:migrate:status\r\n\r\n...\r\n\r\n Status   Migration ID    Migration Name\r\n--------------------------------------------------\r\n   up     001             Valid people have last names\r\n   up     002             We need reminders\r\n   up     003             Innocent jointable\r\n   up     20150819202140  Irreversible migration\r\n   up     20150823202140  Add admin flag to users\r\n   up     20150823202141  Migration tests\r\n```","created_at":"2015-10-02T10:52:36Z","updated_at":"2015-10-07T04:26:51Z","closed_at":null,"merged_at":null,"merge_commit_sha":"092ec2ca8f1f26f27fe07b7849bc92830547a85a","assignee":{"login":"pixeltrix","id":6321,"avatar_url":"https://avatars.githubusercontent.com/u/6321?v=3","gravatar_id":"","url":"https://api.github.com/users/pixeltrix","html_url":"https://github.com/pixeltrix","followers_url":"https://api.github.com/users/pixeltrix/followers","following_url":"https://api.github.com/users/pixeltrix/following{/other_user}","gists_url":"https://api.github.com/users/pixeltrix/gists{/gist_id}","starred_url":"https://api.github.com/users/pixeltrix/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pixeltrix/subscriptions","organizations_url":"https://api.github.com/users/pixeltrix/orgs","repos_url":"https://api.github.com/users/pixeltrix/repos","events_url":"https://api.github.com/users/pixeltrix/events{/privacy}","received_events_url":"https://api.github.com/users/pixeltrix/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/rails/rails/pulls/21841/commits","review_comments_url":"https://api.github.com/repos/rails/rails/pulls/21841/comments","review_comment_url":"https://api.github.com/repos/rails/rails/pulls/comments{/number}","comments_url":"https://api.github.com/repos/rails/rails/issues/21841/comments","statuses_url":"https://api.github.com/repos/rails/rails/statuses/7ba37cf21e744c0d51bbdf4d38aa02a18b1f7eb9","head":{"label":"yui-knk:fix_migration_status","ref":"fix_migration_status","sha":"7ba37cf21e744c0d51bbdf4d38aa02a18b1f7eb9","user":{"login":"yui-knk","id":5356517,"avatar_url":"https://avatars.githubusercontent.com/u/5356517?v=3","gravatar_id":"","url":"https://api.github.com/users/yui-knk","html_url":"https://github.com/yui-knk","followers_url":"https://api.github.com/users/yui-knk/followers","following_url":"https://api.github.com/users/yui-knk/following{/other_user}","gists_url":"https://api.github.com/users/yui-knk/gists{/gist_id}","starred_url":"https://api.github.com/users/yui-knk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yui-knk/subscriptions","organizations_url":"https://api.github.com/users/yui-knk/orgs","repos_url":"https://api.github.com/users/yui-knk/repos","events_url":"https://api.github.com/users/yui-knk/events{/privacy}","received_events_url":"https://api.github.com/users/yui-knk/received_events","type":"User","site_admin":false},"repo":{"id":23390335,"name":"rails","full_name":"yui-knk/rails","owner":{"login":"yui-knk","id":5356517,"avatar_url":"https://avatars.githubusercontent.com/u/5356517?v=3","gravatar_id":"","url":"https://api.github.com/users/yui-knk","html_url":"https://github.com/yui-knk","followers_url":"https://api.github.com/users/yui-knk/followers","following_url":"https://api.github.com/users/yui-knk/following{/other_user}","gists_url":"https://api.github.com/users/yui-knk/gists{/gist_id}","starred_url":"https://api.github.com/users/yui-knk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yui-knk/subscriptions","organizations_url":"https://api.github.com/users/yui-knk/orgs","repos_url":"https://api.github.com/users/yui-knk/repos","events_url":"https://api.github.com/users/yui-knk/events{/privacy}","received_events_url":"https://api.github.com/users/yui-knk/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/yui-knk/rails","description":"Ruby on Rails","fork":true,"url":"https://api.github.com/repos/yui-knk/rails","forks_url":"https://api.github.com/repos/yui-knk/rails/forks","keys_url":"https://api.github.com/repos/yui-knk/rails/keys{/key_id}","collaborators_url":"https://api.github.com/repos/yui-knk/rails/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/yui-knk/rails/teams","hooks_url":"https://api.github.com/repos/yui-knk/rails/hooks","issue_events_url":"https://api.github.com/repos/yui-knk/rails/issues/events{/number}","events_url":"https://api.github.com/repos/yui-knk/rails/events","assignees_url":"https://api.github.com/repos/yui-knk/rails/assignees{/user}","branches_url":"https://api.github.com/repos/yui-knk/rails/branches{/branch}","tags_url":"https://api.github.com/repos/yui-knk/rails/tags","blobs_url":"https://api.github.com/repos/yui-knk/rails/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/yui-knk/rails/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/yui-knk/rails/git/refs{/sha}","trees_url":"https://api.github.com/repos/yui-knk/rails/git/trees{/sha}","statuses_url":"https://api.github.com/repos/yui-knk/rails/statuses/{sha}","languages_url":"https://api.github.com/repos/yui-knk/rails/languages","stargazers_url":"https://api.github.com/repos/yui-knk/rails/stargazers","contributors_url":"https://api.github.com/repos/yui-knk/rails/contributors","subscribers_url":"https://api.github.com/repos/yui-knk/rails/subscribers","subscription_url":"https://api.github.com/repos/yui-knk/rails/subscription","commits_url":"https://api.github.com/repos/yui-knk/rails/commits{/sha}","git_commits_url":"https://api.github.com/repos/yui-knk/rails/git/commits{/sha}","comments_url":"https://api.github.com/repos/yui-knk/rails/comments{/number}","issue_comment_url":"https://api.github.com/repos/yui-knk/rails/issues/comments{/number}","contents_url":"https://api.github.com/repos/yui-knk/rails/contents/{+path}","compare_url":"https://api.github.com/repos/yui-knk/rails/compare/{base}...{head}","merges_url":"https://api.github.com/repos/yui-knk/rails/merges","archive_url":"https://api.github.com/repos/yui-knk/rails/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/yui-knk/rails/downloads","issues_url":"https://api.github.com/repos/yui-knk/rails/issues{/number}","pulls_url":"https://api.github.com/repos/yui-knk/rails/pulls{/number}","milestones_url":"https://api.github.com/repos/yui-knk/rails/milestones{/number}","notifications_url":"https://api.github.com/repos/yui-knk/rails/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/yui-knk/rails/labels{/name}","releases_url":"https://api.github.com/repos/yui-knk/rails/releases{/id}","created_at":"2014-08-27T13:20:12Z","updated_at":"2015-04-12T04:09:16Z","pushed_at":"2015-10-06T12:25:02Z","git_url":"git://github.com/yui-knk/rails.git","ssh_url":"git@github.com:yui-knk/rails.git","clone_url":"https://github.com/yui-knk/rails.git","svn_url":"https://github.com/yui-knk/rails","homepage":"http://rubyonrails.org","size":148014,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"rails:master","ref":"master","sha":"7a96e629efdd91865309e334d89bdca7c63093df","user":{"login":"rails","id":4223,"avatar_url":"https://avatars.githubusercontent.com/u/4223?v=3","gravatar_id":"","url":"https://api.github.com/users/rails","html_url":"https://github.com/rails","followers_url":"https://api.github.com/users/rails/followers","following_url":"https://api.github.com/users/rails/following{/other_user}","gists_url":"https://api.github.com/users/rails/gists{/gist_id}","starred_url":"https://api.github.com/users/rails/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rails/subscriptions","organizations_url":"https://api.github.com/users/rails/orgs","repos_url":"https://api.github.com/users/rails/repos","events_url":"https://api.github.com/users/rails/events{/privacy}","received_events_url":"https://api.github.com/users/rails/received_events","type":"Organization","site_admin":false},"repo":{"id":8514,"name":"rails","full_name":"rails/rails","owner":{"login":"rails","id":4223,"avatar_url":"https://avatars.githubusercontent.com/u/4223?v=3","gravatar_id":"","url":"https://api.github.com/users/rails","html_url":"https://github.com/rails","followers_url":"https://api.github.com/users/rails/followers","following_url":"https://api.github.com/users/rails/following{/other_user}","gists_url":"https://api.github.com/users/rails/gists{/gist_id}","starred_url":"https://api.github.com/users/rails/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rails/subscriptions","organizations_url":"https://api.github.com/users/rails/orgs","repos_url":"https://api.github.com/users/rails/repos","events_url":"https://api.github.com/users/rails/events{/privacy}","received_events_url":"https://api.github.com/users/rails/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/rails/rails","description":"Ruby on Rails","fork":false,"url":"https://api.github.com/repos/rails/rails","forks_url":"https://api.github.com/repos/rails/rails/forks","keys_url":"https://api.github.com/repos/rails/rails/keys{/key_id}","collaborators_url":"https://api.github.com/repos/rails/rails/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/rails/rails/teams","hooks_url":"https://api.github.com/repos/rails/rails/hooks","issue_events_url":"https://api.github.com/repos/rails/rails/issues/events{/number}","events_url":"https://api.github.com/repos/rails/rails/events","assignees_url":"https://api.github.com/repos/rails/rails/assignees{/user}","branches_url":"https://api.github.com/repos/rails/rails/branches{/branch}","tags_url":"https://api.github.com/repos/rails/rails/tags","blobs_url":"https://api.github.com/repos/rails/rails/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/rails/rails/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/rails/rails/git/refs{/sha}","trees_url":"https://api.github.com/repos/rails/rails/git/trees{/sha}","statuses_url":"https://api.github.com/repos/rails/rails/statuses/{sha}","languages_url":"https://api.github.com/repos/rails/rails/languages","stargazers_url":"https://api.github.com/repos/rails/rails/stargazers","contributors_url":"https://api.github.com/repos/rails/rails/contributors","subscribers_url":"https://api.github.com/repos/rails/rails/subscribers","subscription_url":"https://api.github.com/repos/rails/rails/subscription","commits_url":"https://api.github.com/repos/rails/rails/commits{/sha}","git_commits_url":"https://api.github.com/repos/rails/rails/git/commits{/sha}","comments_url":"https://api.github.com/repos/rails/rails/comments{/number}","issue_comment_url":"https://api.github.com/repos/rails/rails/issues/comments{/number}","contents_url":"https://api.github.com/repos/rails/rails/contents/{+path}","compare_url":"https://api.github.com/repos/rails/rails/compare/{base}...{head}","merges_url":"https://api.github.com/repos/rails/rails/merges","archive_url":"https://api.github.com/repos/rails/rails/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/rails/rails/downloads","issues_url":"https://api.github.com/repos/rails/rails/issues{/number}","pulls_url":"https://api.github.com/repos/rails/rails/pulls{/number}","milestones_url":"https://api.github.com/repos/rails/rails/milestones{/number}","notifications_url":"https://api.github.com/repos/rails/rails/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/rails/rails/labels{/name}","releases_url":"https://api.github.com/repos/rails/rails/releases{/id}","created_at":"2008-04-11T02:19:47Z","updated_at":"2015-10-07T04:26:44Z","pushed_at":"2015-10-07T02:18:21Z","git_url":"git://github.com/rails/rails.git","ssh_url":"git@github.com:rails/rails.git","clone_url":"https://github.com/rails/rails.git","svn_url":"https://github.com/rails/rails","homepage":"http://rubyonrails.org","size":466173,"stargazers_count":27940,"watchers_count":27940,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":11250,"mirror_url":null,"open_issues_count":882,"forks":11250,"open_issues":882,"watchers":27940,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/rails/rails/pulls/21841"},"html":{"href":"https://github.com/rails/rails/pull/21841"},"issue":{"href":"https://api.github.com/repos/rails/rails/issues/21841"},"comments":{"href":"https://api.github.com/repos/rails/rails/issues/21841/comments"},"review_comments":{"href":"https://api.github.com/repos/rails/rails/pulls/21841/comments"},"review_comment":{"href":"https://api.github.com/repos/rails/rails/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/rails/rails/pulls/21841/commits"},"statuses":{"href":"https://api.github.com/repos/rails/rails/statuses/7ba37cf21e744c0d51bbdf4d38aa02a18b1f7eb9"}}}}