Class: RedmineInstaller::Database::PostgreSQL
- Inherits:
-
Base
- Object
- Base
- RedmineInstaller::Database::PostgreSQL
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
Instance Method Details
#adapter_name ⇒ Object
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_password ⇒ Object
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_args ⇒ Object
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_command ⇒ Object
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_port ⇒ Object
161
162
163
|
# File 'lib/redmine-installer/database.rb', line 161
def default_port
5432
end
|
#drop_database_command ⇒ Object
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
|