Clean up database.yml files
This commit is contained in:
parent
cd4dc311ae
commit
297d9bb044
5 changed files with 73 additions and 42 deletions
|
@ -1,11 +0,0 @@
|
|||
# Warning: The database defined as "test" will be erased and
|
||||
# re-generated from your development database when you run "rake".
|
||||
# Do not set this db to the same as development or production.
|
||||
test:
|
||||
adapter: mysql2
|
||||
database: zammad_test
|
||||
pool: 50
|
||||
timeout: 5000
|
||||
encoding: utf8
|
||||
username: some_user
|
||||
password: some_pass
|
|
@ -1,11 +0,0 @@
|
|||
# Warning: The database defined as "test" will be erased and
|
||||
# re-generated from your development database when you run "rake".
|
||||
# Do not set this db to the same as development or production.
|
||||
test:
|
||||
adapter: postgresql
|
||||
database: zammad_test
|
||||
pool: 50
|
||||
timeout: 5000
|
||||
encoding: utf8
|
||||
username: postgres
|
||||
password:
|
30
contrib/database.yml
Normal file
30
contrib/database.yml
Normal file
|
@ -0,0 +1,30 @@
|
|||
default: &default
|
||||
# For details on connection pooling, see Rails configuration guide
|
||||
# http://guides.rubyonrails.org/configuring.html#database-pooling
|
||||
pool: 50
|
||||
timeout: 5000
|
||||
encoding: utf8
|
||||
# postgresql -----------------------------------------------------------------
|
||||
adapter: postgresql
|
||||
# username: <username>
|
||||
# password: <password>
|
||||
# mysql ----------------------------------------------------------------------
|
||||
# adapter: mysql2
|
||||
# host: localhost
|
||||
# username: <username>
|
||||
# password: <password>
|
||||
|
||||
production:
|
||||
<<: *default
|
||||
database: zammad_prod
|
||||
|
||||
development:
|
||||
<<: *default
|
||||
database: zammad_development
|
||||
|
||||
# Warning: The database defined as "test" will be erased and
|
||||
# re-generated from your development database when you run "rake".
|
||||
# Do not set this db to the same as development or production.
|
||||
test:
|
||||
<<: *default
|
||||
database: zammad_test
|
|
@ -1,31 +1,54 @@
|
|||
module BootstrapRakeHelper
|
||||
APP_CACHE = Dir.glob(Rails.root.join('tmp', 'cache*'))
|
||||
SERVER_LOG = Rails.root.join('log', "#{Rails.env}.log")
|
||||
AUTO_WIZARD = { source: Rails.root.join('contrib', 'auto_wizard_test.json'),
|
||||
dest: Rails.root.join('auto_wizard.json') }.freeze
|
||||
DB_CONFIG = { source: Rails.root.join('contrib', 'database.yml'),
|
||||
dest: Rails.root.join('config', 'database.yml') }.freeze
|
||||
|
||||
def flush_cache_and_logs
|
||||
FileUtils.rm_rf(APP_CACHE)
|
||||
File.write(SERVER_LOG, '')
|
||||
end
|
||||
|
||||
def run_auto_wizard
|
||||
FileUtils.ln(AUTO_WIZARD[:source], AUTO_WIZARD[:dest], force: true)
|
||||
AutoWizard.setup
|
||||
|
||||
# set system init to done
|
||||
UserInfo.current_user_id = 1
|
||||
Setting.set('system_init_done', true)
|
||||
end
|
||||
|
||||
def add_database_config
|
||||
raise Errno::ENOENT, 'contrib/database.yml not found' unless File.exist?(DB_CONFIG[:source])
|
||||
|
||||
if File.exist?(DB_CONFIG[:dest])
|
||||
return if FileUtils.identical?(DB_CONFIG[:source], DB_CONFIG[:dest])
|
||||
printf 'config/database.yml: File exists. Overwrite? [Y/n] '
|
||||
return if STDIN.gets.chomp.downcase == 'n'
|
||||
end
|
||||
|
||||
FileUtils.cp(DB_CONFIG[:source], DB_CONFIG[:dest])
|
||||
end
|
||||
end
|
||||
|
||||
namespace :bs do
|
||||
desc 'Bootstrap the application'
|
||||
task :init => %i[db:create db:migrate db:seed] do
|
||||
task :init => %i[db_config db:create db:migrate db:seed] do
|
||||
include BootstrapRakeHelper
|
||||
run_auto_wizard
|
||||
end
|
||||
|
||||
desc 'Reset the application to its initial state'
|
||||
task :reset => %i[db:reset] do
|
||||
include BootstrapRakeHelper
|
||||
run_auto_wizard
|
||||
flush_cache_and_logs
|
||||
end
|
||||
end
|
||||
|
||||
APP_CACHE = Dir.glob(Rails.root.join('tmp', 'cache*'))
|
||||
SERVER_LOG = Rails.root.join('log', "#{Rails.env}.log")
|
||||
AUTO_WIZARD = { source: Rails.root.join('contrib', 'auto_wizard_test.json'),
|
||||
dest: Rails.root.join('auto_wizard.json') }.freeze
|
||||
|
||||
def flush_cache_and_logs
|
||||
FileUtils.rm_rf(APP_CACHE)
|
||||
File.write(SERVER_LOG, '')
|
||||
end
|
||||
|
||||
def run_auto_wizard
|
||||
FileUtils.ln(AUTO_WIZARD[:source], AUTO_WIZARD[:dest], force: true)
|
||||
AutoWizard.setup
|
||||
|
||||
# set system init to done
|
||||
UserInfo.current_user_id = 1
|
||||
Setting.set('system_init_done', true)
|
||||
|
||||
task :db_config do
|
||||
include BootstrapRakeHelper
|
||||
add_database_config
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue