Module: Heroku::Helpers::HerokuPostgresql

Extended by:
Heroku::Helpers, HerokuPostgresql
Included in:
Command::Addons, Command::Pg, Command::Pgbackups, HerokuPostgresql
Defined in:
lib/heroku/helpers/heroku_postgresql.rb

Defined Under Namespace

Classes: Attachment, Resolver

Instance Method Summary collapse

Methods included from Heroku::Helpers

action, app_owner, ask, confirm, confirm_command, create_git_remote, debug, debugging?, default_org_host, deprecate, display, display_header, display_object, display_row, display_table, error, error_log, error_log_path, error_with_failure, error_with_failure=, extended, extended_into, fail, format_bytes, format_date, format_error, format_with_bang, get_terminal_environment, git, has_git?, has_git_remote?, has_http_git_entry_in_netrc, home_directory, hprint, hputs, included, included_into, json_decode, json_encode, launchy, line_formatter, longest, org?, org_host, output_with_bang, quantify, redisplay, retry_on_exception, run_command, running_on_a_mac?, running_on_windows?, set_buffer, shell, spinner, status, stderr_print, stderr_puts, string_distance, styled_array, styled_error, styled_hash, styled_header, suggestion, time_ago, truncate, update_git_remote, warn_if_using_jruby, with_tty

Instance Method Details

#hpg_resolve(identifier, default = nil) ⇒ Object


37
38
39
40
41
# File 'lib/heroku/helpers/heroku_postgresql.rb', line 37

def hpg_resolve(identifier, default=nil)
  $stderr.puts " !    #hpg_resolve is deprecated. Please run `heroku plugins:update` to update your plugins."
  $stderr.puts " !    from: #{caller.first}"
  Resolver.new(app, api).resolve(identifier , default)
end

#hpg_translate_db_opts_to_urls(addon, config) ⇒ Object


184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
# File 'lib/heroku/helpers/heroku_postgresql.rb', line 184

def hpg_translate_db_opts_to_urls(addon, config)
  app_name = app rescue nil
  resolver = Resolver.new(app_name, api)
  if addon =~ /^#{resolver.hpg_addon_name}/
    %w[fork follow rollback].each do |opt|
      if val = config[opt]
        unless val.is_a?(String)
          error("--#{opt} requires a database argument.")
        end

        uri = URI.parse(val) rescue nil
        if uri && uri.scheme && uri.scheme == 'postgres'
          argument_url = uri.to_s
        else
          attachment = resolver.resolve(val)
          if attachment.starter_plan?
            error("#{opt.capitalize} is only available on production databases.")
          end
          argument_url = attachment.url
        end

        config[opt] = argument_url
      end
    end
  end
end

#hpg_translate_fork_and_follow(addon, config) ⇒ Object


179
180
181
182
# File 'lib/heroku/helpers/heroku_postgresql.rb', line 179

def hpg_translate_fork_and_follow(addon, config)
  $stderr.puts " !    #hpg_translate_fork_and_follow is deprecated. Update your plugins."
  hpg_translate_db_opts_to_urls(addon, config)
end