]> cat aescling's git repositories - mastodon.git/commitdiff
Add extract_foreign_key_action to Mastodon::MigrationHelpers (#7195)
authorYamagishi Kazutoshi <ykzts@desire.sh>
Fri, 20 Apr 2018 10:21:28 +0000 (19:21 +0900)
committerEugen Rochko <eugen@zeonfederated.com>
Fri, 20 Apr 2018 10:21:28 +0000 (12:21 +0200)
lib/mastodon/migration_helpers.rb

index 6f6f99f63ca7bbd870812cc57591fd9541578ef0..e154b5a2cd7cd0b2194eef1cadf190300623777d 100644 (file)
@@ -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