about summary refs log tree commit diff
path: root/lib/mastodon/migration_helpers.rb
diff options
context:
space:
mode:
authorClaire <claire.github-309c@sitedethib.com>2021-06-02 19:15:17 +0200
committerGitHub <noreply@github.com>2021-06-02 19:15:17 +0200
commit11d3c065a5b71caa66f64d22e08f31eba0c357c5 (patch)
treea665a19d3eb39b47ed823231169b805d731833a6 /lib/mastodon/migration_helpers.rb
parent526332c5454b67f1c498dc82e71657258a79d7e9 (diff)
Fix migration script not being able to run if it fails midway (#16312)
* Fix migration script not being able to run if it fails midway

* Fix old migration script

* Fix old migration script

* Refactor CorruptionError
Diffstat (limited to 'lib/mastodon/migration_helpers.rb')
-rw-r--r--lib/mastodon/migration_helpers.rb14
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/mastodon/migration_helpers.rb b/lib/mastodon/migration_helpers.rb
index 521d903bf..39a6e0680 100644
--- a/lib/mastodon/migration_helpers.rb
+++ b/lib/mastodon/migration_helpers.rb
@@ -41,6 +41,20 @@
 
 module Mastodon
   module MigrationHelpers
+    class CorruptionError < StandardError
+      def initialize(message = nil)
+        super(message.presence || 'Migration failed because of index corruption, see https://docs.joinmastodon.org/admin/troubleshooting/index-corruption/#fixing')
+      end
+
+      def cause
+        nil
+      end
+
+      def backtrace
+        []
+      end
+    end
+
     # Model that can be used for querying permissions of a SQL user.
     class Grant < ActiveRecord::Base
       self.table_name = 'information_schema.role_table_grants'