about summary refs log tree commit diff
path: root/db/migrate/20200724045955_create_inline_media_attachments.rb
blob: a894c38689a1e12bc2b9b6671b4151bda48e8eb8 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
class CreateInlineMediaAttachments < ActiveRecord::Migration[5.2]
  disable_ddl_transaction!

  def change
    create_table :inline_media_attachments do |t|
      t.references :status, index: { algorithm: :concurrently }, foreign_key: { on_delete: :cascade }
      t.references :media_attachment, index: { algorithm: :concurrently }, foreign_key: { on_delete: :cascade }
    end

    add_index :inline_media_attachments, [:status_id, :media_attachment_id], unique: true, algorithm: :concurrently, name: 'uniq_index_on_status_and_attachment'
  end
end