class CreateProducts < ActiveRecord::Migration
  def change
    create_table :products do |t|
      t.string :title, null: false
      t.string :code
      t.string :main_image_uri
      t.text :body
      t.text :specifications
      t.references :manufacturer, null: false
      t.references :catalogue_category, null: false
      t.boolean :published
      t.boolean :delta, default: true, null: false

      t.timestamps
    end
    add_index :products, :manufacturer_id
    add_index :products, :catalogue_category_id

    create_table :products_relations, id: false do |t|
      t.integer :product_id
      t.integer :related_product_id
    end
    add_index :products_relations, [:product_id, :related_product_id]
  end
end
