about summary refs log tree commit diff
path: root/lib
diff options
context:
space:
mode:
authorYamagishi Kazutoshi <ykzts@desire.sh>2018-04-20 19:21:28 +0900
committerEugen Rochko <eugen@zeonfederated.com>2018-04-20 12:21:28 +0200
commit084cf0babffec9e7bee537fd4f6b2294de6c33dc (patch)
tree1e1c1d19a1f09120244c49cd7f55b1b0f118c5b4 /lib
parenta9c440637ca9f36bcf051094abe3bcba1da63166 (diff)
Add extract_foreign_key_action to Mastodon::MigrationHelpers (#7195)
Diffstat (limited to 'lib')
-rw-r--r--lib/mastodon/migration_helpers.rb11
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/mastodon/migration_helpers.rb b/lib/mastodon/migration_helpers.rb
index 6f6f99f63..e154b5a2c 100644
--- a/lib/mastodon/migration_helpers.rb
+++ b/lib/mastodon/migration_helpers.rb
@@ -985,6 +985,17 @@ into similar problems in the future (e.g. when new tables are created).
         BackgroundMigrationWorker.perform_in(delay_interval * index, job_class_name, [start_id, end_id])
       end
     end
+
+    private
+
+    # https://github.com/rails/rails/blob/v5.2.0/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb#L678-L684
+    def extract_foreign_key_action(specifier)
+      case specifier
+      when 'c'; :cascade
+      when 'n'; :nullify
+      when 'r'; :restrict
+      end
+    end
   end
 end