about summary refs log tree commit diff
path: root/lib/mastodon/search_cli.rb
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2019-03-28 02:16:11 +0100
committerGitHub <noreply@github.com>2019-03-28 02:16:11 +0100
commit5d41532d94eda8da692044b7b875cf68e20dfc96 (patch)
tree382f084ef2fcd860b50d5981a13a6f52faf5b645 /lib/mastodon/search_cli.rb
parent08ec7435ce10fc74c257e089d6a2e909287e3daa (diff)
Add `tootctl search deploy` to avoid ugly rake task syntax (#10403)
Diffstat (limited to 'lib/mastodon/search_cli.rb')
-rw-r--r--lib/mastodon/search_cli.rb22
1 files changed, 22 insertions, 0 deletions
diff --git a/lib/mastodon/search_cli.rb b/lib/mastodon/search_cli.rb
new file mode 100644
index 000000000..42ad93f1e
--- /dev/null
+++ b/lib/mastodon/search_cli.rb
@@ -0,0 +1,22 @@
+# frozen_string_literal: true
+
+require_relative '../../config/boot'
+require_relative '../../config/environment'
+require_relative 'cli_helper'
+
+module Mastodon
+  class SearchCLI < Thor
+    desc 'deploy', 'Create or update an ElasticSearch index and populate it'
+    long_desc <<~LONG_DESC
+      If ElasticSearch is empty, this command will create the necessary indices
+      and then import data from the database into those indices.
+
+      This command will also upgrade indices if the underlying schema has been
+      changed since the last run.
+    LONG_DESC
+    def deploy
+      processed = Chewy::RakeHelper.upgrade
+      Chewy::RakeHelper.sync(except: processed)
+    end
+  end
+end