forked from e621ng/e621ng

Since the correct database is now getting created on boot Rails does things a bit different by trying to run migrations. Also creates the test database since that wasn't automatic.
36 lines
1.3 KiB
Ruby
Executable File
36 lines
1.3 KiB
Ruby
Executable File
#!/usr/bin/env ruby
|
|
require 'fileutils'
|
|
|
|
# path to your application root.
|
|
APP_ROOT = File.expand_path('..', __dir__)
|
|
|
|
def system!(*args)
|
|
system(*args) || abort("\n== Command #{args} failed ==")
|
|
end
|
|
|
|
FileUtils.chdir APP_ROOT do
|
|
# This script is a way to set up or update your development environment automatically.
|
|
# This script is idempotent, so that you can run it at any time and get an expectable outcome.
|
|
# Add necessary setup steps to this file.
|
|
|
|
puts "\n== Copying sample files =="
|
|
unless File.exist?('config/danbooru_local_config.rb')
|
|
FileUtils.cp 'docker/danbooru_local_config.rb', 'config/danbooru_local_config.rb'
|
|
end
|
|
|
|
puts "\n== Preparing database =="
|
|
# Create the test database, since only development exists at this point
|
|
system! 'RAILS_ENV=test bin/rails db:create'
|
|
system! 'RAILS_ENV=development bin/rails db:schema:load'
|
|
system! 'RAILS_ENV=development DANBOORU_DISABLE_THROTTLES=true bin/rails db:seed'
|
|
|
|
puts "\n== Preparing search indices =="
|
|
system! 'bin/rails r Post.__elasticsearch__.create_index!'
|
|
system! 'bin/rails r Post.import'
|
|
system! 'bin/rails r PostVersion.__elasticsearch__.create_index!'
|
|
system! 'bin/rails r PostVersion.import'
|
|
|
|
puts "\n== Removing old logs and tempfiles =="
|
|
system! 'bin/rails log:clear tmp:clear'
|
|
end
|