Rails迁移.为什么迁移不起作用



我试图迁移我在网上找到的东西rails-db:migrate没有任何作用。我尝试了其他一个建议修改迁移文件以报告错误的帖子,但重试后仍然没有响应。

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

我生成了一个新的测试迁移用户。而且迁移得很好。此外,我删除了数据库并重新创建,但没有任何效果。

正如Rusian tersly建议的那样,启动迁移修复了它,正如我在评论中所说,我今天回到电脑后会尝试的那样。

您不能将一些文件添加到migrations文件夹中并希望它永远被迁移。

您需要rails generate migration create_doctors,然后将所需内容粘贴到自动创建的迁移中。

最新更新