about summary refs log tree commit diff
path: root/db/migrate/20220714171049_create_tag_follows.rb
diff options
context:
space:
mode:
Diffstat (limited to 'db/migrate/20220714171049_create_tag_follows.rb')
-rw-r--r--db/migrate/20220714171049_create_tag_follows.rb12
1 files changed, 12 insertions, 0 deletions
diff --git a/db/migrate/20220714171049_create_tag_follows.rb b/db/migrate/20220714171049_create_tag_follows.rb
new file mode 100644
index 000000000..a393e90f5
--- /dev/null
+++ b/db/migrate/20220714171049_create_tag_follows.rb
@@ -0,0 +1,12 @@
+class CreateTagFollows < ActiveRecord::Migration[6.1]
+  def change
+    create_table :tag_follows do |t|
+      t.belongs_to :tag, null: false, foreign_key: { on_delete: :cascade }
+      t.belongs_to :account, null: false, foreign_key: { on_delete: :cascade }, index: false
+
+      t.timestamps
+    end
+
+    add_index :tag_follows, [:account_id, :tag_id], unique: true
+  end
+end