class CreateSuppliers < ActiveRecord::Migration[6.1]
  def change
    enable_extension 'pgcrypto' unless extension_enabled?('pgcrypto')
    create_table :suppliers, id: :uuid, default: 'gen_random_uuid()' do |t|
      t.string :name,     null: false, default: ""
      t.text :address,    default: ""
      t.string :tel,      default: ""
      t.string :mail,     default: ""

      t.timestamps
    end

    add_column :products, :supplier_id, :uuid
    add_index :products, :supplier_id
  end
end
