about summary refs log tree commit diff
path: root/db/migrate/20171116161857_create_list_accounts.rb
diff options
context:
space:
mode:
authorDavid Yip <yipdw@member.fsf.org>2017-11-17 17:58:13 -0600
committerGitHub <noreply@github.com>2017-11-17 17:58:13 -0600
commit284e2cde81811d6289dde9542f9c987062f9e7c2 (patch)
tree739fe0417fce9b9f48f924815b436a50b324dfe9 /db/migrate/20171116161857_create_list_accounts.rb
parent6f8ccbfcdf7fd8ca651d1583a608e96b25a09e25 (diff)
parent130aa90d5500f481c181a16012724b5f81d62616 (diff)
Merge pull request #224 from yipdw/merge-upstream
Merge upstream (tootsuite/mastodon#5703)
Diffstat (limited to 'db/migrate/20171116161857_create_list_accounts.rb')
-rw-r--r--db/migrate/20171116161857_create_list_accounts.rb12
1 files changed, 12 insertions, 0 deletions
diff --git a/db/migrate/20171116161857_create_list_accounts.rb b/db/migrate/20171116161857_create_list_accounts.rb
new file mode 100644
index 000000000..b76c90651
--- /dev/null
+++ b/db/migrate/20171116161857_create_list_accounts.rb
@@ -0,0 +1,12 @@
+class CreateListAccounts < ActiveRecord::Migration[5.1]
+  def change
+    create_table :list_accounts do |t|
+      t.belongs_to :list, foreign_key: { on_delete: :cascade }, null: false
+      t.belongs_to :account, foreign_key: { on_delete: :cascade }, null: false
+      t.belongs_to :follow, foreign_key: { on_delete: :cascade }, null: false
+    end
+
+    add_index :list_accounts, [:account_id, :list_id], unique: true
+    add_index :list_accounts, [:list_id, :account_id]
+  end
+end