class CreateParticularHists < ActiveRecord::Migration[6.0]
  def change
    create_table :particular_hists do |t|
      t.references :particular, foreign_key: true
      t.references :p_customer, foreign_key: true
      t.text :description
      t.string :name
      t.string :firstname
      t.string :address_1
      t.string :address_2
      t.string :address_3
      t.string :address_4
      t.string :address_5
      t.string :cp
      t.string :city
      t.string :country
      t.string :tel
      t.string :email
      t.string :civilite
      t.boolean :npai, :default => false

      t.timestamps
      
      PCustomer.update_all(:npai => false)
      PCustomer.where(:imp_npai => "oui").update_all(:npai => true)
    end
  end
end
