2015-08-18 20:50:27 -04:00
|
|
|
#!/usr/bin/env ruby
|
2024-01-25 16:05:29 -05:00
|
|
|
require "fileutils"
|
2015-08-18 20:50:27 -04:00
|
|
|
|
|
|
|
# path to your application root.
|
2024-01-25 16:05:29 -05:00
|
|
|
APP_ROOT = File.expand_path("..", __dir__)
|
2015-08-18 20:50:27 -04:00
|
|
|
|
2018-04-02 13:51:26 -04:00
|
|
|
def system!(*args)
|
2024-01-25 16:05:29 -05:00
|
|
|
system(*args, exception: true)
|
2018-04-02 13:51:26 -04:00
|
|
|
end
|
|
|
|
|
2019-08-29 00:50:40 -04:00
|
|
|
FileUtils.chdir APP_ROOT do
|
2022-10-10 07:22:35 -04:00
|
|
|
# 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.
|
2018-04-02 13:51:26 -04:00
|
|
|
# Add necessary setup steps to this file.
|
|
|
|
|
2021-11-13 21:31:26 -05:00
|
|
|
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
|
2015-08-18 20:50:27 -04:00
|
|
|
|
2023-10-02 12:57:07 -04:00
|
|
|
puts "== Creating opensearch indices ==\n"
|
2023-09-16 11:09:33 -04:00
|
|
|
system! "RAILS_ENV=development bin/rails runner '[Post, PostVersion].each { |model| model.document_store.create_index! }'"
|
2023-09-08 13:17:47 -04:00
|
|
|
|
2015-08-18 20:50:27 -04:00
|
|
|
puts "\n== Preparing database =="
|
2023-03-04 08:19:40 -05:00
|
|
|
# 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'
|
2015-08-18 20:50:27 -04:00
|
|
|
|
|
|
|
puts "\n== Removing old logs and tempfiles =="
|
2018-04-02 13:51:26 -04:00
|
|
|
system! 'bin/rails log:clear tmp:clear'
|
2015-08-18 20:50:27 -04:00
|
|
|
end
|