Rails Migrations. Why does migration not work?

726 Views Asked by At

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.

2

There are 2 best solutions below

1
Ruslan K On BEST ANSWER

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.

0
uberdave On

Starting a migration fixed it as Rusian tersly suggested and as i put in comments that i would try when i got back to the computer today.