title: Cant migrate because of foreign key in ruby on tails
body: <p>Im using ruby on rails and trying to do migration.
  but it comes to error when i run rake db:migrate</p>
  
  <p>my migration files 20190613073017_create_jasas.rb</p>
  
  <pre><code>class CreateJasas &lt; ActiveRecord::Migration
    def change
      create_table :jasas do |t|
        t.string :code
        t.string :name
        t.string :image
        t.boolean :top, default: false
        t.boolean :new, default: true
        t.string :slug
        t.references :jasa_department, index: true, foreign_key: true
        t.references :jasa_category, index: true, foreign_key: true
        t.integer :price
        t.text :description
        t.references :vendor, index: true, foreign_key: true
        t.integer :minimum_order
        t.string :short_description
        t.boolean :catalogue, default: false
        t.boolean :etalase, default: false
        t.integer :availability, default: 0
        t.integer :old_price
        t.integer :discount, default: 0
        t.boolean :status, default: true
        t.boolean :sample, default: true
        t.boolean :stock, default: true
        t.integer :views_counter, default: 0
  
        t.timestamps null: false
      end
      add_index :jasas, :slug, unique: true
      add_index :jasas, :code, unique: true
      add_index :jasas, :name
      add_index :jasas, :availability
      add_index :jasas, :new
      add_index :jasas, :minimum_order
      add_index :jasas, :old_price
      add_index :jasas, :price
      add_index :jasas, :created_at
    end
  end
  </code></pre>
  
  <p>ang this is my error message</p>
  
  <pre><code>== 20190613073017 CreateJasas: migrating ======================================
  -- create_table(:jasas)
  rake aborted!
  StandardError: An error has occurred, all later migrations canceled:
  
  Mysql2::Error: Cannot add foreign key constraint: ALTER TABLE `jasas` ADD CONSTRAINT `fk_rails_f1d155c570`
  FOREIGN KEY (`jasa_department_id`)
    REFERENCES `jasa_departments` (`id`)
  /home/lukni/.rvm/gems/ruby-2.3.1/gems/activerecord-4.2.3/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:305:in `query'
  
  </code></pre>
  
  <p>hope there is onyone can help me</p>