about summary refs log tree commit diff
path: root/db/migrate
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2017-06-05 13:24:00 +0200
committerGitHub <noreply@github.com>2017-06-05 13:24:00 +0200
commit4c06d1cb241020f2407a6be01b584c508a06ffe9 (patch)
treec7ce0c489b32d4344115d21eafb8a4aa822ef1e8 /db/migrate
parent2985d089517a4f83af1cff264d926955f74da2fd (diff)
Fix #3550 - Add all missing foreign keys (#3562)
* Fix #3550 - Add all missing foreign keys

* Add missing foreign keys
Diffstat (limited to 'db/migrate')
-rw-r--r--db/migrate/20170604144747_add_foreign_keys_for_accounts.rb41
1 files changed, 41 insertions, 0 deletions
diff --git a/db/migrate/20170604144747_add_foreign_keys_for_accounts.rb b/db/migrate/20170604144747_add_foreign_keys_for_accounts.rb
new file mode 100644
index 000000000..76a836ca0
--- /dev/null
+++ b/db/migrate/20170604144747_add_foreign_keys_for_accounts.rb
@@ -0,0 +1,41 @@
+class AddForeignKeysForAccounts < ActiveRecord::Migration[5.1]
+  def change
+    add_foreign_key :statuses, :accounts, on_delete: :cascade
+    add_foreign_key :statuses, :accounts, column: :in_reply_to_account_id, on_delete: :nullify
+    add_foreign_key :statuses, :statuses, column: :in_reply_to_id, on_delete: :nullify
+    add_foreign_key :account_domain_blocks, :accounts, on_delete: :cascade
+    add_foreign_key :conversation_mutes, :accounts, on_delete: :cascade
+    add_foreign_key :conversation_mutes, :conversations, on_delete: :cascade
+    add_foreign_key :favourites, :accounts, on_delete: :cascade
+    add_foreign_key :favourites, :statuses, on_delete: :cascade
+    add_foreign_key :blocks, :accounts, on_delete: :cascade
+    add_foreign_key :blocks, :accounts, column: :target_account_id, on_delete: :cascade
+    add_foreign_key :follow_requests, :accounts, on_delete: :cascade
+    add_foreign_key :follow_requests, :accounts, column: :target_account_id, on_delete: :cascade
+    add_foreign_key :follows, :accounts, on_delete: :cascade
+    add_foreign_key :follows, :accounts, column: :target_account_id, on_delete: :cascade
+    add_foreign_key :mutes, :accounts, on_delete: :cascade
+    add_foreign_key :mutes, :accounts, column: :target_account_id, on_delete: :cascade
+    add_foreign_key :imports, :accounts, on_delete: :cascade
+    add_foreign_key :media_attachments, :accounts, on_delete: :nullify
+    add_foreign_key :media_attachments, :statuses, on_delete: :nullify
+    add_foreign_key :mentions, :accounts, on_delete: :cascade
+    add_foreign_key :mentions, :statuses, on_delete: :cascade
+    add_foreign_key :notifications, :accounts, on_delete: :cascade
+    add_foreign_key :notifications, :accounts, column: :from_account_id, on_delete: :cascade
+    add_foreign_key :preview_cards, :statuses, on_delete: :cascade
+    add_foreign_key :reports, :accounts, on_delete: :cascade
+    add_foreign_key :reports, :accounts, column: :target_account_id, on_delete: :cascade
+    add_foreign_key :reports, :accounts, column: :action_taken_by_account_id, on_delete: :nullify
+    add_foreign_key :statuses_tags, :statuses, on_delete: :cascade
+    add_foreign_key :statuses_tags, :tags, on_delete: :cascade
+    add_foreign_key :stream_entries, :accounts, on_delete: :cascade
+    add_foreign_key :subscriptions, :accounts, on_delete: :cascade
+    add_foreign_key :users, :accounts, on_delete: :cascade
+    add_foreign_key :web_settings, :users, on_delete: :cascade
+    add_foreign_key :oauth_access_grants, :users, column: :resource_owner_id, on_delete: :cascade
+    add_foreign_key :oauth_access_grants, :oauth_applications, column: :application_id, on_delete: :cascade
+    add_foreign_key :oauth_access_tokens, :users, column: :resource_owner_id, on_delete: :cascade
+    add_foreign_key :oauth_access_tokens, :oauth_applications, column: :application_id, on_delete: :cascade
+  end
+end