Search code examples
ruby-on-railsrubyruby-on-rails-5.1

Rails Migrations. Why does migration not work?


Im trying to migrate something i found on the net and rails db:migrate has no effect. I tried one of the other posts that suggested moifying migration file to report errors, but still no response after trying again.

class CreateDoctors < ActiveRecord::Migration[5.1] 
def change
  create_table :doctors do |t|
  t.decimal :clinic_latitude, precision: 10, scale: 6
  t.decimal :clinic_longitude, precision: 10, scale: 6
  t.string :clinic_name
  t.timestamps
  end
  add_index :doctors, [:clinic_latitude, :clinic_longitude]
  end
end

I generated a new test migration Users. and that migrated fine. Also i dropped db and recreated to no effect.


Solution

  • You can't add some file to migrations folder and hope that it'll be migrated ever.

    You need to rails generate migration create_doctors, and then paste what you need to that migration that was created automatically.