class CreateAssetAttachments < ActiveRecord::Migration[5.1]
  def change
    create_table :assetable_asset_attachments do |t|
      t.references :asset
      t.references :assetable, :polymorphic => true
      t.string :name
      t.timestamps
    end

    add_index :assetable_asset_attachments, :asset_id
    add_index :assetable_asset_attachments, [:assetable_type, :assetable_id], name: "poly_asset_attachment"
    add_index :assetable_asset_attachments, [:assetable_type, :assetable_id, :name], unique: true, name: "named_asset"
    add_index :assetable_asset_attachments, :assetable_id
  end
end

class CreateAssetAttachments < ActiveRecord::Migration[5.1]
  def change
    create_table :assetable_asset_attachments do |t|
      t.references :asset
      t.references :assetable, :polymorphic => true
      t.string :name
      t.timestamps
    end

    add_index :assetable_asset_attachments, :asset_id
    add_index :assetable_asset_attachments, [:assetable_type, :assetable_id], name: "assetable_asset_attachments_poly_asset_attachment"
    add_index :assetable_asset_attachments, [:assetable_type, :assetable_id, :name], unique: true, name: "assetable_asset_attachments_poly_named_asset"
    add_index :assetable_asset_attachments, :assetable_id, name: "assetable_asset_attachments_assetable_id"
  end
end

Fix migration for rails 5
Fix migration for rails 5
