class CreatePCustomers < ActiveRecord::Migration[6.0]
  def change
    create_table :p_customers do |t|
      t.decimal      :encourt_max,   :precision => 14,   :scale => 2
      t.references   :p_customer_cat,   index: true
      t.references   :particular,   index: true
      t.string       :name
      t.integer      :code
      t.boolean      :fav,   :default => false
      t.boolean      :facture_email,   :default => false
      t.boolean      :risque,   :default => false
      t.integer      :admin_id
      t.decimal      :cache_ca,   :precision => 14,   :scale => 2
      t.decimal      :cache_encours,   :precision => 14,   :scale => 2
      t.integer      :cache_moyenne_paiement
      t.integer      :payment_days
      t.integer      :parent_id
      t.string       :mlm_token
      t.string       :parent_code
      t.boolean      :parent_at_create,   :default => false
      t.boolean      :imported,   :default => false
      t.boolean      :facture_mail,   :default => false
      t.boolean      :comptant,   :default => true
      t.boolean      :acompte,   :default => false
      t.decimal      :acompte_percent,   :precision => 14,   :scale => 2
      t.integer      :payment_delais
      t.boolean      :payment_fin_de_mois,   :default => false
      t.decimal      :cache_encours_th,   :precision => 14,   :scale => 2
      t.decimal      :cache_payments_th,   :precision => 14,   :scale => 2
      t.decimal      :cache_payments,   :precision => 14,   :scale => 2
      t.decimal      :cache_payments_tot,   :precision => 14,   :scale => 2
      t.integer      :p_payment_type_id
      t.string       :i_actif
      t.boolean      :i_cat,   :default => false
      t.decimal      :cache_ca_ttc,   :precision => 14,   :scale => 2
      t.integer      :p_commercial_id

      t.timestamps
    end
  end
end
