Skip to content

Commit a82d1bc

Browse files
Merge pull request rails#49988 from skipkayhil/hm-fix-db-change-no-docker
Fix running db:system:change with no Dockerfile
2 parents e43471a + c8e1fe9 commit a82d1bc

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-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+
* Fix running `db:system:change` when app has no Dockerfile.
2+
3+
*Hartley McGuire*
4+
15
* In Action Mailer previews, list inline attachments separately from normal
26
attachments. For example, attachments that were previously listed like
37

railties/lib/rails/generators/rails/db/system/change/change_generator.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ def edit_gemfile
4141
end
4242

4343
def edit_dockerfile
44+
dockerfile_path = File.expand_path("Dockerfile", destination_root)
45+
return unless File.exist?(dockerfile_path)
46+
4447
build_name = docker_for_database_build
4548
deploy_name = docker_for_database_deploy
4649
if build_name

railties/test/commands/db_system_change_test.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,14 @@ class Rails::Command::DbSystemChangeTest < ActiveSupport::TestCase
6060
assert_match "gsub Gemfile", output
6161
end
6262

63+
test "change works with no Dockerfile" do
64+
remove_file("Dockerfile")
65+
66+
output = change_database(to: "sqlite3")
67+
68+
assert_match "gsub Gemfile", output
69+
end
70+
6371
private
6472
def change_database(to:, **options)
6573
args = ["--to", to]

0 commit comments

Comments
 (0)