Class: RedmineInstaller::Database::PostgreSQL

Inherits:
Base
  • Object
show all
Defined in:
lib/redmine-installer/database.rb

Constant Summary

Constants included from Utils

Utils::PROGRESSBAR_FORMAT

Instance Attribute Summary

Attributes inherited from Base

#backup

Instance Method Summary collapse

Methods inherited from Base

#backuped?, #build, #do_restore, #get_parameters, #initialize, #make_backup, #make_config, #set_paramaters, #to_s

Methods included from Utils

#class_name, #create_dir, #env_user, #error, #logger, #ok, #pastel, #print_title, #prompt, #run_command

Constructor Details

This class inherits a constructor from RedmineInstaller::Database::Base

Instance Method Details

#adapter_nameObject



165
166
167
# File 'lib/redmine-installer/database.rb', line 165

def adapter_name
  'postgresql'
end

#backup_command(file) ⇒ Object



193
194
195
# File 'lib/redmine-installer/database.rb', line 193

def backup_command(file)
  "#{cli_password} pg_dump --clean #{command_args} --format=custom --file=#{file} #{@database}"
end

#cli_passwordObject



177
178
179
180
181
182
183
# File 'lib/redmine-installer/database.rb', line 177

def cli_password
  if @password.present?
    "PGPASSWORD=\"#{@password}\""
  else
    ''
  end
end

#command_argsObject



169
170
171
172
173
174
175
# File 'lib/redmine-installer/database.rb', line 169

def command_args
  args = []
  args << "--host=#{@host}"         unless @host.to_s.empty?
  args << "--port=#{@port}"         unless @port.to_s.empty?
  args << "--username=#{@username}" unless @username.to_s.empty?
  args.join(' ')
end

#create_database_commandObject



185
186
187
# File 'lib/redmine-installer/database.rb', line 185

def create_database_command
  "#{cli_password} psql #{command_args} --command=\"create database #{@database};\""
end

#default_portObject



161
162
163
# File 'lib/redmine-installer/database.rb', line 161

def default_port
  5432
end

#drop_database_commandObject



189
190
191
# File 'lib/redmine-installer/database.rb', line 189

def drop_database_command
  "#{cli_password} psql #{command_args} --command=\"drop database #{@database};\""
end

#restore_command(file) ⇒ Object



197
198
199
# File 'lib/redmine-installer/database.rb', line 197

def restore_command(file)
  "#{cli_password} pg_restore --clean #{command_args} --dbname=#{@database} #{file} 2>/dev/null"
end