Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ heroku git:remote -r staging -a your-staging-app
heroku git:remote -r production -a your-production-app
```
* There is a `config/database.yml` file that can be parsed as YAML for
`['development']['database']`.
`['development']['database']` or `['development']['url']`.

Pipelines
---------
Expand Down
12 changes: 9 additions & 3 deletions lib/parity/backup.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ class Backup
DATABASE_YML_RELATIVE_PATH = "config/database.yml".freeze
DEVELOPMENT_ENVIRONMENT_KEY_NAME = "development".freeze
DATABASE_KEY_NAME = "database".freeze
DATABASE_URL_KEY_NAME = "url".freeze

def initialize(args)
@from, @to = args.values_at(:from, :to)
Expand Down Expand Up @@ -108,9 +109,14 @@ def remote_db_backup_url
end

def development_db
YAML.load(database_yaml_file).
fetch(DEVELOPMENT_ENVIRONMENT_KEY_NAME).
fetch(DATABASE_KEY_NAME)
environment_block = YAML.safe_load(database_yaml_file).
fetch(DEVELOPMENT_ENVIRONMENT_KEY_NAME)
if environment_block.key?(DATABASE_KEY_NAME)
environment_block.fetch(DATABASE_KEY_NAME)
elsif environment_block.key?(DATABASE_URL_KEY_NAME)
url = environment_block.fetch(DATABASE_URL_KEY_NAME)
URI(url).path.tr("/", "")
end
end

def database_yaml_file
Expand Down