Skip to content

Commit 994ceea

Browse files
authored
Merge pull request rails#49644 from kyoshidajp/migration_generator_exit_failure_non_zero
Non-zero exit status on migration file creation errors
2 parents 9ade3f9 + 6cd4de4 commit 994ceea

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-0
lines changed

railties/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
* Exit with non-zero status when the migration generator fails.
2+
3+
*Katsuhiko YOSHIDA*
4+
15
* Use numeric UID and GID in Dockerfile template
26

37
The Dockerfile generated by `rails new` sets the default user and group

railties/lib/rails/generators/rails/migration/migration_generator.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ module Generators
55
class MigrationGenerator < NamedBase # :nodoc:
66
argument :attributes, type: :array, default: [], banner: "field[:type][:index] field[:type][:index]"
77
hook_for :orm, required: true, desc: "ORM to be invoked"
8+
9+
def self.exit_on_failure? # :nodoc:
10+
true
11+
end
812
end
913
end
1014
end

railties/test/generators/migration_generator_test.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ def test_migration_with_invalid_file_name
4949
end
5050
end
5151

52+
def test_exit_on_failure
53+
assert_equal true, generator_class.exit_on_failure?
54+
end
55+
5256
def test_add_migration_with_attributes
5357
migration = "add_title_body_to_posts"
5458
run_generator [migration, "title:string", "body:text"]

0 commit comments

Comments
 (0)