diff --git a/bin/setup b/bin/setup index d74a48b01..305076644 100755 --- a/bin/setup +++ b/bin/setup @@ -18,6 +18,9 @@ FileUtils.chdir APP_ROOT do FileUtils.cp 'docker/danbooru_local_config.rb', 'config/danbooru_local_config.rb' end + puts "== Creating elasticsearch indices ==\n" + system! "RAILS_ENV=development bin/rails runner '[Post, PostVersion].each { |model| model.__elasticsearch__.create_index! }'" + puts "\n== Preparing database ==" # Create the test database, since only development exists at this point system! 'RAILS_ENV=test bin/rails db:create' diff --git a/db/seeds.rb b/db/seeds.rb index 7d4c84108..176c637ab 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -4,12 +4,6 @@ require "digest/md5" require "net/http" require "tempfile" -puts "== Creating elasticsearch indices ==\n" -Post.__elasticsearch__.create_index! -PostVersion.__elasticsearch__.create_index! - -puts "== Seeding database with sample content ==\n" - # Uncomment to see detailed logs # ActiveRecord::Base.logger = ActiveSupport::Logger.new($stdout) diff --git a/test/test_helper.rb b/test/test_helper.rb index f097fabda..d7d9998df 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -37,6 +37,10 @@ end BCrypt::Engine.send(:remove_const, :DEFAULT_COST) BCrypt::Engine::DEFAULT_COST = BCrypt::Engine::MIN_COST +# Clear the elastic indicies completly +Post.__elasticsearch__.create_index!(force: true) +PostVersion.__elasticsearch__.create_index!(force: true) + class ActiveSupport::TestCase include ActionDispatch::TestProcess::FixtureFile include FactoryBot::Syntax::Methods