-
Notifications
You must be signed in to change notification settings - Fork 21.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow
schema_dump
database config to be set via DATABASE_URL
In `database.yml`, `schema_dump` can currently be set to `false`, `nil` or a file path. I found that if you configure your database via DATABASE_URL, the false value does not work because it comes through as a string. This change allows `?schema_dump=false` to disable the dump via database_url.
- Loading branch information
1 parent
4fb230d
commit 67549bc
Showing
2 changed files
with
31 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
activerecord/test/cases/database_configurations/url_config_test.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# frozen_string_literal: true | ||
|
||
require "cases/helper" | ||
|
||
module ActiveRecord | ||
class DatabaseConfigurations | ||
class UrlConfigTest < ActiveRecord::TestCase | ||
def test_schema_dump_set_to_false | ||
config = UrlConfig.new("default_env", "primary", "postges://localhost/foo?schema_dump=false", {}) | ||
assert_nil config.schema_dump | ||
end | ||
|
||
def test_schema_dump_set_to_path | ||
config = UrlConfig.new("default_env", "primary", "postges://localhost/foo?schema_dump=db/foo_schema.rb", {}) | ||
assert_equal "db/foo_schema.rb", config.schema_dump | ||
end | ||
|
||
def test_schema_dump_unset | ||
config = UrlConfig.new("default_env", "primary", "postges://localhost/foo", {}) | ||
assert_equal "schema.rb", config.schema_dump | ||
end | ||
end | ||
end | ||
end |