无法运行db:在Rails中迁移

问题描述:

我试图运行db:通过回形针gem安装图像附件后迁移,它不会允许我执行迁移。有人可以帮忙吗?非常感谢This is what it said on my terminal无法运行db:在Rails中迁移

这是我的配置文件config/database.yml

这是我创建项目表:

class CreateTodoItems < ActiveRecord::Migration[5.0] 
    def change 
    create_table :todo_items do |t| 
     t.column :content 
     t.column :deadline 

     t.references :todo_list, foreign_key: true 

     t.timestamps 
    end 
    end 
end 

项目模型

class TodoItem < ActiveRecord::Base 

    belongs_to :todo_list 

    has_attached_file :image, styles: { medium: "500x500>", thumb: "100x100#"} 

    validates_attachment_content_type :image, content_type: /\Aimage\/.*\z/ 

    def completed? 

    !completed_at.blank? 

    end 

end 
+0

请发表你的config/database.yml文件 – jaysoifer

+0

默认:默认 适配器:sqlite3的 池:5 超时:5000 发展:

+0

@jaysoifer:默认:默认 适配器:sqlite3的 池:5 超时:5000 发展:

你添加一列到数据库不存在。你不碰巧有items表已todo_items表迁移应该是这个样子:

$ bin/rails generate migration AddAttachmentImageToTodoItems attachment_image:string