class CreateSoftwareImages < ActiveRecord::Migration[8.0]
  def change
    create_table :software_images do |t|
      t.bigint  :software_id, null: false, unsigned: true
      t.bigint  :image_id,    null: false
      t.boolean :is_default,  null: false, default: false
      t.integer :position,    null: false, default: 0

      t.timestamps
    end

    add_index :software_images, [:software_id, :image_id], unique: true
    add_index :software_images, [:software_id, :position]

    add_foreign_key :software_images, :softwares
    add_foreign_key :software_images, :images
  end
end
