class CreateAppointments < ActiveRecord::Migration[5.0]
  def change
    enable_extension 'pgcrypto' unless extension_enabled?('pgcrypto')
    create_table :appointments, id: :uuid, default: 'gen_random_uuid()' do |t|
      t.references :user, foreign_key: true
      t.integer :trainer_id
      t.integer :scheduler_id
      t.string :status
      t.string :place
      t.datetime :date
    end

    add_index :appointments, :scheduler_id
    add_index :appointments, :trainer_id
  end
end